Bluetooth car key communication method and system for heterogeneous devices

By configuring the vehicle-mounted adapter box as a fixed host and the smart key and terminal device as fixed slaves, combined with dynamic broadcast mode switching and signal priority connection, the problems of scanning conflicts and unstable connections in the Bluetooth car key system are solved, achieving stable, secure and efficient communication.

CN121583022BActive Publication Date: 2026-05-01ECARTECK
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ECARTECK
Filing Date
2026-01-28
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In multi-device environments, the simultaneous use of the smart key and mobile phone as the host in a Bluetooth car key system can lead to scanning conflicts, signal interference, and unstable connections, affecting the stability of system communication and user experience.

Method used

The vehicle-mounted adapter box is configured as a fixed host, while the smart key and terminal devices are fixed slaves. The vehicle-mounted adapter box manages the connections uniformly. The smart key dynamically switches the broadcast mode according to its lifecycle. During pairing, it uses non-directional broadcast, while during daily use, it switches to directional whitelist broadcast. The system has environmental adaptation and anomaly recovery capabilities, and prioritizes connecting devices by monitoring connection success rate and signal strength.

Benefits of technology

It eliminates conflicts caused by concurrent scanning of multiple devices, improves system stability and security, provides adaptability and high robustness, and ensures efficient connection management and a superior user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121583022B_ABST
    Figure CN121583022B_ABST
Patent Text Reader

Abstract

The application relates to a Bluetooth car key communication method and system for heterogeneous devices, and relates to the field of communication.The method comprises the following steps: configuring a vehicle-mounted adapter box as a fixed host role and configuring a smart key and a terminal device as fixed slave roles; judging a device life cycle stage in which the smart key is currently located; when the smart key is in a pairing stage or a firmware upgrading stage, controlling the smart key to send a discoverable broadcast signal in a non-directional broadcast mode; when the smart key completes pairing and enters a daily use stage, switching a broadcast mode of the smart key into a directional whitelist broadcast mode, controlling the smart key to send a directional broadcast signal to a vehicle-mounted adapter box in an authorized device whitelist which is stored in advance, controlling the vehicle-mounted adapter box to scan and receive the directional broadcast signal, and initiating a connection with the smart key by the vehicle-mounted adapter box after verifying an authentication code. By implementing the method, scanning conflicts caused by the smart key and a mobile phone simultaneously serving as hosts in a Bluetooth car key system can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and in particular to a Bluetooth car key communication method and system for heterogeneous devices. Background Technology

[0002] With the development of intelligent vehicles, Bluetooth digital car keys have become an important alternative to traditional physical car keys. Bluetooth Low Energy (BLE) technology, due to its low power consumption, low cost, and good compatibility, is widely used in keyless entry systems. Modern Bluetooth car key systems need to support the access of various heterogeneous devices such as dedicated smart keys and smartphones to meet user needs in different scenarios.

[0003] In related technologies, Bluetooth car key systems typically employ a dynamic role assignment mechanism, where smart keys, mobile phones, and in-vehicle devices can dynamically assume the roles of master or slave based on connection requirements. Simultaneously, to facilitate device discovery, smart keys and mobile phones use continuous non-directional broadcasting in standby mode to announce their presence to the surrounding environment, enabling any Bluetooth device to discover and attempt to connect.

[0004] However, in multi-device environments, when both the smart key and the mobile phone are activated simultaneously, they may both attempt to connect to the vehicle's in-vehicle system as the primary device, causing both devices to perform Bluetooth scans concurrently. This concurrent scanning can generate signal interference and contention at the radio frequency level, resulting in unstable scan results, increased connection establishment failure rates, and even repeated device disconnections, severely impacting system communication stability and user experience. Summary of the Invention

[0005] This application provides a Bluetooth car key communication method and system for heterogeneous devices, which reduces scanning conflicts caused by both the smart key and the mobile phone acting as the host in the Bluetooth car key system.

[0006] In a first aspect, this application provides a Bluetooth car key communication method for heterogeneous devices, applied to a Bluetooth car key system, which includes an on-board unit (OTU), a smart key, and a terminal device. The method includes: configuring the OTU as a fixed host and configuring the smart key and terminal device as fixed slaves, causing the OTU to perform scanning and connection initiation operations throughout the communication lifecycle, and the smart key and terminal device to perform broadcast and connection response operations; determining the current device lifecycle stage of the smart key; when the smart key is in the pairing or firmware upgrade stage, controlling the smart key to send a discoverable broadcast signal in a non-directional broadcast mode; when the smart key completes pairing and enters the daily use stage, switching the smart key's broadcast mode to a directional whitelist broadcast mode, controlling the smart key to send a directional broadcast signal to the OTU in a pre-stored authorized device whitelist, the directional broadcast signal containing the target MAC address and authentication code; controlling the OTU to scan and receive the directional broadcast signal, and after verifying the authentication code, the OTU actively initiates a connection with the smart key.

[0007] In the above embodiments, fixed role assignment eliminates concurrent scanning conflicts between multiple devices. The vehicle-mounted adapter box acts as the sole host for unified connection management, avoiding radio frequency interference. The smart key dynamically switches broadcast modes according to its lifecycle. During pairing, it uses non-directional broadcast for easy discovery, while during daily use, it switches to directional whitelist broadcast, sending signals containing MAC addresses and authentication codes only to authorized vehicle-mounted adapter boxes, thus improving security and resolving the connection instability issue caused by dynamic role assignment.

[0008] In conjunction with some embodiments of the first aspect, in some embodiments, the step of switching the smart key's broadcast mode to a targeted whitelist broadcast mode when the smart key completes pairing and enters the daily use stage specifically includes: monitoring the historical connection success rate between the smart key and the vehicle adapter box; when the historical connection success rate is lower than a preset success rate threshold, determining that there is environmental interference or device malfunction; in response to environmental interference or device malfunction, controlling the smart key to temporarily exit the targeted whitelist broadcast mode and switch to a non-targeted broadcast mode, wherein the non-targeted broadcast signal in the non-targeted broadcast mode carries an effective time window identifier; within the effective time window, the vehicle adapter box re-scans and verifies the smart key's identity information; after the vehicle adapter box successfully connects to the smart key within the effective time window, the vehicle adapter box sends an updated MAC address and authentication code to the smart key; controlling the smart key to store the updated MAC address and authentication code in the authorized device whitelist; switching the smart key back to the targeted whitelist broadcast mode, and controlling the smart key to send a targeted broadcast signal to the vehicle adapter box using the updated MAC address and authentication code.

[0009] In the above embodiments, the system possesses environmental adaptability and anomaly recovery capabilities. It monitors the connection success rate, and when it falls below a threshold, an anomaly is identified. The smart key temporarily switches to non-directional broadcasting with a time window, and the vehicle adapter re-authenticates and sends the updated MAC address and authentication code within the window. After storing the updated information, the smart key switches back to directional mode. This mechanism provides a recovery channel while ensuring security, avoiding permanent failures caused by MAC changes or interference, and improving system robustness.

[0010] In conjunction with some embodiments of the first aspect, in some embodiments, the step of the vehicle-mounted adapter scanning and receiving directional broadcast signals, verifying the authentication code, and then the vehicle-mounted adapter actively initiating a connection with the smart key specifically includes: measuring the directional broadcast signal strength of the smart key and the directional broadcast signal strength of the terminal device respectively; when the directional broadcast signal strength of the smart key is greater than that of the terminal device, the vehicle-mounted adapter initiates a connection with the smart key first; when the directional broadcast signal strength of the terminal device is greater than that of the smart key and the terminal device is in mobile phone relay mode, the vehicle-mounted adapter initiates a connection with the terminal device first; adding connection requests from devices not prioritized for connection to a pending queue, and processing the connection requests in the pending queue after completing communication with the prioritized connection device.

[0011] In the above embodiments, the system implements intelligent connection priority management. The vehicle-mounted adapter box measures the signal strength of both parties and prioritizes connecting to the device with the stronger signal. When the smart key signal is strong, a direct connection is achieved to obtain low latency. When the terminal device signal is strong and in relay mode, its forwarding capability is utilized. Devices that are not prioritized for connection are added to a queue and processed sequentially. By fully utilizing signal strength information to select the optimal path, the system avoids quality degradation caused by random connections and improves communication efficiency in multi-device scenarios.

