This article is about using AirVantage API for devices. It will focus on OpenAT device like the SL808xT.
Project Name
field. For example: DevProgram1Next
. The Hardware Configuration step appearsNext
A warning may appear at each step, indicating that there is no common SDK Profile between this package and some plugins. If so, ignore it.
New Target Platform
Next
. The Sample Selection step appears.Finish
An application model aims to explain to AirVantage how to deal with the device about communication and authentication and managing the data: variable, settings or commands. If you don’t supply such information, the server will ignore all the communication from your device. In this step, we are going to see how to create this application and release it on AirVantage and associate it to your system.
<data>
area. Once it matches your needs, save everything as model.app.Don’t modify the asset id as it is used in the code source application or modify it accordingly
<?xml version="1.0" encoding="ISO-8859-1"?>
<app:application
xmlns:app="http://www.sierrawireless.com/airvantage/application/1.0"
type="com.test.airvantage.sl.app"
name="AirVantage Greenhouse"
revision="0.0.1">
<capabilities>
<communication>
<protocol comm-id="IMEI" type="MQTT" />
</communication>
<data>
<encoding type="MQTT">
<asset default-label="Greenhouse" id="machine">
<variable default-label="Temperature" path="temperature"
type="double"/>
<variable default-label="Luminosity" path="luminosity"
type="double"/>
<setting default-label="Threshold" path="threshold"
type="int"/>
</asset>
</encoding>
</data>
</capabilities>
<application-manager use="SOFT_IDS" />
</app:application>
It is now time to write an app for our SL808xT. You can have a look about using MQTT in AirVantage , if you want to have a description about the serialization details.
If you are using a serial port to communicate with your device, go on the next section. If you are using an USB connection with your device, do the following :
/* Comment the following line to suppress low-level traces: */
WIP_NET_OPT_DEBUG_PORT, *WIP_NET_DEBUG_PORT_USB*, // low level traces put UART1 if using Serial
WIP_NET_OPT_END);
entry_point.c
and update the server adress (if needed) and the password at the end of the file: /* mqtt library context*/
av_mqttConfig_t config = {
.bufferSize = sizeof(buffer),
.buffer = buffer,
.pingPeriod = 30,
.callback = &serverCallback,
.callbackCtx = NULL,
.deviceId = deviceId, // imei of device
.serverAddress = "eu.airvantage.net",
.serverPort = 1883,
.serialization = SERIALIZE_JSON,
.password = "1234567890",
.qos= QOS_1
};
#define GPRS_APN "apn"
#define GPRS_USER "user"
#define GPRS_PASSWORD "password"
#define GPRS_PINCODE "0000"
#define GPRS_BEARER "GPRS"
Once the binary has been generated, you can:
If a hyperterminal (or any serial port terminal) was previously used to send AT commands, close the connection from the hyperterminal (or any serial port terminal).
Download on the Embedded module
Look, it is alive:
+WDSI: 0
[GPRS]: GPRS CTX (cid=1) found
[GPRS]: GPRS EVENT: 27 (cid=1)
[GPRS]: GPRS CTX (cid=1) found
[GPRS]: GPRS EVENT ACTIVATE OK (cid=1)
[GPRS]: GPRS: -> CONNECTED
[entry_point] Device id 353270040962302
[entry_point] Network up, starting application...
[MQTT] connecting to client eu.airvantage.net:1883
[WIP] new TCPCLIENT 0x1814f3fc
[MQTT] Connection established successfully
...
[MQTT] 60Bytes have been sent for Connection.
...
[MQTT] 4 bytes received.
...
[MQTT] Waiting publish (4)
[callBackFct] Callback user is called
...
[callBackFct] End callback user
...
[Entry_point] Reading measures : temperature=25, humidity=44.000000, luminosity=74.000000
[Entry_point] Reading measures : temperature=25, humidity=36.000000, luminosity=79.000000
[Entry_point] Reading measures : temperature=25, humidity=45.000000, luminosity=75.000000
...
Your data is now sent. You can check your data communication. Just go to Inventory > Systems, then pick your own and click Timeline. That is it.
Next step
Continue the tutorial by using tools supplied by AirVantage to test your communication with your device.