Communication method and device

By detecting the status of Bluetooth service and sending communication signals immediately when idle, communication failure and delay problems caused by busy Bluetooth service are solved, and communication efficiency is improved.

CN119450418APending Publication Date: 2025-02-14BEIJING QISHENG SCIENCE AND TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310945150.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-28
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the prior art, in Bluetooth communication, the instruction write failure occurs due to the busy Bluetooth service, resulting in low communication efficiency and requires delayed writing of instructions to avoid this problem, but this will cause the instruction sending delay to be too long.

Method used

After receiving the communication request through the application, the detection program is called to obtain the status of the Bluetooth service. When the Bluetooth service status is idle, a communication signal is sent to the target device through the Bluetooth service to avoid delayed writing.

Benefits of technology

Reduce communication failure problems caused by busy Bluetooth services, shorten communication time, and improve communication efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119450418A_ABST
    Figure CN119450418A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method and device. And receiving a communication request through the application program, calling the detection program to obtain the state of the Bluetooth service, and when the state of the Bluetooth service is an idle state, sending a communication signal to the target device through the Bluetooth service. Therefore, the problem of communication failure caused by busy Bluetooth service can be reduced without delay, the communication duration is shortened, and the communication efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a communication method and device. Background Art

[0002] A Bluetooth service is a service program used to provide Bluetooth communication. It can be used as a component called by other applications to provide support for Bluetooth functions. When an application interacts with a Bluetooth device through a Bluetooth service, if the previous instruction of the Bluetooth service has not been processed, the Bluetooth service may reject the instruction writing. Therefore, the timing of calling the Bluetooth service has an important impact on the success rate of Bluetooth communication.

[0003] In the prior art, after receiving the communication receipt sent by the Bluetooth service, the application writes the instruction after a certain delay (e.g., 200-500 milliseconds), thereby avoiding the problem of instruction writing failure. However, this method will cause the instruction sending delay to be too long, making the communication efficiency relatively low. Summary of the invention

[0004] In view of this, an object of the embodiments of the present invention is to provide a communication method and device, which can reduce the communication time and improve the communication efficiency.

[0005] In a first aspect, an embodiment of the present invention provides a communication method, the method comprising:

[0006] The application receives the communication request and calls the detection program;

[0007] The detection program obtains the status of the Bluetooth service and sends it to the application program, wherein the status includes an idle state and a busy state; and

[0008] In response to the state being an idle state, the application sends a communication signal to the target device through the Bluetooth service.

[0009] In some embodiments, the communication request is an operation instruction input by a user.

[0010] In some embodiments, the detection program obtains the status of the Bluetooth service and sends it to the application program, including:

[0011] The detection program obtains the status field of the Bluetooth service through a reflection mechanism;

[0012] The detection program determines the status of the Bluetooth service according to the status field; and

[0013] The detection program sends the status of the Bluetooth service to the application program.

[0014] In some embodiments, the detection procedure determines the status of the Bluetooth service according to the status field, including:

[0015] In response to the state represented by the state field being an idle state, determining that the state of the Bluetooth service is an idle state; and

[0016] In response to the state represented by the state field being a busy state, the state of the Bluetooth service is determined according to a current detection number.

[0017] In some embodiments, in response to the state represented by the state field being a busy state, determining the state of the Bluetooth service according to the current detection number includes:

[0018] In response to the state represented by the state field being a busy state and the current detection number being less than a predetermined threshold, executing the next detection process after a predetermined time period; and

[0019] In response to the state represented by the state field being a busy state and the current detection times being greater than or equal to a predetermined threshold, it is determined that the state of the Bluetooth service is a busy state.

[0020] In some embodiments, the process of performing the next detection after a predetermined period of time is specifically as follows:

[0021] The detection program obtains the status field of the Bluetooth service through a reflection mechanism after a predetermined period of time.

[0022] In some embodiments, the operation instruction is an unlock instruction or a lock instruction, and the target device is a vehicle.

[0023] In a second aspect, an embodiment of the present invention provides a communication device, the device comprising:

[0024] An application program, for receiving a communication request and calling a detection program;

[0025] A detection program, used for obtaining the status of the Bluetooth service and sending it to the application, wherein the status includes an idle state and a busy state; and

[0026] The application is further configured to send a communication signal to a target device via the Bluetooth service in response to the state being an idle state.

[0027] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method described in the first aspect.