[0012] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of controlling the vehicle-mounted junction box to scan and receive directional broadcast signals, verify the authentication code, and then having the vehicle-mounted junction box actively initiate a connection with the smart key, the method further includes: receiving a mode switching instruction sent by a terminal device, and switching the smart key between a remote key mode and a mobile phone relay mode according to the mode switching instruction, wherein in the remote key mode, the smart key communicates directly with the vehicle-mounted junction box, and in the mobile phone relay mode, the terminal device forwards vehicle control commands to the vehicle-mounted junction box.

[0013] In the above embodiments, the system supports flexible switching between remote key mode and mobile phone relay mode for the smart key. In remote key mode, a direct connection to the vehicle adapter box provides a low-latency experience, while in relay mode, the control range is extended by utilizing mobile phone forwarding. Users can complete the mode switch by sending a switching command through their terminal device. This dual-mode design balances the efficiency of direct connection with the reliability of relay, adapting to different usage scenarios.

[0014] In conjunction with some embodiments of the first aspect, in some embodiments, after controlling the smart key to send a directional broadcast signal to an on-board unit in a pre-stored whitelist of authorized devices, the method further includes: controlling the on-board unit to calculate the communication distance between the smart key and the on-board unit based on the transmission characteristics of the directional broadcast signal after receiving the directional broadcast signal; when the communication distance exceeds a preset safe distance threshold, determining that there is a risk of relay attack, and controlling the on-board unit to initiate motion state verification to the smart key; controlling the smart key to obtain its own motion state data and send the motion state data to the on-board unit, and controlling the on-board unit to obtain the vehicle's position change data; comparing the smart key's motion state data with the vehicle's position change data to obtain the correlation consistency between the motion state data and the position change data; when the correlation consistency does not meet a preset condition, refusing to establish a connection and marking the smart key as an abnormal device.

[0015] In the above embodiments, the system constructs a relay attack protection mechanism. The vehicle-mounted junction box calculates the communication distance based on signal transmission characteristics. When the distance exceeds a safety threshold, it initiates motion state verification, comparing the consistency between the smart key's motion data and changes in the vehicle's position. If the consistency does not meet the conditions, the connection is rejected and the abnormal device is marked. Through multi-dimensional verification, this effectively prevents attackers from extending the communication distance through relay devices, ensuring the safety of the vehicle and property.

[0016] In conjunction with some embodiments of the first aspect, in some embodiments, after controlling the vehicle adapter box to scan and receive directional broadcast signals, verify the authentication code, and then having the vehicle adapter box actively initiate a connection with the smart key, the method further includes: controlling the vehicle adapter box to collect current vehicle status information, obtaining battery power information reported by the smart key, detecting the signal strength of the first communication link between the smart key and the vehicle adapter box, and the signal strength of the second communication link between the terminal device and the vehicle adapter box; calculating a transmission path score based on the battery power information, the first communication link signal strength, and the second communication link signal strength; selecting the transmission path with the highest transmission path score to push the current vehicle status information, the transmission path including a direct transmission path that pushes directly to the smart key via the first communication link and a collaborative transmission path that pushes first to the terminal device via the second communication link and then forwards it to the smart key by the terminal device; when a transmission failure is detected or the transmission delay exceeds a preset time, switching to a backup transmission path to re-push the current vehicle status information.

[0017] In the above embodiments, the system implements intelligent transmission path selection and dynamic switching. The vehicle-mounted adapter comprehensively evaluates the smart key's battery level and dual-link signal strength, calculates the scores of direct and collaborative transmission paths, and selects the optimal path to push status information. In case of transmission failure or delay timeout, it automatically switches to the backup path. When the battery is sufficient and the signal is good, direct connection is used to reduce latency; when the battery is insufficient or the signal is weak, collaborative connection is used to ensure success rate, balancing energy consumption optimization and reliability.

[0018] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of switching to an alternative transmission path to re-push the vehicle's current status information when a transmission failure is detected or the transmission delay exceeds a preset duration, the method further includes: controlling the on-board unit to record the query frequency of each status type by the smart key and the terminal device to obtain a status attention weight table; when the vehicle's current status information changes, calculating a push priority score based on the attention weight value of the changed status type and the magnitude of the status change; when the push priority score exceeds the push trigger threshold, pushing the vehicle's current status information to the smart key and the terminal device; and dynamically adjusting the push trigger threshold according to the push time interval.

[0019] In the above embodiments, the system constructs an intelligent push mechanism based on user behavior learning. The vehicle-mounted junction box records the query frequency of each state type to generate a attention weight table. When the state changes, a push priority score is calculated based on the weight value and the magnitude of the change. Pushes are only sent when the trigger threshold is exceeded, avoiding power waste caused by frequently sending unimportant information. The system dynamically adjusts the threshold according to the push interval to reduce the number of invalid pushes and ensure the timeliness of the information of interest.

[0020] In a second aspect, embodiments of this application provide a Bluetooth car key system, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, which includes computer instructions, and the one or more processors call the computer instructions to cause the Bluetooth car key system to perform the method described in the first aspect and any possible implementation thereof.

[0021] Thirdly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on a Bluetooth car key system, cause the Bluetooth car key system to perform the method described in the first aspect and any possible implementation thereof.

[0022] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a Bluetooth car key system, cause the Bluetooth car key system to perform the method described in the first aspect and any possible implementation thereof.

[0023] Understandably, the Bluetooth car key system provided in the second aspect, the computer program product provided in the third aspect, and the computer storage medium provided in the fourth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here.

[0024] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:

[0025] 1. This application fundamentally eliminates radio frequency interference and contention caused by concurrent scanning of multiple devices by configuring the vehicle-mounted adapter box as a fixed host and the smart key and terminal device as fixed slaves. The vehicle-mounted adapter box, as the sole initiator of the scan, manages the connection uniformly. The smart key dynamically adjusts its broadcast mode according to its lifecycle. During the pairing phase, it uses non-directional broadcasting for easy discovery. In daily use, it switches to directional whitelist broadcasting, sending signals containing MAC addresses and authentication codes only to authorized vehicle-mounted adapter boxes, reducing the risk of being scanned by unauthorized devices. This effectively solves the connection instability and security risks caused by dynamic role allocation and continuous non-directional broadcasting in existing technologies, thereby achieving stable communication and security.

[0026] 2. This application monitors the historical connection success rate and determines an anomaly when it falls below a threshold. The smart key temporarily switches to non-directional broadcast with a time window, and the vehicle adapter re-verifies the identity within the window and sends the updated MAC address and authentication code. After storing the updated information, the smart key switches back to directional mode, establishing a dynamic parameter update mechanism. This ensures security and low power consumption under normal conditions while providing a flexible recovery channel in case of anomalies. It effectively solves the problem of permanent connection failure caused by MAC address changes or environmental interference in existing technologies, thereby achieving the system's adaptability and high robustness.

[0027] 3. This application measures the signal strength of the smart key and the terminal device through an on-board adapter box, prioritizes connecting to the device with the stronger signal to obtain better communication quality, directly connects when the smart key signal is strong to obtain low latency, utilizes the forwarding capability of the terminal device when the signal is strong and it is in relay mode, and adds the non-priority connection device to the queue to ensure fair response. By making full use of signal strength information to intelligently select the optimal communication path, it effectively solves the problems of unreasonable connection selection and untimely response when multiple devices coexist in the prior art, thereby achieving efficient connection management and a high-quality user experience. Attached Figure Description

[0028] Figure 1 This is a flowchart illustrating a Bluetooth car key communication method for heterogeneous devices in an embodiment of this application.

[0029] Figure 2This is another flowchart illustrating the Bluetooth car key communication method for heterogeneous devices in this application embodiment;

[0030] Figure 3 This is a schematic diagram of the physical device structure of a Bluetooth car key system in the embodiments of this application. Detailed Implementation

[0031] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification of this application, the singular expressions “a,” “an,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to any or all possible combinations including one or more of the listed items.

