Internet of things Command prototype design and framework

Source: Internet
Author: User

In another article, we describe the client API design (IOT command (based on SIP) client API design for Java).

The previous time combed the command design and framework, in fact, the narrow sense of the device control, management, can be managed in the home LAN, can also be remote management (through the open source SIP server:opensips), of course, also contains the device linkage rules of the prototype implementation (ie, the ittt of the Internet of Things).

Command contains two parts: client and server (the server on the client app,gateway on the phone)

The process is as follows:

1. Mobile phone to send a remote request: to the room hue lights 2. The IoT cloud platform receives requests forwarded to the appropriate gateway3. Command_svr receive, parse sent to the Hue module, Hue module for this device type protocol communication, to realize the light request 4-5. COMMAND_SVR sends the operation result back, from Opensips to the client, the client learns the turn on the light successful result. Client main function: 1. Request the gateway's device list, device features, status 2. Send device operation request and receive device operation result 3. Subscribe, receive device message notification Sever main features: 1. Manage the list of different device types that are connected to the gateway, and the device plug-in is accessed as a dynamic library for third-party access. 2. Receiving the client's device operation request, forwarded to the corresponding device module (eg ip_camera), the module for the protocol conversion, the actual device control, and then receive the operation results, and convert it to the command protocol, return to the client response.3. Receives the active push message from the device module and pushes it to the corresponding client.4. ITTT function: Receive and store the device linkage rules developed by client, check the client's device control request, if it is compliant, then the device control is triggered.

The current command implementation is based on the SIP, the SIP method is extended, that is, to add a custom method Sip-command, and on the basis of the implementation of the device control layer, command in the Pjsip Open Source Library based on the implementation, and remote management with open-source opensips server, to achieve rapid prototyping purposes; Another reason is that the project streaming media transmission demand is based on SIP/RTP to achieve, unified in the SIP, reduce the cost of learning input, as soon as possible prototype. is a command framework diagram, the bottom is the SIP layer, on the basis of Pjsip added command method, cmd_mng defined two main interfaces (Cmd_send_inf, cmd_recv_inf) to communicate with the SIP layer, Consider the future easy to replace or compatible with different protocols to achieve loose coupling between modules. The CMD_MNG upper layer is the DEV_MNG and Iot_cmd_proc two modules, DEV_MNG contains the command server side management, loading device plug-in, that is, the function of the device and device metadata file parsing import (by definition Plugin_ The interface interface, which is provided to third parties to develop a new device type for gateway access, and an internal interface for client to query device meta information. The Iot_cmd_proc module contains the client, server's processing framework for sending and receiving command messages, and the interface to the third-party development client (the client API design that starts with).
1. The following describes the server side of the interface for third-party access to the new device type development (third-party implementation, and in the form of a dynamic library to the Gateway COMMAND-SVR) Plugin_interface interface:
typedefstructdev_func{Const Char*funcname;int(* Dev_method) (Cmd_arg *param_list[], uint8_t plist_size); }dev_func;typedefstructDev_plugin {CharDev_pluginname[name_maxsize];//device type name, unique ConstDev_func * Pt_func_array;//function list, the device actually executes the function for COMMAND-SVR callback.  CharDev_metafile[name_maxsize];//device meta-data file}dev_plugin;typedefint(* init_devplugin) (Dev_plugin * pt_plugin, Dev_cmd_interface * pt_inf);
Command-svr through the Init_devplugin function, the above information is read to the device plug-in, and the gateway knows the properties and functions of the device type. (later also need to have the device plug-in hot update, delete, run-time load and other functions) 2. The following is an introduction to the Iot_cmd_proc module, which is the logical processing core of command, using the client side as an example, in the form of memory Message Queuing (using MINI_MQ) to decouple the business layer (cli_proxy), the command layer (CMDHANDLER_PROC) , after the development of the Protocol layer (SIP_PROXY), which carries MSG, summarizes the following problems: 1. Command's device control design, which is based on the action of the device, defines the metadata for the test device type as follows
<Devicetype= "Test_plugin"><Methodname= "Test1"><paramname= "a"type= "int"direction= "in"/><paramname= "B"type= "string"direction= "in"/><paramname= "C"type= "float"direction= "Out"/><paramname= "D"type= "string"direction= "Out"/></Method></Device>

If you join the device propery attribute, you can well fit the protocol of the next stage command in the RESTful style of HTTP, targeting the device resource properties, simply passing set, Get to operate on the device (of course, just as not all Web services can be perfectly restful, device control operations can take the form of attributes, actions are defined). 2. As described above, I consider the command protocol using HTTP, in the gateway using Web services, the client side of the hybrid approach, that is, to avoid the command of the client, server update problems, and the use of original born to avoid the shortcomings of the web, is now in the research. 3. Design a Iot_cloud prototype, the tentative function is mainly for user-friendly remote management of equipment, as well as storage of user equipment data, and simple data analysis.

IoT command prototype design and framework

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.