[0028] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer program instructions, wherein the computer program instructions implement the method described in the first aspect when executed by a processor.

[0029] The technical solution of the embodiment of the present invention receives a communication request through an application, calls a detection program to obtain the status of the Bluetooth service, and when the status of the Bluetooth service is idle, sends a communication signal to the target device through the Bluetooth service. In this way, the problem of communication failure caused by busy Bluetooth service can be reduced without delay, the communication time can be reduced, and the communication efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0031] Figure 1 is a schematic diagram of a communication system according to an embodiment of the present invention;

[0032] Figure 2 is a flow chart of a communication method of the prior art;

[0033] Figure 3 is an interaction diagram of a communication method according to an embodiment of the present invention;

[0034] Figure 4 is a flowchart of an acquisition state of an embodiment of the present invention;

[0035] Figure 5 is a flow chart of a communication method according to an embodiment of the present invention;

[0036] Figure 6 is a schematic diagram of a communication device according to an embodiment of the present invention;

[0037] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The present invention is described below based on embodiments, but the present invention is not limited to these embodiments. In the detailed description of the present invention below, some specific details are described in detail. It is possible for a person skilled in the art to fully understand the present invention without the description of these details. In order to avoid confusing the essence of the present invention, known methods, processes, flows, components and circuits are not described in detail.

[0039] In addition, persons of ordinary skill in the art will appreciate that the drawings provided herein are for illustration purposes and are not necessarily drawn to scale.

[0040] Unless the context clearly requires otherwise, the words "include", "comprising" and the like throughout this application should be interpreted as including rather than exclusive or exhaustive; that is, as meaning "including but not limited to".

[0041] In the description of the present invention, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, "plurality" means two or more.

[0042] With the development of science and technology, Bluetooth technology has gradually been applied to various scenarios in life due to its advantages such as low cost and low power consumption. For example, Bluetooth technology can be used to unlock and / or lock shared vehicles, unlock and / or lock smart cabinets (express cabinets, takeaway cabinets, etc.), borrow shared items (umbrellas, power banks, etc.), unlock and / or lock smart door locks, etc.

[0043] In many scenarios, it is generally necessary for the application installed on the terminal device to call the Bluetooth service to achieve Bluetooth communication connection with the target device. The Bluetooth service is a service program used to provide Bluetooth communication. It can be used as a component called by other applications to provide support for Bluetooth functions. When the application interacts with the Bluetooth device through the Bluetooth service, if the previous instruction of the Bluetooth service has not been processed, the Bluetooth service may refuse to write the instruction. Therefore, the timing of calling the Bluetooth service has an important impact on the success rate of Bluetooth communication.

[0044] Figure 1 Schematic diagram of a communication system according to an embodiment of the present invention. Figure 1 In the illustrated embodiment, the communication system includes a terminal device 1 and a target device 2 .

[0045] The terminal device 1 can be implemented by various devices with Bluetooth communication function, such as mobile phones, tablet computers, laptop computers, desktop computers or other dedicated Bluetooth terminals.

[0046] The target device 2 can be implemented by various devices with Bluetooth communication function. In the embodiment of the present invention, the target device is a shared vehicle as an example for explanation. The target device can be a shared bicycle, a shared electric vehicle, a shared car, etc.

[0047] Specifically, the target device 2 is a shared bicycle, and the terminal device 1 is a mobile phone. When a user needs to borrow a bicycle, the vehicle identification is identified by scanning the vehicle QR code or NFC (NearField Communication) function through the mobile phone application (APP, applet, browser webpage), etc., wherein the vehicle identification is the unique identification number of the shared bicycle, which can be implemented as a Bluetooth communication address or other identification. The terminal device establishes a Bluetooth communication connection with the vehicle according to the vehicle identification. When the user triggers the unlocking control through the terminal device, the application calls the Bluetooth service to send an unlocking command to the vehicle. After the vehicle receives the unlocking command, it opens the lock. In this way, the user can use the car.

[0048] When the user needs to return the car, when the lock control is triggered through the terminal device, the application calls the Bluetooth service to send a lock command to the vehicle, and the vehicle closes the lock after receiving the lock command. In this way, the user can return the car.

[0049] Figure 2 Flowchart of the communication method of the prior art. Figure 1 As shown, the communication method in the prior art includes the following steps:

[0050] Step S101: The application obtains instructions.