[0032] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0033] To facilitate understanding, the application scenarios of the embodiments of this application are described below.

[0034] In Bluetooth Low Energy (BLE) communication systems, connection establishment between devices follows a master-slave architecture. The master device actively scans the surrounding environment for broadcast signals from slave devices and initiates connection requests, while the slave devices periodically send broadcast data packets to announce their presence and passively wait for connection. Traditional Bluetooth car key systems typically employ a dynamic role allocation mechanism to achieve flexible device interconnection. This means that the in-vehicle device, smart key, and smartphone can dynamically assume the role of master or slave based on connection needs. However, this design leads to significant technical problems in practical applications. When a user approaches a vehicle with both the smart key and their smartphone, if both are configured as master devices and simultaneously initiate Bluetooth scanning, radio frequency (RF) scanning conflicts occur on the same Bluetooth broadcast channel. The two master devices send connection requests to the in-vehicle device almost simultaneously, causing data packet collisions and reducing the connection establishment success rate to 50% to 70%. The user then needs to wait 3 to 5 seconds to successfully unlock the vehicle. Simultaneously, repeated scanning and connection attempts increase battery power consumption by 30% to 50%. Furthermore, in traditional systems, smart keys use a continuous non-directional broadcast mode. The broadcast data packets do not specify the recipient, allowing all nearby Bluetooth devices to receive and parse them. This not only allows malicious devices to continuously listen to the smart key's broadcast signals to collect device information for relay attacks, but also requires the smart key to send broadcast packets at a high frequency to ensure timely detection. The reception and parsing of broadcast signals by a large number of unrelated devices wastes the smart key's power consumption, resulting in a shortened battery life.

[0035] To facilitate understanding, the method provided in this implementation will be described in detail below, using the above scenario as an example. Please refer to [link / reference]. Figure 1 This is a flowchart illustrating a Bluetooth car key communication method for heterogeneous devices in an embodiment of this application.

[0036] S101. Configure the vehicle-mounted adapter box as a fixed host and configure the smart key and terminal device as fixed slaves, so that the vehicle-mounted adapter box performs scanning and connection initiation operations throughout the entire communication lifecycle, and the smart key and terminal device perform broadcast and connection response operations.

[0037] An onboard adapter box refers to a Bluetooth communication gateway device installed inside a vehicle, responsible for managing all Bluetooth connections and interacting with the vehicle control system. A fixed master device is one that is permanently configured as the central device, always actively scanning for broadcast signals from surrounding slave devices and initiating connection requests. A smart key is a portable vehicle access control device with a Bluetooth communication module, used to send authentication information to the onboard adapter box to unlock and start the vehicle. A terminal device refers to a user-used mobile computing device such as a smartphone, with a vehicle control application installed, capable of establishing a communication link with the onboard adapter box via Bluetooth. A fixed slave device is one that is permanently configured as a peripheral device, only responsible for periodically sending broadcast data packets and passively responding to the master device's connection requests.

[0038] This step involves configuring the Bluetooth protocol stacks of each device during system initialization. The vehicle adapter's Bluetooth controller is configured as a central role, disabling peripheral device functions at the firmware level and retaining only active scanning and connection initiation capabilities. Simultaneously, the smart key and terminal devices' Bluetooth protocol stacks are configured as peripheral role modes, disabling their scanning and active connection functions, allowing only the sending of broadcast packets and responses to connection requests. This configuration is achieved by modifying the role registers of the device's Bluetooth controller. In the smart key, the microcontroller writes peripheral role configuration parameters to the Bluetooth chip during startup. This fixed role allocation mechanism ensures that only one scanning entity exists in the system. The smart key and terminal devices periodically broadcast their status, and the vehicle adapter, as the sole connection initiator, manages the access of all devices.

[0039] On the vehicle adapter side, during Bluetooth protocol stack initialization, the system calls the controller interface function to set the GAP role as the central device, configures scanning parameters including the scanning window duration and scanning interval, and enters a cyclic scanning process after startup, passing the received broadcast data packets to the upper-layer application for device filtering. On the smart key side, the microcontroller unit communicates with the Bluetooth chip through the serial peripheral interface, sends a role configuration command to set the GAP role as a peripheral device, disables the scanning function, configures the broadcast parameters, starts a broadcast timer to send broadcast packets according to the set period, and registers a connection event callback function to respond to the connection request from the vehicle adapter.

[0040] S102. Determine the current device lifecycle stage of the smart key. When the smart key is in the pairing stage or firmware upgrade stage, control the smart key to send a discoverable broadcast signal in non-directional broadcast mode.

[0041] The device lifecycle stages represent the different functional states of a smart key throughout its entire lifecycle, from initial activation to eventual disposal, used to distinguish the communication strategies the device currently needs to execute. The pairing stage is the initialization stage where the smart key establishes a trust relationship with the vehicle adapter box or terminal device for the first time. During this stage, encryption keys are exchanged and device information is written to the authorization list. The firmware upgrade stage represents a special maintenance stage where the smart key receives and installs a new firmware version wirelessly, requiring a stable connection to the firmware upgrade server. Non-directional broadcast mode means that the broadcast data packets sent by the slave device do not specify a particular recipient; any Bluetooth device in scanning mode can receive and parse the broadcast packet.

[0042] This step implements the lifecycle stage determination logic in the smart key's microcontroller unit, determining the current stage by reading the pairing status flag and firmware version identifier from non-volatile memory. During the pairing stage, when the pairing flag is detected as unpaired, the microcontroller unit sends a broadcast mode switching command to the Bluetooth chip via the serial interface, setting the broadcast type to connectable non-directional broadcast and configuring the broadcast data packet to include the device name and a list of service UUIDs. During the firmware upgrade stage, when the microcontroller unit receives a firmware upgrade request, it switches to non-directional broadcast mode and adds a firmware upgrade service identifier to the broadcast data, enabling the upgrade tool to recognize and connect to the device.

[0043] Upon startup, the smart key reads the pairing flag byte from the EEPROM. If the value of this byte is 0xFF, it indicates that the device is not paired. The microcontroller calls the Bluetooth protocol stack interface function to set the broadcast type to connectable non-directional broadcast, the broadcast interval to 100 milliseconds, fills in the device name, and starts broadcasting. Simultaneously, a pairing timeout timer is started, automatically exiting pairing mode after ten minutes. The smart key compares the current firmware version number with the stored target version number. If the current version is lower than the target version, it modifies the service UUID field of the broadcast data packet to a firmware upgrade service-specific UUID, starts non-directional broadcasting, and enters a waiting state for the upgrade tool to connect.

[0044] S103. When the smart key completes pairing and enters the daily use stage, the broadcast mode of the smart key is switched to the targeted whitelist broadcast mode, and the smart key is controlled to send a targeted broadcast signal to the vehicle adapter box in the pre-stored authorized device whitelist. The targeted broadcast signal contains the target MAC address and authentication code.

[0045] The daily use phase refers to the normal working state after the smart key completes initial pairing and the firmware is in a normal version, primarily performing vehicle access control and status query functions. The targeted whitelist broadcast mode means that the broadcast data packets sent by the slave device explicitly specify the address of the receiving device, and the broadcast signal is only sent to authorized host devices pre-stored in the whitelist. The authorized device whitelist represents a list of authorized host devices stored in the smart key's non-volatile memory; each entry contains the device's MAC address and corresponding authentication parameters. The authentication code is encrypted data used to verify device identity and communication legitimacy, calculated and generated by the smart key based on the pre-shared key and timestamp.

[0046] This step monitors the pairing status flag of the smart key. When the flag indicates completion, the device is considered ready for daily use. The smart key's microcontroller reads the whitelist data area from the non-volatile memory, which stores a list of MAC addresses of paired vehicle adapters. When switching to directional whitelist broadcast mode, the microcontroller sends a configuration command to the Bluetooth chip, setting the broadcast type register to directional connectable broadcast and simultaneously writing the MAC addresses from the whitelist into the Bluetooth chip's whitelist register. The authentication code is calculated using a timestamp-based mechanism. The smart key reads its internal clock to obtain the current timestamp, performs AES encryption on the timestamp and the pre-shared key, and uses the first 8 bytes of the encryption result as the authentication code. The authentication code and timestamp are then encapsulated in the broadcast data packet.

