The lte functions control the cellular modem on products that connect to the internet over LTE.
Available for OS7.1.0 and later
lte.at(command, timeout_ms)
Sends an arbitrary AT command to the LTE modem and returns its response.
This function is available only while the device is connected through its cellular interface. If the active network interface is not cellular, it returns immediately with a fatal status.
Arguments
| Argument | Type | Description |
|---|---|---|
command |
string | The AT command to send. |
timeout_ms |
number | Optional. The time to wait for a response, in milliseconds. Defaults to 10000. |
Return Value
Returns two values: the response and a status code.
| Return | Type | Description |
|---|---|---|
response |
string | nil | The raw response from the modem. nil when the command does not complete successfully. |
status |
number | A status code (see below). |
| Status | Meaning |
|---|---|
0 |
OK. |
1 |
The modem returned an error. |
2 |
Timed out. |
3 |
Fatal error (no modem, the interface is not cellular, or the modem is busy). |
Example: Querying Signal Quality
The following example sends an AT+CSQ command, which asks the modem for its signal quality, whenever a command arrives from obniz.js.
function on_command(command)
os.log("command received: " .. command);
-- Send the AT command received from obniz.js to the modem
local resp, status = lte.at(command);
os.log("response: " .. tostring(resp));
os.log("status: " .. tostring(status));
-- Return the response to obniz.js
if resp ~= nil then
cloud.pluginSend(resp);
end
end
From obniz.js, send the AT command as plugin data.
// Javascript Example
obniz.plugin.send("AT+CSQ");