[0051] The application program acquisition instruction may be an instruction automatically generated by the application program according to a predetermined program, or may be a control instruction input by a user. For the control instruction input by the user, the application program provides a human-computer interaction interface, through which the user may input the control instruction to control the target device. The instruction may be an unlock instruction or a lock instruction, etc.

[0052] Step S102: the application writes instructions.

[0053] The application writes the acquired instructions to the Bluetooth service.

[0054] Step S103: The Bluetooth service sends an instruction.

[0055] After the Bluetooth service obtains the instructions written by the application, it sends the instructions to the target device.

[0056] Step S104: The target device processes the instruction.

[0057] The target device processes the received instruction. For example, assuming the instruction is an unlock instruction, the processing instruction is to execute unlock.

[0058] Step S105: The target device sends a receipt.

[0059] After the target device processes the command, it sends a communication receipt to the Bluetooth service.

[0060] The communication receipt may be a result of processing the command, such as information such as successful unlocking, failed unlocking, successful locking, failed locking, etc.

[0061] Step S106: The Bluetooth service sends a communication receipt.

[0062] After receiving the communication receipt sent by the target device, the Bluetooth service forwards the communication receipt to the application.

[0063] Step S107: delay for a certain period of time.

[0064] Step S108, write the next instruction.

[0065] For steps S107-S108, in order to avoid the interaction failure caused by the busy state of the Bluetooth service, after receiving the communication receipt, the application writes the next instruction to the Bluetooth service after a certain delay (e.g., 200 milliseconds to 500 milliseconds), and then repeats steps S103-S108 until the communication is completed. The busy Bluetooth service means that when the application interacts with the target device through the Bluetooth service, the Bluetooth service may refuse to write the instruction because the previous instruction has not been processed.

[0066] That is to say, in the prior art, each time an instruction is sent, a certain delay is required, which will result in a longer unlocking / locking time.

[0067] Therefore, the embodiment of the present invention provides a communication solution to reduce communication time and improve communication efficiency.

[0068] Figure 3 is an interaction diagram of the communication method of an embodiment of the present invention. Figure 3 As shown, the communication method interaction of the embodiment of the present invention includes the following steps:

[0069] Step S201: The application receives a communication request.

[0070] In this embodiment, the communication request is an operation instruction input by the user. When the user needs to operate the target device, such as borrowing a car, returning a car, etc., the user inputs the corresponding operation instruction through the application program, and the application program receives the operation request.

[0071] When a user needs to borrow a bike, he or she can obtain the vehicle ID by scanning the vehicle QR code through a mobile phone application (APP, mini-program, browser webpage), or by identifying the vehicle ID through the NFC (Near Field Communication) function, where the vehicle ID is the unique identification number of the shared bike, which can be implemented as a Bluetooth communication address or other identifier. The terminal device establishes a Bluetooth communication connection with the vehicle based on the vehicle ID. When the user triggers the unlocking control through the human-computer interaction interface provided by the application, the operation instruction received by the application is an unlocking instruction, that is, the operation request is an unlocking instruction.

[0072] When the user needs to return the vehicle, when the locking control is triggered through the human-computer interaction interface provided by the application, for the application, the operation instruction received is the locking instruction, that is, the operation request is the locking instruction.

[0073] It should be noted that the embodiment of the present invention takes the operation instructions input by the user as unlocking instructions and locking instructions as examples for explanation, but the embodiment of the present invention does not limit the type of operation instructions input by the user, which can be configured according to the actual application scenario. For example, in the scenario of a shared electric vehicle with a helmet, the operation instruction can also be a helmet lock opening instruction, a helmet lock closing instruction, etc. At the same time, the communication request of the embodiment of the present invention is not limited to the operation instruction input by the user, and it can also be a communication request automatically generated by the application according to actual needs.

[0074] Step S202: The application program calls the detection program.

[0075] In this embodiment, after the application receives the communication request, it indicates that there is a need to communicate with the target device. In order to reduce the possibility of communication failure, the application calls the detection program to obtain the status of the Bluetooth service.

[0076] Among them, the Bluetooth service is a service program used by the operating system of the terminal device to provide Bluetooth communication. It can be used as a component called by other applications to provide support for Bluetooth functions. The Bluetooth service built into the operating system of the terminal device provides a series of APIs (Application Programming Interface) to implement functions such as searching, connecting, and transmitting data to Bluetooth devices.

