Intelligent lock gateway device access management method
By establishing a task buffer for terminal devices and calculating task urgency, the Bluetooth connection interval is dynamically adjusted, solving the problem of resource allocation imbalance between the gateway and multiple terminal devices, and achieving rapid response to urgent tasks and global communication stability.
Patent Information
- Application Number
- CN202611654335.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-26
- Publication Date
- 2026-11-24
AI Technical Summary
In existing technologies, Bluetooth connection time slot resources between gateways and multiple terminal devices cannot be allocated differently according to the real-time business urgency of each device, resulting in an imbalance in connection resource allocation, increased response delay for high-priority commands, and the inability to release time slots occupied by devices without tasks, thus reducing overall access management efficiency.
By establishing task buffers for each terminal device, recording task operation types and arrival timestamps, calculating task urgency, and performing capacity access checks in order of urgency, the Bluetooth connection interval is dynamically adjusted to ensure that urgent tasks have more communication opportunities while maintaining global communication stability.
It enables differentiated and dynamic allocation of Bluetooth connection time slot resources, allowing emergency tasks to obtain more frequent communication opportunities, reducing response latency, avoiding resource allocation imbalance, and ensuring communication stability and efficiency.
Smart Images

Figure CN123164547A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of Internet of Things (IoT) communication resource management technology, specifically relating to a smart lock gateway device access management method. Background Technology
[0002] With the advancement of intelligent upgrades in the hotel industry, smart locks, elevator controls, power switches, and other terminal devices are being deployed extensively on guest room floors. Gateway devices, acting as communication relays between cloud servers and local terminal devices, establish persistent connections with multiple terminal devices via Bluetooth Low Energy, undertaking management functions such as remote unlocking, password distribution, and device status monitoring. The number of terminal devices simultaneously connected within the coverage area of a single gateway continues to increase, placing higher demands on the gateway's multi-device concurrent communication management capabilities.
[0003] Currently, gateways and terminal devices generally use a unified and fixed Bluetooth connection interval parameter for communication scheduling. When a device connects, the gateway configures the same connection interval for all devices. Each device periodically interacts with the gateway at this fixed interval, regardless of whether the device currently has pending control commands or data transmission needs, all of which occupy the same connection time slot resources.
[0004] However, the aforementioned fixed connection interval method cannot differentiate the allocation of limited Bluetooth connection time slots based on the real-time business urgency of each device. When multiple devices generate communication needs simultaneously, remote unlocking commands requiring immediate response and idle devices without communication needs occupy the same connection resources, leading to increased response latency for high-priority commands. Meanwhile, time slots continuously occupied by idle devices cannot be released for devices with urgent needs, resulting in an imbalance in the allocation of limited time slot resources among multiple devices and a decrease in the overall access management efficiency of the gateway. Summary of the Invention
[0005] This invention provides a smart lock gateway device access management method to solve the technical problem that the limited Bluetooth connection time slot resources between the gateway and multiple terminal devices cannot be allocated differently according to the real-time business urgency of each device, resulting in an imbalance in connection resource allocation.
[0006] This invention provides a smart lock gateway device access management method, comprising: S101, the gateway stores the control command into the task buffer of the corresponding terminal device, records the task operation type and arrival timestamp, and counts the connection event success rate of each device. S102, the gateway periodically calculates the task urgency of each device with pending tasks. The task urgency is the sum of the task urgency base score and the waiting correction amount. The task urgency base score is positively correlated with the preset urgency level of the task operation type, and the waiting correction amount is positively correlated with the difference between the current time and the arrival timestamp. S103, the gateway performs capacity access checks on each device in descending order of task urgency, determines the candidate interval target value based on task urgency, divides the number of time slots added by shortening the current connection interval to the candidate interval target value by the connection event success rate to obtain the actual expected time slot increment, and uses the ratio of the actual expected time slot increment to the current available time slot balance as the capacity balance ratio. When the capacity balance ratio is less than the preset security threshold, the device is admitted. S104, the gateway sends candidate interval target values to each admitted device to update the Bluetooth connection interval. When the task buffer is cleared, the connection interval is restored to the maximum allowed interval to release the time slot quota.
[0007] Its effects are as follows: the gateway caches control commands for each device and records the operation type and arrival timestamp, providing a data foundation for subsequent urgency quantification; the urgency level is determined by the sum of the task urgency base score and the waiting correction amount, allowing scheduling decisions to simultaneously reflect the inherent urgency of the task type and the fairness of the waiting time; capacity access checks are performed in order of urgency and time slot increments are corrected by the connection event success rate, ensuring that limited quotas are prioritized for urgent and stable communication devices; when the buffer is cleared, the maximum allowed interval is restored to release time slots, allowing short-interval resources to flow between devices on demand rather than being occupied for a long time, thus achieving closed-loop dynamic management of connection resources.
[0008] Furthermore, the basic score for task urgency is positively correlated with the preset urgency level of the task operation type. This includes: the task operation type is divided into three preset urgency levels, with remote unlocking or locking operations corresponding to the high level, password issuance, deletion, or modification operations corresponding to the medium level, and configuration operations corresponding to the low level; the basic score for task urgency corresponding to the high level is the first preset score, the basic score for task urgency corresponding to the medium level is the second preset score, and the basic score for task urgency corresponding to the low level is the third preset score. The first preset score is greater than the second preset score, the second preset score is greater than the third preset score, and the difference between the first preset score and the second preset score is greater than the difference between the second preset score and the third preset score.
[0009] Its effect is that it divides task operation types into three preset urgency levels: high, medium, and low, and sets the difference between the first preset score and the second preset score to be greater than the difference between the second preset score and the third preset score. This ensures that immediate response needs such as remote unlocking are always given priority under normal operating conditions. At the same time, the small score difference between the medium and low levels allows the two to alternate in urgency within a reasonable waiting time, preventing low-level tasks from being shelved for a long time.
[0010] Furthermore, the positive correlation between the waiting correction amount and the difference between the current time and the arrival timestamp includes: the waiting correction amount is equal to the quotient obtained by dividing the difference between the current time and the arrival timestamp by the scheduling cycle duration, where the scheduling cycle duration is a fixed time interval for the gateway to perform periodic scheduling evaluation.
[0011] Furthermore, determining the candidate interval target value based on task urgency includes: dividing the task urgency into high, medium, and low intervals; when the task urgency is in the high interval, the candidate interval target value is the shortest stable interval value of the gateway Bluetooth module; when the task urgency is in the medium interval, the candidate interval target value is less than the default connection interval; when the task urgency is in the low interval, the candidate interval target value is the default connection interval; and for devices with an empty task buffer, the connection interval target value is the maximum allowed interval.
[0012] Furthermore, when the task urgency is in the middle range, the candidate interval target value being less than the default connection interval includes: the candidate interval target value being equal to the default connection interval multiplied by the number of devices with pending tasks and then divided by the total number of currently connected devices.
[0013] Its effect is that the target value of the candidate interval in the middle interval is equal to the default connection interval multiplied by the number of devices with pending tasks and then divided by the total number of currently connected devices. This allows the interval reduction rate to be automatically determined by the real-time load status without the need for manual preset reduction ratio. When only a few devices have tasks, each device obtains a greater communication frequency boost. When multiple devices have tasks at the same time, the reduction rate is automatically converged to avoid excessive resource concentration.
[0014] Furthermore, the success rate of connection events for each device is calculated as follows: after each connection event between the gateway and the device is completed, the gateway records whether the data interaction was successfully completed in this connection event. The success rate of the connection event is obtained by dividing the number of successfully completed data interactions in the most recent consecutive preset number of connection events of the device by the preset number.
[0015] Furthermore, the current available time slot balance is obtained in the following way: the gateway sets a statistical period, which is the product of the default connection interval and the total number of currently connected devices. The default connection interval is the maximum interval value that ensures normal heartbeat communication of all devices under the maximum number of connected devices. The current available time slot balance is obtained by subtracting the total number of time slots actually occupied by all connected devices in a statistical period from the total time slot budget of the Bluetooth scheduler in a statistical period.
[0016] Furthermore, the gateway periodically calculates the task urgency of each device with pending tasks, including: when there are multiple pending tasks in the task buffer of a device, the task with the highest preset urgency level is selected as the representative task; if there are multiple tasks with the same preset urgency level, the task with the earliest arrival timestamp is selected as the representative task; the gateway calculates the task urgency of the device based on the task operation type and arrival timestamp of the representative task.
[0017] Furthermore, after the gateway sends candidate interval target values to each approved device to update the Bluetooth connection interval, it also includes: if the candidate interval target value does not take effect within a preset number of connection events, the gateway re-initiates the interval update; if it does not take effect after a preset number of consecutive retries, the current interval update is abandoned, the device maintains the current connection interval, and the ineffective connection events after a preset number of consecutive retries are included in the statistics of the connection event success rate.
[0018] Its effect is that if the interval update fails to take effect within the preset number of connection events, it will be re-initiated. If it fails to take effect after a preset number of consecutive retries, it will be abandoned and the failure event will be included in the connection event success rate statistics. This will cause devices with unstable communication to be automatically reduced in competitiveness due to the decrease in success rate during subsequent access checks. Resources can be concentrated on links with stable communication quality without human intervention. At the same time, the abandonment mechanism will prevent the gateway from getting stuck in an infinite wait for a single device.
[0019] Furthermore, when the capacity margin ratio is greater than or equal to the preset security threshold, the gateway calculates the backoff interval target value based on the current available time slot margin, the preset security threshold, and the connection event success rate. The backoff interval target value is the connection interval value that makes the capacity margin ratio equal to the preset security threshold. If the backoff interval target value is less than the device's current connection interval, the device is admitted using the backoff interval target value instead of the candidate interval target value. If the backoff interval target value is greater than or equal to the device's current connection interval, the device maintains its current connection interval.
[0020] Its effect is that when the capacity margin ratio is greater than or equal to the preset security threshold, the gateway reversely calculates the backoff interval target value and performs admission by replacing the candidate interval target value when it is less than the current connection interval. This upgrades the admission check from a binary decision of pass or rejection to gradient allocation. Even when the margin is insufficient to support the candidate interval target value, it still strives to shorten the interval for the device and avoids the available time slot margin being idle and wasted due to all devices being rejected.
[0021] The beneficial effects are as follows: This invention establishes an independent task buffer for each terminal device and records the task operation type and arrival timestamp. It obtains the task urgency by superimposing the task urgency base score and the waiting correction amount. It performs capacity admission checks according to urgency and corrects the time slot consumption by combining the connection event success rate. It issues shortened connection intervals to devices that have passed the admission and restores the maximum allowable interval when the buffer is cleared. This enables the differentiated and dynamic allocation of Bluetooth connection time slot resources among multiple devices according to the real-time service urgency and link communication quality. This allows urgent tasks to obtain more frequent communication opportunities to reduce response latency. At the same time, it maintains global communication stability through capacity constraints and backoff interval mechanisms, avoiding the resource allocation imbalance problem caused by fixed connection intervals in the prior art. Attached Figure Description
[0022] Figure 1 This is a flowchart of the smart lock gateway device access management method in this invention.
[0023] Figure 2 This is a schematic diagram of the dynamic adjustment timing of the connection interval in this invention.
[0024] Figure 3 This is a schematic diagram of the gateway and multi-device connection architecture in this invention. Detailed Implementation
[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] An embodiment of the smart lock gateway device access management method provided by the present invention: This embodiment uses a hotel intelligent management scenario as an example. Gateway devices are deployed on hotel floors, maintaining a persistent connection with multiple smart locks and associated terminal devices on that floor via Bluetooth Low Energy protocol, while simultaneously communicating with a cloud server via the uplink network. The cloud server generates control commands based on guest check-in / check-out or remote administrator operations and sends them to the gateway, which then forwards the commands to the corresponding terminal devices for execution. A single gateway can simultaneously connect to 8 to 20 terminal devices within its coverage area. The wireless channel quality varies among devices due to differences in installation location and wall obstruction. The gateway's Bluetooth scheduler has limited time slot resources, requiring reasonable allocation among multiple devices to balance response speed and communication stability.
[0027] like Figure 1 As shown, the smart lock gateway device access management method includes the following steps: S101, the gateway stores instruction records and statistics on device connection success rate.
[0028] The gateway stores control commands in the task buffer of the corresponding terminal device, records the task operation type and arrival timestamp, and calculates the connection event success rate of each device.
[0029] The gateway maintains an independent task buffer for each terminal device with an established Bluetooth connection. When the cloud server sends a control command to the gateway for a specific terminal device, the gateway parses the device identifier field of the command message to determine the target device and writes the control command into the corresponding task buffer of the target device. The task buffer uses a first-in-first-out queue structure to store tasks to be processed, with each task corresponding to a control command that has not yet been successfully sent to the terminal device.
[0030] While writing control commands to the task buffer, the gateway records two attribute pieces of information for the task. The first is the task operation type, which the gateway obtains by parsing the operation type field in the cloud command message. This field identifies whether the command is a remote unlocking / locking operation, a password issuance / deletion / modification operation, or a configuration operation such as setting a normally open mode. The second is the arrival timestamp, which the gateway reads from the local system clock at the moment the task enters the buffer and records. The task operation type and arrival timestamp are stored in the buffer along with the task and are cleared together after the task is successfully processed.
[0031] The gateway also maintains a communication quality metric—the connection event success rate—for each connected terminal device. In the Bluetooth Low Energy protocol, each connection event between the gateway and a terminal device corresponds to one radio frequency interaction opportunity within a predetermined time slot. After each connection event with a device is completed, the gateway determines whether the connection event has successfully completed a valid data exchange. The determination is based on whether the data packet sent by the gateway within the time slot window of the connection event received an acknowledgment from the terminal device. If an acknowledgment is received, it is recorded as a success; otherwise, it is recorded as a failure. The gateway maintains a sliding window of length 10 for each device, storing the success or failure records of the device's most recent 10 consecutive connection events. The connection event success rate is equal to the number of successful events within the window divided by 10. Each time a new connection event is completed, the latest result moves to the end of the window, the oldest record moves out of the beginning of the window, and the success rate is updated accordingly.
[0032] The connection event success rate reflects the actual communication quality of the Bluetooth link between the gateway and the device. Devices installed close to the gateway without significant obstructions have a success rate close to 1; devices installed at the end of a corridor or with multiple walls obstructing the view experience signal attenuation, leading to packet loss in some connection events and a success rate below 1. This metric ranges from greater than 0 to less than or equal to 1. When a device connects for the first time, since there are no historical connection event records, the gateway initializes its connection event success rate to 1.
[0033] The gateway needs to configure basic connection parameters upon initial device connection. The gateway is configured with a unified connection monitoring timeout of 6 seconds for all devices, with a maximum allowed interval of 3 seconds. This value ensures that each device generates at least one connection event within each monitoring timeout period under the maximum allowed interval to maintain the connection. The default connection interval is determined as follows: Under the condition of the maximum number of devices expected to connect to the gateway, the connection interval is gradually increased, and the heartbeat communication of all devices is observed to ensure normal maintenance. The maximum interval value that satisfies the normal heartbeat communication of all devices is taken as the default connection interval.
[0034] In this way, the gateway completes the collection and storage of raw data required for subsequent scheduling decisions by independently maintaining task buffers for each terminal device and statistically analyzing the connection event success rate in real time. The connection event success rate provides a quantitative basis for evaluating the actual transmission efficiency of the link in subsequent access checks, avoiding the waste of time slots caused by link quality differences when allocating resources solely based on the urgency of the task.
[0035] S102, the gateway periodically calculates the urgency of device tasks.
[0036] The gateway periodically calculates the task urgency for each device with pending tasks. The task urgency is the sum of the task urgency base score and the waiting correction amount. The task urgency base score is positively correlated with the preset urgency level of the task operation type, and the waiting correction amount is positively correlated with the difference between the current time and the arrival timestamp.
[0037] The gateway periodically performs scheduling evaluations at fixed time intervals, which is called the scheduling cycle length. The scheduling cycle length is 1 second. This value ensures that, under the default connection interval, each device completes at least one connection event within each scheduling cycle, allowing the urgency evaluation results to be executed within one cycle. The scheduling cycle length is a fixed parameter independent of the device connection interval and the number of devices, and does not change with the operating status.
[0038] At the start of each scheduling cycle, the gateway scans the task buffers of all connected devices. Devices with empty buffers are not included in the urgency calculation and are directly assigned the maximum allowed interval in the subsequent interval allocation stage. For devices with at least one pending task in their buffers, the gateway calculates the current task urgency for that device.
[0039] When a device has multiple pending tasks in its task buffer, the gateway must select a representative task for calculating the device's urgency. The selection rule is as follows: the task with the highest preset urgency level in the buffer is chosen as the representative task; if multiple tasks have the same preset urgency level, the task with the earliest arrival timestamp is chosen as the representative task. This rule ensures that the device's urgency is always determined by its most urgent pending needs. The gateway calculates the device's task urgency based on the representative task's task operation type and arrival timestamp.
[0040] The urgency of a task is obtained by adding two parts: the base score for urgency and the amount of waiting correction.
[0041] The urgency score for a task is determined as follows: Task operation types are divided into three preset urgency levels: remote unlocking or locking operations correspond to a high level, password issuance, deletion, or modification operations correspond to a medium level, and configuration operations correspond to a low level. The high-level task urgency score is the first preset score, the medium-level task urgency score is the second preset score, and the low-level task urgency score is the third preset score. The first preset score is greater than the second preset score, the second preset score is greater than the third preset score, and the difference between the first and second preset scores is greater than the difference between the second and third preset scores.
[0042] In this embodiment, the first preset score is 10, the second preset score is 3, and the third preset score is 1. The classification is based on the difference in user waiting sensitivity: remote unlocking corresponds to a guest standing outside the door waiting to enter the room, and the response delay directly leads to a decline in the guest experience; password operation corresponds to the intermediate step in the front desk check-in process, where the guest is still waiting at the front desk but not blocked at the door; configuration operations are initiated by the administrator and have no immediate time requirement. The difference between the first and second preset scores is 7, and the difference between the second and third preset scores is 2, with the former being greater than the latter. The purpose of this non-equidistant design is that medium-level tasks need to accumulate waiting time for at least 7 scheduling cycles before they can catch up with the newly arrived high-level tasks in terms of urgency value, ensuring that high-level tasks always receive priority service within the normal response capacity of the gateway. The difference between medium and low levels is only 2, and low-level tasks can catch up with newly arrived medium-level tasks after waiting for 2 scheduling cycles. The timeliness difference between the two is small, and there is no need to set an excessively large gap. Each preset score can be calibrated and adjusted based on the user complaint rate and response time statistics of various types of instructions in hotel operations.
[0043] The waiting correction amount is calculated as follows: The waiting correction amount is equal to the difference between the current time and the arrival timestamp of the representative task, divided by the scheduling cycle duration. The scheduling cycle duration is a fixed time interval for the gateway to perform periodic scheduling evaluations; in this embodiment, it is taken as 1 second. The specific calculation formula is as follows:
[0044] In the formula, Waiting for correction amount; This is the local system clock value read by the gateway at the current moment, i.e., when it performs this scheduling evaluation, in seconds; This represents the arrival timestamp of the task, in seconds. The scheduling cycle duration is 1 second. The physical meaning of the waiting correction amount is the number of complete scheduling cycles that the task has been waiting for. This design references the aging mechanism in operating system process scheduling, where the effective priority of a low-priority process increases linearly with the waiting time, preventing it from being constantly preempted by high-priority processes and thus never receiving service.
[0045] The formula for calculating task urgency is:
[0046] In the formula, To assess the urgency of the task; The urgency score is determined by the preset urgency level of the task, with 10 for high urgency, 3 for medium urgency, and 1 for low urgency. The waiting adjustment amount is used because the base score for task urgency reflects the inherent urgency attribute of the task operation type, while the waiting adjustment amount reflects the increase in urgency over time. These are independent dimensions of urgency source. When a low-priority task waits long enough, its urgency can rise to a level similar to that of a high-priority task, thus gaining priority service opportunities and ensuring that no device is permanently unable to obtain communication resources due to low priority.
[0047] Taking this hotel scenario as an example: at the evaluation time of a certain scheduling cycle, the buffers of 3 devices within the gateway's coverage area are not empty. Device A's representative task is a remote unlocking command. =10, =0 seconds, =0 / 1=0, =10+0=10. Device B's representative task is to issue password commands. =3, =8 seconds, =8 / 1=8, =3+8=11. Device C's representative task is a configuration instruction. =1, =2 seconds, =2 / 1=2, =1+2=3. The sorting result is Device B 11, Device A 10, Device C 3. Although Device B is a medium-priority task, its urgency has exceeded that of the newly arrived high-priority task because it has been waiting for 8 seconds without being served, demonstrating the effectiveness of the anti-starvation mechanism. Under normal gateway response conditions, high-priority tasks are processed within 1 to 2 scheduling cycles after arrival, and medium-priority tasks will not accumulate to the point of catching up with high-priority tasks.
[0048] In this way, the gateway periodically calculates the urgency of tasks, transforming the task attribute information in the buffers of each device into a unified and comparable numerical indicator. This allows the scheduling decision to take into account both the inherent urgency of the task type and the fairness of the waiting time, providing a quantitative basis for subsequent differentiated resource allocation based on urgency.
[0049] S103, The gateway performs a device capacity access check based on urgency.
[0050] The gateway performs capacity access checks on each device in descending order of task urgency. Based on the task urgency, it determines the target value of the candidate interval. The actual expected time slot increment is obtained by dividing the number of time slots added by shortening the current connection interval to the target value of the candidate interval by the connection event success rate. The ratio of the actual expected time slot increment to the current available time slot balance is used as the capacity balance ratio. When the capacity balance ratio is less than the preset security threshold, the device is admitted.
[0051] The gateway sorts all devices with the calculated task urgency from highest to lowest urgency value, forming an admission check queue for the current scheduling cycle. Devices with the same urgency are then sorted by the arrival timestamp of their respective tasks, with earlier arrival times listed first. Following this queue order, the gateway performs a capacity admission check on each device sequentially, verifying whether the Bluetooth scheduler still has sufficient time slot resources to maintain stable global communication after the connection interval for that device is shortened.
[0052] The first step in the access check is to determine the candidate interval target value based on the task urgency of the equipment. Task urgency is divided into high, medium, and low intervals, each corresponding to a different candidate interval target value.
[0053] The high interval is defined as a task urgency score of 10 or higher. The base urgency score for remote unlocking commands is 10; such tasks fall into the high interval the moment they enter the buffer. When the task urgency is in the high interval, the candidate interval target value is the shortest stable interval value of the gateway's Bluetooth module. The method for determining the shortest stable interval value is as follows: on the actual Bluetooth module integrated into the gateway, starting from the minimum connection interval value allowed by the Bluetooth Low Energy protocol, the interval is gradually increased. For each interval value, 10 consecutive connection events are tested for data interaction, and the shortest interval value is taken when all 10 consecutive data interactions are successfully completed.
[0054] The middle interval is defined as a task urgency level greater than or equal to 3 and less than 10. Cryptographic operation tasks have a base urgency level of 3; reaching the buffer zone places the task in the middle interval. When the task urgency is in the middle interval, the candidate interval target value is less than the default connection interval, and its specific value is calculated using the following formula:
[0055] In the formula, The target value for the candidate interval; This is the default connection interval, which is the maximum interval value that ensures normal heartbeat communication for all devices under the maximum number of connected devices. This represents the number of devices with pending tasks, i.e., the number of devices whose buffers are not empty during this scheduling cycle. This represents the total number of currently connected devices. The physical meaning of this formula is as follows: The default connection interval originally allocated time slot resources evenly based on the assumption that all devices need to communicate. However, in reality, only some devices have communication needs. Therefore, communication opportunities originally distributed to devices without tasks are consolidated and redistributed to devices with tasks, thus shortening the interval for those with tasks. This calculation method does not require manual preset shortening ratios; the interval value is automatically determined by the real-time operating status. When all devices have tasks to process... equal The formula degenerates to the default connection interval and is not shortened.
[0056] The low interval is defined as a task urgency level greater than or equal to 1 and less than 3. Configuration tasks have a base urgency level of 1 and initially fall into the low interval. When a task's urgency level is in the low interval, the target value for the candidate interval is the default connection interval; no interval shortening is performed, and the device processes buffer tasks in a first-come, first-served order during normal connection events.
[0057] Devices with empty task buffers are not included in the admission check queue, and their connection interval target value is directly set to the maximum allowed interval.
[0058] After determining the target interval value, the gateway calculates the time slot resource consumption resulting from shortening the interval for the device. Before calculation, the current available time slot balance needs to be obtained. The gateway sets a statistical period, which is the product of the default connection interval and the total number of currently connected devices, representing the time required for the Bluetooth scheduler to complete one round of full device polling under the default connection interval. The current available time slot balance is obtained by subtracting the total number of time slots actually occupied by all connected devices according to their respective current connection intervals within a statistical period from the Bluetooth scheduler's total time slot budget within that statistical period.
[0059] In the formula, This represents the current available time slot margin; The total time slot budget is determined by the hardware specifications of the gateway's Bluetooth RF module and is a fixed parameter. For the statistical period, equal to ; This represents the total number of currently connected devices. For equipment The current connection interval. Each term in the summation term represents the device's current connection interval. The number of connection events generated within a statistical period based on the current connection interval is the number of time slots actually occupied by the device. A positive value for the current available time slot margin indicates that the channel still has idle resources, while zero value indicates that the channel is fully loaded.
[0060] After obtaining the current available time slot slack, the gateway calculates the number of time slots added by shortening the current connection interval to the candidate interval target value:
[0061] In the formula, This represents the number of newly added time slots; For statistical periods; The target value for the candidate interval; This represents the current connection interval for this device.
[0062] The number of newly added time slots reflects the ideal increment under perfect, lossless communication link conditions. In actual operation, some connection events of this device fail due to signal attenuation, preventing effective data exchange. To complete the same number of effective exchanges, more time slots are needed. Dividing the number of newly added time slots by the success rate of the device's connection events yields the actual expected time slot increment:
[0063] In the formula, This represents the actual expected time slot increment; This represents the number of newly added time slots; This represents the connection event success rate for the device, with a value greater than 0 and less than or equal to 1. When it is 1, equal The correction has no effect. When it is below 1, Greater than This indicates that devices with poor communication quality require an average of more connection events to successfully complete a single effective interaction, and thus occupy more time slots to achieve the same service effect. This correction enables admission checks to identify devices that are urgent but have low actual transmission efficiency due to poor link quality, avoiding the allocation of limited time slots to inefficient links when resources are scarce.
[0064] The gateway uses the ratio of the actual expected increase in time slots to the current available time slot margin as the capacity margin ratio:
[0065] In the formula, This refers to the capacity margin ratio; This represents the actual expected time slot increment; This represents the current available time slot margin. The capacity margin ratio indicates the proportion of remaining available resources expected to be consumed during this interval reduction operation. Referring to the engineering methods of call admission control in communication networks, when the occupancy ratio of a single new access exceeds the safety margin, the access should be rejected to avoid overload.
[0066] When the capacity margin ratio is less than the preset security threshold, the device passes the admission check. After admission, the gateway confirms the device's candidate interval target value as the official connection interval target value, and deducts the device's actual expected time slot increment from the current available time slot margin. The updated margin is then used for the admission check of the next device in the queue.
[0067] When the capacity margin ratio is greater than or equal to a preset security threshold, the device cannot pass the admission check with the candidate interval target value. In this case, the gateway does not directly reject the device's interval reduction request, but instead calculates the backoff interval target value based on the current available time slot margin, the preset security threshold, and the connection event success rate. The backoff interval target value is the connection interval value that makes the capacity margin ratio exactly equal to the preset security threshold, i.e., the maximum interval reduction the device can achieve under the current margin conditions.
[0068] The derivation process of the target value for the yield interval is as follows. Let the capacity margin ratio be exactly equal to the preset safety threshold. Substitute the expressions for the actual expected increase in time slots and the number of newly added time slots into the equation:
[0069] In the formula, The target value of the yield interval to be solved; For statistical periods; This is the current connection interval for this device; This represents the success rate of connection events for this device. This represents the current available time slot margin; To preset the safety threshold, rearrange the terms in the above equation and solve. :
[0070]
[0071]
[0072] Referring to the engineering method of downgraded admission in the call admission control of communication networks, when the total amount of requested resources cannot be satisfied, the maximum amount of allocable resources is solved in reverse at the capacity constraint boundary by taking the equality sign; all variables in this formula are intermediate results that have been calculated in this step. This indicates the maximum number of time slots that the device is allowed to add under the current margin, after communication quality correction and within the constraints of a preset safety threshold. The sum of the number of time slots occupied by the device within a statistical period at the current interval is the total number of time slots occupied by the device under the backoff interval. The target value of the backoff interval is obtained by dividing the statistical period by the total number of time slots occupied.
[0073] After obtaining the target backoff interval value, the gateway performs a feasibility assessment. If the target backoff interval value is less than the device's current connection interval, it means that although the current margin is insufficient to support the full reduction corresponding to the candidate interval target value, it can still support a certain degree of interval reduction. In this case, the target backoff interval value is used instead of the candidate interval target value to perform admission on the device. The gateway deducts the actual expected time slot increment recalculated with the target backoff interval value from the current available time slot margin, and the updated margin is used by the next device in the queue.
[0074] If the target value of the backoff interval is greater than or equal to the current connection interval of the device, it means that the current margin cannot even be shortened to the minimum. The device will keep the current connection interval unchanged, and its tasks will be kept in the buffer to wait for re-evaluation in the next scheduling cycle.
[0075] When the current available time slot margin is zero, the backoff interval target value of all devices is greater than or equal to their current connection interval, and none of them can achieve interval reduction.
[0076] The preset safety threshold is determined as follows: 0.8 is used for initial deployment, meaning that the actual expected time slot consumption for a single interval shortening operation will not exceed 80% of the remaining available time slots, reserving a 20% margin to handle subsequent more urgent tasks. After actual operation, calibration can be performed by gradually increasing the number of devices simultaneously in short-interval mode and monitoring the global Bluetooth communication success rate. When the global communication success rate begins to fall below 95%, the corresponding capacity margin ratio is the measured safety threshold for this deployment environment, replacing the initial value.
[0077] Taking this hotel scenario as an example, the gateway connects to 10 devices, with a default connection interval. The statistical period is 500 milliseconds. =500 × 10 = 5000 milliseconds. Total time slot budget There are 50 time slots available. Currently, 3 device buffers are not empty and are at the default connection interval of 500 milliseconds, while the remaining 7 device buffers are empty and are at the maximum allowed interval of 3000 milliseconds. The total number of currently occupied time slots is 3×(5000 / 500)+7×(5000 / 3000)=30+11.67, rounded down to 42 time slots. The current available time slots are... =50-42=8 time slots.
[0078] Equipment A is at the front of the line, indicating urgency. =10, belonging to the high interval, candidate interval target value The shortest stable interval is set to 100 milliseconds; the current connection interval is... =500 milliseconds, connection event success rate =1.0. Number of newly added time slots. =(5000 / 100)-(5000 / 500)=50-10=40. Actual expected time slot increment. =40 / 1.0=40. Capacity margin ratio. =40 / 8=5.0, which is greater than the preset security threshold of 0.8. Device A cannot pass the admission test with the candidate interval target value. The gateway calculates the backoff interval target value: =5000 / (0.8×8×1.0+5000 / 500)≈305 milliseconds. The target value of the backoff interval, 305 milliseconds, is less than the current connection interval of 500 milliseconds, which is feasible. The gateway replaces the original candidate interval target value with 305 milliseconds to perform admission on device A. Although device A does not obtain the shortest interval of 100 milliseconds, compared to maintaining 500 milliseconds, the communication frequency increases from 10 times per 5000 milliseconds to 16.4 times per 5000 milliseconds, achieving maximum resource utilization under the current margin constraint. The actual expected increase in time slots consumed by device A is (5000 / 305-5000 / 500) / 1.0=6.4 time slots, and the margin after the update is 8-6.4=1.6 time slots.
[0079] Equipment B is second in the queue, with the highest urgency. =11, belonging to the high interval, candidate interval target value =100 milliseconds =500 milliseconds, =0.5. =40, =40 / 0.5=80, =80 / 1.6=50, which is much greater than 0.8. Calculate the target value for the yield interval: =5000 / (0.8×1.6×0.5+5000 / 500)≈470 milliseconds. The target backoff interval of 470 milliseconds is less than the current connection interval of 500 milliseconds, resulting in a 30 millisecond reduction in interval. While the improvement is limited, it is still better than not reducing it at all. The gateway performs admission on device B at 470 milliseconds. This result also reflects the impact on communication quality: device B's connection event success rate is only 0.5, and the reduction achieved under the same margin is far less than that of device A, which has a success rate of 1.0.
[0080] If the target backoff interval for all devices is greater than or equal to their current connection interval for five consecutive scheduling cycles, meaning no device receives an interval reduction, the gateway reports a channel overload alarm to the cloud server to prompt maintenance personnel to deploy more gateways.
[0081] In this way, the gateway performs capacity admission checks based on urgency, verifying the carrying capacity of time slot resources before shortening connection intervals. This ensures that limited short-interval quotas are prioritized for urgent and stable communication devices. The amplification correction of connection event success rate on time slot increments allows the admission check to consider link transmission efficiency, avoiding the allocation of time slots to devices that frequently retransmit due to signal attenuation. The introduction of a backoff interval target value allows for partial shortening of time slots even when the margin is insufficient to support the candidate interval target value, preventing the waste of available time slots due to all devices being rejected.
[0082] S104, the gateway sends the interval parameter, and the connection is restored after the task ends.
[0083] The gateway sends candidate interval target values to each admitted device to update the Bluetooth connection interval. When the task buffer is cleared, the connection interval is restored to the maximum allowed interval to release the time slot quota.
[0084] For each device that passes the capacity admission check, the gateway initiates a connection parameter update request via the Bluetooth protocol stack. According to the Bluetooth Low Energy protocol specification, the gateway, as the connection master, has the ability to dynamically adjust the connection interval parameter after the connection is established. The gateway writes the target connection interval value for each admitted device into the connection interval field of the connection parameter update request message and sends the request to each device sequentially. For devices that passed admission with a candidate interval target value, the candidate interval target value is sent; for devices that passed admission with a fallback interval target value instead of a candidate interval target value, the fallback interval target value is sent.
[0085] After a connection parameter update request is sent, the gateway checks whether the new interval has taken effect in subsequent connection events with the device. The determination is based on whether the deviation between the actual time interval of two adjacent connection events and the target interval value is within the clock accuracy range allowed by the Bluetooth protocol. If the candidate interval target value does not take effect within a preset number of connection events, the gateway re-initiates the interval update. The preset number of connection events is 2; that is, if no interval change is observed within two current connection interval periods after the update request is sent, the request is considered to have failed, and the gateway resends the update request in the next connection event.
[0086] If the update fails to take effect after a preset number of retries, the current interval update is abandoned. The preset number of retries is 3, meaning that if the device fails to switch to the target interval after the gateway has sent 3 update requests, retries will stop. After abandoning the update, the device maintains its current connection interval, and its task is retained in the buffer, participating again in urgency calculation and admission checks in the next scheduling cycle. The connection events that fail to complete the connection event success rate after a preset number of retries are included in the connection event success rate statistics. That is, events that fail to complete data interaction during these 3 retries are recorded in the device's sliding window. Due to the inclusion of failed events, the device's connection event success rate will decrease. In subsequent admission checks, its actual expected time slot increment will be amplified due to the lower success rate, resulting in a larger available time slot margin required for admission and a naturally reduced competitiveness. This mechanism automatically reduces the resource allocation priority of unstable communication devices without human intervention.
[0087] After the new interval takes effect, the gateway interacts with the device via connection events at the frequency corresponding to the target interval value. During each connection event, the gateway retrieves the task to be processed from the head of the device's task buffer queue, sends the control command data packet to the terminal device, and waits for a response. If a response is received, the task is completed and removed from the buffer; otherwise, the task remains in the buffer awaiting retransmission in the next connection event.
[0088] After each connection event is completed, the gateway updates the connection event success rate of the device, includes the success or failure result of this event in the sliding window statistics of the last 10 events, and checks the status of the device's task buffer.
[0089] When the task buffer is cleared, meaning all control commands in the buffer have been successfully sent to the terminal device and acknowledged, the gateway marks the device as having no pending tasks. In the next scheduling cycle, this device will not participate in urgency calculation, and its connection interval target value will be set to the maximum allowed interval. The gateway will initiate a connection parameter update request to the device, restoring the connection interval from the current short interval to the maximum allowed interval of 3 seconds. After restoration, the number of time slots occupied by the device in a statistical cycle will be significantly reduced, and the released time slot quota will be returned to the currently available time slot reserve, which can be used by other devices with higher urgency in the admission check in the next scheduling cycle.
[0090] Devices with unfinished tasks in their buffers will continue processing the remaining tasks in subsequent connection events while maintaining the current connection interval. If a new control instruction arrives and is written to the device's buffer during processing, and the preset urgency level of the new instruction is higher than that of the current representative task, the urgency of the device will change in the next scheduling cycle due to the change in the representative task, and the target value of the candidate interval may be adjusted accordingly.
[0091] When a device loses its Bluetooth connection, the gateway clears the device's task buffer and connection event success rate record, and releases all time slot quotas it occupied. When the device re-establishes its Bluetooth connection, the gateway recreates an empty task buffer for it, initializes the connection event success rate to 1, and configures the default connection interval.
[0092] In this way, the gateway dynamically shortens the connection interval by issuing a target value for the connection interval to the approved devices, enabling urgent tasks to have more frequent communication opportunities to accelerate the response. After the buffer is cleared, the maximum allowed interval is restored in a timely manner to release the time slot quota, allowing the limited short-interval resources to flow between devices on demand rather than being occupied for a long time. The retry and abandonment mechanism when the interval update fails ensures that the scheme does not fall into infinite waiting under unstable Bluetooth communication conditions. The failure event is included in the connection event success rate, enabling resource allocation to adaptively adjust to changes in communication quality.
[0093] like Figure 2 As shown, when the buffer is empty, the device keeps the maximum allowed interval in an idle state; after the control command arrives, the gateway shortens the connection interval of the device to the backoff interval target value according to the admission check result, and performs data interaction at the target interval frequency during the task processing phase; after the buffer is cleared, the gateway restores the connection interval to the maximum allowed interval and releases the time slot quota for other devices to use.
[0094] like Figure 3As shown, the gateway device connects to the cloud server via the uplink network, receives control commands from the cloud server, and reports device status and alarm information. The gateway device maintains a persistent connection with multiple smart locks and associated devices at the terminal device layer via Bluetooth Low Energy connection. Each device is assigned a different connection interval according to its task buffer status. Devices with urgent tasks are given a short interval or a backoff interval to increase the communication frequency, while devices without pending tasks maintain the maximum allowable interval to release time slot resources.
[0095] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for managing the access of a smart lock gateway device, characterized in that, include: S101, the gateway stores the control command into the task buffer of the corresponding terminal device, records the task operation type and arrival timestamp, and counts the connection event success rate of each device. S102, the gateway periodically calculates the task urgency of each device with pending tasks. The task urgency is the sum of the task urgency base score and the waiting correction amount. The task urgency base score is positively correlated with the preset urgency level of the task operation type, and the waiting correction amount is positively correlated with the difference between the current time and the arrival timestamp. S103, the gateway performs capacity access checks on each device in descending order of task urgency, determines the candidate interval target value based on task urgency, divides the number of time slots added by shortening the current connection interval to the candidate interval target value by the connection event success rate to obtain the actual expected time slot increment, and uses the ratio of the actual expected time slot increment to the current available time slot balance as the capacity balance ratio. When the capacity balance ratio is less than the preset security threshold, the device is admitted. S104, the gateway sends candidate interval target values to each admitted device to update the Bluetooth connection interval. When the task buffer is cleared, the connection interval is restored to the maximum allowed interval to release the time slot quota.
2. The smart lock gateway device access management method according to claim 1, characterized in that, The task urgency base score is positively correlated with the preset urgency level of the task operation type. The task operation type is divided into three preset urgency levels: remote unlocking or locking operations correspond to the high level, password issuance, deletion or modification operations correspond to the medium level, and configuration operations correspond to the low level. The task urgency base score corresponding to the high level is the first preset score, the task urgency base score corresponding to the medium level is the second preset score, and the task urgency base score corresponding to the low level is the third preset score. The first preset score is greater than the second preset score, the second preset score is greater than the third preset score, and the difference between the first preset score and the second preset score is greater than the difference between the second preset score and the third preset score.
3. The smart lock gateway device access management method according to claim 1, characterized in that, The positive correlation between the waiting correction amount and the difference between the current time and the arrival timestamp includes: the waiting correction amount is equal to the quotient obtained by dividing the difference between the current time and the arrival timestamp by the scheduling cycle duration, where the scheduling cycle duration is a fixed time interval for the gateway to perform periodic scheduling evaluation.
4. The smart lock gateway device access management method according to claim 1, characterized in that, The candidate interval target value is determined based on the task urgency, including dividing the task urgency into high, medium and low intervals. When the task urgency is in the high interval, the candidate interval target value is the shortest stable interval value of the gateway Bluetooth module. When the task urgency is in the medium interval, the candidate interval target value is less than the default connection interval. When the task urgency is in the low interval, the candidate interval target value is the default connection interval. The connection interval target value for devices with empty task buffers is the maximum allowed interval.
5. The smart lock gateway device access management method according to claim 4, characterized in that, When the task urgency is in the middle range, the candidate interval target value is less than the default connection interval, including: the candidate interval target value is equal to the default connection interval multiplied by the number of devices with pending tasks and then divided by the total number of currently connected devices.
6. The smart lock gateway device access management method according to claim 1, characterized in that, The success rate of connection events for each device is calculated as follows: after each connection event between the gateway and the device, the gateway records whether the data interaction was successfully completed. The success rate of the connection event is obtained by dividing the number of successfully completed data interactions in the most recent consecutive preset number of connection events by the preset number.
7. The smart lock gateway device access management method according to claim 1, characterized in that, The current available time slots are obtained in the following way: the gateway sets the statistical period, which is the product of the default connection interval and the total number of currently connected devices. The default connection interval is the maximum interval value that ensures normal heartbeat communication for all devices under the maximum number of connected devices. The current available time slots are obtained by subtracting the total number of time slots actually occupied by all connected devices within a statistical period from the total time slot budget of the Bluetooth scheduler within a statistical period.
8. The smart lock gateway device access management method according to claim 1, characterized in that, The gateway periodically calculates the task urgency of each device with pending tasks, including: when there are multiple pending tasks in the task buffer of a device, the task with the highest preset urgency level is selected as the representative task; if there are multiple tasks with the same preset urgency level, the task with the earliest arrival timestamp is selected as the representative task; the gateway calculates the task urgency of the device based on the task operation type and arrival timestamp of the representative task.
9. The smart lock gateway device access management method according to claim 1, characterized in that, After the gateway sends candidate interval target values to each approved device to update the Bluetooth connection interval, it also includes: if the candidate interval target value does not take effect within a preset number of connection events, the gateway re-initiates the interval update; if it does not take effect after a preset number of consecutive retries, the current interval update is abandoned, the device maintains the current connection interval, and the ineffective connection events after a preset number of consecutive retries are included in the connection event success rate statistics.
10. The smart lock gateway device access management method according to claim 1, characterized in that, When the capacity margin ratio is greater than or equal to the preset security threshold, the gateway calculates the backoff interval target value based on the current available time slot margin, the preset security threshold, and the connection event success rate. The backoff interval target value is the connection interval value that makes the capacity margin ratio equal to the preset security threshold. If the backoff interval target value is less than the device's current connection interval, the device is admitted using the backoff interval target value instead of the candidate interval target value. If the backoff interval target value is greater than or equal to the device's current connection interval, the device maintains its current connection interval.
