[ART-Pi Review] 6: OTA connection to onenet cloud platform
[Copy link]
This post was last edited by Digital Leaf on 2021-8-8 22:23
OneNET platform is an ecological platform built by China Mobile based on the Internet of Things industry. It can adapt to a variety of network environments and protocol types, such as MQTT, HTTP, EDP, Modbus, TCP transparent transmission, RGMP, etc., to facilitate user data management and device control. Although it is my first time to use it, I feel it is easier to use than Alibaba Cloud. Unlike Alibaba's documents that jump around, it is easy to quickly check, but it also means that the information is not as detailed as Alibaba.
First, copy a project that has already implemented WiFi networking, so you don’t need to configure the network again
Although copying is fast and efficient, there are still two places to modify. One is to change the project name in the project configuration, and the other is to reload the downloaded algorithm.
RT-Thread has also been adapted for OneNET platform connection and provides a OneNET software package. Through this software package, devices can easily connect to the OneNet platform on RT-Thread to complete functions such as data sending, receiving, device registration and control.
Add OneNET package
The detailed settings of the software package are all parameters related to the cloud platform device. You cannot fill them in yet. You must first create a product and device on the cloud platform.
Because it supports many protocols, in order to cooperate with the OneNET software package, add a product of mqtt protocol
After the product is added successfully, you can continue to add devices under the product. You can add many devices under one product. You can add them individually or in batches. After trying it, this batch addition is still very useful.
After the product is added successfully, it is offline because it is not yet bound to any actual hardware.
Then, you need to find the parameters required in the OneNET software package configuration, including device ID, authentication information, API key, product ID, and Master-API key. The device ID and product ID are generated by the system and are unique, because OneNet charges by device, and the device authentication information can be specified by yourself. The API key can be added as long as it has been removed from the shelf. The Master-API key has the highest level and can only be obtained by verifying the account mobile phone, and it is time-limited.
Fill in the parameter configuration of the OneNET software package in sequence, then save the configuration, compile and download after generating the project
In the FinSH interface, you can see several mqttt communication commands given. Use the command net_mqtt_init to complete the initialization. After the initialization is completed, the device is online.
onenet_mqtt_publish_digit shuju 33
onenet_mqtt_publish_string ceshisrting aabbcc
You can easily transfer data to the cloud platform. You can see the sent data in the data just created.
At the same time, the cloud platform can also send data to the device
However, this needs to be bound to the receiving callback function in the program before it can be displayed in FinSH. Otherwise, there will only be a notification but no specific content.
Several similar operations are encapsulated, such as getting data stream onenet_http_get_datastream, onenet_get_dp_by_limit, etc.
For cloud data flow display, this is the most basic and direct one, and it can also enrich the display and expand it to bar charts, line charts, dashboards, text, etc.
|