[0077] When an application can interact with other Bluetooth devices through the Bluetooth service of the operating system, if the previous instruction has not been processed, the Bluetooth service is in a busy state, and if the previous instruction has been processed, the Bluetooth service is in an idle state. Among them, the previous instruction can come from the shared bicycle application of the embodiment of the present invention, or from other applications of the terminal device. When the Bluetooth service is busy, since the previous instruction has not been processed, the Bluetooth service may refuse to write the instruction. Therefore, the status of the Bluetooth service is detected by setting a detection program.

[0078] In this embodiment, the detection program is used to actively detect the current state of the Bluetooth service before the instruction is written. If the Bluetooth service is busy, the instruction is not written, and if the Bluetooth service is idle, the instruction is written.

[0079] In some embodiments, the detection program may be implemented via an SDK (Software Development Kit). A software development kit is a collection of development tools used to create application software for a specific software package, software framework, hardware platform, operating system, etc.

[0080] Furthermore, the application can call the SDK to obtain the status of the Bluetooth service by calling the API exposed by the SDK.

[0081] Step S203: Detect program acquisition status.

[0082] In this embodiment, the detection program obtains the status of the Bluetooth service.

[0083] The android.bluetooth.BluetoothGatt class of the Android system is the core class of the Bluetooth service. It has a field mDeviceBusy that identifies the current status of the Bluetooth service, but this field is a private field and cannot be read directly. Therefore, the detection program uses the reflection mechanism to read the value of the field mDeviceBusy to obtain the status of the Bluetooth service.

[0084] The status of the Bluetooth service includes a busy state and an idle state.

[0085] Step S204: Detect program sending status.

[0086] After the detection program obtains the status of the Bluetooth service, it sends the status to the application.

[0087] Step S205: the application writes instructions.

[0088] After the application receives the status sent by the Bluetooth service, if the status is idle, the application writes instructions to the Bluetooth service; if the status is busy, the application does not write instructions.

[0089] Step S206: The Bluetooth service sends an instruction.

[0090] After the Bluetooth service obtains the instructions written by the application, it sends the instructions to the target device.

[0091] For steps S205-S206, before entering the instruction writing, the application program calls the detection program to obtain the status of the Bluetooth service, and if the status of the Bluetooth service is idle, the communication signal is sent to the target device through the Bluetooth service. The sending of the communication signal to the target device through the Bluetooth service specifically includes: writing the instruction to the Bluetooth service so that the Bluetooth service sends the instruction to the target device.

[0092] Step S207: The target device processes the instruction.

[0093] The target device processes the received instruction. For example, if the instruction is an unlock instruction, the processing instruction is to control the lock to unlock; if the instruction is a lock instruction, the processing instruction is to control the lock to lock.

[0094] Step S208: The target device sends a receipt.

[0095] After the target device processes the command, it sends a communication receipt to the Bluetooth service.

[0096] The communication receipt may be a result of processing the command, such as information such as successful unlocking, failed unlocking, successful locking, failed locking, etc.

[0097] Step S209: The Bluetooth service sends a communication receipt.

[0098] After receiving the communication receipt sent by the target device, the Bluetooth service forwards the communication receipt to the application.

[0099] Therefore, the above steps S201-S209 are repeated. Before writing the instruction to the Bluetooth service each time, the detection program is called to obtain the status of the Bluetooth service. If the status is idle, the instruction is written to the Bluetooth service so that the Bluetooth service sends the instruction to the target device.

[0100] It should be noted that the detection program of the embodiment of the present invention can be a separate software development kit independent of the application. After the user installs the application, the application pushes related services to the user, and after the user authorizes, the detection program is loaded into the terminal device. Alternatively, the detection program can also be a software development kit integrated with the application, that is, when the user installs the application, the detection program is loaded into the terminal device together with the application.

[0101] The embodiment of the present invention receives a communication request through an application program, calls a detection program to obtain the status of the Bluetooth service, and sends a communication signal to the target device through the Bluetooth service when the status of the Bluetooth service is idle. In this way, the problem of communication failure caused by busy Bluetooth service can be reduced without delay, the communication time can be reduced, and the communication efficiency can be improved.

[0102] Figure 4 is a flowchart of obtaining status according to an embodiment of the present invention. Figure 4 In the embodiment shown, the detection program obtains the status of the Bluetooth service including the following steps:

[0103] Step S301: Obtain the status field of the Bluetooth service.

[0104] Step S302: Determine the status of the Bluetooth service according to the status field.