[0047] After detecting the pairing completion flag, the smart key reads the whitelist area from the EEPROM. Each entry contains a 6-byte MAC address and a 32-byte AES key. It reads the MAC address of the first entry and writes it to the Bluetooth chip register. The broadcast type is configured as directional broadcast, and the broadcast interval is set to 1 second. After broadcasting begins, the microcontroller reads the timestamp every second, calls the AES encryption library function to calculate the authentication code, and updates the broadcast data packet through the Bluetooth protocol stack interface. The smart key implements a dynamic whitelist update mechanism. When a whitelist addition command is received, the microcontroller verifies the command and appends the new MAC address and key to the EEPROM whitelist area. The whitelist is reloaded into the Bluetooth chip the next time broadcasting is initiated.

[0048] S104. Control the vehicle adapter box to scan and receive directional broadcast signals, and after verifying the authentication code, the vehicle adapter box actively initiates a connection with the smart key.

[0049] The scanning operation indicates that the Bluetooth host of the vehicle adapter box continuously or periodically listens to the broadcast channel, receiving and parsing broadcast data packets sent by slave devices. Directional broadcast signal verification means that the vehicle adapter box extracts the authentication code and timestamp from the broadcast packet, performs encrypted calculations using a locally stored key, and compares the calculation result with the received authentication code. The authentication code verification process includes timestamp validity checks and cryptographic verification to ensure that the broadcast packet has not expired and the sender possesses the correct key. The connection initiation operation refers to the vehicle adapter box sending a connection request data packet to the smart key after successful verification, containing connection parameters such as the connection interval and monitoring timeout, thus initiating the connection establishment process.

[0050] This step implements the scanning and connection management logic in the Bluetooth protocol stack of the vehicle adapter box. After the vehicle adapter box starts up, it enters scanning mode, and the Bluetooth controller listens alternately on three broadcast channels: 37, 38, and 39. When a directional broadcast packet is received, the host protocol stack parses the broadcast data content and extracts the authentication code and timestamp fields. The verification process first checks the validity of the timestamp, calculates the difference between the received time and the broadcast timestamp, and discards the packet if it exceeds 10 seconds. When the timestamp is valid, the vehicle adapter box reads the pre-shared AES key, performs AES encryption on the received timestamp, compares the encryption result with the received authentication code, and if they match, the verification is successful. The vehicle adapter box then initiates a connection request, constructs a connection data packet, and sends it to the smart key.

[0051] The vehicle adapter box configures the Bluetooth controller's scanning parameter register, setting the scanning interval to 100 milliseconds and the scanning window to 30 milliseconds. After starting the scan, it registers a broadcast reception callback function. In the callback, it parses the broadcast data, extracts the 8-byte authentication code and 4-byte timestamp, calculates the time difference and compares it with a 10-second threshold. If the timestamp is valid, it calls an encryption library function to encrypt the timestamp, compares the encrypted output with the authentication code, and if they match, it calls the connection interface to initiate a connection. The vehicle adapter box implements an RSSI-based connection priority mechanism. When multiple smart keys are scanned, it records the signal strength of each broadcast packet, selects the device with the highest RSSI to initiate a connection first, and adds other devices to the waiting queue.

[0052] The following provides a more detailed description of the process of the method provided in this implementation. Please refer to [link / reference]. Figure 2 This is another flowchart illustrating the Bluetooth car key communication method for heterogeneous devices in this application embodiment.

[0053] S201. Configure the vehicle-mounted junction box as a fixed host and the smart key and terminal device as fixed slaves, so that the vehicle-mounted junction box performs scanning and connection initiation operations throughout the entire communication lifecycle, and the smart key and terminal device perform broadcast and connection response operations.

[0054] An onboard unit (OTU) is a Bluetooth communication gateway device installed inside a vehicle, responsible for managing Bluetooth connections and interacting with the vehicle control system. A fixed master device is one permanently configured as the central device, responsible for actively scanning and initiating connections. A smart key is a portable vehicle access control device with a Bluetooth module, used to send authentication information to unlock the vehicle. A terminal device refers to a user's smartphone or other mobile device that has a vehicle control application installed and communicates with the OTU via Bluetooth. A fixed slave device is one permanently configured as a peripheral device, only sending broadcast data packets and passively responding to connections.

[0055] This step configures the roles of the Bluetooth protocol stacks of each device during system initialization. The Bluetooth controller of the vehicle adapter box is configured in central role mode, disabling peripheral device functions at the firmware level, retaining only active scanning and connection initiation capabilities. Scanning parameters include a 30-millisecond scan window and a 100-millisecond scan interval, and it enters a cyclic scanning process after startup. The Bluetooth protocol stacks of the smart key and terminal devices are configured in peripheral role mode, disabling scanning and active connection functions, allowing only the sending of broadcast data packets and the response to connection requests. At startup, the microcontroller writes peripheral role configuration parameters to the Bluetooth chip via the serial interface, sets the broadcast interval to 1 second, starts a broadcast timer to send broadcast packets periodically, and registers a connection event callback function to respond to the connection requests from the vehicle adapter box.

[0056] S202. Determine the current device lifecycle stage of the smart key. When the smart key is in the pairing stage or firmware upgrade stage, control the smart key to send a discoverable broadcast signal in a non-directional broadcast mode.

[0057] The device lifecycle stages represent the different functional states of a smart key from activation to obsolescence, used to distinguish the currently executed communication strategy. The pairing stage refers to the initialization stage where the smart key establishes a trust relationship with the vehicle's junction box for the first time, requiring the exchange of encryption keys and the addition of authorization lists. The firmware upgrade stage represents the maintenance stage where the smart key receives and installs a new firmware version wirelessly, requiring a stable connection to the upgrade server. Non-directional broadcast mode refers to the broadcast data packets sent by the slave device not specifying a particular recipient; any Bluetooth device in scanning mode can receive them.

[0058] This step implements the lifecycle stage judgment logic in the microcontroller unit of the smart key. The microcontroller unit reads the pairing status flag bit in the non-volatile memory. If the flag bit is 0xFF, indicating an unpaired state, it determines that it is in the pairing stage. The microcontroller unit sends a broadcast mode switching command to the Bluetooth chip through the serial interface, setting the broadcast type to connectable non-directional broadcast, the broadcast interval to 100 milliseconds, and the broadcast data packet to include the device name and service UUID list. Simultaneously, a 10-minute pairing timeout timer is started. The microcontroller unit compares the current firmware version number with the stored target version number. If the current version is lower than the target version, it determines that it is in the firmware upgrade stage, modifies the service UUID field of the broadcast data packet to a firmware upgrade service-specific UUID, starts non-directional broadcast, and enters a waiting state for the upgrade tool to connect.

[0059] S203. Monitor the historical connection success rate between the smart key and the vehicle adapter box. When the historical connection success rate is lower than the preset success rate threshold, it is determined that there is environmental interference or equipment abnormality.

[0060] Historical connection success rate refers to the percentage of successful connections established between the smart key and the vehicle adapter box over a past period out of the total number of connection attempts. The preset success rate threshold is a system-defined critical value for judging connection quality; a value below this threshold indicates an abnormal communication environment. Environmental interference includes radio frequency band congestion, strong electromagnetic field interference, or signal attenuation caused by physical obstructions. Device abnormality refers to hardware failure, firmware errors, or corrupted configuration parameters of the smart key or vehicle adapter box.

[0061] This step implements a connection quality monitoring mechanism in the vehicle-mounted adapter box. The adapter box maintains a connection record array in non-volatile memory, recording a timestamp and the target device's MAC address each time a connection is initiated. A success flag is set upon successful connection establishment, and a failure flag is set upon connection timeout or failure. Every 5 minutes, the microcontroller unit counts the number of successful connections from the last 100 attempts, calculating the success rate as the number of successful attempts divided by the total number of attempts multiplied by 100%. This result is compared to a preset success rate threshold of 80%. If the success rate is below 80%, the adapter box triggers an anomaly detection process, sending a fault code to the vehicle diagnostic system via the CAN bus and simultaneously sending a command data packet containing an anomaly identifier and a timestamp to the smart key, instructing the smart key to switch to broadcast mode.

