RockBLOCK 9704 C Library
Doxygen documentation for the RockBLOCK 9704 C Library.
|
#include "rockblock_9704.h"
#include "jspr_command.h"
#include "serial.h"
#include "imt_queue.h"
#include "third_party/cJSON/cJSON.h"
#include "third_party/base64/base64.h"
#include <stddef.h>
#include <errno.h>
#include <stdlib.h>
#include "crossplatform.h"
#include <unistd.h>
#include "kermit_io.h"
Macros | |
#define | IMT_MIN_TOPIC_ID 64U |
#define | IMT_MAX_TOPIC_ID 65535U |
#define | FIRMWARE_VERSION_STRING_LEN 13U |
Functions | |
void | rbRegisterCallbacks (const rbCallbacks_t *callbacks) |
Registers a set of user-defined callbacks with the library. | |
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 bool | setApi (void) |
static bool | setSim (void) |
static bool | setState (void) |
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. | |
static size_t | encodeData (const char *srcBuffer, const size_t srcLength, char *destBuffer, const size_t destLength) |
static size_t | decodeData (const char *srcBuffer, const size_t srcLength, char *destBuffer, const size_t destLength) |
static bool | appendCrc (uint8_t *buffer, size_t length) |
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. | |
static bool | sendMoFromQueue (const int timeout) |
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. | |
static bool | listenForMt (void) |
static bool | sendMoFromQueueAsync (void) |
bool | rbSendMessageAsync (uint16_t topic, const char *data, const size_t length) |
Queue a message to be sent. | |
size_t | rbReceiveMessageAsync (char **buffer) |
Check if a valid message exists, stored at the head of the receiving queue. | |
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 | rbAcknowledgeReceiveHeadAsync (void) |
Acknowledge the head of the receiving queue by discarding it. | |
static bool | checkMoQueue (void) |
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. | |
static bool | getHwInfo (jsprHwInfo_t *hwInfo) |
char * | rbGetImei (void) |
Get the imei. | |
char * | rbGetHwVersion (void) |
Get the hardware version. | |
char * | rbGetSerialNumber (void) |
Get the serial number. | |
int8_t | rbGetBoardTemp (void) |
Get the board temperature. | |
static bool | getSimStatus (jsprSimStatus_t *simStatus) |
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. | |
static bool | getFirmwareInfo (jsprFirmwareInfo_t *fwInfo) |
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. | |
static uint16_t | calculateCrc (const uint8_t *buffer, const size_t bufferLength, const uint16_t initialCRC) |
bool | rbEnd (void) |
Uninitialise/close the the serial connection. | |
static bool | checkProvisioning (uint16_t topic) |
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. | |
Variables | |
int | messageReference |
serialContext | context |
enum serialState | serialState |
static uint8_t | base64Buffer [2048U] |
static uint8_t | crcBuffer [2U] |
static char | firmwareVersion [13U] |
jsprHwInfo_t | hwInfo |
jsprSimStatus_t | simStatus |
jsprFirmwareInfo_t | firmwareInfo |
jsprMessageProvisioning_t | messageProvisioningInfo |
uint32_t | messageLengthAsync = 0 |
uint16_t | moQueuedMessages = 0 |
uint16_t | mtQueuedMessages = 0 |
bool | Receivelock = false |
bool | moDropped = false |
bool | moSent = false |
bool | mtDropped = false |
bool | mtReceived = false |
static const rbCallbacks_t * | rbCallbacks = NULL |
static const uint16_t | CRC16Table [256] |
struct k_data | kermitData |
struct k_response | kermitResponse |
int | kermitStatus = 0 |
unsigned char | i_buf [IBUFLEN+8] |
#define FIRMWARE_VERSION_STRING_LEN 13U |
#define IMT_MAX_TOPIC_ID 65535U |
#define IMT_MIN_TOPIC_ID 64U |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
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 |
|
static |
|
static |
|
static |
|
static |
|
static |
|
extern |
|
static |
|
static |
jsprFirmwareInfo_t firmwareInfo |
|
static |
jsprHwInfo_t hwInfo |
unsigned char i_buf[IBUFLEN+8] |
struct k_data kermitData |
struct k_response kermitResponse |
int kermitStatus = 0 |
uint32_t messageLengthAsync = 0 |
jsprMessageProvisioning_t messageProvisioningInfo |
|
extern |
bool moDropped = false |
uint16_t moQueuedMessages = 0 |
bool moSent = false |
bool mtDropped = false |
uint16_t mtQueuedMessages = 0 |
bool mtReceived = false |
|
static |
bool Receivelock = false |
|
extern |
jsprSimStatus_t simStatus |