Point-to-point login method and device, internet of things equipment and storage medium

By prioritizing the reuse of licenses within their validity period through local caching, the problem of long latency and high battery consumption of peer-to-peer devices in weak network environments is solved, enabling fast login and low-power peer-to-peer connections.

CN123055386APending Publication Date: 2026-11-06SHENZHEN XIAOPAI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611254827.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-18
Publication Date
2026-11-06

AI Technical Summary

Technical Problem

Existing point-to-point device connections require multiple network interactions in weak network environments, resulting in long latency and high battery consumption, as well as heavy concurrent processing pressure on the license server.

Method used

By prioritizing the reuse of licenses within their validity period through local caching, in response to the online status of IoT devices, the system obtains the license and its validity period from persistent storage. If the license is within its validity period, it directly initiates peer-to-peer server login; otherwise, it updates the license and logs in again.

Benefits of technology

In weak network environments, the time from device wake-up to peer-to-peer availability is shortened, reducing battery consumption and the pressure on the license server, thus improving the device's battery life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123055386A_ABST
    Figure CN123055386A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of Internet of Things, in particular to a point-to-point login method and device, an Internet of Things equipment and a storage medium. In response to the online of the Internet of Things equipment, a license and a valid period thereof are acquired from persistent storage; a current timestamp is acquired, and whether the license is within the valid period is identified according to the current timestamp; if it is identified that the license is within the valid period, a login request is initiated to a point-to-point server according to the license; if it is identified that the license is outside the valid period, a license update request is sent to a license server, and after a new license and a valid period thereof returned by the license server are received, a login request is initiated to the point-to-point server according to the new license, and the new license and the valid period thereof are stored persistently. The application can effectively shorten the time required from the wakeup of the Internet of Things equipment to the availability of the point-to-point, and can also reduce the concurrent processing pressure and network bandwidth consumption of the license server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet of Things (IoT) technology, and more particularly to a peer-to-peer login method, a peer-to-peer login device, an IoT device, and a computer-readable storage medium. Background Technology

[0002] The Internet of Things (IoT) refers to a network that connects any object to the internet through information sensing devices and according to agreed-upon protocols, enabling information exchange and communication to achieve intelligent identification, location, tracking, monitoring, and management. In the field of IoT technology, peer-to-peer (P2P) connectivity is widely used for remote communication between smart devices (such as network cameras, storage devices, smart doorbells, low-power sensors, and low-power cameras) and user terminals (such as mobile apps). Through P2P technology, devices can establish direct network connections with user terminals without relying on a central server, enabling functions such as video streaming, remote control, and data reporting. "P2P" refers to the direct peer-to-peer connection established between two nodes (e.g., a device and a user terminal) in a communication network, thereby bypassing or reducing dependence on intermediate servers, reducing transmission latency, and improving data transmission efficiency.

[0003] In existing peer-to-peer device connection architectures, devices first need to obtain a license from a license server, and then use the license to initiate a login registration with the peer-to-peer server to establish a peer-to-peer listening channel. This process involves two serial network interactions: the first is a request interaction with the license server to obtain the license; the second is a login interaction with the peer-to-peer server to establish the listening channel. In weak network environments, the total time taken for these two serial network interactions can often reach several seconds or even tens of seconds. Furthermore, making a network request with each wake-up also accelerates battery consumption and shortens device battery life. Summary of the Invention

[0004] This application provides a peer-to-peer login method, a peer-to-peer login device, an Internet of Things (IoT) device, and a computer-readable storage medium, which can effectively shorten the time required for an IoT device to become available peer-to-peer, while also reducing the concurrent processing pressure on the license server and network bandwidth consumption.

[0005] Firstly, the peer-to-peer login method provided in this application is applicable to Internet of Things (IoT) devices, and the peer-to-peer login method includes: In response to the online status of IoT devices, a license and its validity period are obtained and persistently stored. The license and its validity period are persistently stored after the last time they were obtained from the license server. Obtain the current timestamp and determine whether the license is valid based on the current timestamp; If the license is found to be valid, a login request is sent to the peer-to-peer server based on the license. If the license is found to be out of validity, a license renewal request is sent to the license server. After receiving the new license and its validity period from the license server, a login request is initiated to the peer-to-peer server based on the new license, and the new license and its validity period are persistently stored.