[0062] S204. In response to environmental interference or equipment malfunction, the control smart key temporarily exits the directional whitelist broadcast mode and switches to the non-directional broadcast mode. The non-directional broadcast signal in the non-directional broadcast mode carries an effective time window identifier.

[0063] Targeted whitelist broadcast mode refers to the broadcast data packets sent by the slave device explicitly specifying the address of the receiving device, and only sending broadcasts to authorized hosts in the whitelist. Non-targeted broadcast mode refers to broadcast data packets that do not specify a recipient; any scanning device can receive them. The valid time window identifier is a time parameter carried in the broadcast data packet, indicating the valid duration of the non-targeted broadcast. After the time expires, the smart key automatically reverts to the original broadcast mode.

[0064] This step is executed after the smart key receives an abnormal command from the vehicle adapter box. The smart key's microcontroller parses the command data packet, extracts the abnormal identifier field, verifies the legality of the command, stops the current directional whitelist broadcast, and clears the MAC address in the Bluetooth chip's whitelist register. The microcontroller configures the Bluetooth chip to switch to non-directional connectable broadcast mode, sets the broadcast interval to 500 milliseconds, and writes a valid time window identifier in the manufacturer-defined data field when constructing the broadcast data packet. This identifier occupies 2 bytes and indicates that the window duration is 60 seconds. The smart key starts a 60-second countdown timer. After the timer interrupt service routine expires, it automatically triggers the broadcast mode recovery process, reloads the whitelist, and switches back to directional broadcast mode. At the same time, it appends the device serial number and a temporary authentication code to the broadcast data. The temporary authentication code is generated by performing a SHA256 hash operation on the current timestamp and the device serial number, and the first 16 bytes of the hash result are used as the authentication code.

[0065] S205. Within the valid time window, the vehicle-mounted adapter box rescans and verifies the identity information of the smart key.

[0066] The effective time window refers to the period during which the smart key sends non-directional broadcasts, within which the on-board unit (OBJT) needs to complete scanning and authentication. Rescanning refers to the OBJT initiating a new scanning process, listening to the broadcast channel to receive non-directional broadcast data packets from the smart key. Identity verification refers to the OBJT extracting the device serial number and temporary authentication code from the broadcast packet and comparing them with locally stored device information and the key.

[0067] This step is executed after the vehicle adapter box receives the non-directional broadcast from the smart key. During the scanning process, the vehicle adapter box's Bluetooth controller receives the broadcast data packet. The protocol stack parses the data packet to extract the valid time window identifier. The window duration is 60 seconds, and the microcontroller unit starts a 60-second scan timer. The vehicle adapter box extracts the device serial number and temporary authentication code from the manufacturer-defined fields in the broadcast data packet. It reads the list of authorized devices from its local non-volatile memory, finds the corresponding device record based on the serial number, and obtains the device's AES key and last communication timestamp. The vehicle adapter box uses the device serial number and current timestamp as input, calls the SHA256 hash function to calculate the hash, and takes the first 16 bytes of the result as the verification code. It compares the verification code byte-by-byte with the received temporary authentication code. If all 16 bytes match, the verification is successful, the vehicle adapter box records the successful verification event and prepares to initiate a connection. If the comparison fails, the broadcast packet is discarded and the scanning continues.

[0068] S206. After the vehicle adapter box successfully connects to the smart key within the valid time window, the vehicle adapter box sends the updated MAC address and authentication code to the smart key.

[0069] A successful connection means that after the onboard unit sends a connection request to the smart key, the smart key responds and completes link layer parameter negotiation to establish a point-to-point communication link. The updated MAC address is the Bluetooth device physical address reassigned by the onboard unit to the smart key, replacing the original address which might be subject to interference. The updated authentication code is encrypted data recalculated based on the new MAC address and the current timestamp, used for authentication during subsequent targeted broadcasts.

[0070] This step is performed after the vehicle adapter box and smart key establish a connection. The microcontroller unit of the vehicle adapter box generates a new random MAC address. It obtains a 6-byte random number by calling a random number generator, setting the highest bit of the random number to 1 to represent the local management address and avoid conflicts with public addresses. The vehicle adapter box reads the current system timestamp, concatenates the new MAC address and timestamp into 14 bytes of data, and encrypts the concatenated data using a pre-shared AES-128 key. The encryption process uses CBC mode, the initialization vector uses the device serial number, and the first 8 bytes of the encrypted output are used as the updated authentication code. The vehicle adapter box constructs a configuration data packet containing the new MAC address and authentication code. The data packet format is: 1-byte frame header, 1-byte command type, 6-byte MAC address, 8-byte authentication code, 4-byte timestamp, and 2-byte checksum. It is sent to the smart key via the established Bluetooth connection. After sending, a confirmation waiting timer is started, with a timeout of 3 seconds, waiting for the smart key's confirmation response.

[0071] S207. Control the smart key to store the updated MAC address and authentication code in the authorized device whitelist.

[0072] The authorized device whitelist is a list of authorized host devices stored in the smart key's non-volatile memory. Each entry contains the device's MAC address, authentication code, and validity period. Storage operations refer to the process by which the smart key writes newly received MAC addresses and authentication codes into the whitelist, including data verification, address allocation, and persistent storage.

[0073] This step is executed after the smart key receives the configuration data packet sent by the vehicle adapter box. The smart key's microcontroller unit parses the data packet, extracts the frame header to verify the data packet integrity, calculates the checksum of the received data and compares it with the checksum field in the data packet; if they match, processing continues. The microcontroller unit extracts 6 bytes of new MAC address data and 8 bytes of authentication code data, reads the starting address of the whitelist storage area in the EEPROM. The whitelist area is pre-allocated with 256 bytes of space, with each entry occupying 32 bytes, including 6 bytes of MAC address, 8 bytes of authentication code, 4 bytes of validity period timestamp, and 14 bytes of reserved fields. The microcontroller unit traverses the whitelist entries, searching for a record that matches the current vehicle adapter box device serial number. If a match is found, the MAC address and authentication code fields of that entry are updated; otherwise, a new entry is appended to the end of the whitelist. The microcontroller writes the new MAC address to the offset position of bytes 0-5 of the entry, writes the authentication code to the offset position of bytes 6-13, and writes the current timestamp plus 30 days' worth of seconds as the validity period to the offset position of bytes 14-17. After writing is complete, it performs an EEPROM erase / write operation, waits for the write completion flag to be set, and sends a confirmation response data packet to the vehicle adapter box.

[0074] S208. Switch the smart key back to the directional whitelist broadcast mode, and control the smart key to send a directional broadcast signal to the vehicle junction box using the updated MAC address and authentication code. The directional broadcast signal contains the target MAC address and authentication code.

[0075] The targeted whitelist broadcast mode means that the broadcast data packet sent by the smart key explicitly specifies the address of the receiving device and is only sent to authorized hosts in the whitelist. The destination MAC address is the physical address of the receiving Bluetooth device carried in the broadcast data packet, used to identify the vehicle adapter box expected to receive the broadcast. The authentication code is encrypted data calculated based on a pre-shared key and a timestamp, embedded in the broadcast data packet for the vehicle adapter box to verify the legitimacy of the broadcast source.

[0076] This step is executed after the smart key completes the whitelist update. The smart key's microcontroller reads the updated whitelist entry from the EEPROM, extracts the 6 bytes of data for the new MAC address, sends a configuration command to the Bluetooth chip via the serial interface, sets the Bluetooth controller's broadcast type register to directional connectable broadcast, writes the new MAC address to the Bluetooth chip's target address register, clears the chip's internal whitelist cache, and reloads the whitelist. The microcontroller reads the real-time clock to obtain the current timestamp, converts the timestamp to a 4-byte unsigned integer, extracts the 8 bytes of authentication code data from the whitelist entry, constructs the broadcast data packet payload, with the payload format being 1 byte for device type, 4 bytes for device serial number, 4 bytes for timestamp, 8 bytes for authentication code, and 3 bytes for reserved fields, for a total length of 20 bytes. The microcontroller configures the broadcast interval to 1 second, starts the broadcast timer, and the timer interrupt service routine triggers once per second, reads the latest timestamp and updates the timestamp field in the broadcast data packet, and sends the data packet to the Bluetooth chip's transmit buffer via the Bluetooth protocol stack interface. The Bluetooth chip transmits the data packet through the RF module in the next broadcast event window, with the transmit power configured to 0dBm, providing an effective coverage range of approximately 10 meters.

