SparkFun_Swarm_Satellite_Arduino_Library
Classes | Macros | Enumerations | Variables
SparkFun_Swarm_Satellite_Arduino_Library.h File Reference
#include "WProgram.h"
#include <Wire.h>

Go to the source code of this file.

Classes

struct  Swarm_M138_DateTimeData_t
 
struct  Swarm_M138_GPS_Jamming_Indication_t
 
struct  Swarm_M138_GeospatialData_t
 
struct  Swarm_M138_GPS_Fix_Quality_t
 
struct  Swarm_M138_Power_Status_t
 
struct  Swarm_M138_Receive_Test_t
 
class  SWARM_M138
 

Macros

#define SWARM_M138_STANDARD_RESPONSE_TIMEOUT   1000
 Standard command timeout: allow one second for the modem to respond. More...
 
#define SWARM_M138_MESSAGE_DELETE_TIMEOUT   5000
 Allow extra time when deleting a message.
 
#define SWARM_M138_MESSAGE_ID_TIMEOUT   5000
 Allow extra time when reading the message IDs.
 
#define SWARM_M138_MESSAGE_READ_TIMEOUT   3000
 Allow extra time when reading a message.
 
#define SWARM_M138_MESSAGE_TRANSMIT_TIMEOUT   3000
 Allow extra time when queueing a message for transmission.
 
#define SWARM_M138_SERIAL_BAUD_RATE   115200
 The modem serial baud rate is 115200 and cannot be changed. More...
 
#define SFE_QWIIC_SWARM_DEFAULT_I2C_ADDRESS   0x52
 The default I2C address for the SparkFun Qwiic Swarm Breakout. More...
 
#define SWARM_M138_MAX_PACKET_LENGTH_BYTES   192
 The maximum packet length - defined as binary bytes. More...
 
#define SWARM_M138_MAX_PACKET_LENGTH_HEX   384
 The maximum packet length - encoded as ASCII Hex.
 
#define SWARM_M138_MEM_ALLOC_CS   30
 E.g. DI=0x001abe,DN=M138 . Should be 20 but maybe the modem model could be longer than 4 bytes? More...
 
#define SWARM_M138_MEM_ALLOC_FV   37
 E.g. 2021-12-14T21:27:41,v1.5.0-rc4 . Should be 31 but maybe each v# could be three digits?
 
#define SWARM_M138_MEM_ALLOC_MS   128
 Allocate enough storage to hold the $M138 Modem Status debug or error text. GUESS! TO DO: confirm the true max length.
 
#define SWARM_M138_SUCCESS   SWARM_M138_ERROR_SUCCESS
 Hey, it worked!
 
#define SWARM_M138_MAX_CMD_ERROR_LEN   32
 Allocate 32 bytes to store the most recent command error. More...
 
#define _RxBuffSize   512
 
#define QWIIC_SWARM_I2C_POLLING_WAIT_MS   2
 
#define QWIIC_SWARM_LEN_REG   0xFD
 
#define QWIIC_SWARM_DATA_REG   0xFF
 
#define QWIIC_SWARM_SER_PACKET_SIZE   8
 
#define QWIIC_SWARM_I2C_BUFFER_LENGTH   32
 

Enumerations

enum  Swarm_M138_Error_e {
  SWARM_M138_ERROR_ERROR = 0 , SWARM_M138_ERROR_SUCCESS , SWARM_M138_ERROR_MEM_ALLOC , SWARM_M138_ERROR_TIMEOUT ,
  SWARM_M138_ERROR_INVALID_FORMAT , SWARM_M138_ERROR_INVALID_CHECKSUM , SWARM_M138_ERROR_INVALID_RATE , SWARM_M138_ERROR_INVALID_MODE ,
  SWARM_M138_ERROR_ERR
}
 
