Create and configure a LTE object. See __init__ for params of configuration.
from LTE import LTE
lte = LTE()
This method is used to set up the LTE subsystem. Optionally specify
-
carrier name
. The currently available options are:'att'
'verizon'
'standard'
'docomo'
'kddi'
'telstra'
'tmo'
'verizon-no-roaming'
'3gpp-conformance'
-
cid
is the connection id. Most operators use cid=1 except Verizon which uses cid=3 when using a Verizon issued SIM card -
mode
is LTE.CATM1 or LTE.NBIOT. If not specified, modem will use current setting -
baudrate
is the speed with which the modem is operating. Default is 115200bps -
debug
. True or False, display additional debugging output
Disables LTE modem completely. This reduces the power consumption to the minimum. Call this before entering deepsleep. Optional parameter reset was added for compatibility with legacy code and is not used
Enable radio functionality and attach to the LTE network authorised by the inserted SIM card. Optionally specify:
band
: to scan for networks. If no band (orNone
) is specified, the currently configured bands will be scanned (this is persistent through resetting the modem). The possible values for the band are:1,2,3,4,5,8,12,13,17,18,19,20,25,26,28,66 or 71
.bands
: a tuple of mutiple band entries (see band above)apn
: Specify the APN (Access point Name).cid
: connection ID, seeLTE.\_\_init()\_\_
andLTE.connect()
. when the ID is set here it will be remembered when doing connect so no need to specify againtype
: PDP context type eitherIP
orIPV4V6
. These are options to specify PDP type ‘Packet Data protocol’ either IP [Internet Protocol] or IPV4V6 [Internet Protocol version 4 and version 6] , that depend on what the Network supports.
Returns True
if the cellular mode is attached to the network. False
otherwise.
Returns True
if the cellular mode is attached to the network. False
otherwise.
Same as lte.isattached()
and provided for compatibility with legacy scripts
Gracefully detach the modem from the LTE-M network and disable the radio functionality.
Start a data session and obtain and IP address. Optionally specify a CID (Connection ID) for the data session. The arguments are:
cid
: connection ID, seeLTE.\_\_init()\_\_
andLTE.attach()
.
Returns True
if there is an active LTE data session and IP address has been obtained. False
otherwise.
Returns True
if there is an active LTE data session and IP address has been obtained. False
otherwise.
End the data session with the network.
Send an AT command directly to the modem. Returns the raw response from the modem as a string object. You can find the possible AT commands here.
If a data session is active (i.e. the modem is connected), you will need to
lte.pause_ppp()
andlte.resume_ppp
around the AT command.
Example:
lte.send_at_cmd('AT+CEREG?') # check for network registration manually (sames as lte.isattached())
Optionally the response can be parsed for pretty printing:
timeout
: specify the timeout milliseconds the esp32 chip will wait after the AT command to receive the response. -1 means wait foreverwait_ok_error
: wait for the modem to respond with OK or ERROR after sending the command. Not all commands return OK or ERROR which means the command might be waiting forever. Some commands such asAT+SQNINS
run longer than the maximum timeout, and settingwait_ok_error=True
is required to get the resultscheck_error
: Will check if an error occured and raise an exception. Helpful in scripts that should abort if an error occurs.
Perform a hardware reset on the cellular modem. This function can take up to 5 seconds to return as it waits for the modem to shutdown and reboot.
Suspend PPP session with LTE modem. this function can be used when needing to send AT commands which is not supported in PPP mode.
Resumes PPP session with LTE modem.
If no parameter is specified, return the current operating mode (0 for LTE.CATM1 and 1 for LTE.NBIOT)
If new_mode
is specified, switches the modem into the specified operating mode. Use LTE.CATM1 or LTE.NBIOT
Example: lte.mode(new_mode=LTE.CATM1)
The modem will reset and switch to the new operating mode
Turn the LTE modem power on. Will optionally wait until the modem answers with OK.
Turn off power to the LTE modem. Will gracefully shut down the LTE connection unless force=True is used.
Check if a SIM card is present and readable
Returns True if the lte module is powered on, otherwise false
Removes unnecessary line feed and OK/ERROR output from a modem response before printing the response on the REPL
Removes unnecessary line feed and OK/ERROR output from a modem response before returning the resp
This function allows reading unsolicited responses from the modem. These are responses sent by the modem without being requested using lte.send_at_cmd()
. The response can be formatted with lte.return_pretty_response
and lte.print_pretty_response
if desired.
Function will raise an exception if the modem is in active ppp mode.
Function will return a tuple of IP address information from the PPP stack
Function will return the IMEI (International Mobile Equipment Identity) number from the LTE module
Function will return the SIM card ICCID (Integrated Circuit Card Identification number). This function will check if a SIM card is present.
-
LTE.CATM1
: For use in CATM1 mode -
LTE.NBIOT
: For use in NBIOT mode
Written with StackEdit.