[0077] In some embodiments, after step S208, the method may further include: controlling the vehicle-mounted junction box to calculate the communication distance between the smart key and the vehicle-mounted junction box based on the transmission characteristics of the directional broadcast signal after receiving the directional broadcast signal; when the communication distance exceeds a preset safe distance threshold, determining that there is a risk of relay attack, and controlling the vehicle-mounted junction box to initiate motion state verification to the smart key; controlling the smart key to acquire its own motion state data and send the motion state data to the vehicle-mounted junction box, and controlling the vehicle-mounted junction box to acquire the vehicle's position change data; comparing the smart key's motion state data with the vehicle's position change data to obtain the correlation consistency between the motion state data and the position change data; when the correlation consistency does not meet a preset condition, refusing to establish a connection and marking the smart key as an abnormal device.

[0078] S209. Measure the directional broadcast signal strength of the smart key and the directional broadcast signal strength of the terminal device respectively.

[0079] Directional broadcast signal strength refers to the radio signal power measured by the receiving device, expressed in dBm, reflecting the distance between the transmitting and receiving devices and the signal propagation quality. The directional broadcast signal of a smart key is the radio frequency signal generated by the broadcast data packet containing the target MAC address sent by the smart key to the vehicle adapter box. The directional broadcast signal of a terminal device is the radio frequency signal generated by the broadcast data packet containing the target MAC address sent by the terminal device to the vehicle adapter box. Measurement operation refers to the process by which the Bluetooth controller of the vehicle adapter box extracts the signal strength indication value when receiving the broadcast data packet.

[0080] This step is executed after the vehicle adapter box receives directional broadcast data packets from the smart key and terminal device. During the scanning process, the Bluetooth controller in the vehicle adapter box receives the broadcast data packet. The RF front-end chip measures the power level of the received signal and converts the analog signal into a digital value through a logarithmic amplifier; this value is the RSSI (Received Signal Strength Indicator). The Bluetooth protocol stack reads the RSSI value from the controller register. This value is in dBm, ranging from -127dBm to 20dBm, with an accuracy of 1dBm. The microcontroller unit parses the broadcast data packet to extract the MAC address of the sending device. Based on the MAC address, it determines whether the data packet originates from the smart key or the terminal device. The RSSI value of the smart key is stored in the variable `rssi_key`, and the RSSI value of the terminal device is stored in the variable `rssi_phone`. The vehicle adapter box samples the RSSI of each device three times within a 100-millisecond scanning window and calculates the arithmetic mean of the three samples as the final signal strength. The average value is calculated using the formula (rssi1 + rssi2 + rssi3) / 3, eliminating the influence of instantaneous signal fluctuations and improving measurement accuracy.

[0081] S210. When the directional broadcast signal strength of the smart key is greater than that of the directional broadcast signal strength of the terminal device, the vehicle-mounted adapter box shall initiate a connection to the smart key first.

[0082] A directional broadcast signal strength greater than the RSSI measurement of the smart key indicates that the RSSI measurement is numerically higher than that of the terminal device. Since RSSI is a negative value, a higher value indicates a stronger signal. "Priority connection initiation" means that when the vehicle adapter detects multiple connectable devices, it selects the smart key as the primary connection target according to preset rules and sends a connection request data packet to it. The connection request data packet contains connection parameters such as connection interval, slave delay, and monitoring timeout, used to establish a point-to-point communication link.

[0083] This step is executed after the on-board unit (OTU) completes the signal strength measurement. The OTU reads the variables `rssi_key` and `rssi_phone`, performs a value comparison operation, and determines whether `rssi_key` is greater than `rssi_phone`. If the value of `rssi_key` is -45dBm and the value of `rssi_phone` is -68dBm, then -45 is greater than -68, and the condition is met. The OTU calls the Bluetooth protocol stack's connection interface function, passing the smart key's MAC address as the target device parameter, configuring the connection interval to 15 milliseconds, the slave latency to 0, and the monitoring timeout to 2 seconds. The Bluetooth controller constructs a connection request PDU data packet, which includes 6 bytes of initiating device address, 6 bytes of target device address, 12 bytes of connection parameters, and 5 bytes of channel mapping, for a total length of 34 bytes. The connection request is then sent via the radio frequency module on the broadcast channel. After receiving a connection request, the smart key stops broadcasting and switches to the data channel. It completes a link layer handshake with the vehicle adapter box, establishes a connection, and then exchanges GATT service discovery requests with the smart key. The smart key reads the authentication service feature value and completes authentication and key negotiation.

[0084] S211. When the directional broadcast signal strength of the terminal device is greater than that of the smart key and the terminal device is in mobile phone relay mode, the vehicle adapter box shall initiate a connection to the terminal device first.

[0085] A stronger directional broadcast signal from the terminal device than the smart key indicates that the terminal device's RSSI measurement is numerically higher than the smart key's RSSI measurement, meaning the terminal device is closer to the vehicle adapter box. In "Mobile Relay Mode," the terminal device acts as a communication relay between the smart key and the vehicle adapter box. The smart key connects to the terminal device via Bluetooth, and the terminal device then forwards data to the vehicle adapter box. "Prioritize Connection to Terminal Device" means the vehicle adapter box selects the terminal device as the primary connection target, establishing a Bluetooth link with it.

[0086] This step is executed after the vehicle adapter box completes the signal strength comparison. The microcontroller unit of the vehicle adapter box determines whether rssi_phone is greater than rssi_key. If rssi_phone is -50dBm and rssi_key is -72dBm, then -50 is greater than -72, and the first condition is met. The microcontroller unit parses the manufacturer-defined field in the terminal device's broadcast data packet and extracts the device operating mode identifier byte. If the byte value is 0x02, it indicates a phone relay mode; if the value is 0x01, it indicates a direct connection mode. If the mode identifier is 0x02, then the second condition is met. When both conditions are met, the microcontroller unit calls the Bluetooth protocol stack connection interface, passes in the terminal device's MAC address, configures the connection interval to be 30 milliseconds, the slave latency to be 0, and the monitoring timeout to be 4 seconds. The vehicle adapter sends a connection request to the terminal device. The terminal device responds and establishes a connection. The vehicle adapter sends a data forwarding request to the terminal device via the GATT protocol. The request includes the MAC address of the target smart key and the authentication command. After receiving the request, the terminal device forwards the command through the Bluetooth connection it has established with the smart key. The smart key processes the command and sends the response back to the vehicle adapter through the terminal device, thus realizing three-way indirect communication.

[0087] S212. Add connection requests from devices that are not prioritized for connection to the pending queue. Process the connection requests in the pending queue after completing communication with the prioritized connected device.

[0088] Devices not prioritized for connection refer to smart keys or terminal devices that were not selected as the primary connection target in the priority determination and need to wait for subsequent connection processing. The pending queue is a first-in, first-out (FIFO) data structure maintained in the vehicle adapter box's memory, used to store information about devices waiting to be connected and connection parameters. Connection requests include information such as the device's MAC address, RSSI value, broadcast timestamp, and device type, stored as queue elements. Communication completion refers to the vehicle adapter box completing data interaction with the prioritized connection device and actively disconnecting, or entering an idle state after a connection timeout.