enum  Swarm_M138_GPIO1_Mode_e {
  SWARM_M138_GPIO1_ANALOG = 0 , SWARM_M138_GPIO1_EXIT_SLEEP_LOW_HIGH , SWARM_M138_GPIO1_EXIT_SLEEP_HIGH_LOW , SWARM_M138_GPIO1_OUTPUT_LOW ,
  SWARM_M138_GPIO1_OUTPUT_HIGH , SWARM_M138_GPIO1_MESSAGES_PENDING_LOW , SWARM_M138_GPIO1_MESSAGES_PENDING_HIGH , SWARM_M138_GPIO1_SLEEP_MODE_LOW ,
  SWARM_M138_GPIO1_SLEEP_MODE_HIGH , SWARM_M138_GPIO1_INVALID
}
 
enum  Swarm_M138_GPS_Fix_Type_e {
  SWARM_M138_GPS_FIX_TYPE_NF = 0 , SWARM_M138_GPS_FIX_TYPE_DR , SWARM_M138_GPS_FIX_TYPE_G2 , SWARM_M138_GPS_FIX_TYPE_G3 ,
  SWARM_M138_GPS_FIX_TYPE_D2 , SWARM_M138_GPS_FIX_TYPE_D3 , SWARM_M138_GPS_FIX_TYPE_RK , SWARM_M138_GPS_FIX_TYPE_TT ,
  SWARM_M138_GPS_FIX_TYPE_INVALID
}
 
enum  Swarm_M138_Wake_Cause_e { SWARM_M138_WAKE_CAUSE_GPIO = 0 , SWARM_M138_WAKE_CAUSE_SERIAL , SWARM_M138_WAKE_CAUSE_TIME , SWARM_M138_WAKE_CAUSE_INVALID }
 
enum  Swarm_M138_Modem_Status_e {
  SWARM_M138_MODEM_STATUS_BOOT_ABORT = 0 , SWARM_M138_MODEM_STATUS_BOOT_POWERON , SWARM_M138_MODEM_STATUS_BOOT_RUNNING , SWARM_M138_MODEM_STATUS_BOOT_UPDATED ,
  SWARM_M138_MODEM_STATUS_BOOT_VERSION , SWARM_M138_MODEM_STATUS_BOOT_RESTART , SWARM_M138_MODEM_STATUS_BOOT_SHUTDOWN , SWARM_M138_MODEM_STATUS_DATETIME ,
  SWARM_M138_MODEM_STATUS_POSITION , SWARM_M138_MODEM_STATUS_DEBUG , SWARM_M138_MODEM_STATUS_ERROR , SWARM_M138_MODEM_STATUS_UNKNOWN ,
  SWARM_M138_MODEM_STATUS_INVALID
}
 

Variables

const char SWARM_M138_COMMAND_CONFIGURATION [] = "$CS"
 Configuration Settings. More...
 
const char SWARM_M138_COMMAND_DATE_TIME_STAT [] = "$DT"
 Date/Time Status.
 
const char SWARM_M138_COMMAND_FIRMWARE_VER [] = "$FV"
 Retrieve Firmware Version.
 
const char SWARM_M138_COMMAND_GPS_JAMMING [] = "$GJ"
 GPS Jamming/Spoofing Indication.
 
const char SWARM_M138_COMMAND_GEOSPATIAL_INFO [] = "$GN"
 Geospatial Information.
 
const char SWARM_M138_COMMAND_GPIO1_CONTROL [] = "$GP"
 GPIO1 Control.
 
const char SWARM_M138_COMMAND_GPS_FIX_QUAL [] = "$GS"
 GPS Fix Quality.
 
const char SWARM_M138_COMMAND_MSG_RX_MGMT [] = "$MM"
 Messages Received Management.
 
const char SWARM_M138_COMMAND_MSG_TX_MGMT [] = "$MT"
 Messages to Transmit Management.
 
const char SWARM_M138_COMMAND_POWER_OFF [] = "$PO"
 Power Off.
 
const char SWARM_M138_COMMAND_POWER_STAT [] = "$PW"
 Power Status.
 
const char SWARM_M138_COMMAND_RX_DATA_MSG [] = "$RD"
 Receive Data Message.
 
const char SWARM_M138_COMMAND_RESTART [] = "$RS"
 Restart Device.
 
const char SWARM_M138_COMMAND_RX_TEST [] = "$RT"
 Receive Test.
 
