Intelligent ring equipment state management method, system and application
By introducing a state wait mechanism and a state manager, the state judgment logic of the smart ring device is optimized, the connection stability and data synchronization problems are solved, the user experience and code maintenance efficiency are improved, and the system reliability and scalability are achieved.
Patent Information
- Application Number
- CN202411294569.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-01-07
AI Technical Summary
Existing smart ring devices have problems with connection stability and data synchronization, resulting in poor user experience and inefficient code readability and maintenance efficiency.
Introduce a state wait mechanism and a state manager to integrate device addition logic, device connection logic and data synchronization logic, optimize state judgment logic, and improve connection stability and data synchronization reliability.
It improves the connection stability of smart ring equipment and the reliability of data synchronization, reduces the user's need for manual intervention, improves the readability and maintenance efficiency of code, and enhances the reliability and scalability of the system.
Smart Images

Figure CN119271490A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart rings, and specifically, to a smart ring device status management method, system and application. Background Art
[0002] With the development of Internet of Things technology, smart wearable devices have gradually become popular. Among them, smart rings, as an emerging wearable device, are favored by the market because of their small size, portability and rich functions. Smart rings on the market usually have multiple functions such as health monitoring and message reminders, which enable them to better integrate into users' daily lives. However, in actual use, how to efficiently manage devices and synchronize data has become an urgent problem to be solved. Most smart ring devices on the market currently use Bluetooth or other wireless communication technologies to connect to users' smartphones or other terminal devices to achieve functions such as data interaction and information push. However, with the increasing demand for smart ring functions, the stability of connection between devices and the timeliness of data synchronization have become one of the important indicators for measuring user experience.
[0003] Existing solutions generally use parallel requests. Due to the different data types of parallel requests and the fact that multiple data types are requested simultaneously during parallel requests, there is an excessive amount of data requests, which leads to network congestion and unstable connection. The state mechanism design improves the connection stability of the device. In addition, since parallel requests may time out and fail to obtain data, they will jump directly to the next step, resulting in abnormal data synchronization. When the communication of the ring device is unstable, data synchronization abnormalities will occur, which will affect the main program's data processing and cause certain errors. Due to the lack of an effective state management mechanism, when the smart ring and the terminal device are disconnected due to unstable connection, the process of re-establishing the connection is not smooth enough, and sometimes even requires manual intervention by the user to restore the connection, which not only affects the user experience, but also reduces the convenience of using the device. In addition, the device addition logic, device connection logic, and data synchronization logic of the prior art involve different code modules, resulting in reduced code readability and low maintenance efficiency.
[0004] Therefore, it is necessary to develop a new smart ring device status management method to overcome the problems existing in the above-mentioned prior art and improve the intelligence level of device management and user experience. Summary of the invention
[0005] In view of the above problems, this application provides a smart ring device state management method, system and application, which optimizes the state judgment logic in the device connection process by introducing a state waiting mechanism, thereby solving the drawbacks of the prior art and improving the connection stability of the smart ring device and the reliability of data synchronization. The specific solution is as follows:
[0006] In the first part, this application provides a smart ring device status management method, including the following:
[0007] Starting a pre-created state manager through a main program, wherein the state manager is configured with a state waiting mechanism and integrates device adding logic, device connection logic and data synchronization logic;
[0008] Start the main program to scan the smart ring, monitor the scanning result through the state manager, and start the device adding logic and the device connecting logic;
[0009] When the device information of the smart ring is obtained from the scanning result, whether the smart ring has been bound to the main program is analyzed based on the device information:
[0010] If it is not bound, the device information is fed back to the main program through the state manager, and the device binding of the smart ring is completed;
[0011] If it has been bound, the device adding logic is terminated, the connection service is triggered through the state manager, and the device connection of the smart ring is completed;
[0012] When the data synchronization logic is started, the state manager completes the data synchronization involving multiple data types between the smart ring and the main program based on the state waiting mechanism.
[0013] In some specific embodiments, the state waiting mechanism includes a first state, a second state, and a third state;
[0014] The first state records that the state manager is in a synchronizing state and a synchronizing completed state;
[0015] The second state records the state of the next data type to be executed by the state manager;
[0016] The third state records the process executed by the state manager in the current state.
[0017] In some specific embodiments, when executing the data synchronization logic, it also includes:
[0018] Sort the various data types to be synchronized according to the preset rules and synchronize them one by one in order;
[0019] When the first state is in the state of being synchronized, the main program calls the interface to determine whether the third state performs data synchronization according to the preset rules, and supports the main program to resynchronize in case of synchronization failure;
[0020] When the first state is in a synchronization completed state, the main program is supported to request synchronization of the next data type, and the state manager assigns the second state to the third state, and updates the second state and the third state;
[0021] When the third state shows that synchronization of a certain data type fails, resynchronization is performed;
[0022] When the third state shows that a certain data type is synchronized successfully, the data type is recorded according to the second state for synchronization, and the second state is updated.
[0023] In some specific embodiments, the device adding logic specifically includes:
[0024] Start scanning to determine whether the main program has enabled the Bluetooth service. If not, notify the program.
[0025] After starting the Bluetooth service, monitor the LeScanCallback interface;
[0026] When the onLeScan method in the LeScanCallback interface has a data callback, obtain the smart ring connected to Bluetooth, read its device name and make a judgment with the preset chooseDevice;
[0027] If the device name exists in chooseDevice, the state manager terminates the device adding logic;
[0028] If the device name does not exist in chooseDevice, add the smart ring to the ringDeviceScans collection and open the getRingDeviceScans interface;
[0029] The main program enters the add binding interface, reads the getRingDeviceScans interface to obtain the scanned smart ring, selects the device to be added and reports it to the server, completing the addition and binding of the smart ring.
[0030] In some specific embodiments, the device connection logic specifically includes:
[0031] Start the connection service and determine whether the main program has enabled the Bluetooth service. If not, notify the program.
[0032] After starting the Bluetooth service, monitor the LeScanCallback interface;
[0033] When the onLeScan method in the LeScanCallback interface has a data callback, obtain the smart ring connected to Bluetooth, read its device name and make a judgment with the preset chooseDevice;
[0034] If the device name does not exist in chooseDevice, the connection service is triggered and connectDevice is set. The callback information of the IResponseListener interface is listened to to determine whether the device connection is successful.
[0035] In some specific embodiments, the data types include device time, device battery level, firmware version, and historical data.
[0036] In some specific embodiments, in the device adding logic and the device connecting logic, the isConnectReady status field is removed, and the connectDevice device cache is judged to determine whether to enter the device adding logic or the device connecting logic.
[0037] In the second part, this application proposes a smart ring device status management system, including the following:
[0038] A pre-creation unit, used to start a pre-created state manager through a main program, wherein the state manager is configured with a state waiting mechanism and integrates device adding logic, device connection logic and data synchronization logic;
[0039] A scanning and starting unit, used to start the main program to scan the smart ring, monitor the scanning result through the state manager, and start the device adding logic and the device connecting logic;
[0040] A scanning and analyzing unit, configured to, when obtaining device information of the smart ring from the scanning result, analyze whether the smart ring has been bound to the main program based on the device information:
[0041] If it is not bound, the device information is fed back to the main program through the state manager, and the device binding of the smart ring is completed;
[0042] If it has been bound, the device adding logic is terminated, the connection service is triggered through the state manager, and the device connection of the smart ring is completed;
[0043] A data synchronization unit is used for completing the data synchronization involving multiple data types between the smart ring and the main program based on the state waiting mechanism when the data synchronization logic is started.
[0044] In the third part, the present application proposes a computer device, the computer device comprising:
[0045] one or more processors;
[0046] A memory for storing one or more programs;
[0047] When the one or more programs are executed by the one or more processors, the one or more processors implement the smart ring device status management method as described in any one of the first parts.
[0048] In the fourth part, the present application proposes a computer program product, including executable instructions, which are used to implement the smart ring device status management method as described in any one of the first parts when executed by a processor.
[0049] Beneficial effects: This application proposes a method, system and application for managing the state of a smart ring device, introduces a state waiting mechanism and a state manager, optimizes the state judgment logic during the connection process of the smart ring, improves the connection stability of the device and the reliability of data synchronization, and avoids abnormal data synchronization of the smart ring when the system is unstable. The state manager integrates the device addition logic, device connection logic and data synchronization logic, and uses the singleton mode to integrate the above logic modules into one area for implementation, which improves the readability and maintenance efficiency of the code, reduces the division of code modules, and facilitates project maintenance. The reliability and stability of the system are enhanced through the refined management and automatic retry mechanism of the state manager. Through a modular implementation method, the system has better scalability and maintainability, which is convenient for future function upgrades and improvements.
[0050] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0052] Figure 1 It is a flowchart of the smart ring device status management method of the present application;
[0053] Figure 2 It is a schematic diagram of the principle of the smart ring device status management method of the present application;
[0054] Figure 3 It is a flowchart of the data synchronization logic of this application;
[0055] Figure 4 This is a schematic diagram of the smart ring device status management system module of this application.
[0056] Figure numerals: 1 - pre-creation unit; 2 - scan start unit; 3 - scan analysis unit; 4 - data synchronization unit. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0058] This application proposes a smart ring device state management method, which optimizes the state judgment logic in the device connection process by introducing a state waiting mechanism, thereby solving the drawbacks of the prior art and improving the connection stability and data synchronization reliability of the smart ring device. Figure 1 The principle is shown in the attached Figure 2 The specific plan is as follows:
[0059] A method for managing the state of a smart ring device, comprising:
[0060] 101. Start the pre-created state manager through the main program. The state manager is configured with a state waiting mechanism and integrates device adding logic, device connection logic and data synchronization logic;
[0061] 102. Start the main program to scan the smart ring, monitor the scanning results through the state manager, and start the device adding logic and device connection logic;
[0062] 103. When the device information of the smart ring is obtained from the scanning result, whether the smart ring has been bound to the main program is analyzed based on the device information: if it has not been bound, the device information is fed back to the main program through the state manager, and the device binding of the smart ring is completed; if it has been bound, the device adding logic is terminated, the connection service is triggered through the state manager, and the device connection of the smart ring is completed;
[0063] 104. When the data synchronization logic is started, the state manager completes the data synchronization involving multiple data types between the smart ring and the main program based on the state waiting mechanism.
[0064] This application optimizes the state judgment logic in the device connection process by introducing a state waiting mechanism, thereby solving the drawbacks existing in the prior art and improving the connection stability and data synchronization reliability of the smart ring device. The state mechanism design not only reduces the unstable device connection, but also restores the connection and completes data synchronization without manual user intervention when a disconnection occurs. The state manager integrates the add function, connection function and data synchronization function, reduces the division of code modules, and improves project maintenance. The ring data synchronization adopts a state waiting mechanism to complete serial data synchronization, avoiding abnormal scenarios caused by the smart ring when the mobile phone system is unstable, and causing data synchronization abnormalities, thereby providing stability for device data synchronization.
[0065] When the main program is running, the state manager instance is created through the proxy mode. The state manager provides a series of APIs for the main program to call to perform operations such as device scanning, adding and binding. The main program creates a state manager instance through the proxy mode. The proxy mode allows the client to indirectly access the target object through the proxy object, which helps to add additional operations or logic between the main program and the state manager, such as caching, logging, etc. Device scanning interface: When the main program needs to add or bind a new device, it calls the scanning interface provided by the state manager. This interface is responsible for discovering the available smart ring devices around and returning the scanning results. ChooseDevice instance: Based on the scanning results, the main program creates a chooseDevice instance. The role of this instance is to decide whether the device addition logic or the device connection logic should be executed later based on the status of the device (whether it has been bound). If the device is not bound, the chooseDevice instance will guide the state manager to execute the device binding logic; if the device has been bound, it will directly enter the device connection logic. The state manager has been instantiated before the main program runs and is ready to perform related tasks, so that the state manager can respond to various events quickly, without creating a new instance each time it is used, thereby improving efficiency.
[0066] Step 102 starts the main program to scan the smart ring. The main program starts to scan the surrounding smart rings to detect whether there are new smart ring devices in a connectable state. Through scanning, new devices can be discovered to provide basic information for subsequent binding or connection operations. Exemplary, start scanning startScan: Before performing the scan, the main program needs to confirm whether Bluetooth is turned on. If Bluetooth is not turned on, the user needs to be prompted with the current Bluetooth status and is advised to turn on Bluetooth. This can be achieved through pop-ups, notification bar prompts, or other friendly user interface elements. If Bluetooth is turned on, continue to perform subsequent operations. When Bluetooth is turned on, the main program will start the Bluetooth service. To ensure that the Bluetooth function can work properly and lay the foundation for subsequent device discovery and connection operations. After the Bluetooth service is started, the main program will receive the scan results through a listener (LeScanCallback). This listener will continuously check whether new devices are discovered and pass the information of these devices to the state manager for further processing. After receiving the scan results, the LeScanCallback listener passes the device information to the state manager for analysis and processing.
[0067] After the main program obtains the information of the smart ring device through scanning, it needs to further analyze this information to determine whether the device has been bound by the main program. Different logical processes will be executed according to the analysis results. When the onLeScan method in the LeScanCallback interface has a data callback, the main program will obtain an object BluetoothDevice containing device information. This object contains basic information about the device, such as MAC address, name, etc. Based on the obtained device information (such as device name, MAC address, etc.), the state manager needs to determine whether the device has been bound by the main program. It can query the database or call the API to verify the status of the device as needed.
[0068] If the device is not bound: the state manager feeds the device information back to the main program and executes the device binding logic to complete the device binding process of the smart ring. If the device is already bound: terminate the device adding logic, trigger the connection service through the state manager, and complete the device connection of the smart ring.
[0069] In some specific embodiments, the device adding logic specifically includes: starting scanning, determining whether the main program has turned on the Bluetooth service, and notifying if it is not turned on; after starting the Bluetooth service, listening to the LeScanCallback interface; when the onLeScan method in the LeScanCallback interface has a data callback, obtaining the smart ring connected to the Bluetooth, reading its device name and judging it with the preset chooseDevice; if the device name exists in chooseDevice, the state manager terminates the device adding logic; if the device name does not exist in chooseDevice, the smart ring is filled into the ringDeviceScans collection, and the getRingDeviceScans interface is opened; the main program enters the add binding interface, reads the getRingDeviceScans interface to obtain the scanned smart ring, and selects the device to be added and reports it to the server to complete the addition and binding of the smart ring.
[0070] In some specific embodiments, in the device connection logic, it specifically includes: starting the connection service, determining whether the main program has enabled the Bluetooth service, and notifying if it is not enabled; after starting the Bluetooth service, monitoring the LeScanCallback interface; when the onLeScan method in the LeScanCallback interface has a data callback, obtaining the smart ring connected to the Bluetooth, reading its device name and judging it with the preset chooseDevice; setting connectDevice to avoid multiple triggers of the scanning interface leading to multiple connections. If the device name does not exist in chooseDevice, the connection service is triggered, and connectDevice is set to determine whether the device connection is successful by monitoring the information of the IResponseListener interface callback. When the callback lmBleConnectionSucceeded is received, the device has been successfully connected, and when the callback lmBleConnectionFailed is received, it fails and all connection states are reset.
[0071] After the smart ring device successfully establishes a connection with the main program, a mechanism is required to support the main program to synchronize the relevant data of the ring. The "relevant data" here may include but is not limited to health monitoring data, notification data, setting information, etc. Define the initData interface. When the main program starts, call this interface to synchronize the cache data stored in the ring to ensure that the main program can obtain the latest data in the ring device at the beginning of startup for subsequent data processing and display. Define the syncDeviceData interface. When the device is successfully connected, use this interface to synchronize the device data to achieve real-time or periodic data synchronization to ensure the latest and consistency of the data. By setting a timer, the syncDeviceData interface is executed once at a fixed time interval (here every second), and the call of the syncDeviceData interface is triggered every second. During the synchronization process, different states (such as the first state, the second state, and the third state) can be defined according to different stages of data synchronization. Before and after each synchronization operation, the corresponding state transition is performed according to the current state to ensure the continuity and consistency of the data synchronization process. The state manager is responsible for maintaining the current state and deciding whether to perform the synchronization operation based on the current state.
[0072] In some specific embodiments, the state waiting mechanism includes a first state, a second state and a third state; the first state records the state manager in the state of being synchronized and the state of synchronization completed; the second state records the state of the next data type to be executed by the state manager; the third state records the process of the state manager executing the current state. Among them, the initial state: before the device is connected and the data synchronization starts, the state manager is in an unprepared state, waiting for the start signal. Synchronization state: when a certain data type is being synchronized, the state manager is also in the first state, indicating that data synchronization is currently being performed but has not been completed. The second state records the state of the next data type to be executed by the state manager. When the current data synchronization is completed, the state manager enters the second state and prepares to execute the synchronization task of the next data type. The two states play a coordination role to ensure that after the current data synchronization is completed, it can seamlessly transition to the synchronization task of the next data type. The third state records the process of the state manager executing the current state. When executing a synchronization task of a certain data type, the state manager is in the third state. This means that the task currently being executed is proceeding as planned. The third state can also be used to track the execution progress of the current task to ensure that every step of data synchronization can be effectively managed.
[0073] In some specific embodiments, when executing the data synchronization logic, it also includes: sorting various data types to be synchronized according to preset rules, and synchronizing them one by one in order; when the first state is in the state of being synchronized, the main program calls the interface to determine whether the third state performs data synchronization according to the preset rules, and supports the main program to resynchronize in the case of synchronization failure; when the first state is in the state of synchronization completion, the main program is supported to request synchronization of the next data type, and the state manager assigns the second state to the third state; when the third state shows that a certain data type fails to synchronize, resynchronize; when the third state shows that a certain data type is synchronized successfully, record the data type according to the second state for synchronization, and update the second state. Arrange data types according to priority, importance or time sensitivity. Synchronize one data type at a time, and record the data type currently being synchronized. When starting to synchronize a certain data type, the state manager enters the first state. During the synchronization process, the state manager enters the third state, indicating that the synchronization task is currently being executed. When a certain data type is synchronized successfully, the state manager records the next data type to be synchronized (enters the second state) and updates the current state (returns to the first state). The state manager can effectively coordinate synchronization tasks of different data types to ensure that each task can be carried out in an orderly manner, thereby improving the overall efficiency and stability of data synchronization.
[0074] In some specific embodiments, the data types include device time, device power, firmware version, and historical data. Device time: the current time of the device. Device power: the current remaining power of the device. Firmware version: the firmware version number currently running on the device. Historical data: historical data stored in the device, such as health monitoring data, activity records, etc. Data types with higher priority (such as device time and device power) may need to be synchronized first. Data types with lower priority (such as historical data) can be synchronized after the previous data types are completed.
[0075] In some specific embodiments, in the device adding logic and the device connecting logic, the isConnectReady status field is removed, and the connectDevice device cache is judged to determine whether to enter the device adding logic or the device connecting logic, which can more effectively simplify the logic judgment, so that the state manager can handle the device adding and connecting process more efficiently. At the same time, it also enables the state manager to better adapt to different device states and ensure the stability and reliability of data synchronization.
[0076] In some specific embodiments, the data synchronization logic specifically includes:
[0077] Define three state variables reqNowStatus, reqNextStatus, and requesting as the first state, the second state, and the third state, respectively.
[0078] State variable definition
[0079] 1.reqNowStatus (current status)
[0080] 0 Initial state: Indicates that no data synchronization task is currently being executed and the ring time (LmAPI.SYNC_TIME) can be synchronized.
[0081] 1Get the power of the ring device (LmAPI.GET_BATTERY): indicates that the power information of the ring device is currently being obtained or is about to be obtained.
[0082] 2Get the ring device firmware version (LmAPI.GET_VERSION): indicates that the firmware version information of the ring device is currently being obtained or is about to be obtained.
[0083] 3Synchronize ring device historical data: Indicates that the historical data of the ring device is currently being synchronized or will be synchronized.
[0084] 4Data synchronization completed: indicates that all data synchronization tasks have been completed and you need to wait for a while before re-executing data synchronization.
[0085] 2.reqNextStatus (next status)
[0086] Used to record the next status to be executed. When the current status (reqNowStatus) is completed, the next status (reqNextStatus) will be executed.
[0087] 3.Requesting (waiting state)
[0088] true: indicates that the current state is being executed and no new synchronization tasks can be executed.
[0089] false: Indicates that the current state has been completed and a new synchronization task can be executed.
[0090] Synchronous logic implementation
[0091] 1. Initial status (reqNowStatus is 0)
[0092] When the main program calls the syncDeviceData interface, if reqNowStatus is 0, the action of synchronizing the ring time (LmAPI.SYNC_TIME) is triggered.
[0093] 2. Synchronize ring time (reqNowStatus is 0)
[0094] After the ring time is synchronized, update reqNowStatus to the next state (e.g. 1, get the device power level). Update requesting to true, indicating that the current state is being executed. After the synchronization is completed, update requesting to false.
[0095] 3. Get the device power level (reqNowStatus is 1)
[0096] After completing the acquisition of the device power, update reqNowStatus to the next state (for example, 2, to obtain the firmware version). Update requesting to true, indicating that the current state is being executed. After completing the acquisition, update requesting to false.
[0097] 4. Get the firmware version (reqNowStatus is 2)
[0098] After the firmware version is acquired, reqNowStatus is updated to the next state (e.g. 3, synchronizing historical data). Requesting is updated to true, indicating that the current state is being executed. After the acquisition is completed, requesting is updated to false.
[0099] 5. Synchronize historical data (reqNowStatus is 3)
[0100] After the synchronization of historical data is completed, update reqNowStatus to the next status (for example, 4, data synchronization is completed). Update requesting to true, indicating that the current status is being executed. After the synchronization is completed, update requesting to false.
[0101] 6. Data synchronization completed (reqNowStatus is 4)
[0102] After data synchronization is completed, wait for a while and then re-execute data synchronization. Update requesting to true, indicating that the current status is being executed. After the wait is over, update reqNowStatus to 0 and restart the synchronization process. Update requesting to false.
[0103] The state waiting mechanism mainly determines which data synchronization to enter based on the state; when synchronization fails, it supports the main program to retry; when it succeeds, it sets the state to the next data request and supports the main program to request the next data synchronization. The state waiting mechanism prevents excessive requests and sets the logic of waiting for 10 minutes to reset the state. The logical steps are as follows Figure 3 The specific instructions are as follows:
[0104] 1. The main program calls the syncDeviceData interface through customization
[0105] When the device is in the connected state, the main program will call the syncDeviceData interface to determine whether requesting is false or reqNowStatus is not 4 (data synchronization completed). If the conditions are met, the following states are executed: 0, 1, 2, 3.
[0106] 2. Execution state 0: Synchronize ring time
[0107] Set requesting to true, indicating that the synchronization operation is currently being performed. Set reqNextStatus to 1, indicating that the next state is to obtain the device power. Call the LmAPI.SYNC_TIME() method to synchronize the ring time. When the callback syncTime succeeds, reset the requesting state to false, indicating that the current state has been executed.
[0108] If the callback times out, the main program will request status 0 again.
[0109] 3. Execution status 1: Get device power
[0110] When state 0 succeeds, execute state 1. Set reqNextStatus to 2, indicating that the next state is to obtain the firmware version. Call LmAPI.GET_BATTERY() method to obtain the device power. When the battery callback succeeds, set the batteryValue power value. If the callback times out, the main program re-requests state 1.
[0111] 4. Execution status 2: Get firmware version
[0112] When state 1 succeeds, execute state 2. Set reqNextStatus to 3, indicating that the next state is to synchronize historical data. Call LmAPI.GET_VERSION() method to obtain the firmware version. When the callback VERSION succeeds, save the version information. If the callback times out, the main program will re-request state 2.
[0113] 5. Execution state 3: Synchronize historical data
[0114] When state 2 succeeds, execute state 3. Set reqNextStatus to 4, indicating that the next state is data synchronization completed. Call LmAPI.SYNC_HISTORICAL_DATA() method to synchronize historical data. When the IHistoryListener listener calls back success, it means that the synchronization is successful, and the relevant historical data is obtained and synchronized to the data processor. If the callback is error or timeout, the main program re-requests state 3.
[0115] 6. Execution status 4: Data synchronization completed
[0116] When state 3 succeeds, execute state 4. The manager completes data synchronization and needs to wait for the next synchronization cycle. You can set a timer or timer to reset the state after waiting for a certain period of time (such as 10 minutes) and restart the synchronization process.
[0117] In some embodiments, in ring device data synchronization, a thread pool is used to separate resources of device synchronization instructions to improve synchronization efficiency.
[0118] Due to the use of the request waiting method, each request must ensure that the request has a result before supporting the next data request, in order to prevent the data request from failing or timing out when the device connection is unstable, causing errors and user experience when the main program processes related data services, thereby improving the success rate of ring device data synchronization.
[0119] This application proposes a smart ring device status management system, which systematizes the above-mentioned smart ring device status management method to make it more practical. A module diagram of a smart ring device status management system is shown in the attached figure. Figure 4 The specific plan is as follows:
[0120] A smart ring device status management system, comprising:
[0121] The pre-creation unit 1 is used to start the pre-created state manager through the main program. The state manager is configured with a state waiting mechanism and integrates device adding logic, device connection logic and data synchronization logic;
[0122] Scanning and starting unit 2, used to start the main program to scan the smart ring, monitor the scanning results through the state manager, and start the device adding logic and device connection logic;
[0123] The scanning and analyzing unit 3 is used to analyze whether the smart ring has been bound to the main program based on the device information when the device information of the smart ring is obtained from the scanning result:
[0124] If it is not bound, the device information is fed back to the main program through the state manager, and the device binding of the smart ring is completed;
[0125] If it has been bound, terminate the device adding logic, trigger the connection service through the state manager, and complete the device connection of the smart ring;
[0126] The data synchronization unit 4 is used for completing the data synchronization involving multiple data types between the smart ring and the main program based on the state waiting mechanism when the data synchronization logic is started.
[0127] The present application provides a computer program product, which includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes a smart ring device state management method. A smart ring device state management method is applied to a computer program product for easy execution.
[0128] The present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a smart ring device status management method as described above.
[0129] The computer storage medium of the present application may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. The present application applies a smart ring device state management method to a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the state management method provided in the present application are implemented, which is simple and fast, easy to store, and not easy to lose.
[0130] This application proposes a method, system and application for managing the state of a smart ring device, introduces a state waiting mechanism and a state manager, optimizes the state judgment logic during the connection process of the smart ring, improves the connection stability of the device and the reliability of data synchronization, and avoids abnormal data synchronization of the smart ring when the system is unstable. The state manager integrates the device addition logic, device connection logic and data synchronization logic, and uses the singleton mode to integrate the above logic modules into one area for implementation, which improves the readability and maintenance efficiency of the code, reduces the division of code modules, and facilitates project maintenance. The reliability and stability of the system are enhanced through the refined management and automatic retry mechanism of the state manager. Through a modular implementation method, the system has better scalability and maintainability, which is convenient for future function upgrades and improvements.
[0131] Those skilled in the art should understand that the modules of the present application described above can be implemented by a general-purpose computing system, they can be concentrated on a single computing system, or distributed on a network composed of multiple computing systems, and optionally, they can be implemented by program codes executable by a computer system, so that they can be stored in a storage system and executed by the computing system, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0132] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
[0133] The above disclosure only discloses several specific implementation scenarios of the present application. However, the present application is not limited thereto, and any changes that can be conceived by technicians in this field should fall within the scope of protection of the present application.
Claims
1. A method for managing the status of a smart ring device, characterized in that: These include: Starting a pre-created state manager through a main program, wherein the state manager is configured with a state waiting mechanism and integrates device adding logic, device connection logic and data synchronization logic; Start the main program to scan the smart ring, monitor the scanning result through the state manager, and start the device adding logic and the device connecting logic; When the device information of the smart ring is obtained from the scanning result, whether the smart ring has been bound to the main program is analyzed based on the device information: If it is not bound, the device information is fed back to the main program through the state manager, and the device binding of the smart ring is completed; If it has been bound, the device adding logic is terminated, the connection service is triggered through the state manager, and the device connection of the smart ring is completed; When the data synchronization logic is started, the state manager completes the data synchronization involving multiple data types between the smart ring and the main program based on the state waiting mechanism.
2. The smart ring device status management method according to claim 1, characterized in that: The state waiting mechanism includes a first state, a second state and a third state; The first state records that the state manager is in a synchronizing state and a synchronizing completed state; The second state records the state of the next data type to be executed by the state manager; The third state records the process executed by the state manager in the current state.
3. The smart ring device status management method according to claim 1, characterized in that: When executing the data synchronization logic, it also includes: Sort the various data types to be synchronized according to the preset rules and synchronize them one by one in order; When the first state is in a synchronizing state, the main program calls an interface to determine whether the third state performs data synchronization according to a preset rule, and supports the main program to resynchronize in case of synchronization failure; When the first state is in a synchronization completed state, the main program is supported to request synchronization of the next data type, and the state manager assigns the second state to the third state; When the third state shows that synchronization of a certain data type fails, resynchronization is performed; When the third state shows that a certain data type is synchronized successfully, the data type is recorded according to the second state for synchronization, and the second state is updated.
4. The smart ring device status management method according to claim 1, characterized in that: The device adding logic specifically includes: Start scanning to determine whether the main program has enabled the Bluetooth service. If not, notify the user. After starting the Bluetooth service, monitor the LeScanCallback interface; When the onLeScan method in the LeScanCallback interface has a data callback, obtain the smart ring connected to Bluetooth, read its device name and make a judgment with the preset chooseDevice; If the device name exists in chooseDevice, the state manager terminates the device adding logic; If the device name does not exist in chooseDevice, add the smart ring to the ringDeviceScans collection and open the getRingDeviceScans interface; The main program enters the add binding interface, reads the getRingDeviceScans interface to obtain the scanned smart ring, selects the device to be added and reports it to the server, completing the addition and binding of the smart ring.
5. The smart ring device status management method according to claim 1, characterized in that: The device connection logic specifically includes: Start the connection service and determine whether the main program has enabled the Bluetooth service. If not, notify the program. After starting the Bluetooth service, monitor the LeScanCallback interface; When the onLeScan method in the LeScanCallback interface has a data callback, obtain the smart ring connected to Bluetooth, read its device name and make a judgment with the preset chooseDevice; If the device name does not exist in chooseDevice, the connection service is triggered and connectDevice is set. The callback information of the IResponseListener interface is listened to to determine whether the device connection is successful.
6. The smart ring device status management method according to claim 1, characterized in that: The data types include device time, device battery level, firmware version, and historical data.
7. The smart ring device status management method according to claim 5, characterized in that: In the device adding logic and the device connecting logic, the isConnectReady status field is removed, and the connectDevice device cache is judged to determine whether to enter the device adding logic or the device connecting logic.
8. A smart ring device status management system, characterized in that: These include: A pre-creation unit, used to start a pre-created state manager through a main program, wherein the state manager is configured with a state waiting mechanism and integrates device adding logic, device connection logic and data synchronization logic; A scanning and starting unit, used to start the main program to scan the smart ring, monitor the scanning result through the state manager, and start the device adding logic and the device connecting logic; A scanning and analyzing unit, configured to, when obtaining device information of the smart ring from the scanning result, analyze whether the smart ring has been bound to the main program based on the device information: If it is not bound, the device information is fed back to the main program through the state manager, and the device binding of the smart ring is completed; If it has been bound, the device adding logic is terminated, the connection service is triggered through the state manager, and the device connection of the smart ring is completed; A data synchronization unit is used for completing the data synchronization involving multiple data types between the smart ring and the main program based on the state waiting mechanism when the data synchronization logic is started.
9. A computer device, characterized in that: The computer device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the smart ring device status management method as described in any one of claims 1-7.
10. A computer program product, characterized in that It includes executable instructions for implementing the smart ring device status management method as described in any one of claims 1-7 when executed by a processor.
Citation Information
Cited By
State management method of intelligent ring system
CN120448212A