[0089] This step is executed after the vehicle adapter box determines the preferred connection device. The microcontroller unit of the vehicle adapter box allocates a 256-byte circular queue buffer in RAM, defining a queue structure including a head pointer, a tail pointer, and an element counter. Each queue element occupies 32 bytes, including a 6-byte MAC address, a 1-byte RSSI value, a 4-byte timestamp, a 1-byte device type, a 1-byte connection priority, and a 19-byte reserved field. When the smart key is connected first, the microcontroller unit writes the terminal device's MAC address, the measured RSSI value, the current timestamp, and device type 0x02 into the queue element, moves the tail pointer forward, and increments the element counter. After the vehicle adapter box and smart key complete authentication and vehicle control command interaction, the disconnect interface is called, and the Bluetooth controller sends a disconnect PDU to release connection resources. After the microcontroller detects a connection loss event, it reads the head pointer of the queue to be processed, checks whether the element counter is greater than 0, and if the queue is not empty, it reads the queue element from the head pointer position, extracts the MAC address and connection parameters, calls the connection interface to initiate a connection to the device, and after the connection is established, it moves the head pointer forward and decrements the element counter. It then processes all the devices to be connected in the queue in a loop until the queue is empty.

[0090] In some embodiments, after step S212, the following may also be included:

[0091] The system receives a mode switching command from the terminal device and switches the smart key between remote key mode and mobile phone relay mode according to the mode switching command. In remote key mode, the smart key communicates directly with the vehicle transfer box. In mobile phone relay mode, the terminal device forwards vehicle control commands to the vehicle transfer box.

[0092] The mode switching command is a control command data packet sent by the terminal device to the smart key, containing a mode identifier field specifying the target operating mode. Remote key mode refers to the smart key acting as an independent slave device, establishing a direct connection with the vehicle adapter box via directional broadcast to send vehicle control commands such as unlocking and starting. Mobile phone relay mode refers to the smart key connecting to the terminal device via Bluetooth, sending vehicle control commands to the terminal device, which then forwards them to the vehicle adapter box.

[0093] This step is executed after the smart key establishes a connection with the terminal device. The terminal device constructs a mode switching instruction data packet with the following format: frame header 0xAA, command type 0x10, mode identifier 1 byte, timestamp 4 bytes, and checksum 2 bytes. The remote key mode identifier is 0x01, and the mobile phone relay mode identifier is 0x02. This data packet is written to the smart key's configuration feature value via the GATT protocol. The smart key parses the data packet to extract the mode identifier and writes it to the EEPROM working mode register. When the mode identifier is 0x01, the smart key initiates a directional broadcast, writing the vehicle adapter box's MAC address to the target address register. After scanning the broadcast, the vehicle adapter box initiates a connection. The smart key directly writes vehicle control commands to the vehicle adapter box's control feature value via GATT. The vehicle adapter box then controls the vehicle's actuators via the CAN bus. When the mode identifier is 0x02, the smart key stops broadcasting and enters a connectable state. When the user presses the unlock button, a control command data packet is constructed and written to the terminal device relay characteristic value via GATT. The terminal device forwards the command to the vehicle adapter box control characteristic value. The vehicle adapter box executes the operation and sends the result back to the smart key via the original path.

[0094] The system controls the on-board unit to collect the vehicle's current status information, obtains the battery level information reported by the smart key, detects the signal strength of the first communication link between the smart key and the on-board unit, and the signal strength of the second communication link between the terminal device and the on-board unit; calculates a transmission path score based on the battery level information, the first communication link signal strength, and the second communication link signal strength; selects the transmission path with the highest transmission path score to push the vehicle's current status information, which includes a direct transmission path that pushes directly to the smart key via the first communication link and a collaborative transmission path that pushes to the terminal device first via the second communication link and then forwards it to the smart key by the terminal device; when a transmission failure is detected or the transmission delay exceeds a preset time, the system switches to the backup transmission path to re-push the vehicle's current status information.

[0095] The vehicle's current status information includes door lock status, engine running status, battery voltage, tire pressure, and fault codes. Battery power information refers to the remaining percentage of the button battery inside the smart key, calculated using an ADC to collect battery voltage. The first communication link is a direct Bluetooth connection established between the smart key and the vehicle adapter box; signal strength is represented by the RSSI value. The second communication link is a Bluetooth connection established between the terminal device and the vehicle adapter box; signal strength is also represented by the RSSI value. The transmission path score is a comprehensive value calculated based on battery power, link signal strength, and device availability, used to select the optimal data transmission path.

[0096] This step is performed when the vehicle adapter box needs to push status information. The vehicle adapter box reads the status register of the body control module via the CAN bus, extracts information such as door status and engine status, and encapsulates it into a 32-byte data packet. The vehicle adapter box sends a battery query command to the smart key. The smart key's ADC collects the battery voltage, divides the voltage value by the rated voltage of 3.0V to calculate the battery percentage, and sends the battery value via GATT response. The vehicle adapter box reads the Bluetooth controller register to obtain the first link RSSI value rssi1 and the second link RSSI value rssi2. The transmission path score is calculated: direct path score = battery percentage × 0.4 + (rssi1 + 127) × 0.6, cooperative path score = (rssi2 + 127) × 1.0, and the path with the higher score is selected. If the battery level is 80%, RSSI1 is -50dBm, and RSSI2 is -45dBm, then the direct connection score = 80 × 0.4 + (−50 + 127) × 0.6 = 78.2, and the collaborative score = (−45 + 127) × 1.0 = 82. Selecting the collaborative path, the vehicle adapter box sends the status data to the terminal device via the second link, and the terminal device forwards it to the smart key. The vehicle adapter box starts a 500ms timeout timer. If no confirmation is received or the timeout occurs, it switches to the backup path and sends data directly to the smart key via the first link.

[0097] The system controls the vehicle-mounted junction box to record the frequency of queries for each status type by the smart key and terminal devices, thus obtaining a status attention weight table. When the current status information of the vehicle changes, the system calculates the push priority score based on the attention weight value of the changed status type and the magnitude of the status change. When the push priority score exceeds the push trigger threshold, the system pushes the current status information of the vehicle to the smart key and terminal devices. The push trigger threshold is dynamically adjusted according to the push time interval.

[0098] Status type refers to the classification of vehicle status information, including door status, engine status, battery voltage, tire pressure, and fuel level. Query frequency is the cumulative number of times the smart key and terminal device actively request a certain status type within a statistical period. The status attention weight table is a list of normalized weight values ​​calculated based on query frequency, with weight values ​​ranging from 0 to 1, reflecting the user's level of attention to each status type. Status change amplitude refers to the ratio of the change in a status parameter to its normal range; for example, the change amplitude of a door from locked to unlocked is 1.0, and the change amplitude of a 5% drop in battery voltage is 0.05. Push priority score is the weighted product of attention weight and change amplitude; a higher value indicates a stronger necessity for the push.

[0099] This step creates a query record array during the initialization of the vehicle adapter box, assigning a counter to each status type. Each counter increments by 1 upon receiving a query request. The vehicle adapter box counts the number of queries for each status type every 24 hours, calculating the weight as the number of queries for that type divided by the total number of queries. For example, if the door status is queried 80 times, the battery voltage 20 times, and the total number of queries is 100, then the door weight is 0.8 and the battery weight is 0.2. These weight values ​​are stored in the EEPROM. The vehicle adapter box monitors the vehicle status in real time via the CAN bus. When it detects a door status change from 0x01 to 0x00, the change magnitude is calculated as 1.0, and the push priority score is calculated as 0.8 × 1.0 × 100 = 80. The initial push trigger threshold is 50. When the score exceeds 80, the vehicle adapter box constructs a status data packet and sends it to the smart key and terminal device via Bluetooth. The vehicle-mounted adapter box records the push timestamp and calculates the time interval between the push and the last push. If the interval is less than 60 seconds, the threshold is increased by 10% to 55. If the interval is greater than 600 seconds, the threshold is decreased by 10% to 45. The threshold adjustment range is limited to between 30 and 80 to avoid excessively frequent or delayed pushes.

[0100] The Bluetooth car key system in the embodiments of this invention is described below from the perspective of hardware processing. Please refer to [link / reference]. Figure 3 This is a schematic diagram of the physical device structure of a Bluetooth car key system in an embodiment of this application.

