DigiXBeeCellularTransparent class
The class for any of Digi Cellular XBee or XBee3 modules operating in Digi's "transparent" mode.
- Reference
- Detailed Descriptions
The "transparent" refers to the Digi name for the operating mode of the module.
Base classes
- class DigiXBee
- The parent class for all Digi XBee and XBee3 wifi and cellular modules.
Constructors, destructors, conversion operators
- DigiXBeeCellularTransparent(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, const char* apn, const char* user = NULL, const char* pwd = NULL)
- Construct a new Digi XBee Cellular Transparent object.
- ~DigiXBeeCellularTransparent()
- Destroy the Digi XBee Cellular Transparent object - no action needed.
Public functions
- bool modemWake(void) -> bool override
- Wake up the modem.
- bool connectInternet(uint32_t maxConnectionTime = 50000L) -> bool override
- Wait for the modem to successfully register on the cellular network and then request that it establish either EPS or GPRS data connection.
- void disconnectInternet(void) override
- Detatch from EPS or GPRS data connection and then deregister from the cellular network.
- uint32_t getNISTTime(void) -> uint32_t override
- Get the time from NIST via TIME protocol (rfc868).
- bool getModemSignalQuality(int16_t& rssi, int16_t& percent) -> bool override
- Query the modem for the current signal quality and write the results to the supplied non-constant references.
- bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) -> bool override
- Query the modem for battery information and write the values to the supplied non-constant references.
- float getModemChipTemperature(void) -> float override
- Get the current temperature provided by the modem module.
- bool updateModemMetadata(void) -> bool override
- Query the modem for signal quality, battery, and temperature information and store the values to the static internal variables.
Public variables
Protected functions
- bool isInternetAvailable(void) -> bool override
- Check whether there is an active internet connection available.
- bool modemWakeFxn(void) -> bool override
- Perform the parts of the modem wake up process that are unique to a specific module, as opposed to the parts of setup that are common to all modem modules.
- bool modemSleepFxn(void) -> bool override
- Perform the parts of the modem sleep process that are unique to a specific module, as opposed to the parts of setup that are common to all modem modules.
- bool extraModemSetup(void) -> bool override
- Perform the parts of the modem set up process that are unique to a specific module, as opposed to the parts of setup that are common to all modem modules.
- bool isModemAwake(void) -> bool override
- Check if the modem was awake using all possible means.
Function documentation
DigiXBeeCellularTransparent:: DigiXBeeCellularTransparent(Stream* modemStream,
int8_t powerPin,
int8_t statusPin,
bool useCTSStatus,
int8_t modemResetPin,
int8_t modemSleepRqPin,
const char* apn,
const char* user = NULL,
const char* pwd = NULL)
Construct a new Digi XBee Cellular Transparent object.
Parameters | |
---|---|
modemStream | The Arduino stream instance for serial communication. |
powerPin | The digital pin number of the mcu pin controlling power to the modem (active HIGH ). |
statusPin | The digital pin number of the mcu pin connected to the modem status output pin. |
useCTSStatus | True to use the CTS_N/DIO7 pin of the XBee as a status indicator rather than the true status (ON/SLEEP_N/DIO9 ) pin. This inverts the loggerModem:: |
modemResetPin | The digital pin number of the pin on the mcu attached the the hard or panic reset pin of the modem. |
modemSleepRqPin | The digital pin number of a pin on the mcu used to request the modem enter its lowest possible power state. |
apn | The Access Point Name (APN) for the SIM card. |
user | The user name, if required, associated with the APN; optional, defaulting to NULL |
pwd | The password, if required, associated with the APN; optional, defaulting to NULL |
The constuctor initializes all of the provided member variables, constructs a loggerModem parent class with the appropriate timing for the module, calls the constructor for a TinyGSM modem on the provided modemStream, and creates a TinyGSM Client linked to the modem.
Should be set to a negative number if the modem should be continuously powered or the power cannot be controlled by the MCU.
Should be set to a negative number if the modem status pin cannot be read. This can be either the pin named ON/SLEEP_N/DIO9
or CTS_N/DIO7
pin in Digi's hardware reference.
Should be set to a negative number if the modem reset pin is not connected to the MCU. This shold be the pin called RESET_N
in Digi's hardware reference.
Should be set to a negative number if there is no pin usable for deep sleep modes or it is not accessible to the MCU. This shold be the pin called DTR_N/SLEEP_RQ/DIO8
in Digi's hardware reference.
bool DigiXBeeCellularTransparent:: modemWake(void) override
Wake up the modem.
Returns | bool True if the modem is responsive and ready for action. |
---|
This sets pin modes, powers up the modem if necessary, sets time stamps, runs the specific modem's wake function, tests for responsiveness to AT commands, and then re-runs the TinyGSM init() if necessary. If the modem fails to respond, this attempts a "hard" pin reset if possible.
For most modules, this function is created by the MS_
Set-up pin modes. Because the modem calls wake BEFORE the first setup, we must set the pin modes in the wake function.
Run the specific modemWakeFxn().
Check that the modem is responding to AT commands.
Hard reset is there's no AT response.
Exit if we can't hard reset.
Clean any junk out of the modem buffer.
Re-run the modem init, or setup if necessary. This will turn off echo, which often turns itself back on after a reset/power loss. This also checks the SIM card state.
If we run setup, take success value entirely from that.
bool DigiXBeeCellularTransparent:: connectInternet(uint32_t maxConnectionTime = 50000L) override
Wait for the modem to successfully register on the cellular network and then request that it establish either EPS or GPRS data connection.
Parameters | |
---|---|
maxConnectionTime | The maximum length of time in milliseconds to wait for network registration and data sconnection. Defaults to 50,000ms (50s). |
Returns | bool True if EPS or GPRS data connection has been established. False if the modem wasunresponsive, unable to register with the cellular network, or unable to establish a EPS or GPRS connection. |
Power up, if necessary
Check if the modem was awake, wake it if not
wait
uint32_t DigiXBeeCellularTransparent:: getNISTTime(void) override
Get the time from NIST via TIME protocol (rfc868).
Returns | uint32_t The number of seconds since Jan 1, 1970 IN UTC |
---|
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.
bool DigiXBeeCellularTransparent:: getModemSignalQuality(int16_t& rssi,
int16_t& percent) override
Query the modem for the current signal quality and write the results to the supplied non-constant references.
Parameters | |
---|---|
rssi | A reference to an int16_t which will be set with the received signal strength indicator |
percent | A reference to an int16_t which will be set with the "percent" signal strength |
Returns | bool True indicates that the communication with the modem was successful and the values referenced by the pointers should be valid. |
bool DigiXBeeCellularTransparent:: getModemBatteryStats(int8_t& chargeState,
int8_t& percent,
int16_t& milliVolts) override
Query the modem for battery information and write the values to the supplied non-constant references.
Parameters | |
---|---|
chargeState | A reference to an uint8_t which will be set with the current charge state (significance of value varies) |
percent | A reference to an int8_t which will be set with the current charge percent - this may or may not be a valid value depending on the module and breakout. |
milliVolts | A reference to an uint16_t which will be set with the current battery voltage in mV - this may or may not be a valid value depending on the module and breakout. |
Returns | bool True indicates that the communication with the modem was successful and the values referenced by the pointers should be valid. |
float DigiXBeeCellularTransparent:: getModemChipTemperature(void) override
Get the current temperature provided by the modem module.
Returns | float The temperature in degrees Celsius |
---|
bool DigiXBeeCellularTransparent:: updateModemMetadata(void) override
Query the modem for signal quality, battery, and temperature information and store the values to the static internal variables.
Returns | bool True indicates that the communication with the modem was successful and the values of the internal static variables should be valid. |
---|
bool DigiXBeeCellularTransparent:: isInternetAvailable(void) override protected
Check whether there is an active internet connection available.
Returns | bool True if there is an active data connection to the internet. |
---|
bool DigiXBeeCellularTransparent:: modemWakeFxn(void) override protected
Perform the parts of the modem wake up process that are unique to a specific module, as opposed to the parts of setup that are common to all modem modules.
Returns | bool True if the unique part of the wake function ran sucessfully - does NOT indicate that the modem is now responsive. |
---|
bool DigiXBeeCellularTransparent:: modemSleepFxn(void) override protected
Perform the parts of the modem sleep process that are unique to a specific module, as opposed to the parts of setup that are common to all modem modules.
Returns | bool True if the unique part of the sleep function ran sucessfully. |
---|
bool DigiXBeeCellularTransparent:: extraModemSetup(void) override protected
Perform the parts of the modem set up process that are unique to a specific module, as opposed to the parts of setup that are common to all modem modules.
Returns | bool True if the extra setup succeeded. |
---|
For XBees, this sets the appropriate operating mode (transparent or bypass), enables pin sleep, sets the DIO pins to the expected functions, and reboots the modem to ensure all settings are applied.
First run the TinyGSM init() function for the XBee.
Then enter command mode to set pin outputs.
Enable pin sleep functionality on DIO9
. NOTE: Only the DTR_N/SLEEP_RQ/DIO8
pin (9 on the bee socket) can be used for this pin sleep/wake.
Enable status indication on DIO9
- it will be HIGH when the XBee is awake. NOTE: Only the ON/SLEEP_N/DIO9
pin (13 on the bee socket) can be used for direct status indication.
Enable CTS on DIO7
- it will be LOW
when it is clear to send data to the XBee. This can be used as proxy for status indication if that pin is not readable. NOTE: Only the CTS_N/DIO7
pin (12 on the bee socket) can be used for CTS.
Enable association indication on DIO5
- this is should be directly attached to an LED if possible.
- Solid light indicates no connection
- Single blink indicates connection
- double blink indicates connection but failed TCP link on last attempt
NOTE: Only the Associate/DIO5
pin (15 on the bee socket) can be used for this function.
Enable RSSI PWM output on DIO10
- this should be directly attached to an LED if possible. A higher PWM duty cycle (and thus brighter LED) indicates better signal quality. NOTE: Only the DIO10/PWM0
pin (6 on the bee socket) can be used for this function.
Enable pin sleep on the XBee.
Disassociate from the network for the lowest power deep sleep.
Disable remote manager, USB Direct, and LTE PSM NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no easy way on the LTE-M Bee to wake the cell chip itself from PSM, so we'll use the Digi pin sleep instead.
Ask data to be "packetized" and sent out with every new line (0x0A) character.
Set the socket timeout to 10s (this is default).
Save the network connection parameters.
Write all changes to flash and apply them.
Finally, exit command mode.
Force restart the modem to make sure all settings take.
bool DigiXBeeCellularTransparent:: isModemAwake(void) override protected
Check if the modem was awake using all possible means.
Returns | bool True if the modem is already awake. |
---|
If possible, we always want to check if the modem was awake before attempting to wake it up. Most cellular modules are woken and put to sleep by identical pulses on a sleep or "power" pin. We don't want to accidently pulse an already on modem to off.
For most modules, this function is created by the MS_
If the wake up is one where a pin is held (0 wake time) and * that pin is defined, then we're going to check the level of the * held pin as the indication of whether attempts were made to * wake the modem before entering the setup function.
If there's a status pin, use that to determine if the modem is * awake.
If we can't determine status by pin level, try checking if the * modem responds to AT commands.