[0105] In this embodiment, the detection program obtains the status field of the Bluetooth service through a reflection mechanism, and determines the status of the Bluetooth service according to the status field of the Bluetooth service.

[0106] Take the Android system as an example. The android.bluetooth.BluetoothGatt class is the core class of the Bluetooth service. It has a status field mDeviceBusy to identify the current status of the Bluetooth service. However, this status field is a private field and cannot be read directly. Therefore, the detection program uses the reflection mechanism to read the value of the status field mDeviceBusy to obtain the status of the Bluetooth service.

[0107] Among them, the reflection mechanism is that in the running state, for any class, all the properties and methods of this class can be known, and for any object, any method and property of it can be called. This function of dynamically obtaining information and dynamically calling object methods is the reflection mechanism. In other words, through the reflection mechanism, the detection program can obtain the status of the Bluetooth service it wants to obtain.

[0108] Specifically, the detection program uses the reflection mechanism of Java (programming language) to reflect android.bluetooth.BluetoothGat, and then reflects the mDeviceBusy field of the class. The type of this field is boolean type. If mDeviceBusy=true, it means that the current state of the Bluetooth service is busy. If mDeviceBusy=false, it means that the current state of the Bluetooth service is idle.

[0109] Step S303: Detect whether the status of the Bluetooth service is idle.

[0110] In this embodiment, whether the state of the Bluetooth service is an idle state is determined according to the acquired state field.

[0111] If the Bluetooth service is in idle state, go to step S305.

[0112] If the Bluetooth service is busy, go to step S304.

[0113] Step S304: Check whether the current number of detections is less than a predetermined threshold.

[0114] In this embodiment, the Bluetooth service may be in a busy state for a long time. At the same time, the embodiment of the present invention obtains the state by polling, which may result in too many detection times. Therefore, by setting a predetermined threshold N (N is a positive integer and N≥2), in response to the obtained state of the Bluetooth service being busy, it is detected whether the current detection times are less than the predetermined threshold N. If the current detection times are less than the predetermined threshold N, the next detection process is executed after a predetermined time, until the state is obtained to be an idle state, wherein the predetermined time can be set according to the actual application scenario, such as 5 milliseconds, 10 milliseconds, 20 milliseconds, etc., wherein the execution of the next detection process is to return to step S301. If the current detection times are not less than the predetermined threshold N, proceed to step S305.

[0115] Step S305: Send status.

[0116] In this embodiment, the detection program sends the acquired status of the Bluetooth service to the application program.

[0117] If in step S303, the state of the Bluetooth service obtained is an idle state, the state sent by the detection program to the application is an idle state.

[0118] If it is detected in step S304 that the current detection times are not less than the predetermined threshold, the status sent by the detection program to the application program is a busy status or a detection failure or a detection timeout.

[0119] In some embodiments, the predetermined threshold is 10, and the predetermined duration is 10ms. Thus, through the communication scheme of the embodiment of the present invention, the status of the Bluetooth service can be obtained within 0-90ms. Compared with the prior art delay of 200-500ms, the communication duration can be greatly reduced and the communication efficiency can be improved.

[0120] That is to say, through the technical solution of the embodiment of the present invention, the application calls the API exposed by the Bluetooth service busy detection SDK before entering the instruction writing. Since the android.bluetooth.BluetoothGatt class of the Android system is the core class of the Bluetooth service, there is a field mDeviceBusy that identifies the current state of the Bluetooth service, but this field is a private field and cannot be read directly. The value of mDeviceBusy can be read through the Java reflection mechanism. The service busy detection SDK will first use the Java reflection mechanism to reflect android.bluetooth.BluetoothGat, and then reflect the mDeviceBusy field of this class. The type of this field is boolean type. If mDeviceBusy=true, it means that the Bluetooth service is currently busy, and if the number of round-trip detections written in this instruction is less than the predetermined threshold, the thread will be started and the detection task will be executed again after a predetermined delay, that is, the mDeviceBusy field will be reflected again to obtain the current state of the Bluetooth service. If mDeviceBusy=false, it means that the Bluetooth service is currently in idle state, then the detection state is exited and the current state of the Bluetooth service is returned to the application. If the number of detection times mPollCount written in this instruction reaches the predetermined threshold, it means timeout, then the detection state is exited and the current state of the Bluetooth service is returned to the application.