[0006] Secondly, the peer-to-peer login device provided in this application includes: The cache acquisition module is used to obtain the license and its validity period for persistent storage in response to the online of IoT devices. The license and its validity period are persistently stored after being obtained from the license server last time. The validity verification module is used to obtain the current timestamp and identify whether the license is valid based on the current timestamp; The quick request module is used to initiate a login request to the peer-to-peer server based on the license when it is detected that the license is valid. The regular request module is used to send a license renewal request to the license server when it is detected that the license is out of validity, and after receiving the new license and its validity period from the license server, to initiate a login request to the peer-to-peer server based on the new license, and to persistently store the new license and its validity period.

[0007] Optionally, in one embodiment, when obtaining the current timestamp, the validity verification module is used to: Get the current timestamp from the local clock.

[0008] Optionally, in one embodiment, after obtaining the current timestamp from the local clock, the validity verification module is further configured to: If obtaining the current timestamp from the local clock fails, or if the current timestamp obtained from the local clock is abnormal, the current timestamp will be retrieved again from the network time protocol server.

[0009] Optionally, in one embodiment, the peer-to-peer login device provided in this application further includes a certificate keep-alive module, which, after initiating a login request to the peer-to-peer server according to the license, is used to: In response to successful login, a keep-alive request is sent to the license server. The keep-alive request is used to request the license server to update the validity period of the license. In response to receiving the updated validity period from the license server, the validity period of the license stored persistently is updated.

[0010] Optionally, in one embodiment, when sending a keep-alive request to the license server in response to successful login, the certificate keep-alive module is used to: Upon successful login and detection that the license is about to expire, a keep-alive request is sent to the license server.

[0011] Optionally, in one embodiment, when a keep-alive request is sent to the license server in response to successful login and detection that the license's validity period is about to expire, the certificate keep-alive module is used to: Upon successful login and detection that the license is about to expire, a random delay time is generated, and a keep-alive request is sent to the license server after waiting for the random delay time.

[0012] Optionally, after sending a keep-alive request to the license server in response to successful login, the certificate keep-alive module is also used for: In response to receiving a keep-alive failure response from the license server, a license update request is sent to the license server, and after receiving the new license and its validity period from the license server, the new license and its validity period are persistently stored.

[0013] Thirdly, the Internet of Things device provided in this application includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, it implements the peer-to-peer login method provided in this application.

[0014] Fourthly, the computer-readable storage medium provided in this application stores a computer program that, when executed by a processor, implements the peer-to-peer login method provided in this application.

[0015] This application provides a peer-to-peer login scheme. In response to an IoT device coming online, it obtains a persistently stored license and its validity period; obtains the current timestamp and identifies whether the license is valid based on the timestamp; if the license is valid, it initiates a login request to the peer-to-peer server; if the license is expired, it sends a license update request to the license server, and upon receiving the new license and its validity period from the license server, it initiates a login request to the peer-to-peer server based on the new license, and persistently stores the new license and its validity period. Thus, through a "caching priority, on-demand refresh" mechanism that prioritizes reusing valid licenses via local caching, IoT devices can directly enter the peer-to-peer login process when the license cache is valid, saving a complete request-response cycle. In weak network environments, this optimization can reduce the time from wake-up to point-to-point availability of IoT devices from tens of seconds to a few seconds, shortening the active time of radio frequency modules (such as mobile communication network modules) and having a significant power-saving effect on battery-powered low-power IoT devices; it also greatly reduces invalid duplicate requests to the license server, reducing the concurrent processing pressure on the license server and network bandwidth consumption. Attached Figure Description

[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a schematic diagram illustrating an application scenario of the peer-to-peer login method provided in this application embodiment; Figure 2 This is a flowchart illustrating the peer-to-peer login method provided in an embodiment of this application; Figure 3 This is a schematic diagram of the peer-to-peer login device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the Internet of Things device provided in the embodiments of this application. Detailed Implementation

[0018] To make the technical problems, technical solutions, and beneficial effects solved by this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0019] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0020] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0021] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0022] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0023] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0024] This application provides a peer-to-peer login method, a peer-to-peer login device, an Internet of Things (IoT) device, a computer-readable storage medium, and a computer program product. The peer-to-peer login method can be executed by the peer-to-peer login device or by an IoT device integrating the peer-to-peer login device.

