ModularSensors > Files > modems / LoggerModemMacros.h

LoggerModemMacros.h file

Contains PRE-ROCESSOR MACROS for use with logger modems.

Defines

#define MS_MODEM_EXTRA_SETUP(specificModem) = bool specificModem::extraModemSetup(void) { \ bool success = gsmModem.init(); \ gsmClient.init(&gsmModem); \ _modemName = gsmModem.getModemName(); \ return success; \ }
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(uint32_t maxConnectionTime) 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_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( \ uint8_t& chargeState, int8_t& percent, uint16_t& milliVolts) { \
Creates a getModemBatteryStats(uint8_t& chargeState, int8_t& percent, uint16_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_EXTRA_SETUP(specificModem) = bool specificModem::extraModemSetup(void) { \ bool success = gsmModem.init(); \ gsmClient.init(&gsmModem); \ _modemName = gsmModem.getModemName(); \ return success; \ }

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(uint32_t maxConnectionTime) function for a specific modem subclass.

Parameters
specificModem The modem subclass
Returns The text of a connectInternet(uint32_t maxConnectionTime) 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_MODEM_SET_APN.

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(uint32_t maxConnectionTime).


#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_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 ESP8266 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_MODEM_CALC_SIGNAL_QUALITY to convert the quality to the proper units.


#define MS_MODEM_GET_MODEM_BATTERY_DATA(specificModem) = bool specificModem::getModemBatteryStats( \ uint8_t& chargeState, int8_t& percent, uint16_t& milliVolts) { \

Creates a getModemBatteryStats(uint8_t& chargeState, int8_t& percent, uint16_t& milliVolts) function for a specific modem subclass.

Parameters
specificModem The modem subclass
Returns The text of a getModemBatteryStats(uint8_t& chargeState, int8_t& percent, uint16_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, uint16_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 avaialble

This returns -9999 for modems that don't return such data.