[0121] The embodiment of the present invention receives a communication request through an application program, calls a detection program to obtain the status of the Bluetooth service, and sends a communication signal to the target device through the Bluetooth service when the status of the Bluetooth service is idle. In this way, the problem of communication failure caused by busy Bluetooth service can be reduced without delay, the communication time can be reduced, and the communication efficiency can be improved.

[0122] Figure 5 is a flow chart of a communication method according to an embodiment of the present invention. Figure 5 In the illustrated embodiment, the communication method is applicable to a terminal device, wherein the terminal device includes an application program, a detection program, and a Bluetooth service, and specifically includes the following steps:

[0123] Step S410: The application receives a communication request and calls a detection program.

[0124] Step S420: The detection program obtains the status of the Bluetooth service and sends it to the application program, where the status includes an idle state and a busy state.

[0125] Step S430: In response to the state being an idle state, the application sends a communication signal to the target device through the Bluetooth service.

[0126] In some embodiments, the communication request is an operation instruction input by a user.

[0127] In some embodiments, the detection program obtains the status of the Bluetooth service and sends it to the application program, including:

[0128] The detection program obtains the status field of the Bluetooth service through a reflection mechanism;

[0129] The detection program determines the status of the Bluetooth service according to the status field; and

[0130] The detection program sends the status of the Bluetooth service to the application program.

[0131] In some embodiments, the detection procedure determines the status of the Bluetooth service according to the status field, including:

[0132] In response to the state represented by the state field being an idle state, determining that the state of the Bluetooth service is an idle state; and

[0133] In response to the state represented by the state field being a busy state, the state of the Bluetooth service is determined according to a current detection number.

[0134] In some embodiments, in response to the state represented by the state field being a busy state, determining the state of the Bluetooth service according to the current detection number includes:

[0135] In response to the state represented by the state field being a busy state and the current detection number being less than a predetermined threshold, executing the next detection process after a predetermined time period; and

[0136] In response to the state represented by the state field being a busy state and the current detection times being greater than or equal to a predetermined threshold, it is determined that the state of the Bluetooth service is a busy state.

[0137] In some embodiments, the process of performing the next detection after a predetermined period of time is specifically as follows:

[0138] The detection program obtains the status field of the Bluetooth service through a reflection mechanism after a predetermined period of time.

[0139] In some embodiments, the operation instruction is an unlock instruction or a lock instruction, and the target device is a vehicle.

[0140] The embodiment of the present invention receives a communication request through an application program, calls a detection program to obtain the status of the Bluetooth service, and sends a communication signal to the target device through the Bluetooth service when the status of the Bluetooth service is idle. In this way, the problem of communication failure caused by busy Bluetooth service can be reduced without delay, the communication time can be reduced, and the communication efficiency can be improved.

[0141] Figure 6 Schematic diagram of a communication device according to an embodiment of the present invention. Figure 6 In the illustrated embodiment, the communication device is applicable to a terminal device, and the communication device includes an application 61, a detection program 62, and a Bluetooth service 63. The application 61 is used to receive a communication request and call the detection program 62. The detection program 62 is used to obtain the status of the Bluetooth service 63 and send it to the application 61, and the status includes an idle state and a busy state. The application 61 is also used to send a communication signal to the target device through the Bluetooth service 63 in response to the status being an idle state.

[0142] In some embodiments, the communication request is an operation instruction input by a user.

[0143] In some embodiments, the detection procedure comprises:

[0144] A status field acquisition unit, used to acquire the status field of the Bluetooth service through a reflection mechanism;

[0145] a state determining unit, configured to determine the state of the Bluetooth service according to the state field; and

[0146] A status sending unit is used to send the status of the Bluetooth service to the application.

[0147] In some embodiments, the state determination unit includes:

[0148] A first state determination subunit, configured to determine that the state of the Bluetooth service is an idle state in response to the state represented by the state field being an idle state; and

[0149] The second state determination subunit is configured to determine the state of the Bluetooth service according to a current detection number in response to the state represented by the state field being a busy state.

[0150] In some embodiments, the second state determination subunit is configured to:

[0151] In response to the state represented by the state field being a busy state and the current detection number being less than a predetermined threshold, executing the next detection process after a predetermined time period; and

[0152] In response to the state represented by the state field being a busy state and the current detection times being greater than or equal to a predetermined threshold, it is determined that the state of the Bluetooth service is a busy state.

[0153] In some embodiments, the second state determination subunit is configured to:

[0154] The detection program obtains the status field of the Bluetooth service through a reflection mechanism after a predetermined period of time.