[0025] Please refer to Figure 1 This application also provides a peer-to-peer login system, such as Figure 1 As shown, this peer-to-peer login system includes IoT devices, a license server, and a peer-to-peer server. The IoT devices can establish network connections with the license server and peer-to-peer server via 4G IoT cards, Wi-Fi, or wired communication methods. Upon going online (e.g., after device power-on or network interruption recovery), the IoT device can obtain a persistently stored license and its validity period; obtain the current timestamp and determine whether the license is valid based on the timestamp; if the license is valid, it initiates a login request to the peer-to-peer server based on the license; if the license is expired, it sends a license update request to the license server, and upon receiving the new license and its validity period from the license server, initiates a login request to the peer-to-peer server based on the new license, and persistently stores the new license and its validity period.

[0026] It should be noted that, Figure 1The schematic diagram of the peer-to-peer login system shown is merely an example. The peer-to-peer login system and scenario described in this application embodiment are for the purpose of more clearly illustrating the technical solutions of this application embodiment and do not constitute a limitation on the technical solutions provided in this application embodiment. As those skilled in the art will know, with the evolution of peer-to-peer login systems and the emergence of new business scenarios, the technical solutions provided in this application embodiment are also applicable to similar technical problems.

[0027] Please refer to Figure 2 This is a flowchart illustrating a peer-to-peer login method disclosed in an embodiment of this application, as shown below. Figure 2 As shown, the process of this peer-to-peer login method can be as follows: In S110, in response to the IoT device coming online, a license and its validity period are obtained and persistently stored. The license and its validity period are persistently stored after the last time they were obtained from the license server.

[0028] Internet of Things (IoT) devices refer to terminal devices that are connected to the Internet of Things (IoT) and have network communication and data processing capabilities, such as network cameras, network storage devices, smart doorbells, various sensors, and low-power cameras. This application is particularly applicable to low-power IoT devices powered by batteries and IoT devices that communicate using IoT cards.

[0029] A weak network environment refers to a network environment with poor network quality, high latency, limited bandwidth, and unstable signal. For example, when using IoT cards for communication, compared with wired or Wi-Fi networks, it has higher latency and worse stability.

[0030] A license server is a server used to authenticate IoT devices and issue licenses. IoT devices first need to send a request to the license server, carrying authentication information such as product keys and device keys. After successful verification, the license server issues the license required for point-to-point communication.

[0031] A license is an authorization credential granted by a license server to IoT devices. It may contain parameters such as device ID, API license, CRC checksum key, peer-to-peer key, and initialization string, and is used for identity and permission verification when IoT devices log in to the peer-to-peer server. Specifically, the device ID is the unique identifier of the IoT device in the peer-to-peer network; the API license is the authorization credential for peer-to-peer services; the CRC checksum key is the data integrity verification key; the peer-to-peer key is the encryption key for peer-to-peer communication; and the initialization string and other parameters are the initialization parameters for the peer-to-peer software development kit.

[0032] The validity period refers to the effective period during which a license can be used after it is signed, such as 7 days. Licenses issued by the license server all have a validity period, and IoT devices can only use the license for peer-to-peer login within the license's validity period.

[0033] In this embodiment, the IoT device can obtain a persistently stored license and its validity period upon going online. "Going online" refers to the IoT device completing initialization and possessing network communication capabilities, such as after power-on, waking from sleep, or recovering from a network interruption. The license and its validity period are persistently stored by the IoT device after its last acquisition from the license server; that is, after successfully requesting a license from the license server, the IoT device persistently stores the license and its validity period in local non-volatile storage media, forming a license cache.

[0034] For example, IoT devices can persistently store the licenses and their validity periods requested from the license server in a structured format, such as JSON. A JSON structure for license caching could be as follows: { "did": "XXXX-123456-abcde", "apilicens": "api_license_string", "crckey": "crc_key_string", "p2pKey": "p2p_key_string", "initString": "init_string_value", "didFailureTime": 1735660800000 } Among them, the "did" field is the device ID; the "apilicens" field is the API license; the "crckey" field is the CRC check key; the "p2pKey" field is the peer-to-peer key; the "initString" field is the initialization string; and the "didFailureTime" field is the license expiration timestamp, which takes a value in milliseconds.

[0035] In practice, the expiration timestamp is calculated based on the validity period issued by the license server. For example, the expiration timestamp = the real-time timestamp at the time the license was obtained + the validity period returned by the server. For instance, if the license server returns a validity period of 7 days, and the IoT device records a real-time timestamp at the time of license acquisition, then the expiration timestamp equals the recorded real-time timestamp plus the number of milliseconds corresponding to 7 days.