const char SWARM_M138_COMMAND_SLEEP [] = "$SL"
 Sleep Mode.
 
const char SWARM_M138_COMMAND_MODEM_STAT [] = "$M138"
 Modem Status.
 
const char SWARM_M138_COMMAND_TX_DATA [] = "$TD"
 Transmit Data.
 
const uint32_t SWARM_M138_MAX_MESSAGE_RATE = 0x7FFFFFFF
 2147483647 (2^31 - 1) More...
 

Detailed Description

SparkFun Swarm Satellite Arduino Library

This library facilitates communication with the Swarm M138 satellite modem.

Want to support open source hardware? Buy a board from SparkFun!
SparkX Swarm Serial Breakout (SPX-19236): https://www.sparkfun.com/products/19236

This library was written by: Paul Clark SparkFun Electronics January 2022

Please see LICENSE.md for the license information

Macro Definition Documentation

◆ SFE_QWIIC_SWARM_DEFAULT_I2C_ADDRESS

#define SFE_QWIIC_SWARM_DEFAULT_I2C_ADDRESS   0x52

The default I2C address for the SparkFun Qwiic Swarm Breakout.

Default I2C address used by the Qwiic Swarm Breakout. Can be changed.

◆ SWARM_M138_MAX_CMD_ERROR_LEN

#define SWARM_M138_MAX_CMD_ERROR_LEN   32

Allocate 32 bytes to store the most recent command error.

Storage for the most recent command error

◆ SWARM_M138_MAX_PACKET_LENGTH_BYTES

#define SWARM_M138_MAX_PACKET_LENGTH_BYTES   192

The maximum packet length - defined as binary bytes.

Swarm packet length

◆ SWARM_M138_MEM_ALLOC_CS

#define SWARM_M138_MEM_ALLOC_CS   30

E.g. DI=0x001abe,DN=M138 . Should be 20 but maybe the modem model could be longer than 4 bytes?

Minimum memory allocations for each message type

◆ SWARM_M138_SERIAL_BAUD_RATE

#define SWARM_M138_SERIAL_BAUD_RATE   115200

The modem serial baud rate is 115200 and cannot be changed.

Modem Serial Baud Rate

◆ SWARM_M138_STANDARD_RESPONSE_TIMEOUT

#define SWARM_M138_STANDARD_RESPONSE_TIMEOUT   1000

Standard command timeout: allow one second for the modem to respond.

Timeouts for the serial commands

Enumeration Type Documentation

◆ Swarm_M138_Error_e

An enum defining the command result

Enumerator
SWARM_M138_ERROR_ERROR 

Just a plain old communication error.

SWARM_M138_ERROR_SUCCESS 

Hey, it worked!

SWARM_M138_ERROR_MEM_ALLOC 

Memory allocation error.

SWARM_M138_ERROR_TIMEOUT 

Communication timeout.

SWARM_M138_ERROR_INVALID_FORMAT 

Indicates the command response format was invalid.

SWARM_M138_ERROR_INVALID_CHECKSUM 

Indicates the command response checksum was invalid.

SWARM_M138_ERROR_INVALID_RATE 

Indicates the message rate was invalid.

SWARM_M138_ERROR_INVALID_MODE 

Indicates the GPIO1 pin mode was invalid.

SWARM_M138_ERROR_ERR 

Command input error (ERR) - the error is copied into commandError.

◆ Swarm_M138_GPIO1_Mode_e

Enum for the GPIO1 pin modes

◆ Swarm_M138_GPS_Fix_Type_e

Enum for the GPS fix type

◆ Swarm_M138_Modem_Status_e

An enum for the modem status

◆ Swarm_M138_Wake_Cause_e

An enum for the sleep mode wake cause

Variable Documentation

◆ SWARM_M138_COMMAND_CONFIGURATION

const char SWARM_M138_COMMAND_CONFIGURATION[] = "$CS"

Configuration Settings.

Suported Commands

◆ SWARM_M138_MAX_MESSAGE_RATE

const uint32_t SWARM_M138_MAX_MESSAGE_RATE = 0x7FFFFFFF

2147483647 (2^31 - 1)

Define the maximum message 'rate' (interval)