LoggerModemMacros.h file
Contains PRE-PROCESSOR MACROS for use with logger modems.
Defines
- #define MS_MODEM_NTP_SYNC
- A macro to add the line to sync the modem with NTP after it wakes.
- #define MS_MODEM_EXTRA_SETUP(specificModem) = bool specificModem::extraModemSetup(void) { \ bool success = gsmModem.init(); \ _modemName = gsmModem.getModemName(); \
- Creates an extraModemSetup() function for a specific modem subclass.
- #define MS_IS_MODEM_AWAKE(specificModem)
- Creates an isModemAwake() function for a specific modem subclass.
- #define MS_MODEM_WAKE(specificModem)
- Creates a modemWake() function for a specific modem subclass.
- #define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) = bool specificModem::isInternetAvailable(void) { \ return gsmModem.isGprsConnected(); \ }
- Creates an isInternetAvailable() function for a specific modem subclass.
- #define MS_MODEM_SET_APN =
- Creates a text string of the functions to call for a specific modem to set the APN and connect to GPRS during the internet connection sequence.
- #define MS_MODEM_CONNECT_INTERNET(specificModem)
- Creates a connectInternet() function for a specific modem subclass.
- #define MS_MODEM_DISCONNECT_INTERNET(specificModem) = void specificModem::disconnectInternet(void) { \
- Creates a disconnectInternet() function for a specific modem subclass.
- #define MS_MODEM_CREATE_CLIENT(specificModem) = Client* specificModem::createClient() { \ /* Use the new keyword to create a new client on the **heap** */ \ /* NOTE: Be sure to delete this object when you're done with it! */ \ Client* newClient = new TinyGsmClient(gsmModem); \ return newClient; \ }
- Creates createClient functions for a specific modem subclass.
- #define MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem) = Client* specificModem::createSecureClient( \ SSLAuthMode, SSLVersion, const char*, const char*, const char*) { \ return nullptr; \ } \ Client* specificModem::createSecureClient(const char*, const char*, \ SSLVersion) { \ return nullptr; \ } \ Client* specificModem::createSecureClient(const char*, SSLVersion) { \ return nullptr; \ }
- Helper to create null functions for modems that do not support secure clients.
- #define MS_MODEM_CREATE_SECURE_CLIENT(specificModem) = Client* specificModem::createSecureClient() { \ return nullptr; \ } \
- Creates createSecureClient functions for a specific modem subclass.
-
#define MS_MODEM_DELETE_CLIENT(specificModem) = void specificModem::deleteClient(Client* client) { \
if (client != nullptr) { \
TinyGsmClient* cast_pointer = static_cast
(client); \ delete cast_pointer; \ } \ } - Creates a deleteClient function for a specific modem subclass.
- #define MS_MODEM_DELETE_SECURE_CLIENT(specificModem) = void specificModem::deleteSecureClient(Client*) {}
- Creates a deleteClient function for a specific modem subclass.
- #define TIME_PROTOCOL_PORT = 37
- The port hosting the NIST "time" protocol (37)
- #define NIST_RESPONSE_BYTES = 4
- The size of the NIST response from the "time" protocol, in bytes.
- #define NIST_SERVER_RETRYS = 12
- The number of retry attempts when connecting to the NIST server.
- #define MS_MODEM_GET_NIST_TIME(specificModem)
- Creates a getNISTTime() function for a specific modem subclass.
- #define MS_MODEM_CALC_SIGNAL_QUALITY = rssi = getRSSIFromCSQ(signalQual); \
- Creates a text string of the functions to convert the signal quality returned by a specific modem to RSSI and percent signal strength.
- #define MS_MODEM_GET_MODEM_SIGNAL_QUALITY(specificModem) = bool specificModem::getModemSignalQuality(int16_t& rssi, \ int16_t& percent) { \ /* Get signal quality */ \
- Creates a getModemSignalQuality(int16_t& rssi, int16_t& percent) function for a specific modem subclass.
- #define MS_MODEM_GET_MODEM_BATTERY_DATA(specificModem) = bool specificModem::getModemBatteryStats( \ int8_t& chargeState, int8_t& percent, int16_t& milliVolts) { \
- Creates a getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) function for a specific modem subclass.
- #define MS_MODEM_GET_MODEM_TEMPERATURE_DATA(specificModem) = float specificModem::getModemChipTemperature(void) { \
- Creates a getModemChipTemperature() function for a specific modem subclass.
Define documentation
#define MS_MODEM_NTP_SYNC
A macro to add the line to sync the modem with NTP after it wakes.
This needs to be called at wake because many modules forget their time when they are powered down.
#define MS_MODEM_EXTRA_SETUP(specificModem) = bool specificModem::extraModemSetup(void) { \ bool success = gsmModem.init(); \ _modemName = gsmModem.getModemName(); \
Creates an extraModemSetup() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of an extraModemSetup() function specific to a single modem subclass. |
This is a passthrough to the TinyGSM init() and getModemName() for a specific modem.
#define MS_IS_MODEM_AWAKE(specificModem)
Creates an isModemAwake() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of an isModemAwake() function specific to a single modem subclass. |
#define MS_MODEM_WAKE(specificModem)
Creates a modemWake() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of a modemWake() function specific to a single modem subclass. |
#define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) = bool specificModem::isInternetAvailable(void) { \ return gsmModem.isGprsConnected(); \ }
Creates an isInternetAvailable() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of an isInternetAvailable() function specific to a single modem subclass. |
For cellular modems, this is a passthrough to isGprsConnected() for the specific TinyGSM modem type.
For wifi modems, this is a passthrough to isNetworkConnected() for the specific TinyGSM modem type.
#define MS_MODEM_SET_APN =
Creates a text string of the functions to call for a specific modem to set the APN and connect to GPRS during the internet connection sequence.
Returns | Text string containing the functions to set the APN and connect to GPRS. |
---|
For most cellular modems, this is a passthrough to gprsConnect() for the specific TinyGSM modem type. For the XBee, this is an empty string.
#define MS_MODEM_CONNECT_INTERNET(specificModem)
Creates a connectInternet() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of a connectInternet() function specific to a single modem subclass. |
For cellular modems, this uses the TinyGSM waitForNetwork() function for the specific modem and then connects to GPRS using MS_
For WiFi modems, this first checks for pre-existing internet connection and if that isn't present uses the specific modem's networkConnect(ssid, pwd) function followed by waitForNetwork().
#define MS_MODEM_DISCONNECT_INTERNET(specificModem) = void specificModem::disconnectInternet(void) { \
Creates a disconnectInternet() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of a disconnectInternet() function specific to a single modem subclass. |
For cellular modems, this is a passthrough to gprsDisconnect() for the specific TinyGSM modem type.
For Wifi modems, this is a passthrough to networkDisconnect() for the specific TinyGSM modem type
#define MS_MODEM_CREATE_CLIENT(specificModem) = Client* specificModem::createClient() { \ /* Use the new keyword to create a new client on the **heap** */ \ /* NOTE: Be sure to delete this object when you're done with it! */ \ Client* newClient = new TinyGsmClient(gsmModem); \ return newClient; \ }
Creates createClient functions for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of createClient functions specific to a single modem subclass. |
#define MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem) = Client* specificModem::createSecureClient( \ SSLAuthMode, SSLVersion, const char*, const char*, const char*) { \ return nullptr; \ } \ Client* specificModem::createSecureClient(const char*, const char*, \ SSLVersion) { \ return nullptr; \ } \ Client* specificModem::createSecureClient(const char*, SSLVersion) { \ return nullptr; \ }
Helper to create null functions for modems that do not support secure clients.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of createSecureClient functions specific to a single modem subclass. |
#define MS_MODEM_CREATE_SECURE_CLIENT(specificModem) = Client* specificModem::createSecureClient() { \ return nullptr; \ } \
Creates createSecureClient functions for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of createClient functions specific to a single modem subclass. |
For modems that don't support SSL, this returns a nullptr.
#define MS_MODEM_DELETE_CLIENT(specificModem) = void specificModem::deleteClient(Client* client) { \
if (client != nullptr) { \
TinyGsmClient* cast_pointer = static_cast(client); \
delete cast_pointer; \
} \
}
Creates a deleteClient function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of deleteClient function specific to a single modem subclass. |
#define MS_MODEM_DELETE_SECURE_CLIENT(specificModem) = void specificModem::deleteSecureClient(Client*) {}
Creates a deleteClient function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of deleteSecureClient function specific to a single modem subclass. |
#define MS_MODEM_GET_NIST_TIME(specificModem)
Creates a getNISTTime() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of a getNISTTime() function specific to a single modem subclass. |
This gets the time from NIST via TIME protocol (rfc868)
This would be much more efficient if done over UDP, but I'm doing it over TCP because I don't have a UDP library for all the modems.
#define MS_MODEM_CALC_SIGNAL_QUALITY = rssi = getRSSIFromCSQ(signalQual); \
Creates a text string of the functions to convert the signal quality returned by a specific modem to RSSI and percent signal strength.
Returns | Text string containing the functions to put signal strength in the correct units. |
---|
Most modules return CSQ between 0 and 31. The RSSI in dBm is calculated using getRSSIFromCSQ(int16_t csq) and a the percent strength is calculated using getPctFromCSQ(int16_t csq).
XBee and Espressif modules return RSSI in dBm and the percent strength is calculated using getPctFromRSSI(int16_t rssi).
#define MS_MODEM_GET_MODEM_SIGNAL_QUALITY(specificModem) = bool specificModem::getModemSignalQuality(int16_t& rssi, \ int16_t& percent) { \ /* Get signal quality */ \
Creates a getModemSignalQuality(int16_t& rssi, int16_t& percent) function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of a getModemSignalQuality(int16_t& rssi, int16_t& percent) function specific to a single modem subclass. |
This calls the specific modem getSignalQuality() and the text from MS_
#define MS_MODEM_GET_MODEM_BATTERY_DATA(specificModem) = bool specificModem::getModemBatteryStats( \ int8_t& chargeState, int8_t& percent, int16_t& milliVolts) { \
Creates a getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of a getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) function specific to a single modem subclass. |
This is a passthrough to the specific modem's getBattStats(uint8_t& chargeState, int8_t& percent, int16_t& milliVolts) for modems where such data is available.
This populates the entered references with -9999s for modems where such data is not available.
#define MS_MODEM_GET_MODEM_TEMPERATURE_DATA(specificModem) = float specificModem::getModemChipTemperature(void) { \
Creates a getModemChipTemperature() function for a specific modem subclass.
Parameters | |
---|---|
specificModem | The modem subclass |
Returns | The text of a getModemChipTemperature() function specific to a single modem subclass. |
This is a passthrough to the specific modem's getTemperature() for modems where such data is available
This returns -9999 for modems that don't return such data.