[0036] In S120, the current timestamp is obtained, and the validity of the license is identified based on the current timestamp.

[0037] After obtaining the persistent storage license and its expiration date, the IoT device obtains the current timestamp and compares it with the license's expiration timestamp to determine if the license is still valid. Specifically, if the current timestamp is less than the expiration timestamp, the license is considered valid; if the current timestamp is greater than or equal to the expiration timestamp, the license is considered expired. There are no specific restrictions on how the current timestamp is obtained; for example, the IoT device can obtain the current timestamp from a local real-time clock or from a network time protocol server.

[0038] To improve the reliability of cache reuse, IoT devices can further introduce a safety margin mechanism when determining the validity of licenses. This means that a license is considered valid only if its expiration timestamp is greater than the sum of the current timestamp and the safety margin; otherwise, it is considered invalid. This prevents the use of cached data when licenses are about to expire, which could lead to license expiration and connection interruption during subsequent peer-to-peer sessions. The value of the safety margin is not specifically limited and can be flexibly set according to the business scenario. For example, the safety margin can be set to N times the expected duration of a single session (N is a positive integer greater than or equal to 2). For instance, if the expected duration of a single session is 5 minutes, the safety margin can be set to 10 minutes. The duration of a single session can be estimated based on historical session data or configured as a fixed value based on the business's requirements for connection stability. Furthermore, the specific value of the safety margin can be dynamically adjusted based on network environment stability to balance connection success rate and resource consumption. For example, the safety margin can be increased when network fluctuations are greater than or equal to a fluctuation threshold, and decreased when network fluctuations are less than the fluctuation threshold.

[0039] In S130, if the license is found to be valid, a login request is sent to the peer-to-peer server based on the license.

[0040] If the persistently stored license is found to be valid, it means the license can still be reused. The IoT device no longer needs to request the license server; instead, it directly initiates a login request to the peer-to-peer server based on the license, completing the peer-to-peer login, establishing a peer-to-peer listening channel, and waiting for the user terminal to connect. This process skips the interactive step of requesting the license from the license server, thus saving a complete request-response cycle. For example, in a weak network environment, it can save several to tens of seconds of waiting time.

[0041] In practice, IoT devices can directly use cached licenses to initialize peer-to-peer services and perform peer-to-peer listening. For example, an IoT device can call the initialization interface of a peer-to-peer software development kit to initialize the service, perform peer-to-peer listening, and log in and register with the peer-to-peer server.

[0042] After successfully logging in, IoT devices can continuously monitor the license's validity period. For example, the IoT device checks the remaining license validity period at fixed intervals (e.g., every 3 time units). When an expired license is detected (remaining validity period exhausted), a process of re-requesting the license is triggered: a new license is requested from the license server; all existing peer-to-peer session connections are closed; the deinitialization interface of the peer-to-peer software development kit is called to release old peer-to-peer resources; the peer-to-peer service is reinitialized using the new license, and the device logs in again. This automatic expiration recovery mechanism ensures that the peer-to-peer service remains available after the license expires, preventing devices from being offline for extended periods.

[0043] In addition, IoT devices can trigger a process to re-request a license when they receive an authentication rejection response from a peer-to-peer server.

[0044] In S140, if it is detected that the license is out of validity, a license renewal request is sent to the license server. After receiving the new license and its validity period from the license server, a login request is initiated to the peer-to-peer server based on the new license, and the new license and its validity period are persistently stored.

[0045] If the persistently stored license is found to be out of validity, it means that the license is no longer usable. At this time, the IoT device sends a license update request (i.e., re-requests a license) to the license server. After receiving the new license and its validity period from the license server, the device initiates a login request to the peer-to-peer server based on the new license. At the same time, the new license and its validity period are persistently stored to update the local cache for reuse in subsequent deployments.

[0046] In practice, IoT devices can send an HTTP POST request to the license server (e.g., a request URL of / device / cloud / getLicense), carrying authentication information such as product keys and device keys in the request body. After verifying the device's identity, the license server returns the license required for peer-to-peer communication and its validity period. Once a new license is obtained, the IoT device can write it, along with an expiration timestamp calculated based on the validity period, to a local cache file in the aforementioned JSON format. Then, it can use the new license to perform peer-to-peer login and register with the peer-to-peer server.

