A lightweight online service communication system and method
Through the lightweight online service communication system, using the orayiotsvr service program and orayiotsdk, low-cost access and stable online of IoT devices are achieved, solving the high cost problem in the traditional development process and meeting the needs of various IoT applications.
Patent Information
- Application Number
- CN202310019240.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-06
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2043-01-06
AI Technical Summary
In the traditional software development process, the cost of connecting IoT devices to the Internet is high, and it is difficult to keep the devices online stably, resulting in high R&D and maintenance costs.
A lightweight online service communication system is used, including the orayiotsvr service program, client software integrated with orayiotsdk, database and request calling terminal. Data is exchanged through UDP and TCP ports, and the redis database is used to store status information, providing device online functions and business logic interaction.
It reduces the development and maintenance costs of IoT devices accessing the Internet, simplifies the establishment of business communication frameworks, improves the stability and flexibility of online devices, and meets the needs of various IoT users.
Smart Images

Figure CN116033031B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and in particular to a lightweight online service communication system and method. Background Art
[0002] The Internet of Things (IoT) connects ubiquitous terminal devices, facilities, software, and systems to various communication networks, enabling intelligent identification, positioning, tracking, supervision, scheduling, and control, enabling efficient, energy-efficient, safe, and environmentally friendly management, control, and operation of all things. With the rapid development of IoT technology, an increasing number of smart devices, shared software, and systems are connected to the internet, and an increasing number of businesses are embracing IoT products and technologies. However, for individuals and businesses with limited R&D capabilities who wish to embrace the IoT, the traditional software development process involves prohibitively high costs for developing and maintaining online services. Developing their own software and applications, successfully connecting devices to the internet, and maintaining a stable online presence are major roadblocks. Summary of the Invention
[0003] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a lightweight online service communication system that can easily realize the construction and operation of the Internet of Things communication framework and provide complete online services, as well as a lightweight online service communication method using this system.
[0004] The present invention is achieved through the following technical solutions:
[0005] A lightweight online service communication system, characterized by including an orayiotsvr service program, client software integrated with orayiotsdk, a client, a database, and a request calling terminal;
[0006] The orayiotsvr service program is used to accept the client's login request through the UDP port and maintain its online status, and is responsible for data interaction with it; accept the HTTP request initiated by the request caller through the TCP port, and forward the request to the client to realize data transfer; establish a connection with the database, store the client's status information in the database, and publish the client's online and offline status information in real time;
[0007] The client is used to implement specific business functions and access the orayiotsvr service program through the integrated orayiotsdk client software to realize the device online function;
[0008] The database is responsible for storing the registration information and status information of the client;
[0009] The request calling end is used to send an http request to the client according to the established interface to complete the interaction.
[0010] Furthermore, the orayiotsdk includes a global logging enable module, a client device configuration setting module, a callback monitoring connection module, a server connection module, and a server connection stop module.
[0011] The global logging enable module is used to enable global logging by calling IOT_OpenLog, the client device configuration setting module is used to set the client configuration by calling IOT_SetConfig, the callback monitoring connection module is used to set the callback monitoring of client events by calling IOT_SetCallback, the connection server module is used to connect to the orayiotsvr service program by calling IOT_Start, and the connection server stop module is used to stop the connection with the orayiotsvr service program by calling IOT_Stop.
[0012] Furthermore, the database is a lightweight database redis.
[0013] Furthermore, the client is an IoT device or IoT software, such as some monitoring devices, sensor devices, execution devices, etc., which can be used in the present invention, and some shared software, online service software or system can also be used in the present invention.
[0014] A lightweight online service communication method, using the above lightweight online service communication system, includes the following steps:
[0015] S1. Register the client in the redis database and store its information;
[0016] S2. The orayiotsvr service program reads the orayiotsvr.ini configuration, opens and listens to the TCP and UDP ports, connects to the Redis database, and waits for client login requests.
[0017] S3. The client logs in to the orayiotsvr service program through the client software integrated with orayiotsdk. The orayiotsvr service program receives the client's login request and updates the client's status information in the Redis database. Redis publishes the client's online message through PUBLISH, and the orayiotsvr service program maintains the connection with the client.
[0018] S4. The request calling end initiates an HTTP request to the orayiotsvr service program, wherein the HTTP request carries the client ID information;
[0019] S5. The orayiotsvr service program receives and parses the http request, identifies the corresponding client ID, and forwards the http request to the corresponding client based on the client ID;
[0020] S6. The client (client software integrated with orayiotsdk) receives and parses the http request forwarded by the orayiotsvr service program, makes a corresponding reply and sends it to the orayiotsvr service program;
[0021] S7, the orayiotsvr service program receives the client's response and forwards it to the request caller;
[0022] S8. The request calling end receives and parses the client's response.
[0023] Furthermore, the client accesses the orayiotsvr service program through the client software integrated with orayiotsdk, and the method is as follows:
[0024] Open global logging by calling IOT_OpenLog;
[0025] Set the client configuration by calling IOT_SetConfig;
[0026] Set the callback listener for client events by calling IOT_SetCallback;
[0027] Connect to the orayiotsvr service program by calling IOT_Start;
[0028] Stop the connection with the orayiotsvr service program by calling IOT_Stop.
[0029] Furthermore, the configuration of the client set by calling IOT_SetConfig includes: configuring the device ID of the current client through szSerialNumber, setting the request path when the request caller initiates an http request to the current client through szUrlPath, setting the MAC address of the current client login through szMacAddress, setting the domain name or IP of the orayiotsvr service program through szServer, and setting the UDP port of the orayiotsvr service program through nPort.
[0030] Furthermore, in the S3 step, the method for the orayiotsvr service program to maintain connection with the client is:
[0031] The orayiotsvr service program and the client are kept alive through keepAlive. When the request caller sends an http request to the client, the orayiotsvr service program will address the corresponding client according to the client ID in the http request and send the http request to the client through the online connection, and set a timeout retransmission mechanism. The timeout retransmission mechanism sets the time for timeout retransmission.
[0032] After the client receives and parses the http request, it executes the corresponding business response to the orayiotsvr service program, which then forwards the response to the request caller.
[0033] The orayiotsvr service program updates the client status information to the Redis database, and Redis publishes the client's online status message to subscribers through PUBLISH;
[0034] When keepAlive times out, the orayiotsvr service program will reset the client's status information in the redis database, and redis will publish the client's offline message to subscribers through PUBLISH.
[0035] Furthermore, the request calling end simulates creating and sending an http request through the Postman tool.
[0036] Furthermore, it also includes (the request calling end and the orayiotsvr service program) obtaining the client (device) information in the redis database through the GET token_iot_xxxx command, where xxxx is the client (device) ID, and the return value includes aes_key, auth, devtype, ip, port, state, sn, sid, online, and domain. Among them, the aes_key value is the base64-encoded data of the aes_key between the client and the orayiotsvr service program; the auth value is the authentication code for the client to log in to the orayiotsvr service program. The client will be verified when logging in. If the auth value is 0, no verification is required; the devtype value is the client (device) model; the ip value is the public IP address of the client (device); the port value is the public port of the client (device); the state value is the client's status identifier; the sn value is the client (device) SN number; the sid value is the session of the client (device) login, which is generated by the orayiotsvr service program; the online value is whether the current client (device) is online, 1 for online and 0 for offline; the domain value is the domain name during the HTTP request, which can be calculated using the same method as md5(iot_kvm_sn) or md5(iot_plug_sn).
[0037] The present invention integrates orayiotsdk through client software and cooperates with the independently deployed orayiotsvr, so that developers can easily complete the construction of a business communication framework. After the client logs in to orayiotsvr through orayiotsdk, the remote end notifies the client through a customized HTTP request to complete the specified action, providing complete online services, including device online and offline, business logic interaction notification and other functions. Developers do not need to worry about the process of the entire business communication framework and the reconnection mechanism of accidental network disconnection, and can focus more on the realization of their own business functions, quickly develop and iterate a new Internet application, and at the same time reduce their development and operation costs while meeting their business needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 This is a structural framework diagram of the online service communication system of the present invention.
[0039] Figure 2 This is a workflow diagram of the online service communication method of the present invention.
[0040] Figure 3 This is a schematic diagram of the interface for connecting the client software of the present invention to orayiotsvr.
[0041] Figure 4This is a schematic diagram of the interface for the request calling end of the present invention to send an http request.
[0042] Figure 5 This is a schematic diagram of the interface of the client software response of the present invention. DETAILED DESCRIPTION
[0043] A lightweight online service communication system, such as Figure 1 , including orayiotsvr service program, client software integrated with orayiotsdk, client, database and request calling end.
[0044] The orayiotsvr service program is a client online service program, which is mainly used to keep the client online stably and transfer requests, specifically:
[0045] (1) Enable UDP port listening: used to accept the client's login request through the UDP port and maintain its online status, and is responsible for exchanging data with the client.
[0046] (2) Enable TCP port listening: Accept the http request initiated by the request calling end through the TCP port, and forward the request to the client to realize data transfer.
[0047] (3) Establish a connection with the database, store the client's status information in the database, and publish the client's online and offline status information in real time.
[0048] The client is used to realize specific business functions, and accesses orayiotsvr service program by integrating the client software of orayiotsdk to realize device online function.The client of the present invention can be some software (such as remote office software, sharing software, online service software, etc.) or Internet of Things hardware equipment (such as various sensing devices, monitoring equipment, positioning equipment, smart home equipment, execution equipment, etc.). Nowadays, Internet of Things software and various Internet of Things devices are of various types, in various forms, and their configurations are also very different, and corresponding operating systems or device software are also varied, therefore it is a major challenge to realize that these devices and software go up to the cloud and cross-platform operation, and by orayiotsdk, device and software can be made to have cloud capabilities.
[0049] The Orayiot SDK is a client for online services, providing functionality for device access, device management, device operation and maintenance, and device interaction with the IoT platform. Devices can access the Orayiot SDK through a provided API. Specifically, the Orayiot SDK includes a module for enabling global logging, a module for configuring client device configuration, a module for listening for callbacks, a module for connecting to a server, and a module for stopping server connections.
[0050] The global logging enable module is used to enable global logging by calling IOT_OpenLog, the client device configuration setting module is used to set the client configuration by calling IOT_SetConfig, the callback monitoring connection module is used to set the callback monitoring of client events by calling IOT_SetCallback, the connection server module is used to connect to the orayiotsvr service program by calling IOT_Start, and the connection server stop module is used to stop the connection with the orayiotsvr service program by calling IOT_Stop.
[0051] The database is responsible for storing the registration and status information of IoT devices. In this embodiment, the database is Redis, a high-performance key-value database that supports master-slave synchronization and fully implements a publish / subscribe mechanism. This allows a slave database to subscribe to a channel and receive the complete message publishing history of the master server when synchronizing the tree anywhere. Of course, other databases can also be used.
[0052] The request calling end is used to send an http request to the client according to the established interface to complete the interaction.
[0053] A lightweight online service communication method, using the above lightweight online service communication system, such as Figure 2 , including the following steps:
[0054] S1. Register the client in the redis database and store its information.
[0055] S2. The orayiotsvr service program reads the orayiotsvr.ini configuration, opens and listens to the TCP port and UDP port, connects to the Redis database, and waits for client login requests.
[0056] S3. The client logs in to the orayiotsvr service program through the client software integrated with orayiotsdk. The orayiotsvr service program receives the client's login request and updates the client's status information in the redis database. Redis publishes the client's online message through PUBLISH. The orayiotsvr service program maintains the connection with the client. The interface for the client to log in to the orayiotsvr service program can be as follows: Figure 3 shown.
[0057] S4, the request calling end initiates an http request to the orayiotsvr service program, and the http request carries the client ID information. Figure 4The request calling end can simulate creating and sending http requests through the Postman tool. Postman provides the ability to generate calling code snippets in different programming languages for http requests, such as Figure 4 , open Postman, fill in the interface address, request parameters, etc. on the Postman interface, and you can see the HTTP request calling code.
[0058] S5. The orayiotsvr service program receives and parses the http request, identifies the corresponding client ID, and forwards the http request to the corresponding client according to the client ID.
[0059] S6. The client (client software integrated with orayiotsdk) receives and parses the http request forwarded by the orayiotsvr service program, makes a corresponding reply and sends it to the orayiotsvr service program. The interface of the client responding to the http request can be as follows Figure 5 shown.
[0060] S7. The orayiotsvr service program receives the client's response and forwards it to the request caller.
[0061] S8. The requesting end receives and parses the client software's response, thus completing a business interaction.
[0062] The client connects to orayiotsdk to provide cloud access capabilities for the device. The open API interface of orayiotsdk is very streamlined. The client software can complete the integration of an application and connect to the orayiotsvr service program through the following steps:
[0063] (1) Enable global logging: Enable global logging by calling IOT_OpenLog;
[0064] (2) Set basic configuration: Set the client configuration by calling IOT_SetConfig; among them, configure the current client device ID through szSerialNumber, set the request path when the request caller initiates an http request to the current client through szUrlPath, set the MAC address of the current client login through szMacAddress, set the domain name or IP of the orayiotsvr service program through szServer, and set the UDP port of the orayiotsvr service program through nPort.
[0065] The global configuration IOT_CONFIG is described in detail as follows:
[0066] szSerialNumber: The unique serial number of the client device, which is also the device ID that uniquely identifies the current client. This serial number consists of 12 digits, defined by the developer and guaranteed to be unique. It can be used to associate with the developer's own account system. This serial number must be used by only one client at a time;
[0067] szUrlPath: The request path in the HTTP request initiated by the request caller to the client device. The client will reject all requests not under this path;
[0068] szMacAddress: The MAC address of the current client device, mainly used for identification. If you think this MAC address information is too sensitive, you can enter a fixed MAC address value without affecting the specific business process;
[0069] szServer: the domain name or IP address of the independently deployed orayiotsvr;
[0070] nPort: The port (UDP) of the independently deployed orayiotsvr;
[0071] (3) Connect callback monitoring: Set the callback monitoring of client events by calling IOT_SetCallback;
[0072] (4) Start the service: connect to the orayiotsvr service program by calling IOT_Start;
[0073] (5) Stop service: Stop the connection with the orayiotsvr service program by calling IOT_Stop.
[0074] The method for the orayiotsvr service program to maintain connection with the client in the S3 step is:
[0075] The orayiotsvr service program and the client are kept alive through keepAlive. When the request caller sends an HTTP request to the client, the orayiotsvr service program will address the client according to the client ID in the HTTP request and send the HTTP request to the client through the online connection, and set a timeout retransmission mechanism. The timeout retransmission mechanism sets the timeout retransmission time (such as 2s);
[0076] After the client receives and parses the http request, it executes the corresponding business response to the orayiotsvr service program, which then forwards the response to the request caller.
[0077] The orayiotsvr service program updates the client's status information to the Redis database, and Redis publishes the client's status message to subscribers via PUBLISH;
[0078] When keepAlive times out, the orayiotsvr service program will reset the client's status information in the redis database, and redis will publish the client's offline message to subscribers through PUBLISH.
[0079] To obtain the client device information in the Redis data, you can use the command with the key name token_iot_xxxx, where xxxx is the device ID. Assuming the client device ID is 856126251217, you can use the following command to obtain the device information:
[0080] GET token_iot_856126251217
[0081] The return value is as follows:
[0082] aes_key=Z8Zpc1H / Suwpzbqr8vvjRnzCVPgb6OeNdlouYzOfyZo=&auth=0&devtype=1&domain=f4417d05dd2 2dc96b7abda939ed9fdfa&ip=1699836873&kvm_state=1&online=1&port=43607&sid=3&sn=856126251217
[0083] Parameter explanation:
[0084] aes_key is the base64-encoded data of the aes_key between the client and the orayiotsvr service program;
[0085] auth is the authentication code for the client to log in to the orayiotsvr service program. The client will verify it when logging in. If it is set to 0, it means no verification is required.
[0086] devtype is the device model;
[0087] ip is the public IP address of the device;
[0088] port is the public network port of the device;
[0089] state is the status identifier of the client; different client types correspond to different status identifiers;
[0090] sn is the device sn number;
[0091] sid is the session for device login, generated by the orayiotsvr service program;
[0092] Online indicates whether the current device is online, 1 means online, 0 means offline;
[0093] domain is the domain name used in the HTTP request, which can be calculated using md5(iot_kvm_sn) or md5(iot_plug_sn). For example, if the client sn is 856126251217, then domain is md5(iot_kvm_856126251217), i.e. f4417d05dd22dc96b7abda939ed9fdfa.
[0094] The Orayiotsvr service program, Orayiotsdk integrated tool module, and interfaces between modules in the present invention are all IoT service programs and tools independently developed by our company. These IoT service programs and tools can be applied to a variety of IoT software and hardware devices to meet the various needs of a variety of IoT users (request callers). The IoT online service system thus formed has been applied in multiple application scenarios in the field of IoT. For example, IoT users can remotely access various office systems, file servers, video surveillance, etc. anytime and anywhere, including remote access to various remote sensing mapping instruments in the industrial manufacturing field, obtaining monitoring data from various sensors, controlling the operation of certain switch devices, and so on.
[0095] The above detailed description is a specific description of a feasible embodiment of the present invention. The embodiment is not intended to limit the patent scope of the present invention. Any equivalent implementation or modification that does not depart from the present invention should be included in the patent scope of this case.
Claims
1. A lightweight online service communication system, characterized in that: Including orayiotsvr service program, client software integrated with orayiotsdk, client, database and request calling end; The orayiotsvr service program is used to accept the client's login request through the UDP port and maintain its online status, and is responsible for data interaction with the client; accept the HTTP request initiated by the request caller through the TCP port and forward the request to the client to realize data transfer; establish a connection with the database, store the client's status information in the database, and publish the client's online and offline status information in real time; The client is used to implement specific business functions and access the orayiotsvr service program through the client software integrated with orayiotsdk to realize the device online function; the client is an Internet of Things device or Internet of Things software; The database is responsible for storing the client's registration information and status information; The request calling end is used to send an http request to the client according to the established interface to complete the interaction; The orayiotsdk includes a global logging enable module, a client device configuration setting module, a callback monitoring connection module, a server connection module, and a server stop connection module; The global logging enable module is used to enable global logging by calling IOT_OpenLog, the client device configuration setting module is used to set the client configuration by calling IOT_SetConfig, the callback monitoring connection module is used to set the callback monitoring of client events by calling IOT_SetCallback, the connection server module is used to connect to the orayiotsvr service program by calling IOT_Start, and the connection server stop module is used to stop the connection with the orayiotsvr service program by calling IOT_Stop.
2. A lightweight online service communication system according to claim 1, characterized in that: The database is a lightweight redis service.
3. A lightweight online service communication method, using the lightweight online service communication system according to claim 1 or 2, characterized in that: The steps include: S1. Register the client in the redis database and store its information; S2. The orayiotsvr service program reads the orayiotsvr.ini configuration, opens and listens to the TCP and UDP ports, connects to the Redis database, and waits for client login requests. S3. The client logs in to the orayiotsvr service program through the client software integrated with orayiotsdk. The orayiotsvr service program receives the client's login request and updates the client's status information in the Redis database. Redis publishes the client's online message through PUBLISH, and the orayiotsvr service program maintains the connection with the client. S4. The request calling end initiates an HTTP request to the orayiotsvr service program, wherein the HTTP request carries the client ID information; S5. The orayiotsvr service program receives and parses the http request, identifies the corresponding client ID, and forwards the http request to the corresponding client based on the client ID; S6. The client receives and parses the http request forwarded by the orayiotsvr service program, makes a corresponding reply and sends it to the orayiotsvr service program; S7, the orayiotsvr service program receives the client's response and forwards it to the request caller; S8. The requesting end receives and parses the client's response; The client logs in to the orayiotsvr service program through the client software integrated with orayiotsdk, and the method is as follows: Open global logging by calling IOT_OpenLog; Set the client configuration by calling IOT_SetConfig; Set the callback listener for client events by calling IOT_SetCallback; Connect to the orayiotsvr service program by calling IOT_Start; Stop the connection with the orayiotsvr service program by calling IOT_Stop.
4. A lightweight online service communication method according to claim 3, characterized in that: The configuration of the client set by calling IOT_SetConfig includes: configuring the device ID of the current client through szSerialNumber, setting the request path when the request caller initiates an http request to the current client through szUrlPath, setting the MAC address of the current client login through szMacAddress, setting the domain name or IP of the orayiotsvr service program through szServer, and setting the UDP port of the orayiotsvr service program through nPort.
5. A lightweight online service communication method according to claim 3, characterized in that: The method for the orayiotsvr service program to maintain connection with the client in the S3 step is: The orayiotsvr service program and the client are kept alive through keepAlive. When the request caller sends an http request to the client, the orayiotsvr service program will address the corresponding client according to the client ID in the http request and send the http request to the client through the online connection, and set a timeout retransmission mechanism. The timeout retransmission mechanism sets the time for timeout retransmission. After the client receives and parses the http request, it executes the corresponding business response to the orayiotsvr service program, which then forwards the response to the request caller. The orayiotsvr service program updates the client status information to the Redis database, and Redis publishes the client's online status message to subscribers through PUBLISH; When keepAlive times out, the orayiotsvr service program resets the client's status information in the Redis database, and Redis publishes the client's offline message to subscribers through PUBLISH.
6. A lightweight online service communication method according to claim 3, characterized in that: The request calling end simulates creating and sending an http request through the Postman tool.
7. A lightweight online service communication method according to claim 3, characterized in that: It also includes obtaining client information in the redis database through the GETtoken_iot_xxxx command, where xxxx is the client ID and the return value includes aes_key, auth, devtype, ip, port, state, sn, sid, online, and domain; Among them, the aes_key value is the base64-encoded data of the aes_key between the client and the orayiotsvr service program; the auth value is the authentication code for the client to log in to the orayiotsvr service program. The client will be verified when logging in. If the auth value is 0, no verification is required; the devtype value is the client model; the ip value is the client's public IP address; the port value is the client's public port; the state value is the client's status identifier; the sn value is the client's SN number; the sid value is the client's login session, which is generated by the orayiotsvr service program; the online value is whether the current client is online, 1 for online and 0 for offline; the domain value is the domain name used in the HTTP request.
Citation Information
Patent Citations
Internet of Things platform management system capable of being deployed at cloud end
CN110505312A
Construction method of remote Internet of Things platform based on heterogeneous equipment
CN113114760A