edit

Overview

Luat = Lua + AT, The IoT open source architecture introduced by Luat relies on the communication module for simple and rapid development. The traditional AT commands are encapsulated into APIs in Lua, and demos of various functional applications are provided, which greatly reduces the development cost for users.

Developers can easily and conveniently implement functions like TTS, GPS, SOCKER, MQTT, and OTA. For example, with these code, you can implement GPS and MQTT.

GPS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
--import gps.lua、sys.lua
require"gps"
require"sys"

--define function prtgps, which output the gps information in trace
--get 3D positioning, latitude and longitude, speed, direction angle, altitude or not
local function prtgps()
    print("gps", gps.is3dfix(), gps.getgpslocation(), gps.getgpsspd(), gps.getgpscog(), gps.getaltitude())  
end

--set the timer to call the prtgps function every 10 seconds
sys.timer_loop_start(prtgps, 10000)
--after booting, initialize gps; gps timing synchronization clock
gps.init()
gps.settimezone(gps.GPS_BEIJING_TIME)

MQTT

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
--import mqtt.lua
require"mqtt"

--mqtt connect callback funcition successfully
local function connectedcb()
    --subscribe the topic
    mqttclient:subscribe({topic="/event0",qos=1})
    --publish notifications
    mqttclient:publish("/event0", "qos1data", 1)
end

--create mqtt client
mqttclient = mqtt.create("TCP", "lbsmqtt.airm2m.com", 8083)
--connect to the mqtt server
mqttclient:connect("clientID", 240, "username", "password", connectedcb)

Introduction of Luat

The Lua script is embedded in the core which is the basic module software (the core compiled file is a .lod file). Lod has an environment that supports Lua running and the Lua script runs in this environment. The script implementation functionality is realized through the API (which encapsulates the AT commands).

Inside the module, Lua issues an AT command and interacts with the AT command through the virtual uart.ATC port and Lod. That is, Lua issues an AT command. After Lod receives the parsing and returns the result of the AT command, the host computer (usually a single-chip microcomputer) does not need to send an AT command to the module through the physical serial port, thus saving the cost of the single-chip microcomputer.

coreLua


Terminology Explanation

下载github上的Luat开发包。开发包的目录为下: Download Luat SDK from github. The directory of the SDK is:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
├── core

    └──Luat_VXXXX_8955.lod:does not support LCD function of SSL, TTS, or SPI
    768KB available for Luat script and resource(files burned with burner, like lua script, mp3 files)
    860KB available for file system(like argument files, recording files, and remote upgrate files created while the script is running)

    └──Luat_VXXXX_8955_SSL.lod:supports SSL
    768KB available for LuaDB script and resources(files burned with burner, like lua script, mpe3 files)
    796KB available for file system(like argument files, recording files, and remote update files created while the script is running)

    └──Luat_VXXXX_8955_SSL_TTS.lod:supports SSL and TTS, does not MP3, MIDI, or recording
    324KB available for LuaDB script and resources(files burned with burner, like lua script, mpe3 files)
    344KB available for file system(like argument files, recording files, and remote update files created while the script is running)


    └──Luat_VXXXX_8955_SSL_UI.lod:supports LCD function with interface of SSL and SPI
    704KB available for LuaDB script and resources(files burned with burner, like lua script, mpe3 files)
    540KB available for file system(like argument files, recording files, and remote update files created while the script is running)

    └──Luat_VXXXX_8955_TTS_UI.lod:supports LCD function with interface of TTS and SPI
    152KB available for LuaDB script and resources(files burned with burner, like lua script, mpe3 files)
    132KB available for file system(like argument files, recording files, and remote update files created while the script is running)

    └──Luat_VXXXX_8955_TTS1.lod:supports TTS function
    216KB available for LuaDB script and resources(files burned with burner, like lua script, mpe3 files)
    260KB available for file system(like argument files, recording files, and remote update files created while the script is running)

    └──Luat_VXXXX_8955_UI.lod:supports LCD function with SPI interface
    512KB available for LuaDB script and resources(files burned with burner, like lua script, mpe3 files)
    796KB available for file system(like argument files, recording files, and remote update files created while the script is running)

    └──Luat_VXXXX_8955_SSL_FLOAT.lod:support SSL,float number

    └──Luat_VXXXX_8955_SSL_UI_FLOAT.lod:support SSL, LCD with PI interface, and float number

    └──Luat_VXXXX_8955F.lod:64M flash version(Air202F), support LCD function with SSL、TTS、SPI interface


├── script_LuaTask Lua-based coroutines implement multi-threaded support

    └── demo
    └── lib
    └── product/LuatBoard_Air202  LuatBoard

The underlying software (also known as the underlying software, located at /core) is developed in C language to support the operation of Lua.

"Library script" in the lib directory (all projects should be used),

User-written "application scripts" (such as scripts in the demo directory)

LuaTools

Use the Luat debug development tool to download lod and script for the module. The tool functions as follows:

Encrypt lod function;

Download the official lod bottom layer;

Download the Lua script for secondary development;

Use the App to verify that the development board is good;

Output analysis of the module print trace;

Generate mass production files for remote upgrade/mass production.

This took does not support code editing, if you want to edit the code, you need to download other editor liek sublime text 3, vscode, notepad++ etc.

User guide

Download