[0047] As described above, the peer-to-peer login solution provided in this application, upon the IoT device coming online, obtains a persistently stored license and its validity period; obtains the current timestamp and identifies whether the license is valid based on the current timestamp; if the license is valid, it initiates a login request to the peer-to-peer server based on the license; if the license is expired, it sends a license update request to the license server, and upon receiving the new license and its validity period from the license server, it initiates a login request to the peer-to-peer server based on the new license, and persistently stores the new license and its validity period. Thus, through a "caching priority, on-demand refresh" mechanism that prioritizes reusing valid licenses via local caching, the IoT device can directly enter the peer-to-peer login process when the license cache is valid, saving a complete request-response cycle. In weak network environments, this optimization can reduce the time from wake-up to point-to-point availability of IoT devices from tens of seconds to a few seconds, shortening the active time of radio frequency modules (such as mobile communication network modules) and having a significant power-saving effect on battery-powered low-power IoT devices; it also greatly reduces invalid duplicate requests to the license server, reducing the concurrent processing pressure on the license server and network bandwidth consumption.

[0048] Optionally, in one embodiment, obtaining the current timestamp includes: Get the current timestamp from the local clock.

[0049] Based on the above embodiments, this application provides an optional method for obtaining the current timestamp. Specifically, after the IoT device comes online, it preferentially obtains the current timestamp from a local clock (such as a real-time clock). The local clock is a hardware clock within the IoT device, capable of continuously keeping time when the device is powered off or in sleep mode. This allows for the rapid acquisition of a reliable local time reference without needing to connect to the network after the device is powered on, avoiding the additional latency and power consumption incurred by acquiring time via a network connection.

[0050] Optionally, in one embodiment, after obtaining the current timestamp from the local clock, the method further includes: If obtaining the current timestamp from the local clock fails, or if the current timestamp obtained from the local clock is abnormal, the current timestamp will be retrieved again from the network time protocol server.

[0051] Based on the above embodiments, this application provides another optional method for obtaining the current timestamp. Specifically, when the IoT device fails to obtain the current timestamp from the local clock (e.g., due to local clock hardware failure, local clock battery depletion leading to time loss, local clock not being initialized, etc.), or when the current timestamp obtained from the local clock is abnormal, the IoT device re-obtains the current timestamp from a network time protocol server to obtain a reliable time reference.

[0052] The IoT device can perform a validity check on the timestamp obtained from the local clock. If the timestamp falls within a preset abnormal range, it is considered abnormal. For example, the IoT device can preset an earliest time (e.g., January 1, 2025) and a latest time (e.g., December 31, 2100). If the obtained timestamp is earlier than the earliest time or later than the latest time, it is considered abnormal. This abnormal time value detection mechanism can prevent time base errors caused by local clock failures, thereby avoiding incorrect judgments of license expiration or non-expiration due to time misjudgment and ensuring the accuracy of cache validity determination.

[0053] Optionally, in one embodiment, after initiating a login request to the peer-to-peer server based on the license, the method further includes: In response to successful login, a keep-alive request is sent to the license server. The keep-alive request is used to request the license server to update the validity period of the license. In response to receiving the updated validity period from the license server, the validity period of the license stored persistently is updated.

[0054] In this embodiment of the application, after successfully logging into the peer-to-peer server, the IoT device executes an online keep-alive mechanism during operation to continuously refresh the validity period of the license and ensure the continuous availability of the cache.

[0055] After successful login, IoT devices can send a keep-alive request to the license server, which can include the product key and device key. Upon receiving and verifying the keep-alive request, the license server extends the license's validity period (e.g., resetting it to 7 days) and returns the updated validity period to the IoT device. Upon receiving the updated validity period from the license server, the IoT device updates the validity period of the license in its persistent storage. In practice, the IoT device can recalculate the expiration timestamp and write it back to its local cache file, ensuring consistency between the local cache and the server-side validity information.

[0056] Optionally, in one embodiment, in response to successful login, a keep-alive request is sent to the license server, including: Upon successful login and detection that the license is about to expire, a keep-alive request is sent to the license server.

[0057] Based on the above embodiments, this application provides an optional method for triggering a keep-alive request. In this method, after successful login, the IoT device further checks whether the license's validity period is about to expire. Only when the expiration date is detected will a keep-alive request be sent to the license server, thereby reducing unnecessary network interactions and power consumption.

