RockBLOCK 9704 C Library
Doxygen documentation for the RockBLOCK 9704 C Library.
|
The RockBLOCK 9704 library. Maintained by Ground Control (https://www.groundcontrol.com/) and license under the MIT License. More...
#include "serial.h"
#include "jspr.h"
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stddef.h>
#include "gpio.h"
Go to the source code of this file.
Classes | |
struct | rbCallbacks_t |
Struct containing user defined callback functions for asynchronous operations. More... | |
Macros | |
#define | BASE64_TEMP_BUFFER 2048U |
Temporary buffer size used for Base64 encoding/decoding of IMT messages. | |
#define | RB9704_BAUD 230400U |
Fixed serial baud rate for communication with the RockBLOCK 9704 modem. | |
#define | SERIAL_CONTEXT_SETUP_FUNC setContextLinux |
Platform-specific macro to define the serial context setup function. | |
Typedefs | |
typedef void(* | updateProgressCallback) (void *context, const unsigned long sofar, const unsigned long total) |
A callback definition for the kermit transfer. | |
Enumerations | |
enum | rbMsgStatus_t { RB_MSG_STATUS_OK = 1 , RB_MSG_STATUS_FAIL = -1 } |
Indicates the result of a message operation. More... | |
enum | cloudloopTopics_t { RAW_TOPIC = 244 , PURPLE_TOPIC = 313 , PINK_TOPIC = 314 , RED_TOPIC = 315 , ORANGE_TOPIC = 316 , YELLOW_TOPIC = 317 } |
Predefined Cloudloop topic identifiers for RockBLOCK 9704. More... | |
Functions | |
void | rbRegisterCallbacks (const rbCallbacks_t *callbacks) |
Registers a set of user-defined callbacks with the library. | |
bool | rbBegin (const char *port) |
Initialise the the serial connection in the detected context (or user defined), if successful continue to set the API, SIM & state of the modem in order to be ready for messaging. | |
bool | rbEnd (void) |
Uninitialise/close the the serial connection. | |
bool | rbSendMessage (const char *data, const size_t length, const int timeout) |
Send a mobile originated message from the modem on the default topic (244). | |
bool | rbSendMessageCloudloop (cloudloopTopics_t topic, const char *data, const size_t length, const int timeout) |
Send a mobile originated message from the modem on a cloudloop topic of choice. | |
bool | rbSendMessageAny (uint16_t topic, const char *data, const size_t length, const int timeout) |
Send a mobile originated message from the modem on any topic. | |
size_t | rbReceiveMessage (char **buffer) |
Listen for a mobile terminated message from the modem. | |
size_t | rbReceiveMessageWithTopic (char **buffer, uint16_t topic) |
Listen for a mobile terminated message from the modem. | |
size_t | rbReceiveMessageAsync (char **buffer) |
Check if a valid message exists, stored at the head of the receiving queue. | |
bool | rbAcknowledgeReceiveHeadAsync (void) |
Acknowledge the head of the receiving queue by discarding it. | |
void | rbReceiveLockAsync (void) |
Locks the receiving queue so that old messages aren't discarded when incoming ones arrive. | |
void | rbReceiveUnlockAsync (void) |
Unlocks the receiving queue so that old messages are discarded to make space for incoming ones. | |
bool | rbSendMessageAsync (uint16_t topic, const char *data, const size_t length) |
Queue a message to be sent. | |
void | rbPoll (void) |
Polling function that handles all incoming communication from the modem. | |
int8_t | rbGetSignal (void) |
Get the current signal strength from the modem. | |
char * | rbGetHwVersion (void) |
Get the hardware version. | |
char * | rbGetSerialNumber (void) |
Get the serial number. | |
char * | rbGetImei (void) |
Get the imei. | |
int8_t | rbGetBoardTemp (void) |
Get the board temperature. | |
bool | rbGetCardPresent (void) |
Check if SIM presence is currently asserted. | |
bool | rbGetSimConnected (void) |
Check if SIM card is present, communicating properly with, and has presented no errors in SIM transactions with the transceiver. | |
char * | rbGetIccid (void) |
Get the iccid. | |
char * | rbGetFirmwareVersion (void) |
Get the Iridium modem firmware version as vX.Y.X with X being the major number, Y being the minor number and X being the patch number. | |
bool | rbResyncServiceConfig (void) |
Requests a resynchronisation of the service configuration. | |
bool | rbUpdateFirmware (const char *firmwareFile, updateProgressCallback progress, void *context) |
Update 9704 firmware. This is a blocking call and will take approximately 10 minutes to upgrade, the updateProgressCallback is recommended. | |
bool | rbBeginGpio (char *port, const rbGpioTable_t *gpioInfo, const int timeout) |
Drives user defined pin (power enable) low and user defined pin (iridium enable) high to initialise the RB9704 PiHat. Initialise the serial connection in the detected context (or user defined), if successful continue to set the API, SIM & state of the modem in order to be ready for messaging. | |
bool | rbEndGpio (const rbGpioTable_t *gpioInfo) |
Drives user defined pin (power enable) high and another user defined pin (iridium enable) low to deinitialise the RB9704 PiHat. Deinitialises/closes the the serial connection. | |
static uint16_t | calculateCrc (const uint8_t *buffer, const size_t bufferLength, const uint16_t initialCRC) |
Calculate CRC for a buffer. | |
static bool | appendCrc (uint8_t *buffer, size_t length) |
Append CRC to the end of a buffer. | |
static size_t | encodeData (const char *srcBuffer, const size_t srcLength, char *destBuffer, const size_t destLength) |
Encode binary data to base64 format. | |
static size_t | decodeData (const char *srcBuffer, const size_t srcLength, char *destBuffer, const size_t destLength) |
Decode base64 data back into binary. | |
static bool | setApi (void) |
Set the modem API version. | |
static bool | setSim (void) |
Initialise SIM card configuration. | |
static bool | setState (void) |
Set operational state for the modem. | |
static bool | checkProvisioning (uint16_t topic) |
Check if the given topic is provisioned. | |
static bool | sendMoFromQueue (const int timeout) |
Send a queued message using mobile originated (MO) transmission. | |
static bool | listenForMt (void) |
Listen for an incoming mobile terminated (MT) message. | |
static bool | getHwInfo (jsprHwInfo_t *hwInfo) |
Retrieve hardware information from the modem. | |
static bool | getSimStatus (jsprSimStatus_t *simStatus) |
Get current SIM card status. | |
static bool | sendMoFromQueueAsync (void) |
Send a the modem a request to queue a message. | |
static bool | checkMoQueue (void) |
Checks if any more messages have been queued, if so, send them. | |
The RockBLOCK 9704 library. Maintained by Ground Control (https://www.groundcontrol.com/) and license under the MIT License.
#define BASE64_TEMP_BUFFER 2048U |
Temporary buffer size used for Base64 encoding/decoding of IMT messages.
#define RB9704_BAUD 230400U |
Fixed serial baud rate for communication with the RockBLOCK 9704 modem.
This value should not be changed, as it is required by the modem hardware.
#define SERIAL_CONTEXT_SETUP_FUNC setContextLinux |
Platform-specific macro to define the serial context setup function.
This macro resolves to a platform-appropriate function used to configure the serial context. By default, it maps to:
setContextLinux
on Linux and macOSsetContextWindows
on WindowssetContextArduino
on Arduino platformsYou can override this macro by defining SERIAL_CONTEXT_SETUP_FUNC
manually before including this library, allowing for custom serial context initialisation logic.
Example:
typedef void(* updateProgressCallback) (void *context, const unsigned long sofar, const unsigned long total) |
A callback definition for the kermit transfer.
context | a pointer to some shared context given in rbUpdateFirmware. |
sofar | the number of bytes transferred so far. |
total | the total number of bytes to transfer. |
enum cloudloopTopics_t |
Predefined Cloudloop topic identifiers for RockBLOCK 9704.
This enum defines known topic IDs used to route messages through the Cloudloop data.
enum rbMsgStatus_t |
|
static |
Append CRC to the end of a buffer.
buffer | Pointer to the buffer to append CRC to. |
length | Length of the buffer in bytes. |
|
static |
Calculate CRC for a buffer.
buffer | Pointer to the data buffer. |
bufferLength | Length of the buffer in bytes. |
initialCRC | Initial CRC value to start from. |
|
static |
Checks if any more messages have been queued, if so, send them.
|
static |
Check if the given topic is provisioned.
topic | Topic ID to check. |
|
static |
Decode base64 data back into binary.
srcBuffer | Pointer to base64-encoded string. |
srcLength | Length of encoded string. |
destBuffer | Pointer to destination binary buffer. |
destLength | Length of destination buffer. |
|
static |
Encode binary data to base64 format.
srcBuffer | Pointer to source binary data. |
srcLength | Length of source data in bytes. |
destBuffer | Pointer to destination buffer for base64 string. |
destLength | Length of destination buffer. |
|
static |
Retrieve hardware information from the modem.
hwInfo | Pointer to structure to populate with hardware info. |
|
static |
Get current SIM card status.
simStatus | Pointer to structure to populate with SIM status. |
|
static |
Listen for an incoming mobile terminated (MT) message.
bool rbAcknowledgeReceiveHeadAsync | ( | void | ) |
Acknowledge the head of the receiving queue by discarding it.
bool rbBegin | ( | const char * | port | ) |
Initialise the the serial connection in the detected context (or user defined), if successful continue to set the API, SIM & state of the modem in order to be ready for messaging.
port | pointer to port name. |
bool rbBeginGpio | ( | char * | port, |
const rbGpioTable_t * | gpioInfo, | ||
const int | timeout | ||
) |
Drives user defined pin (power enable) low and user defined pin (iridium enable) high to initialise the RB9704 PiHat. Initialise the serial connection in the detected context (or user defined), if successful continue to set the API, SIM & state of the modem in order to be ready for messaging.
port | pointer to port name. |
gpioInfo | structure containing a valid chip & pin for powerEnable, IridiumEnable and booted. |
timeout | in seconds. |
bool rbEnd | ( | void | ) |
Uninitialise/close the the serial connection.
bool rbEndGpio | ( | const rbGpioTable_t * | gpioInfo | ) |
Drives user defined pin (power enable) high and another user defined pin (iridium enable) low to deinitialise the RB9704 PiHat. Deinitialises/closes the the serial connection.
gpioInfo | structure containing a valid chip & pin for powerEnable, IridiumEnable and booted. |
int8_t rbGetBoardTemp | ( | void | ) |
Get the board temperature.
bool rbGetCardPresent | ( | void | ) |
Check if SIM presence is currently asserted.
char * rbGetFirmwareVersion | ( | void | ) |
Get the Iridium modem firmware version as vX.Y.X with X being the major number, Y being the minor number and X being the patch number.
char * rbGetHwVersion | ( | void | ) |
Get the hardware version.
char * rbGetIccid | ( | void | ) |
Get the iccid.
char * rbGetImei | ( | void | ) |
Get the imei.
char * rbGetSerialNumber | ( | void | ) |
Get the serial number.
int8_t rbGetSignal | ( | void | ) |
Get the current signal strength from the modem.
The signal strength is returned in signal bars from 0 to 5:
bool rbGetSimConnected | ( | void | ) |
Check if SIM card is present, communicating properly with, and has presented no errors in SIM transactions with the transceiver.
void rbPoll | ( | void | ) |
Polling function that handles all incoming communication from the modem.
void rbReceiveLockAsync | ( | void | ) |
Locks the receiving queue so that old messages aren't discarded when incoming ones arrive.
size_t rbReceiveMessage | ( | char ** | buffer | ) |
Listen for a mobile terminated message from the modem.
buffer | pointer to buffer of the stored MT messages. |
size_t rbReceiveMessageAsync | ( | char ** | buffer | ) |
Check if a valid message exists, stored at the head of the receiving queue.
buffer | pointer to buffer of the stored MT messages. |
size_t rbReceiveMessageWithTopic | ( | char ** | buffer, |
uint16_t | topic | ||
) |
Listen for a mobile terminated message from the modem.
buffer | pointer to buffer of the stored MT messages. |
topic | uint16_t topic. |
void rbReceiveUnlockAsync | ( | void | ) |
Unlocks the receiving queue so that old messages are discarded to make space for incoming ones.
void rbRegisterCallbacks | ( | const rbCallbacks_t * | callbacks | ) |
Registers a set of user-defined callbacks with the library.
This function will store the user provided callback functions, which will be called by the library during relevant events.
callbacks | Pointer to a structure containing function pointers to user-defined callbacks. |
bool rbResyncServiceConfig | ( | void | ) |
Requests a resynchronisation of the service configuration.
Call this method if the provisioning state has changed but the modem is still reporting outdated configuration data. This will clear the stored provisioning configuration and force a resync with the gateway.
This function must be called after the modem has been power-cycled. It is recommended to:
rbBegin()
.bool rbSendMessage | ( | const char * | data, |
const size_t | length, | ||
const int | timeout | ||
) |
Send a mobile originated message from the modem on the default topic (244).
data | pointer to data (message). |
length | size_t of data length. (Max 100kB). |
timeout | in seconds. |
bool rbSendMessageAny | ( | uint16_t | topic, |
const char * | data, | ||
const size_t | length, | ||
const int | timeout | ||
) |
Send a mobile originated message from the modem on any topic.
topic | uint16_t topic. |
data | pointer to data (message). |
length | size_t of data length. (Max 100kB). |
timeout | in seconds. |
bool rbSendMessageAsync | ( | uint16_t | topic, |
const char * | data, | ||
const size_t | length | ||
) |
Queue a message to be sent.
topic | uint16_t topic. |
data | pointer to data (message). |
length | size_t of data length. (Max 100kB). |
bool rbSendMessageCloudloop | ( | cloudloopTopics_t | topic, |
const char * | data, | ||
const size_t | length, | ||
const int | timeout | ||
) |
Send a mobile originated message from the modem on a cloudloop topic of choice.
topic | uint16_t topic. |
data | pointer to data (message). |
length | size_t of data length. (Max 100kB). |
timeout | in seconds. |
bool rbUpdateFirmware | ( | const char * | firmwareFile, |
updateProgressCallback | progress, | ||
void * | context | ||
) |
Update 9704 firmware. This is a blocking call and will take approximately 10 minutes to upgrade, the updateProgressCallback is recommended.
firmwareFile | path to the sxbin firmware files from Iridium |
progress | pointer to the update progress callback, this can be NULL. |
context | pointer to to some shared memory to pass to progress, this can be NULL. |
|
static |
Send a queued message using mobile originated (MO) transmission.
timeout | Timeout duration in seconds. |
|
static |
Send a the modem a request to queue a message.
|
static |
Set the modem API version.
|
static |
Initialise SIM card configuration.
|
static |
Set operational state for the modem.