[0155] In some embodiments, the operation instruction is an unlock instruction or a lock instruction, and the target device is a vehicle.

[0156] The embodiment of the present invention receives a communication request through an application program, calls a detection program to obtain the status of the Bluetooth service, and sends a communication signal to the target device through the Bluetooth service when the status of the Bluetooth service is idle. In this way, the problem of communication failure caused by busy Bluetooth service can be reduced without delay, the communication time can be reduced, and the communication efficiency can be improved.

[0157] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present invention. Figure 7 The electronic device shown is a general data processing device, which includes a general computer hardware structure, which at least includes a processor 71 and a memory 72. The processor 71 and the memory 72 are connected via a bus 73. The memory 72 is suitable for storing instructions or programs executable by the processor 71. The processor 71 can be an independent microprocessor or a collection of one or more microprocessors. Thus, the processor 71 executes the instructions stored in the memory 72, thereby executing the method flow of the embodiment of the present invention as described above to realize the processing of data and the control of other devices. The bus 73 connects the above-mentioned multiple components together, and at the same time connects the above-mentioned components to the display controller 74 and the display device and the input / output (I / O) device 75. The input / output (I / O) device 75 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a somatosensory input device, a printer, and other devices known in the art. Typically, the input / output device 75 is connected to the system via an input / output (I / O) controller 76.

[0158] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, devices (equipment) or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0159] The present invention is described with reference to flowcharts of methods, apparatuses (devices) and computer program products according to embodiments of the present application. It should be understood that each process in the flowchart can be implemented by computer program instructions.

[0160] These computer program instructions may be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device that implements the process Figure 1 A function specified in a process or multiple processes.

[0161] These computer program instructions may also be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce the instructions for implementing the process Figure 1 A device that specifies functions in a process or multiple processes.

[0162] The solutions described in this specification and in the examples, if they involve the processing of personal information, will be processed on the premise of having a legal basis (such as obtaining the consent of the subject of personal information, or being necessary for the performance of a contract, etc.), and will only be processed within the scope of regulations or agreements. If a user refuses to process personal information other than the necessary information for basic functions, it will not affect the user's use of basic functions.

[0163] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A communication method, characterized in that: The method comprises: The application receives the communication request and calls the detection program; The detection program obtains the status of the Bluetooth service and sends it to the application program, wherein the status includes an idle state and a busy state; and In response to the state being an idle state, the application sends a communication signal to the target device through the Bluetooth service.

2. The method according to claim 1, characterized in that The communication request is an operation instruction input by a user.

3. The method according to claim 1, characterized in that The detection program obtains the status of the Bluetooth service and sends it to the application program, including: The detection program obtains the status field of the Bluetooth service through a reflection mechanism; The detection program determines the status of the Bluetooth service according to the status field; and The detection program sends the status of the Bluetooth service to the application program.

4. The method according to claim 3, characterized in that The detection procedure determines the status of the Bluetooth service according to the status field, including: In response to the state represented by the state field being an idle state, determining that the state of the Bluetooth service is an idle state; and In response to the state represented by the state field being a busy state, the state of the Bluetooth service is determined according to a current detection number.

5. The method according to claim 4, characterized in that In response to the state represented by the state field being a busy state, determining the state of the Bluetooth service according to the current detection number includes: In response to the state represented by the state field being a busy state and the current detection number being less than a predetermined threshold, executing the next detection process after a predetermined time period; and In response to the state represented by the state field being a busy state and the current detection times being greater than or equal to a predetermined threshold, it is determined that the state of the Bluetooth service is a busy state.

6. The method according to claim 5, characterized in that The specific process of performing the next detection after the predetermined time is as follows: The detection program obtains the status field of the Bluetooth service through a reflection mechanism after a predetermined period of time.

7. The method according to claim 2, characterized in that The operation instruction is an unlock instruction or a lock instruction, and the target device is a vehicle.

8. A communication device, characterized in that: The device comprises: An application program, for receiving a communication request and calling a detection program; A detection program, used for obtaining the status of the Bluetooth service and sending it to the application, wherein the status includes an idle state and a busy state; and The application is further configured to send a communication signal to a target device via the Bluetooth service in response to the state being an idle state.

9. An electronic device, comprising a memory and a processor, characterized in that: The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing computer program instructions, characterized in that: The computer program instructions implement the method according to any one of claims 1 to 7 when executed by a processor.