[0058] It should be noted that "the validity period is about to expire" means that the remaining validity period of the license is less than a preset threshold. For example, an IoT device can start a keep-alive timer, with the keep-alive interval set to a reasonable proportion of the license validity period (for example, once every 12 hours if the validity period is 7 days). When the keep-alive timer expires, it is considered that the license validity period is about to expire, and at this time a keep-alive request is sent to the license server.

[0059] Optionally, in one embodiment, in response to successful login and detection that the license's validity period is about to expire, a keep-alive request is sent to the license server, including: Upon successful login and detection that the license is about to expire, a random delay time is generated, and a keep-alive request is sent to the license server after waiting for the random delay time.

[0060] Based on the above embodiments, this application provides another optional method for triggering keep-alive requests. To avoid overwhelming the server with a large number of devices simultaneously sending keep-alive requests, when an IoT device detects that the license's validity period is about to expire, it first generates a random delay time and then sends the keep-alive request to the license server after waiting for this random delay time. For example, the random delay time can be a random value between 0 and 240 time units, thus staggering the keep-alive times of different devices and ensuring the stable operation of the license server.

[0061] Optionally, in one embodiment, after sending a keep-alive request to the license server in response to successful login, the method further includes: In response to receiving a keep-alive failure response from the license server, a license update request is sent to the license server, and after receiving the new license and its validity period from the license server, the new license and its validity period are persistently stored.

[0062] In this embodiment, if the keep-alive request fails, the license server will return a keep-alive failure response to the IoT device (e.g., keep-alive request timeout, network error, or device authentication failure). When the IoT device receives the keep-alive failure response from the license server, it indicates that the license's validity period may not be extended through keep-alive. At this time, the IoT device sends a license update request (i.e., re-requests the license) to the license server, and after receiving the new license and its validity period from the license server, it persists the new license and its validity period to ensure that the license does not expire due to keep-alive failure, thus guaranteeing the continuous availability of the device's point-to-point service.

[0063] In other embodiments, the IoT device may also record a failure flag when the keep-alive request fails, and detect the failure flag in subsequent running loops. Only when the number of consecutive failures exceeds a threshold will the process of re-requesting the license be triggered.

[0064] To facilitate better implementation of the above peer-to-peer login method, this application also provides a corresponding peer-to-peer login device. The meanings of the terms used are the same as in the above peer-to-peer login method; for specific implementation details, please refer to the descriptions in the above method embodiments.

[0065] Please refer to Figure 3 The peer-to-peer login device may include a cache retrieval module 210, a validity verification module 220, a fast request module 230, and a regular request module 240. Detailed descriptions of each functional module are as follows: The cache acquisition module 210 is used to obtain the license and its validity period for persistent storage in response to the online of the Internet of Things device. The license and its validity period are persistently stored after being obtained from the license server last time. The validity verification module 220 is used to obtain the current timestamp and identify whether the license is within the validity period based on the current timestamp; The quick request module 230 is used to initiate a login request to the peer-to-peer server based on the license when it is detected that the license is valid. The regular request module 240 is used to send a license update request to the license server when it is detected that the license is out of validity, and after receiving the new license and its validity period returned by the license server, to initiate a login request to the peer-to-peer server based on the new license, and to persistently store the new license and its validity period.

[0066] Optionally, in one embodiment, when obtaining the current timestamp, the validity verification module 220 is used to: Get the current timestamp from the local clock.

[0067] Optionally, in one embodiment, after obtaining the current timestamp from the local clock, the validity verification module 220 is further configured to: If obtaining the current timestamp from the local clock fails, or if the current timestamp obtained from the local clock is abnormal, the current timestamp will be retrieved again from the network time protocol server.

[0068] Optionally, in one embodiment, the peer-to-peer login device provided in this application further includes a certificate keep-alive module, which, after initiating a login request to the peer-to-peer server according to the license, is used to: In response to successful login, a keep-alive request is sent to the license server. The keep-alive request is used to request the license server to update the validity period of the license. In response to receiving the updated validity period from the license server, the validity period of the license stored persistently is updated.

[0069] Optionally, in one embodiment, when sending a keep-alive request to the license server in response to successful login, the certificate keep-alive module is used to: Upon successful login and detection that the license is about to expire, a keep-alive request is sent to the license server.

[0070] Optionally, in one embodiment, when a keep-alive request is sent to the license server in response to successful login and detection that the license's validity period is about to expire, the certificate keep-alive module is used to: Upon successful login and detection that the license is about to expire, a random delay time is generated, and a keep-alive request is sent to the license server after waiting for the random delay time.