[0101] It should be noted that, Figure 3 The structure of the Bluetooth car key system shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0102] like Figure 3 As shown, the Bluetooth car key system includes a Central Processing Unit (CPU) 301, which can perform various appropriate actions and processes based on a program stored in Read-Only Memory (ROM) 302 or a program loaded from storage portion 308 into Random Access Memory (RAM) 303, such as performing the methods described in the above embodiments. The RAM 303 also stores various programs and data required for system operation. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An Input / Output (I / O) interface 305 is also connected to the bus 304.

[0103] The following components are connected to I / O interface 305: input section 306 including audio input devices, push-button switches, etc.; output section 307 including a liquid crystal display (LCD) and audio output devices, indicator lights, etc.; storage section 308 including a hard disk, etc.; and communication section 309 including a network interface card such as a LAN (Local Area Network) card, modem, etc. Communication section 309 performs communication processing via a network such as the Internet. Drive 310 is also connected to I / O interface 305 as needed. Removable media 311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 310 as needed so that computer programs read from them can be installed into storage section 308 as needed.

[0104] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 309, and / or installed from removable medium 311. When the computer program is executed by central processing unit (CPU) 301, it performs the various functions defined in the present invention.

[0105] It should be noted that specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0106] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those shown in the drawings.

[0107] Specifically, the Bluetooth car key system of this embodiment includes a processor and a memory. The memory stores a computer program. When the computer program is executed by the processor, it implements the Bluetooth car key communication method for heterogeneous devices provided in the above embodiment.

[0108] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the Bluetooth car key system described in the above embodiments; or it may exist independently and not assembled into the Bluetooth car key system. The storage medium carries one or more computer programs, which, when executed by a processor of the Bluetooth car key system, cause the Bluetooth car key system to implement the Bluetooth car key communication method for heterogeneous devices provided in the above embodiments.

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

[0110] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".

[0111] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A Bluetooth car key communication method for heterogeneous devices, characterized in that, Applied to a Bluetooth car key system, the Bluetooth car key system including an on-board adapter box, a smart key, and a terminal device, the method includes: Configure the vehicle-mounted adapter box as a fixed host and the smart key and terminal device as fixed slaves, so that the vehicle-mounted adapter box performs scanning and connection initiation operations throughout the entire communication lifecycle, and the smart key and the terminal device perform broadcast and connection response operations; Determine the current device lifecycle stage of the smart key. When the smart key is in the pairing stage or firmware upgrade stage, control the smart key to send a discoverable broadcast signal in a non-directional broadcast mode. Monitor the historical connection success rate between the smart key and the vehicle adapter box. When the historical connection success rate is lower than a preset success rate threshold, it is determined that there is environmental interference or equipment malfunction. In response to the environmental interference or the device malfunction, the smart key is controlled to temporarily exit the directional whitelist broadcast mode and switch to the non-directional broadcast mode. The non-directional broadcast signal in the non-directional broadcast mode carries an effective time window identifier. Within the valid time window, the vehicle-mounted adapter box rescans and verifies the identity information of the smart key; After the vehicle adapter box successfully connects to the smart key within the effective time window, the vehicle adapter box sends an updated MAC address and authentication code to the smart key. The smart key is controlled to store the updated MAC address and authentication code into the authorized device whitelist; Switch the smart key back to the targeted whitelist broadcast mode, control the smart key to send a targeted broadcast signal to the vehicle adapter box using the updated MAC address and authentication code, and control the smart key to send a targeted broadcast signal to the vehicle adapter box in the pre-stored authorized device whitelist. The targeted broadcast signal contains the target MAC address and authentication code. The vehicle-mounted adapter box is controlled to scan and receive the directional broadcast signal, and after verifying the authentication code, the vehicle-mounted adapter box actively initiates a connection with the smart key.

2. The method according to claim 1, characterized in that, The step of controlling the vehicle-mounted adapter box to scan and receive the directional broadcast signal, verify the authentication code, and then having the vehicle-mounted adapter box actively initiate a connection with the smart key specifically includes: The directional broadcast signal strength of the smart key and the directional broadcast signal strength of the terminal device were measured respectively. When the directional broadcast signal strength of the smart key is greater than the directional broadcast signal strength of the terminal device, the vehicle-mounted adapter box will initiate a connection to the smart key first. When the directional broadcast signal strength of the terminal device is greater than the directional broadcast signal strength of the smart key and the terminal device is in mobile phone relay mode, the vehicle adapter box will initiate a connection to the terminal device first. Connection requests from devices that are not prioritized for connection are added to a waiting queue. After communication with the prioritized device is completed, the connection requests in the waiting queue are processed.

3. The method according to claim 1, characterized in that, After the steps of controlling the vehicle adapter box to scan and receive the directional broadcast signal, verifying the authentication code, and then the vehicle adapter box actively initiating a connection with the smart key, the method further includes: The system receives a mode switching instruction sent by the terminal device and switches the smart key between remote key mode and mobile phone relay mode according to the mode switching instruction. In the remote key mode, the smart key communicates directly with the vehicle adapter box. In the mobile phone relay mode, the terminal device forwards vehicle control commands to the vehicle adapter box.

4. The method according to claim 1, characterized in that, After the step of controlling the smart key to send a directional broadcast signal to the vehicle adapter box in the pre-stored authorized device whitelist, the method further includes: After receiving the directional broadcast signal, the vehicle-mounted adapter box calculates the communication distance between the smart key and the vehicle-mounted adapter box based on the transmission characteristics of the directional broadcast signal. When the communication distance exceeds the preset safe distance threshold, it is determined that there is a risk of relay attack, and the vehicle-mounted adapter box is controlled to initiate motion status verification to the smart key; The system controls the smart key to acquire its own motion status data and send the motion status data to the vehicle adapter box, and controls the vehicle adapter box to acquire the vehicle's position change data. By comparing the motion state data of the smart key with the position change data of the vehicle, the correlation consistency between the motion state data and the position change data is obtained. If the association consistency does not meet the preset conditions, the connection will be refused and the smart key will be marked as an abnormal device.

5. The method according to claim 4, characterized in that, After the steps of controlling the vehicle adapter box to scan and receive the directional broadcast signal, verifying the authentication code, and then the vehicle adapter box actively initiating a connection with the smart key, the method further includes: The system controls the vehicle adapter box to collect the current status information of the vehicle, obtain the battery power information reported by the smart key, detect the signal strength of the first communication link between the smart key and the vehicle adapter box, and the signal strength of the second communication link between the terminal device and the vehicle adapter box. A transmission path score is calculated based on the battery power information, the signal strength of the first communication link, and the signal strength of the second communication link; The vehicle's current status information is pushed to the transmission path with the highest transmission path score. The transmission path includes a direct transmission path that pushes directly to the smart key through the first communication link and a collaborative transmission path that pushes to the terminal device first through the second communication link and then forwards it to the smart key by the terminal device. When a transmission failure is detected or the transmission delay exceeds a preset duration, the system switches to an alternative transmission path to re-push the vehicle's current status information.

6. The method according to claim 5, characterized in that, After the step of switching to an alternative transmission path to re-push the vehicle's current status information when a transmission failure or transmission delay exceeds a preset duration is detected, the method further includes: The vehicle-mounted junction box is controlled to record the frequency of queries for each state type by the smart key and the terminal device, thereby obtaining a state attention weight table. When the current status information of the vehicle changes, the push priority score is calculated based on the attention weight value of the change status type and the magnitude of the status change. When the push priority score exceeds the push trigger threshold, the vehicle's current status information is pushed to the smart key and the terminal device. The push trigger threshold is dynamically adjusted based on the push interval.

7. A Bluetooth car key system, characterized in that, The Bluetooth car key system includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the Bluetooth car key system to perform the method as described in any one of claims 1-6.

8. A computer-readable storage medium comprising instructions, characterized in that, When the instruction is executed on the Bluetooth car key system, the Bluetooth car key system performs the method as described in any one of claims 1-6.

9. A computer program product, characterized in that, When the computer program product is run on the Bluetooth car key system, it causes the Bluetooth car key system to perform the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Bluetooth connection method and system based on multiple terminals

    CN112911563A

  • Bluetooth car key car control method and device and storage medium

    CN115019418A