NB IoT
api.nbSend(addr, port, msg, timeout, type, nownewdatatimeout, rxport)
- Overview
- Arguments
- Example
Sends buffer msg to NB on specified IP, port and protocol type. Maximum length of Rx and Tx messages is 512 Bytes. Maximum execution time is limited by timeout milliseconds.
- addr (string) - IP address
- port (integer) - Port
- msg (string) - String to be sent to NB
- timeout (integer) - The maximum execution time in milliseconds
- type (string) - Protocol type, either UDP or TCP.
- nownewdatatimeout (integer, optional) - The maximum delay between data chunks on reception
- rxport (integer, optional) - Port to use for reception, if not specified, Port value is used
-- sends "test message" string to IP 185.8.239.192 on port 5566 with 6s timeout
status,answer = api.nbSend("185.8.239.192", 5566, "test message", 6000, "UDP")
api.nbAT(command, arg2, wakeUp)
- Overview
- Commands
- Arguments
- Return
- Example #1
- Example #2
- Example #3
- Example #4
- Example #5
Sends an AT command to NB module with specified timeout. Or use one of the defined commands.
- "AT_DEBUG_OFF" - turn off printing of AT commands
- "AT_DEBUG_ON" - turn on printing of AT commands
- "REINITIALIZE" - re-initialize the NB-IoT module
- "ICCID?" - returns ICCID value of current SIM card
- "IMSI?" - returns IMSI value of current SIM card
- "IMEI?" - returns IMEI value of the modem
- "DOWNLINK_MAX_PERIOD" - If there is no downlink for given value, set timeout to 30 seconds and re-initialize the module.
- "REINIT_HARD_LIMIT_RETRY" - If NB-IoT module is initialized 5 times in a row -> sleep 4 hours and then reset
- "FORCED_REINIT_DONE?" - monitors if "DOWNLINK_MAX_PERIOD" happened (1=true)
Default
- command (string) - AT command
- arg2 (integer) - The maximum execution time in milliseconds
- wakeUp (integer, optional) - Sending 1 will make sure that module is not asleep
Other
- "DOWNLINK_MAX_PERIOD" arg2 (integer) - time in milliseconds
- "REINIT_HARD_LIMIT_RETRY" arg2 (integer) - value defining how many times it will re-initialize module before reset
- answer (string) - Nil or non-zero length string with an answer to a AT command
- status (integer) - Zero for success, negative for failure
-- Get IMSI number of SIM card with timeout of 4 seconds
res = api.nbAT("AT+CIMI", 4000)
print(res)
-- IMEI --
x=api.nbAT("AT+CGSN")
start = string.find(x, "\n")
finish = string.find(x, "\r", start+1)
imei = string.sub(x,(start+1),(finish-1))
print("IMEI: " .. imei)
-- Get signal strength
res,b = api.nbAT("AT+CSQ")
print(res)
-- AT_DEBUG_OFF - turn off
-- AT_DEBUG_ON - turn on
-- REINITIALIZE - re-initialize the NB-IoT module
-- ICCID? - returns ICCID value of current SIM card
-- IMSI? - returns IMSI value of current SIM card
-- IMEI? - returns IMEI value of the modem
api.nbAT("AT_DEBUG_ON")
-- If there is no downlink for given value, set timeout to 30 seconds and re-initialize the module.
- api.nbAT("DOWNLINK_MAX_PERIOD", 3*24*3600*1000)
--if NB-IoT module is initialized 5 times in a row -> sleep 4 hours and then reset
- api.nbAT("REINIT_HARD_LIMIT_RETRY", 5)
-- "1" if DOWNLINK_MAX_PERIOD situation happened since reset.
- api.nbAT("FORCED_REINIT_DONE?")
api.nbReceiveBuffer(str)
- Overview
- Arguments
- Return
Enables internal buffer to receive NB data. Increases memory efficiency.
- str has 3 options:
- "activate" - activates the internal buffer
- "deactivate" - deactivates the internal buffer
- "dump" - dumps the internal buffer
- When "dump" option is used, functions returns the content of the buffer.