[0071] Optionally, after sending a keep-alive request to the license server in response to successful login, the certificate keep-alive module is also used for: In response to receiving a keep-alive failure response from the license server, a license update request is sent to the license server, and after receiving the new license and its validity period from the license server, the new license and its validity period are persistently stored.

[0072] Specific limitations regarding the peer-to-peer login device can be found in the limitations of the peer-to-peer login method above, and will not be repeated here. Each module in the aforementioned peer-to-peer login device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in the IoT device, or stored in software in the memory of the IoT device, so that the processor can call and execute the corresponding operations of each module.

[0073] In one embodiment, an Internet of Things (IoT) device is provided, the internal structure of which can be shown as follows: Figure 4As shown. This IoT device includes a processor, memory, network interface, and database connected via a system bus.

[0074] The processor in an Internet of Things (IoT) device is used to provide computing and control capabilities.

[0075] The memory of an IoT device includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and databases. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media to run. The network interface of the IoT device is used to connect to external devices; for example, a user terminal can access the IoT device through the network interface to obtain device status data or issue control commands.

[0076] When a computer program is executed by a processor, it implements the peer-to-peer login method provided in this application.

[0077] In one embodiment, an Internet of Things (IoT) device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the peer-to-peer login method described in the above embodiment.

[0078] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the peer-to-peer login method described in the above embodiment.

[0079] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0080] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0081] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A peer-to-peer login method, applicable to Internet of Things (IoT) devices, characterized in that, The peer-to-peer login method includes: In response to the IoT device coming online, a license and its validity period are obtained and persistently stored. The license and its validity period are persistently stored after being last obtained from the license server. Obtain the current timestamp, and identify whether the license is within the validity period based on the current timestamp; If the license is found to be within the validity period, a login request is initiated to the peer-to-peer server based on the license. If the license is found to be outside its validity period, a license update request is sent to the license server. After receiving the new license and its validity period from the license server, a login request is initiated to the peer-to-peer server based on the new license, and the new license and its validity period are persistently stored.

2. The peer-to-peer login method according to claim 1, characterized in that, The step of obtaining the current timestamp includes: Obtain the current timestamp from the local clock.

3. The peer-to-peer login method according to claim 2, characterized in that, After obtaining the current timestamp from the local clock, the process further includes: If obtaining the current timestamp from the local clock fails, or if the current timestamp obtained from the local clock is abnormal, the current timestamp shall be obtained again from the network time protocol server.

4. The peer-to-peer login method according to any one of claims 1-3, characterized in that, After initiating a login request to the peer-to-peer server based on the license, the process further includes: In response to successful login, a keep-alive request is sent to the license server, which requests the license server to update the validity period of the license; In response to receiving the updated validity period returned by the license server, the validity period of the license in persistent storage is updated.

5. The peer-to-peer login method according to claim 4, characterized in that, The response upon successful login includes sending a keep-alive request to the license server, including: Upon successful login and detection that the license is about to expire, a keep-alive request is sent to the license server.

6. The peer-to-peer login method according to claim 5, characterized in that, The response, upon successful login and detection that the license is about to expire, sends the keep-alive request to the license server, including: Upon successful login and detection that the license is about to expire, a random delay time is generated, and after waiting for the random delay time, the keep-alive request is sent to the license server.

7. The peer-to-peer login method according to claim 4, characterized in that, After responding to a successful login and sending a keep-alive request to the license server, the process also includes: In response to receiving a keep-alive failure response from the license server, a license update request is sent to the license server, and after receiving the new license and its validity period from the license server, the new license and its validity period are persistently stored.

8. A peer-to-peer login device, suitable for Internet of Things (IoT) devices, characterized in that, The peer-to-peer login device includes: The cache acquisition module is used to obtain a persistently stored license and its validity period in response to the IoT device coming online. The license and its validity period are persistently stored after being obtained from the license server last time. A validity verification module is used to obtain the current timestamp and identify whether the license is within the validity period based on the current timestamp; The quick request module is used to initiate a login request to the peer-to-peer server based on the license when it is detected that the license is within the validity period; The regular request module is used to send a license update request to the license server when it is detected that the license is outside the validity period, and after receiving the new license and its validity period returned by the license server, to initiate a login request to the peer-to-peer server according to the new license, and to persistently store the new license and its validity period.

9. An Internet of Things (IoT) device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the peer-to-peer login method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the peer-to-peer login method according to any one of claims 1 to 7.