#include <src/modems/DigiXBeeLTEBypass.h>
DigiXBeeLTEBypass
class
The class for any of Digi's cellular LTE-M XBee3 modules operating in Digi's "bypass" mode.
- Reference
- Detailed Descriptions
Base classes
- class DigiXBee
- The parent class for all Digi XBee and XBee3 wifi and cellular modules.
Constructors, destructors, conversion operators
- DigiXBeeLTEBypass(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, const char* apn)
- Construct a new Digi XBee LTE Bypass object.
- ~DigiXBeeLTEBypass()
- Destroy the Digi XBee LTE Bypass 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 modemHardReset(void) -> bool override
- Use the modem reset pin specified in the constructor to perform a "hard" or "panic" reset.
Public variables
Protected functions
- bool isInternetAvailable(void) -> bool override
- Check whether there is an active internet connection available.
- 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
DigiXBeeLTEBypass:: DigiXBeeLTEBypass(Stream* modemStream,
int8_t powerPin,
int8_t statusPin,
bool useCTSStatus,
int8_t modemResetPin,
int8_t modemSleepRqPin,
const char* apn)
Construct a new Digi XBee LTE Bypass 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. |
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 DigiXBeeLTEBypass:: 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 DigiXBeeLTEBypass:: 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 DigiXBeeLTEBypass:: 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.
Check for and bail if not connected to the internet.
Try up to 12 times to get a timestamp from NIST.
Make TCP connection.
Wait up to 5 seconds for a response.
bool DigiXBeeLTEBypass:: 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 DigiXBeeLTEBypass:: 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 DigiXBeeLTEBypass:: getModemChipTemperature(void) override
Get the current temperature provided by the modem module.
Returns | float The temperature in degrees Celsius |
---|
bool DigiXBeeLTEBypass:: modemHardReset(void) override
Use the modem reset pin specified in the constructor to perform a "hard" or "panic" reset.
Returns | bool True if the reset succeeded and the modem should now be responsive. False if the modem remains non-responsive either because the reset failed to fix the communication issue or because a reset is not possible with the current pin/modem configuration. |
---|
This should only be used if the modem is clearly non-responsive.
bool DigiXBeeLTEBypass:: 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 DigiXBeeLTEBypass:: 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, wait the required guard time before entering command mode.
Now, enter command mode to set all pin I/O functionality.
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.
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.
Make sure airplane mode is off - bypass and airplane mode are incompatible.
Enable bypass mode.
Write changes to flash.
Apply changes.
Allow 5s for the unit to reset.
Re-initialize the TinyGSM SARA R4 instance.
bool DigiXBeeLTEBypass:: 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.