CN114143906B - Electronic equipment connection method and electronic equipment - Google Patents

Electronic equipment connection method and electronic equipment Download PDF

Info

Publication number
CN114143906B
CN114143906B CN202210113163.5A CN202210113163A CN114143906B CN 114143906 B CN114143906 B CN 114143906B CN 202210113163 A CN202210113163 A CN 202210113163A CN 114143906 B CN114143906 B CN 114143906B
Authority
CN
China
Prior art keywords
state
event
connection
electronic equipment
disconnection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210113163.5A
Other languages
Chinese (zh)
Other versions
CN114143906A (en
Inventor
张雅姝
宋业全
黄鹏飞
牛永民
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202210113163.5A priority Critical patent/CN114143906B/en
Publication of CN114143906A publication Critical patent/CN114143906A/en
Application granted granted Critical
Publication of CN114143906B publication Critical patent/CN114143906B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/20Manipulation of established connections
    • H04W76/27Transitions between radio resource control [RRC] states

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephone Function (AREA)

Abstract

The embodiment of the application provides an electronic equipment connection method and electronic equipment, wherein the connection method comprises the following steps: the method comprises the steps that the first electronic equipment responds to a connection triggering event and obtains a first event state, wherein the first event state is used for indicating the state of the first electronic equipment for processing the current event; if the first event state is the initialization state, the first electronic equipment executes a connection task with the second electronic equipment according to the connection triggering event, and sets the first event state as the connection state; and if the first event state is not the initialization state, setting a second event state as a to-be-connected state, wherein the second event state is used for indicating the state of the next to-be-processed event of the first electronic equipment. Therefore, the first electronic device can successfully process the current event by sequentially and serially processing the received events, and avoids processing exception caused by simultaneously processing a plurality of events. And other events received in the processing process can not be omitted, and the success rate and the efficiency of the connection of the electronic equipment are improved.

Description

Electronic equipment connection method and electronic equipment
Technical Field
The application relates to the technical field of terminals, in particular to an electronic equipment connection method and electronic equipment.
Background
With the widespread use of electronic devices in life, the functional demands of users on electronic devices are increasing. In order to meet the use requirements of users, electronic devices (for convenience of description, hereinafter, referred to as a central device) such as a tablet computer and a mobile phone can be connected with other electronic devices (for convenience of description, hereinafter, referred to as an external device) such as a wireless keyboard, a touch pen and a wireless sound box with professional use functions, and richer functions are realized through the matching use of the central device and the external device. At present, most of the central devices and the external devices are HID devices (human interface devices) supporting bluetooth technology. Therefore, the center device and the external device can establish wireless connection through the bluetooth technology. The central equipment and the external equipment can establish or break Bluetooth connection according to the change of the physical connection state between the two equipment. Taking the tablet personal computer and the wireless keyboard as examples, when the tablet personal computer and the wireless keyboard are connected in an adsorption manner, the tablet personal computer is triggered to scan and connect the wireless keyboard. When the tablet personal computer and the wireless keyboard are disconnected from the adsorption device, the tablet personal computer and the wireless keyboard are triggered to be disconnected.
In the process of connecting the tablet computer and the wireless keyboard, the tablet computer marks the wireless keyboard as being connected. At this time, if the tablet computer is disconnected from the wireless keyboard for adsorption, the bluetooth protocol stack of the tablet computer cancels the connection. However, since the connection between the tablet computer and the wireless keyboard is not established yet, and the bluetooth keyboard is not a connected device of the tablet computer at present, the tablet computer cannot normally execute a disconnection process, so that the wireless keyboard is still in a connection state. Under the condition, if the tablet computer and the Bluetooth keyboard are adsorbed again, the tablet computer cannot trigger the second connection with the wireless keyboard, so that the connection between the tablet computer and the wireless keyboard fails, the user needs to manually operate and connect the tablet computer again, and the use experience of the user is reduced.
Disclosure of Invention
The application provides an electronic equipment connection method and electronic equipment, and aims to solve the problem that in the existing electronic equipment connection method, if physical connection is established after physical connection is disconnected between the electronic equipment in the connection process of the electronic equipment, the connection of the electronic equipment fails.
In a first aspect, an embodiment of the present application provides an electronic device connection method, including: the first electronic device responds to a connection triggering event, acquires a first event state, wherein the connection triggering event is generated when the first electronic device detects that the first electronic device and the second electronic device meet a connection triggering condition, the first event state is used for indicating a state of the first electronic device for processing an event currently, and the first event state comprises: an initialization state, a connection state and a disconnection state; the first electronic equipment judges whether the first event state is an initialization state; if the first event state is the initialization state, the first electronic equipment executes a connection task with the second electronic equipment according to the connection triggering event, and sets the first event state as the connection state; if the first event state is not the initialization state, the first electronic device sets a second event state to be in a to-be-connected state, the second event state is used for indicating the state of the next to-be-processed event of the first electronic device, and the second event state comprises: an initialization state, a to-be-connected state, and a to-be-disconnected state. According to the electronic device connection method provided by the embodiment of the application, after the first electronic device receives the connection triggering event, the first event state is firstly acquired, and then whether the first electronic device has the event being processed currently is judged according to the first event state. And if the current event is not processed, the first electronic equipment processes the connection triggering event and executes the connection task. And if the first electronic equipment has the event currently being processed, the first electronic equipment sets the connection triggering event as the next event to be processed, and indicates the state of the next event to be processed of the first electronic equipment through the second event state. And after the current task of the first electronic equipment is executed, acquiring a second event state, and executing a corresponding task according to the second event state. Therefore, the first electronic device can smoothly complete the processing of the current event by sequentially and serially processing the received events, and the condition that the processing is abnormal due to the fact that a plurality of events are processed at the same time is avoided. In addition, other events to be processed received in the processing process can not be omitted, and the success rate and the efficiency of electronic equipment connection are further improved.
In an alternative implementation manner, after performing the connection task with the second electronic device, the method further includes: the first electronic equipment judges whether the connection task is successfully completed; if the connection task is successfully completed, the first electronic device sets the state of the first event to an initialization state. In this implementation manner, after the first electronic device connection task is successfully completed, the state of the first event is restored to the initialization state. Therefore, if the first electronic device receives other events again, the events can be processed in time, and the efficiency of processing the events by the first electronic device is improved.
In an alternative implementation manner, after the first electronic device sets the first event state to the initialization state, the method further includes: the first electronic equipment acquires a second event state; the first electronic equipment judges whether the second event state is a to-be-disconnected state or not; and if the second event state is the to-be-disconnected state, the first electronic equipment executes the disconnection task with the second electronic equipment, and sets the second event state to be the initialized state. In the implementation manner, after the first electronic device successfully completes the connection task, the second event state is acquired, and the received other events are continuously processed according to the second event state. Because the first electronic device and the second electronic device are already in the connection state, only if the second event state is the to-be-disconnected state, the first electronic device processes the disconnection triggering event and executes the disconnection task with the second electronic device. Meanwhile, the first electronic device restores the second event state to the initialization state. Therefore, when the first electronic device receives other to-be-processed events again, the second event state can be set again according to the to-be-processed events, and the first electronic device is prevented from missing the to-be-processed events.
In an alternative implementation, the method further comprises: and if the second event state is not the to-be-disconnected state, the first electronic equipment does not execute the task and sets the second event state to be the initialization state. In this implementation manner, since the first electronic device and the second electronic device are already in the connected state, when the second event state is not the to-be-disconnected state, that is, the initialized state or the to-be-connected state, the first electronic device does not need to process the to-be-processed event, and does not need to execute the task. Meanwhile, the first electronic device restores the second event state to the initialization state, so that when the first electronic device receives other to-be-processed events again, the second event state can be set again according to the to-be-processed events, and the first electronic device is prevented from missing the to-be-processed events.
In an alternative implementation manner, the step of the first electronic device performing the connection task with the second electronic device includes: the method comprises the steps that first electronic equipment sends a first connection instruction to second electronic equipment, wherein the first connection instruction is used for indicating the second electronic equipment to be in standard hid profile connection with the first electronic equipment; the first electronic equipment receives a first connection result sent by the second electronic equipment, wherein the first connection result is a result of the hid profile connection; the first electronic equipment judges whether the hid profile connection is successful according to the first connection result; and if the hid profile is successfully connected, the first electronic equipment sends a second connection instruction to the second electronic equipment, wherein the second connection instruction is used for indicating the second electronic equipment to carry out the private channel general attribute specification gatt connection with the first electronic equipment. In this implementation manner, the task of executing connection with the second electronic device by the first electronic device includes a connection hid profile task and a connection gatt task. The first electronic device firstly sends a first connection instruction to the second electronic device to indicate the second electronic device to perform the standard hid profile connection with the first electronic device. The first electronic device receives a first connection result sent by the second electronic device, and the first connection result is used for feeding back a connection result of the hid profile connection. And only if the hid profile is successfully connected, the first electronic equipment sends a second connection instruction to the second electronic equipment, and the second electronic equipment performs gatt connection according to the second connection instruction. If the hid profile connection fails, the first electronic device does not send the second connection instruction to the second electronic device. Therefore, the first electronic equipment can find abnormal conditions in the connection task in time, so that the specific abnormal conditions can be conveniently processed, and the connection success rate of the first electronic equipment is improved.
In an alternative implementation, the method further comprises: the first electronic equipment receives a first connection result sent by the second electronic equipment, wherein the first connection result is a result of the hid profile connection; the first electronic equipment judges whether the connection task is successfully completed according to the second connection result; if the second connection result is that the connection is successful, the first electronic equipment determines that the connection task is successfully completed; and if the second connection result is connection failure, the first electronic equipment determines that the connection task fails. In this implementation, the second electronic device connects the gatt according to the second connection instruction and sends the second connection result to the first electronic device to feed back the connection result of the gatt connection. And the first electronic equipment can judge whether the gatt connection is successful according to the second connection result, and if the gatt connection is successful, the connection of the hid profile in the previous step can be successful, namely, the connection task of the first electronic equipment is completed successfully.
In an alternative implementation, the method further comprises: the method comprises the steps that first electronic equipment obtains connection time of a connection task; if the connection time exceeds a preset time threshold, the first electronic equipment sets the first event state to be an initialization state and acquires a second event state; the first electronic equipment judges whether the second event state is a to-be-disconnected state or not; and if the second event state is a to-be-disconnected state, the first electronic equipment executes a disconnection task with the second electronic equipment. In this implementation manner, if an abnormal condition of connection timeout occurs in the first electronic device, the first event state is first restored to an initialization state, and the current connection task is no longer processed. And then the first electronic equipment acquires the second event state, and executes the disconnection task only when the second event state is the to-be-disconnected state, so as to disconnect the last connection process in the abnormal condition. In this way, the initial state of the unconnected state between the first electronic device and the second electronic device can be recovered, so that the abnormal condition that the connection of the first electronic device is overtime is solved.
In an alternative implementation, the method further comprises: the first electronic equipment acquires the state of the first event through a first zone bit, and the first zone bit is arranged in the first electronic equipment. In this implementation manner, the first electronic device may directly obtain the state of the current processing event by setting the first flag, and different states of the current processing event of the first electronic device may be represented by performing different assignments on the first flag.
In an alternative implementation, the method further comprises: the first electronic equipment acquires the second event state through the second zone bit, and the second zone bit is arranged in the first electronic equipment. In this implementation manner, the first electronic device may directly obtain the state of the next event to be processed by setting the second flag, and different states of the next event to be processed of the first electronic device may be represented by performing different assignments on the second flag.
In an alternative implementation, the connection triggering condition includes: the first electronic device is adsorbed to the second electronic device through the coil, or the first electronic device is connected to the second electronic device through the connection port, or the distance between the first electronic device and the second electronic device is smaller than a preset distance threshold. In this implementation manner, when the first electronic device detects the connection trigger condition, a connection trigger event such as a suction event, an insertion event, and a proximity event may be generated, and the first electronic device executes a corresponding connection task according to the connection trigger event.
In a second aspect, an embodiment of the present application provides an electronic device connection method, including: the first electronic equipment responds to a disconnection triggering event, acquires a first event state, wherein the connection triggering event is generated when the first electronic equipment detects that the first electronic equipment and the second electronic equipment meet a disconnection triggering condition, and the first event state comprises: an initialization state, a connection state and a disconnection state; the first electronic equipment judges whether the first event state is an initialization state; if the first event state is the initialization state, the first electronic equipment executes the disconnection task with the second electronic equipment according to the disconnection triggering event, and sets the first event state as the disconnection state; if the first event state is not the initialization state, the first electronic device sets a second event state to a to-be-disconnected state, the second event state is used for indicating the state of the next to-be-processed event of the first electronic device, and the second event state comprises: an initialization state, a pending connection state, and a pending disconnection state. According to the electronic device connection method provided by the embodiment of the application, after the first electronic device receives the disconnection triggering event, the first event state is firstly acquired, and then whether the first electronic device has the event being processed currently is judged according to the first event state. And if the current event is not processed, the first electronic equipment processes the disconnection triggering event and executes the disconnection task. And if the first electronic equipment has the event which is currently processed, the first electronic equipment sets the disconnection triggering event as the next event to be processed, and indicates the state of the next event to be processed of the first electronic equipment through the second event state. And after the current task of the first electronic equipment is executed, acquiring a second event state, and executing a corresponding task according to the second event state. Therefore, the first electronic device can smoothly complete the processing of the current event by sequentially and serially processing the received events, and the condition that the processing is abnormal due to the fact that a plurality of events are processed simultaneously is avoided. In addition, other events to be processed received in the processing process can not be omitted, and the disconnection success rate and efficiency of the electronic equipment are further improved.
In an alternative implementation manner, after performing the disconnection task with the second electronic device, the method further includes: the first electronic equipment judges whether the disconnection task is successfully completed; and if the disconnection task is successfully completed, the first electronic equipment sets the state of the first event to be an initialization state. In this implementation manner, after the disconnection task of the first electronic device is successfully completed, the state of the first event is restored to the initialization state. Therefore, if the first electronic device receives other events again, the events can be processed in time, and the efficiency of processing the events by the first electronic device is improved.
In an alternative implementation manner, after the first electronic device sets the first event state to the initialization state, the method further includes: the first electronic equipment acquires a second event state; the first electronic equipment judges whether the second event state is a to-be-connected state; and if the second event state is the state to be connected, the first electronic equipment executes the connection task with the second electronic equipment and sets the second event state to be the initialization state. In the implementation manner, after the disconnection task of the first electronic device is successfully completed, the second event state is acquired, and the received other events are continuously processed according to the second event state. Because the first electronic device and the second electronic device are already in the disconnected state, only if the second event state is the to-be-connected state, the first electronic device processes the connection triggering event and executes the connection task with the second electronic device. Meanwhile, the first electronic device restores the second event state to the initialization state. Therefore, when the first electronic device receives other to-be-processed events again, the second event state can be set again according to the to-be-processed events, and the first electronic device is prevented from missing the to-be-processed events.
In an alternative implementation, the method further comprises: and if the second event state is not the to-be-connected state, the first electronic equipment does not execute the task and sets the second event state to be the initialization state. In this implementation manner, since the first electronic device and the second electronic device are already in the disconnected state, when the second event state is not the to-be-connected state, that is, the initialized state or the to-be-disconnected state, the first electronic device does not need to process the to-be-processed event, and does not need to execute the task. Meanwhile, the first electronic device restores the second event state to the initialization state, so that when the first electronic device receives other to-be-processed events again, the second event state can be set again according to the to-be-processed events, and the first electronic device is prevented from missing the to-be-processed events.
In an alternative implementation manner, the step of the first electronic device performing the disconnection task with the second electronic device includes: the method comprises the steps that a first electronic device sends a first disconnection instruction to a second electronic device, wherein the first disconnection instruction is used for indicating the second electronic device to perform man-machine interface device specification (hid) profile disconnection with the first electronic device; the first electronic equipment receives a first disconnection result sent by the second electronic equipment, wherein the first disconnection result is a hid profile disconnection result; the first electronic equipment judges whether the hid profile is disconnected successfully or not according to the first disconnection result; and if the hid profile is disconnected successfully, the first electronic equipment sends a second disconnection instruction to the second electronic equipment, and the second disconnection instruction is used for indicating the second electronic equipment to perform private channel general attribute specification gatt disconnection with the first electronic equipment. In this implementation manner, the first electronic device executes the disconnection task with the second electronic device, which includes a disconnection hid profile task and a disconnection gatt task. The first electronic device firstly sends a first disconnection instruction to the second electronic device to indicate the second electronic device to perform disconnection of the human-computer interface device specification hid profile with the first electronic device. The first electronic equipment receives a first disconnection result sent by the second electronic equipment, and the first disconnection result is used for feeding back a disconnection result of the hid profile disconnection. And only if the hid profile is disconnected successfully, the first electronic equipment sends a second disconnection instruction to the second electronic equipment, and the second electronic equipment performs gatt disconnection according to the second disconnection instruction. And if the hid profile disconnection fails, the first electronic equipment does not send a second disconnection instruction to the second electronic equipment. Therefore, the first electronic equipment can find the abnormal condition in the disconnection task in time so as to process the specific abnormal condition and improve the disconnection success rate of the first electronic equipment.
In an alternative implementation, the method further comprises: the first electronic equipment receives a second disconnection result sent by the second electronic equipment, wherein the second disconnection result is a gatt disconnection result; the first electronic equipment judges whether the disconnection task is successfully completed or not according to the second disconnection result; if the second disconnection result is that the disconnection is successful, the first electronic equipment determines that the disconnection task is successfully completed; and if the second disconnection result is disconnection failure, the first electronic equipment determines that the disconnection task fails. In the implementation manner, the second electronic device disconnects the gatt according to the second disconnection instruction, and sends a second disconnection result to the first electronic device to feed back the disconnection result of gatt disconnection. The first electronic device may determine whether the gatt disconnection is successful according to the second disconnection result, and if the gatt disconnection is successful, it may be indicated that the hid profile in the previous step is also successfully disconnected, that is, the disconnection task of the first electronic device is completed successfully.
In an alternative implementation, the method further comprises: the method comprises the steps that first electronic equipment obtains disconnection time of a disconnection task; if the disconnection time exceeds a preset time threshold, the first electronic equipment sets the first event state to be an initialization state and acquires a second event state; the first electronic equipment judges whether the second event state is a to-be-connected state; and if the second event state is the state to be connected, the first electronic equipment executes the connection task with the second electronic equipment. In this implementation manner, if an abnormal condition of disconnection timeout occurs in the first electronic device, the first event state is first restored to an initialization state, and the current disconnection task is not processed any more. And then the first electronic equipment acquires the second event state, and only when the second event state is the state to be connected, the first electronic equipment executes the connection task so as to connect the disconnection process in the abnormal condition last time. Therefore, the initial state of the connection between the first electronic device and the second electronic device can be recovered, and the abnormal condition of disconnection timeout of the first electronic device is solved.
In an alternative implementation, the method further comprises: the first electronic equipment acquires the state of the first event through a first zone bit, and the first zone bit is arranged in the first electronic equipment. In this implementation manner, the first electronic device may directly obtain the state of the current processing event by setting the first flag, and different states of the current processing event of the first electronic device may be represented by performing different assignments on the first flag.
In an alternative implementation, the method further comprises: the first electronic equipment acquires the second event state through the second zone bit, and the second zone bit is arranged in the first electronic equipment. In this implementation manner, the first electronic device can directly obtain the state of the next event to be processed by setting the second flag bit, and different assignments are performed on the second flag bit to indicate different states of the next event to be processed by the first electronic device.
In an alternative implementation, the disconnection triggering condition includes: the first electronic device and the second electronic device are disconnected from adsorption, or the second electronic device is separated from the first electronic device through the connecting port, or the distance between the first electronic device and the second electronic device is larger than a preset distance threshold. In this implementation manner, when the first electronic device detects the disconnection triggering condition, disconnection triggering events such as a take-off event, a pull-out event, and a far-away event may be generated, and the first electronic device executes a corresponding disconnection task according to the disconnection triggering event.
In a third aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor, the processor and the memory coupled; wherein the memory comprises program instructions which, when executed by the processor, cause the electronic device to perform the method as in the first and second aspects and their respective implementations described above.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium, in which computer program instructions are stored, and when the computer program instructions are executed, the method in the first and second aspects and their respective implementation manners described above is implemented.
Drawings
Fig. 1 is a usage scenario diagram of an electronic device according to an embodiment of the present application;
fig. 2 is a schematic diagram of an adsorption connection between a tablet computer and a wireless keyboard according to an embodiment of the present disclosure;
fig. 3A is a schematic diagram of an exemplary hardware structure of the electronic device 100 according to an embodiment of the present application;
fig. 3B is a schematic diagram of an exemplary software architecture of the electronic device 100 according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a wireless keyboard 200 according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a wireless keyboard accommodating a stylus according to an embodiment of the present disclosure;
fig. 6 is a schematic side view of an electronic device, a stylus and a wireless keyboard according to an embodiment of the present disclosure;
fig. 7 is a schematic structural frame diagram of a wireless keyboard according to an embodiment of the present application;
fig. 8 is a flowchart of a method of connecting an electronic device according to an embodiment of the present disclosure;
fig. 9 is a flowchart of a method for a central device to scan a target device according to an embodiment of the present application;
fig. 10 is a flowchart of a method for connecting a central device to a target device according to an embodiment of the present disclosure;
fig. 11 is a flowchart of a method for processing connection timeout according to an embodiment of the present application;
fig. 12 is a flowchart of a method of another electronic device connection method according to an embodiment of the present application;
fig. 13 is a flowchart of a method for processing disconnection timeout according to an embodiment of the present application.
Detailed Description
The technical solutions of the embodiments of the present application will be described below clearly with reference to the drawings in the embodiments of the present application.
In the description of this application, "/" means "or" unless otherwise stated, for example, A/B may mean A or B. "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. Further, "at least one" means one or more, "a plurality" means two or more. The terms "first", "second", and the like do not necessarily limit the number and execution order, and the terms "first", "second", and the like do not necessarily limit the difference.
It is noted that, in the present application, words such as "exemplary" or "for example" are used to mean exemplary, illustrative, or descriptive. Any embodiment or design described herein as "exemplary" or "e.g.," is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion.
In order to facilitate the technical solutions of the embodiments of the present application to be understood by the skilled person, the technical terms related to the embodiments of the present application are explained below.
1. HID device
Human Interface Devices (HIDs) are common types of devices in Universal Serial Bus (USB) devices, and are USB devices that interact directly with a person, such as keyboards, mice, joysticks, and the like. The HID device has low cost and can be used as a low-speed, full-speed and high-speed device. In practical applications, besides transmitting data to the host, the HID device also receives data from the host and interacts with the host. Generally, the HID device does not necessarily have a human-machine interaction function, and devices conforming to the HID class specification are all HID devices.
2、hidprofile
The human interface device profile (bluetooth profile) is a bluetooth profile, in which a profile is defined, which defines how a device implements a connection or application. The hidrowfile is a standard designed for peripheral products such as a wireless keyboard, a wireless mouse, a game machine controller and the like, the wireless keyboard or the wireless mouse with the Bluetooth module can be connected with host equipment such as a computer with a Bluetooth function through the hidrowfile so as to realize wireless application.
3、Bluetoothstack
The Bluetooth protocol stack (Bluetooth stack) includes a plurality of applications in a Bluetooth framework, each Application defining a respective message format and Application rules, and a core protocol, the Application being a Bluetooth service (Application). In order to realize interconnection and intercommunication of different devices under different platforms, the bluetooth protocol defines specifications such as A2DP (advanced audio distribution profile), HFP (wings-free profile), and the like for various possible and common application scenarios. The core protocol includes, but is not limited to, a bluetooth basic service protocol sdp (service discovery protocol), a logical link control and adaptation protocol L2CAP (local link control and adaptation protocol), and the like. The core protocol is essential in the bluetooth protocol stack.
With the wide application of electronic devices such as tablet computers and mobile phones in life, the functional requirements of users on the electronic devices are increasing, and the functions of some electronic devices cannot meet the use requirements of users. Fig. 1 is a usage scenario diagram of an electronic device according to an embodiment of the present application. As shown in fig. 1, when a user types with a tablet computer, the virtual keyboard interface occupies a large portion of the tablet computer display screen. Therefore, the virtual keyboard interface can block part of the information of the operation interface, the user operation interface cannot be completely displayed, and the use of the user is influenced.
In order to meet the use requirements of users, electronic devices such as tablet computers and mobile phones (for convenience of description, hereinafter referred to as a central device) can be connected with other electronic devices such as wireless keyboards, touch pens and wireless sound boxes (for convenience of description, hereinafter referred to as an external device) with professional use functions, and richer functions are realized through the cooperation of the central device and the external device. At present, most of central equipment and external equipment are HID equipment supporting Bluetooth technology. Therefore, the center device and the external device can establish wireless connection through the bluetooth technology.
The following describes an exemplary connection process between the central device and the external device by taking a tablet pc and a wireless keyboard as examples. Referring to fig. 2, fig. 2 is a schematic view illustrating an adsorption connection between a tablet computer and a wireless keyboard according to an embodiment of the present disclosure. As shown in fig. 2, when the tablet pc is connected to the wireless keyboard for the first time, a user is required to attach the tablet pc to the wireless keyboard, and then manually operate the tablet pc to perform configuration, so that the tablet pc is paired with the wireless keyboard and a connection is established. After that, when detecting that the tablet computer is connected to the wireless keyboard in an attached manner, the tablet computer triggers a connection broadcast sent by the scanning wireless keyboard, and if the wireless keyboard meeting the condition (for example, the wireless keyboard is connected to the tablet computer in a paired manner) is scanned, the tablet computer and the wireless keyboard do not need to be paired again, and the connection is directly established.
Generally, the tablet computer records the connection state with the wireless keyboard. After the tablet computer and the wireless keyboard are disconnected from the adsorption device, the tablet computer can determine whether the tablet computer needs to be disconnected from the wireless keyboard according to the connection state of the tablet computer and the wireless keyboard. And if the tablet personal computer is in an unconnected state or a connected state with the wireless keyboard, the tablet personal computer cannot be disconnected with the wireless keyboard. The tablet computer can be disconnected from the wireless keyboard only if the tablet computer is in a connected state with the wireless keyboard.
In contrast, after the tablet computer is connected with the wireless keyboard in an adsorption manner, the tablet computer can determine whether the connection with the wireless keyboard is required to be established according to the connection state of the tablet computer and the wireless keyboard. If the tablet computer is in a connected state or a connecting state with the wireless keyboard, the tablet computer cannot be repeatedly connected with the wireless keyboard. If the tablet computer is not connected with the wireless keyboard, the tablet computer can be connected with the wireless keyboard.
When the tablet personal computer is connected with the wireless keyboard, the tablet personal computer sends a connection instruction to a Bluetooth protocol stack of the tablet personal computer, and the Bluetooth protocol stack determines whether to respond to the connection instruction according to the adsorption state of the tablet personal computer and the wireless keyboard. And if the tablet personal computer and the wireless keyboard are in an adsorption state, the Bluetooth protocol stack responds to the connection instruction and controls the Bluetooth to realize the connection operation of the tablet personal computer and the wireless keyboard. And if the tablet personal computer and the wireless keyboard are in a non-adsorption state, the Bluetooth protocol stack does not respond to the connection instruction, and the connection operation of the tablet personal computer and the wireless keyboard is cancelled.
In some practical application scenarios, in the process of connecting the tablet personal computer and the wireless keyboard, if the tablet personal computer is detached from the wireless keyboard and then is attached again, the situation of connection failure between the tablet personal computer and the wireless keyboard may occur.
Specifically, in the process of connecting the tablet personal computer and the wireless keyboard, if the sensor of the tablet personal computer detects that the wireless keyboard is disconnected from the tablet personal computer, the tablet personal computer is triggered to be disconnected from the wireless keyboard. However, since the tablet computer and the wireless keyboard are still connected, the tablet computer has no connected device, and thus the tablet computer fails to be disconnected.
Moreover, although the connection instruction sent by the tablet computer is already sent to the bluetooth protocol stack, the bluetooth protocol stack does not respond to the connection instruction and cancel the connection between the tablet computer and the wireless keyboard at this time because the wireless keyboard and the tablet computer are in a non-adsorption state at this time.
At the moment, if the sensor in the tablet personal computer detects that the wireless keyboard is connected with the tablet personal computer in an adsorption mode again, the tablet personal computer is triggered to scan for the second time and is connected with the wireless keyboard. If the cancellation process of the first connection between the tablet computer and the wireless keyboard is not completed, the tablet computer and the wireless keyboard are still in a connected state. Therefore, the tablet computer cannot be triggered to be connected with the wireless keyboard for the second time, so that the connection between the tablet computer and the wireless keyboard fails, the user needs to manually operate and connect the tablet computer again, and the use experience of the user is reduced.
The user experience under the scene that the central equipment is connected with the external equipment is improved. The embodiment of the application provides an electronic equipment connection method and electronic equipment, and the method can be applied to a scene that central equipment is connected with external equipment, so that the situation that the connection between the central equipment and the external equipment fails due to abnormal connection caused by re-establishment of physical connection after the central equipment is disconnected from the external equipment in a short time is avoided. The central equipment can be accurately and successfully connected with the external equipment without manual operation of a user, and the use experience of the user is improved.
The central device in the embodiment of the present application may be referred to as a User Equipment (UE), a terminal (terminal), and the like, for example, the electronic device 100 may be a mobile terminal or a fixed terminal having a touch screen, such as a tablet computer (PAD), a Personal Digital Assistant (PDA), a handheld device having a wireless communication function, a computing device, a vehicle-mounted device, or a wearable device, a Virtual Reality (VR) terminal device, an Augmented Reality (AR) terminal device, a wireless terminal in industrial control (industrial control), a wireless terminal in self driving (self driving), a wireless terminal in remote medical (remote medical), a wireless terminal in smart grid (smart grid), a wireless terminal in transportation safety (transportation safety), a wireless terminal in smart city (smart city), a wireless terminal in smart home (smart home), and the like. The form of the terminal device is not particularly limited in the embodiment of the present application.
Fig. 3A is a schematic diagram of an exemplary hardware structure of the electronic device 100 provided in the embodiment of the present application, where the electronic device 100 may be used as a central device in the embodiment of the present application, and the structure of the electronic device 100 is exemplarily described below with reference to fig. 3A.
The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) interface 130, an antenna, a wireless communication module 140, an audio module 150, a sensor module 160, a motor 170, a display screen 180, and a coil 190, among others.
It is to be understood that the illustrated structure of the embodiment of the present application does not specifically limit the electronic device 100. In other embodiments of the application, the electronic device 100 may include more or fewer components than shown, or some components may be combined, or some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Processor 110 may include one or more processing units, such as: the processor 110 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a memory, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), etc. The different processing units may be separate devices or may be integrated into one or more processors. In some embodiments, the electronic device 100 may also include one or more processors 110.
The controller can generate an operation control signal according to the instruction operation code and the time sequence signal to complete the control of instruction fetching and instruction execution.
A memory may also be provided in processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to reuse the instruction or data, it can be called directly from memory. Avoiding repeated accesses reduces the latency of the processor 110, thereby increasing the efficiency of the electronic device 100.
In some embodiments, processor 110 may include one or more interfaces. The interface may include an integrated circuit (I2C) interface, an integrated circuit built-in audio (I2S) interface, a Pulse Code Modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a general-purpose input/output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and/or a Universal Serial Bus (USB) interface, etc.
The I2C interface is a bi-directional synchronous serial bus that includes a serial data line (SDA) and a Serial Clock Line (SCL). In some embodiments, processor 110 may include multiple sets of I2C buses. The processor 110 may be coupled to the touch sensor 160B, etc. via different I2C bus interfaces, respectively. For example: the processor 110 may be coupled to the touch sensor 160B via an I2C interface, such that the processor 110 and the touch sensor 160B communicate via an I2C bus interface to implement the touch function and the drag function of the electronic device 100.
The UART interface is a universal serial data bus used for asynchronous communications. The bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, a UART interface is generally used to connect the processor 110 with the wireless communication module 140. For example: the processor 110 communicates with a bluetooth module in the wireless communication module 140 through a UART interface to implement a bluetooth function. In some embodiments, the audio module 150 may transmit the audio signal to the wireless communication module 140 through the UART interface, so as to realize the function of playing music through the bluetooth headset.
The MIPI interface may be used to connect the processor 110 with peripheral devices such as the display screen 180. The MIPI interface includes a display screen 180 serial interface (DSI) and the like. In some embodiments, processor 110 and display screen 180 communicate through a DSI interface to implement display functionality of electronic device 100 to present a dragged display effect to a user.
The GPIO interface may be configured by software. The GPIO interface may be configured as a control signal and may also be configured as a data signal. In some embodiments, a GPIO interface may be used to connect the processor 110 with the camera 183, the display screen 180, the wireless communication module 140, the audio module 150, the sensor module 160, and the like. The GPIO interface may also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, and the like.
The USB interface 130 is an interface conforming to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 140 may be used to connect a charger to charge the electronic device 100, and may also be used to transmit data between the electronic device 100 and a peripheral device. And the earphone can also be used for connecting an earphone and playing audio through the earphone. The interface may also be used to connect other electronic devices, such as AR devices and the like.
It should be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only an illustration, and does not limit the structure of the electronic device 100. In other embodiments, the electronic device 100 may also adopt different interface connection manners or a combination of multiple interface connection manners in the above embodiments.
The wireless communication function of the electronic device 100 may be implemented by an antenna, the wireless communication module 140, a baseband processor, and the like.
The antenna is used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: the multiplexing may be as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The wireless communication module 140 may provide a solution for wireless communication applied to the electronic device 100, including Wireless Local Area Networks (WLANs) (e.g., wireless fidelity (Wi-Fi) networks), bluetooth (bluetooth, BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and the like. The wireless communication module 140 may be one or more devices integrating at least one communication processing module. The wireless communication module 140 receives electromagnetic waves via an antenna, performs frequency modulation and filtering processing on electromagnetic wave signals, and transmits the processed signals to the processor 110. Wireless communication module 150 may also receive signals to be transmitted from processor 110, frequency modulate them, amplify them, and convert them into electromagnetic waves via an antenna for radiation.
In some embodiments, the antenna of the electronic device 100 and the wireless communication module 140 are coupled such that the electronic device 100 may communicate with networks and other devices through wireless communication techniques. The wireless communication technology may include global system for mobile communications (GSM), General Packet Radio Service (GPRS), code division multiple access (code division multiple access, CDMA), Wideband Code Division Multiple Access (WCDMA), time-division code division multiple access (time-division code division multiple access, TD-SCDMA), Long Term Evolution (LTE), LTE, BT, GNSS, WLAN, NFC, FM, and/or IR technologies, among others. GNSS may include Global Positioning System (GPS), global navigation satellite system (GLONASS), beidou satellite navigation system (BDS), quasi-zenith satellite system (QZSS), and/or Satellite Based Augmentation System (SBAS).
In some embodiments, the solution for WLAN wireless communication provided by wireless communication module 140 may also enable the electronic device to communicate with devices in a network (e.g., devices that are cooperative with electronic device 100). Thus, the electronic device can perform data transmission with the cooperative device.
The electronic device 100 implements display functions via the GPU, the display screen 180, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 180 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change interface display effects.
The display screen 180 is used for displaying a User Interface (UI) related to the embodiment of the present application. The display screen 180 includes a display panel, and the display panel may adopt a liquid crystal display 180 (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a miniature, a Micro-oeled, a quantum dot light-emitting diode (QLED), and the like.
In some embodiments of the present application, when the display panel is made of OLED, AMOLED, FLED, or the like, the display screen 180 may be bent. Here, the display screen 180 may be bent means that the display screen 180 may be bent at any position to any angle and may be held at the angle, for example, the display screen 180 may be folded right and left from the middle. Or can be folded up and down from the middle part.
In some embodiments, the display screen 180 may be a touch screen and may serve as an input surface, and operations such as drawing, writing, and clicking of the user may be recognized through the display screen 180, and information input by the user may be acquired.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to extend the memory capability of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, data such as music, photos, videos, and the like are stored in the external memory card.
Internal memory 121 may be used to store one or more computer programs, including instructions. The processor 110 may execute the above-mentioned instructions stored in the internal memory 121, so as to enable the electronic device 100 to execute the interface display method provided in some embodiments of the present application, and various functional applications, data processing, and the like. The internal memory 121 may include a program storage area and a data storage area. Wherein, the storage program area can store an operating system; the storage area may also store one or more application programs (e.g., gallery, contacts, etc.), etc. The storage data area may store data created during the use of the electronic device 100 (such as the number of objects dragged by the user, etc.), and the like. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (UFS), and the like.
The audio module 150 is used to convert digital audio information into an analog audio signal output and also to convert an analog audio input into a digital audio signal. The audio module 150 may also be used to encode and decode audio signals. In some embodiments, the audio module 150 may be disposed in the processor 110, or some functional modules of the audio module 150 may be disposed in the processor 110. The audio module 150 may include a speaker, a microphone, and a headphone interface, etc.
The sensor module 160 may include a pressure sensor 160A and a touch sensor 160B.
The pressure sensor 160A is used for sensing a pressure signal, and can convert the pressure signal into an electrical signal. In some embodiments, pressure sensor 160A may be disposed on display screen 180. The pressure sensor 160A can be of a variety of types, such as a resistive pressure sensor, an inductive pressure sensor, a capacitive pressure sensor, and the like. The capacitive pressure sensor may be a sensor comprising at least two parallel plates having an electrically conductive material. When a force acts on the pressure sensor 160A, the capacitance between the electrodes changes. The electronic device 100 determines the strength of the pressure from the change in capacitance. When a touch operation is applied to the display screen 180, the electronic apparatus 100 detects the intensity of the touch operation based on the pressure sensor 160A. The electronic apparatus 100 may also calculate the touched position from the detection signal of the pressure sensor 160A.
Touch sensor 160B, which may also be referred to as a touch panel or touch sensitive surface. The touch sensor 160B may be disposed on the display screen 180, and the touch sensor 160B and the display screen 180 form a touch screen, which is also called a "touch screen". The touch sensor 160B is used to detect a touch operation and an off-hand operation acting thereon or thereabout. The touch sensor 160B may communicate the detected touch operation to the processor 110 to determine the touch event type. The electronic device 100 may calculate a position touched by the user and a position away from the hand of the user according to the detection signal of the touch sensor 160B, and may determine to recognize the drag operation of the user according to a continuous change of the position touched by the user. Further, the electronic apparatus 100 may provide visual output related to the aforementioned related operations (touch operation, hands-off operation, and drag operation) through the display screen 180.
The sensor module 160 may also include a gyroscope sensor, a barometric sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, an ambient light sensor, a bone conduction sensor, and the like.
The motor 170 may generate a vibration cue. The motor 170 may be used for both an incoming call vibration prompt and a touch vibration feedback. For example, touch operations applied to different applications (e.g., photographing, audio playing, etc.) may correspond to different vibration feedback effects. The motor 170 may also respond to different vibration feedback effects for touch operations applied to different areas of the display screen 180. Different application scenes (such as time reminding, receiving information, alarm clock, game and the like) can also correspond to different vibration feedback effects. The touch vibration feedback effect may also support customization.
The electronic device 100 further comprises a coil 190. In some embodiments, the coil 180 is disposed at a bezel of the electronic device 100. The electronic device 100 can be connected to the wireless keyboard 200 via the coil 190, and the coil 280 can perform data interaction with the wireless charging coil 250 of the wireless keyboard 200.
The software system of the electronic device 100 may adopt a hierarchical architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes an Android system with a layered architecture as an example, and exemplarily illustrates a software structure of the electronic device 100.
Fig. 3B is a schematic diagram of an exemplary software architecture of the electronic device 100 according to an embodiment of the present application.
The layered architecture divides the software into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into four layers, an application layer, an application framework layer, an Android runtime (Android runtime) and system library, and a kernel layer from top to bottom.
The application layer may include a series of application packages.
As shown in fig. 3B, the application package may include Applications (APP) such as camera, gallery, mailbox, bluetooth, memo, music, video, file management, etc.
The application framework layer provides an Application Programming Interface (API) and a programming framework for the application program of the application layer. The application framework layer includes a number of predefined functions.
As shown in FIG. 3B, the application framework layers may include a window manager, a view system, a drag manager, a content provider, a resource manager, a notification manager, and the like. The functional modules of the application framework layer may be integrated into the processor 110 illustrated in fig. 3A, and the functions of the application framework layer in this embodiment may be implemented by the hardware processor 110 illustrated in fig. 3A.
The window manager is used for managing window programs. Illustratively, the window manager may obtain the size of the display screen 184, determine if there is a status bar, lock the screen, intercept the screen, etc. The window manager may also manage the distribution of each APP in the application layer, and the window layout of each APP, to achieve the function of the display screen 184 displaying two APP windows. In addition, the window manager has the function of identifying the file types supported by the APP, and the like, so that the window manager can determine whether the APP can support the file types of the user dragging objects.
The view system includes visual interface elements such as interface elements that display text, interface elements that display images, and the like. The view system may be used to build a display interface for an APP. The display interface may be composed of one or more views. For example, a display interface including various types of APP icons, and the like. The view system may also construct a snapshot of the dragged object. The snapshot includes, for example, a size, an identifier, and the like of the snapshot, and the identifier may include a layer, a mark, and the like.
The drag manager may determine the location touched by the user and the snapshot of the corresponding object based on the detection signal reported by the touch sensor 160B. Further, the drag manager may control the corresponding snapshot to move on the display screen 180 along with the position touched by the user, so as to implement the drag function.
The content provider is used to store and retrieve data and make it accessible to applications. The data may include video, images, audio, calls made and answered, browsing history and bookmarks, phone books, etc.
The resource manager provides various resources for the application, such as localized strings, icons, images, layout files, video files, and the like.
The notification manager enables the application to display notification information in the status bar, can be used to convey notification-type messages, can disappear automatically after a short dwell, and does not require user interaction. Such as a notification manager used to inform download completion, message alerts, etc. The notification manager may also be a notification that appears in the form of a chart or scrollbar text in a status bar at the top of the system, such as a notification of a running application in the background, or a notification that appears on the screen in the form of a dialog window. For example, prompting text information in the status bar, sounding a prompt tone, vibrating the electronic device, flashing an indicator light, etc.
The Android Runtime comprises a core library and a virtual machine. The Android runtime is responsible for scheduling and managing an Android system.
The core library comprises two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. And executing java files of the application program layer and the application program framework layer into a binary file by the virtual machine. The virtual machine is used for performing the functions of object life cycle management, stack management, thread management, safety and exception management, garbage collection and the like.
The system library may include a plurality of functional modules. For example: surface managers (surface managers), media libraries (media libraries), three-dimensional graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), accessory management services, Bluetooth apk, BT stack, and the like.
The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
The media library supports a variety of commonly used audio, video format playback and recording, and still image files, among others. The media library may support a variety of audio-video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like.
The 2D graphics engine is a drawing engine for 2D drawing.
The accessory management service is used to manage accessories (e.g., wireless keyboard, stylus, headset, mouse, etc.) of the electronic device, such as pairing, connecting, disconnecting, and data transfer with the accessories.
The Bluetooth apk is mainly responsible for the management of the Bluetooth state of the electronic equipment, is connected with the BT stack and provides various Bluetooth services.
BT stack provides all the actual operations of bluetooth, including: switching on and off Bluetooth, management of Bluetooth, search management, link management, realization of various profiles and the like
The kernel layer is a layer between hardware and software. The kernel layer at least comprises a display driver, a camera driver, an audio driver, a sensor driver and the like, and the embodiment of the application does not limit the display driver, the camera driver, the audio driver, the sensor driver and the like.
The external device in the embodiment of the present application may be, for example, an electronic device such as a wireless keyboard, a touch pen, a wireless mouse, a wireless headset, and a wireless sound box. Taking a wireless keyboard as an example, please refer to fig. 4, and fig. 4 is a schematic structural diagram of a wireless keyboard 200 according to an embodiment of the present application. As shown in fig. 4, the wireless keyboard 200 may include a first portion 201 and a second portion 202. Illustratively, the wireless keyboard 200 may include: keyboard main part and keyboard cover. The first portion 201 may be a keypad sleeve and the second portion 202 a keypad body. The first portion 201 is used for placing the electronic device 100, and the second portion 202 may be provided with keys, a touch pad, and the like for user operation.
When the wireless keyboard 200 is used, the first portion 201 and the second portion 202 of the wireless keyboard 200 need to be opened, and when the wireless keyboard 200 is not used, the first portion 201 and the second portion 202 of the wireless keyboard 200 can be closed. In one embodiment, the first portion 201 and the second portion 202 of the wireless keyboard 200 are rotatably coupled. For example, the first portion 201 and the second portion 202 may be connected by a hinge or a rotating shaft, or, in some examples, the first portion 201 and the second portion 202 may be rotatably connected by a flexible material (e.g., a leather material or a cloth material). Or, in some examples, the first portion 201 and the second portion 202 may be integrally formed, and the connection between the first portion 201 and the second portion 202 is processed by thinning, so that the connection between the first portion 201 and the second portion 202 may be bent. The connection between the first portion 201 and the second portion 202 may include, but is not limited to, the above-mentioned several rotation connection manners.
Wherein the first portion 201 may comprise at least two pivotally connected supports. For example, referring to fig. 4, the first portion 201 includes a first support 201a and a second support 201b, the first support 201a and the second support 201b are rotatably connected, and when in use, the first support 201a and the second support 201b can be used to jointly support the electronic device 100 (refer to fig. 2). Alternatively, the first stand 201a provides support for the second stand 201b, and the second stand 201b supports the electronic device 100. Referring to fig. 4, the second bracket 201b is rotatably connected to the first portion 201.
As shown in fig. 4, the wireless keyboard 200 may be provided with a storage portion 203 for storing a stylus pen in order to facilitate storage of the stylus pen. Referring to fig. 4, the housing 203 is a cylindrical cavity, and when housed, the stylus pen is inserted into the housing along an arrow in fig. 4. In this embodiment, referring to fig. 4, the second portion 202 and the second bracket 201b are rotatably connected by a connecting portion 204, and the connecting portion 204 is provided with a receiving portion 203. The connecting portion 204 may be a rotating shaft.
Fig. 5 is a schematic structural diagram of a wireless keyboard accommodating a stylus according to an embodiment of the present disclosure, and fig. 6 is a schematic side view of the wireless keyboard 200 accommodating the stylus in an accommodating portion 203. Referring to fig. 6, the receiving portion 203 is a circular cavity, and an inner diameter of the receiving portion 203 is larger than an outer diameter of the stylus.
In order to prevent the stylus pen from falling off when being placed in the receiving portion 203, in one embodiment, a magnetic material may be disposed on an inner wall of the receiving portion 203, and the magnetic material may be disposed in the stylus pen. The stylus pen is attracted to the housing portion 203 by a magnetic attraction effect between the magnetic materials. Of course, in some examples, when the stylus is fixed to the receiving portion 203, including but not limited to using magnetic attraction, for example, the stylus may be fixed to the receiving portion 203 by a snap-fit manner.
In order to facilitate the stylus to be taken out from the receiving portion 203, an ejecting mechanism may be disposed in the receiving portion 203, for example, one end of the stylus is pressed, and the ejecting mechanism may drive the one end of the stylus to eject outwards from the receiving portion 203.
Fig. 7 is a schematic structural frame diagram of a wireless keyboard according to an embodiment of the present application. Referring to fig. 7, the wireless keyboard 200 may include a processor 210, a memory 220, a charging interface 230, a charging management module 240, a wireless charging coil 250, a battery 260, a wireless communication module 270, a touch pad 280, and a keyboard 290.
The processor 210, the memory 220, the charging interface 230, the charging management module 240, the battery 260, the wireless communication module 270, the touch pad 280, the keyboard 290, and the like may be disposed on the keyboard body (i.e., the second portion 202 shown in fig. 1) of the wireless keyboard 200. The wireless charging coil 250 may be provided in a connecting part 204 (shown in fig. 4) for movably connecting the keyboard main body and the stand. It is to be understood that the illustrated structure of the present embodiment does not constitute a specific limitation to the wireless keyboard 200. In other embodiments, wireless keyboard 200 may include more or fewer components than shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Memory 220 may be used to store program code, such as program code for wirelessly charging a stylus, among others. The memory 220 may also have stored therein a bluetooth address for uniquely identifying the wireless keyboard 200. In addition, the memory 220 may also store connection data of electronic devices that have been successfully paired with the wireless keyboard 200 before. For example, the connection data may be a bluetooth address of an electronic device that has successfully paired with the wireless keyboard 200. Based on the connection data, wireless keyboard 200 is able to automatically pair with the electronic device without having to configure a connection therewith, such as for legitimacy verification and the like. The bluetooth address may be a Media Access Control (MAC) address.
The processor 210 may be configured to execute the application code and call the relevant modules to implement the functions of the wireless keyboard 200100 in the embodiment of the present application. For example, a wired charging function, a reverse wireless charging function, a wireless communication function, etc. of the wireless keyboard 200 are implemented. The processor 210 may include one or more processing units, and the different processing units may be separate devices or may be integrated in one or more of the processors 210. The processor 210 may be specifically an integrated control chip, or may be composed of a circuit including various active and/or passive components, and the circuit is configured to perform the functions described in the embodiments of the present application and pertaining to the processor 210. Wherein the processor of the wireless keyboard 200 may be a microprocessor.
The wireless communication module 270 may be configured to support data exchange between the wireless keyboard 200 and other electronic devices, including Bluetooth (BT), Global Navigation Satellite System (GNSS), Wireless Local Area Network (WLAN) (such as wireless fidelity (Wi-Fi) network), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and other wireless communications.
In some embodiments, the wireless communication module 270 may be a bluetooth chip. The wireless keyboard 200 may be a bluetooth keyboard. The wireless keyboard 200 can be paired with bluetooth chips of other electronic devices through the bluetooth chip and establish a wireless connection, so as to realize wireless communication between the wireless keyboard 200 and other electronic devices through the wireless connection.
In addition, the wireless communication module 270 may further include an antenna, and the wireless communication module 270 receives an electromagnetic wave via the antenna, frequency-modulates and filters a signal of the electromagnetic wave, and transmits the processed signal to the processor 210. The wireless communication module 270 may also receive a signal to be transmitted from the processor 210, frequency modulate it, amplify it, and convert it into electromagnetic waves via an antenna for radiation.
In some embodiments, wireless keyboard 200 may support wired charging. Specifically, the charging management module 240 may receive a charging input of the wired charger through the charging interface 230.
In other embodiments, wireless keyboard 200 may support forward wireless charging. The charging management module 240 may receive a wireless charging input through the wireless charging coil 250 of the wireless keyboard 200. Specifically, the charging management module 240 is connected to the wireless charging coil 250 through a matching circuit. The wireless charging coil 250 may be coupled to the wireless charging coil of the wireless charger to induce an alternating electromagnetic field emitted by the wireless charging coil 250 of the wireless charger to generate an alternating electrical signal. The alternating electrical signal generated by the wireless charging coil 250 is transmitted to the charging management module 240 through the matching circuit so as to wirelessly charge the battery 260.
In some embodiments, wireless keyboard 200 may also be suction connected to electronic device 100 through wireless charging coil 250. Wireless charging coil 250 may be magnetically coupled to coil 190 and may allow for data transfer.
The charging management module 240 may also supply power to the wireless keyboard 200 while charging the battery 260. The charging management module 240 receives an input of the battery 260 and supplies power to the processor 210, the memory 220, the external memory, the wireless communication module 270, and the like. The charge management module 240 may also be used to monitor parameters such as battery capacity, battery cycle number, battery state of health (leakage, impedance) of the battery 260. In some other embodiments, the charging management module 240 may also be disposed in the processor 210.
In other embodiments, wireless keyboard 200 may support reverse wireless charging. Specifically, the charging management module 240 may further receive an input from the charging interface 230 or the battery 260, and convert a dc signal input from the charging interface 230 or the battery 260 into an ac signal. The ac signal is transmitted to the wireless charging coil 250 through the matching circuit. The receipt of the alternating current signal by the wireless charging coil 250 may generate an alternating electromagnetic field. The wireless charging coils of other mobile terminals induce the alternating electromagnetic field, and wireless charging can be carried out. That is, the wireless keyboard 200 may also be used to wirelessly charge other mobile terminals. In one embodiment, the wireless charging coil 250 may be disposed in the receiving portion 203 of the wireless keyboard 200, and the wireless charging coil is disposed in the shaft 20 of the stylus pen, so that the wireless keyboard 200 can charge the stylus pen through the wireless charging coil 250 when the stylus pen is placed in the receiving portion 203.
It should be noted that the matching circuit may be integrated in the charging management module 240, or the matching circuit may be independent from the charging management module 240, which is not limited in this embodiment of the application. Fig. 7 is a schematic diagram illustrating a hardware structure of the wireless keyboard 200, taking as an example that the matching circuit may be integrated in the charging management module 240.
Charging interface 230 may be used to provide a wired connection for charging or communication between wireless keyboard 200 and another electronic device (e.g., a wired charger of wireless keyboard 200).
The touch pad 280 is integrated with a touch sensor. The notebook computer can receive a control command of the notebook computer from a user through the touch pad 280 and the keyboard 290.
It is to be understood that the illustrated structure of the embodiment of the present application does not constitute a specific limitation to the wireless keyboard 200. It may have more or fewer components than shown in fig. 7, may combine two or more components, or may have a different configuration of components. For example, the housing of the wireless keyboard 200 may further include a receiving cavity for receiving a stylus. The wireless charging coil 250 is disposed in the accommodating cavity, and is configured to wirelessly charge the stylus pen after the stylus pen is accommodated in the accommodating cavity.
For another example, the external surface of the wireless keyboard 200 may further include a key, an indicator light (which may indicate the status of power, incoming/outgoing call, pairing mode, etc.), a display screen (which may prompt the user for relevant information), and the like. The key may be a physical key or a touch key (used in cooperation with the touch sensor), and is used for triggering operations such as power on, power off, starting charging, stopping charging, and the like.
Fig. 8 is a flowchart of a method for connecting an electronic device according to an embodiment of the present disclosure. Next, with reference to fig. 8, each step of the electronic device connection method provided in the embodiment of the present application is specifically described.
The method provided by the embodiment of the application can be applied to a scene that the physical connection is firstly disconnected and then established again in the connection process of the central equipment (also called as first electronic equipment) and the external equipment (also called as second electronic equipment). Specifically, the method provided in the embodiment of the present application is implemented in a central device, where the central device at least includes a system layer, a kernel layer, and a bluetooth chip (BT controller, BTC). Wherein the system layer comprises: accessory management service, bluetooth application (apk), and bluetooth protocol stack (BT stack). The inner core layer includes: and (6) driving the sensor.
As shown in fig. 8, the method may be implemented by the following steps S101-S111:
s101: the central equipment receives the connection triggering event sent by the sensor.
In one implementation, step S101 may be implemented by an accessory management service of the central device. For example: if the sensor of the central equipment detects a connection trigger event or disconnection trigger event of the external equipment, the sensor sends the connection trigger event or disconnection trigger event to the sensor driver. The sensor drive then sends the connection trigger event or disconnection trigger event to the accessory management service. The connection triggering event may be a physical connection event that triggers the connection between the external device and the central device, for example: adsorption events, insertion events, and proximity events, among others. When the external equipment and the central equipment are connected together through magnetic components such as coils, an adsorption event can be generated. When an external device is plugged into a connection port of the central device, a plug-in event is generated. When the distance between the external device and the central device enters a distance threshold value, a proximity event is generated. The disconnection triggering event may be a physical disconnection event triggering disconnection of the external device from the central device, for example: take-off events, pull-out events, and away events, among others. When the external device is disconnected from the central device, a take-off event is generated. When the external device is unplugged from the connection port of the central device, an unplugging event may occur. A distancing event may occur when the distance between the peripheral device and the central device exceeds a distance threshold. When the sensor detects a connection triggering event, it indicates that the central device needs to be triggered to execute a connection task with the external device. In contrast, when the sensor detects the disconnection triggering event, it indicates that the central device needs to be triggered to perform a disconnection task with the external device.
Taking the central device as a tablet computer and the external device as a wireless keyboard as an example, a user can connect the tablet computer and the wireless keyboard together through magnetic components such as coils and the like in an adsorption manner. When a sensor of the tablet personal computer detects that the wireless keyboard is adsorbed to the tablet personal computer, the sensor sends an adsorption event to an accessory management service of the tablet personal computer, and the accessory management service triggers the tablet personal computer to be connected with the wireless keyboard according to the adsorption event.
S102: the method comprises the following steps that the central equipment acquires a first event state, wherein the first event state is used for indicating the current processing event state of the central equipment, and the first event state comprises the following steps: an initialization state, a connection state, and a disconnection state.
In one implementation, step S102 may be implemented by an accessory management service of the central device. In this embodiment, the first event state may be a state of an event currently processed by the accessory management service. When the accessory management service is not currently processing any event and is in an idle state, the first event state is an initialization state. When the accessory management service is currently processing the connection triggering event sent by the sensor and is in the connection state, the first event state is the connection state. When the accessory management service is currently processing the disconnection triggering event sent by the sensor and is in a disconnection state, the first event state is a disconnection state.
The accessory management service is configured to determine whether to process the connection triggering event based on the first event status. In a specific implementation, when the accessory management service is configured to be in a connected state or a disconnected state, the connection triggering event sent by the sensor cannot be processed. The accessory management service, when configured in an initialization state, can process connection triggering events sent by the sensors.
In some embodiments, the central device may obtain the status of the first event by setting a parameter in the code of the accessory management service. For example, the central device may set a flag bit in the code of the accessory management service, such as: the mJurrentSensorState can indicate the state of the current processing event of the accessory management service by carrying out different assignments on the flag mJurrentSensorState. For example, mCurrentSensorState 0 indicates an initialization state, mcurrentsensestate 1 indicates a connection state, and mcurrentsensestate 2 indicates an disconnection state. It should be noted that the above is merely an exemplary description of states represented by different assignments of the flag mCurrentSensorState, and in some practical application scenarios, other assignments of the flag mCurrentSensorState may also be used to represent other different states. For example, mCurrentSensorState 3 represents an open-cover connection state, mCurrentSensorState 4 represents a close-cover disconnection state, and the like, and a user can set assignment according to actual application conditions.
S103: the center device judges whether the state of the first event is an initialization state.
In one implementation, step S103 may be implemented by an accessory management service of the central device. For example, the accessory management service determines whether to process the connection trigger event sent by the sensor by judging whether the first event state is the initialization state, and only when the first event state is the initialization state, the accessory management service processes the connection trigger event sent by the sensor to trigger the central device to execute the task of connecting with the external device. Therefore, the accessory management service cannot process a plurality of events at the same time, and the condition that the connection between the central equipment and the external equipment fails due to abnormal processing is avoided.
S104: and if the first event state is the initialization state, the central equipment executes the connection task according to the connection triggering event and sets the first event state to be the connection state.
In one implementation, step S104 may be implemented by an accessory management service of the central device. For example, if the first event state is the initialization state, the accessory management service processes a connection trigger event, i.e., triggers the central device to perform a connection task with the external device. At the same time, the first event status is set to a connected status. Therefore, if the accessory management service receives other events sent by the sensor again, the event is not processed, and the central equipment is ensured to smoothly complete the task of connecting with the external equipment.
In some embodiments, before the central device is connected to the external device, the central device first needs to acquire the target device, i.e., the external device that needs to be connected, through scanning.
For example, the accessory management service of the central device may acquire the target device through bluetooth scanning. Fig. 9 is a flowchart of a method for a central device to scan a target device according to an embodiment of the present application, and as shown in fig. 9, a specific scanning process may be implemented through the following steps S201 to S209:
s201: the accessory management service sends a scan instruction to the bluetooth apk.
In the embodiment of the present application, the system services of the central device include a bluetooth apk, and the bluetooth apk has a main function of being responsible for managing a bluetooth state, connecting a BT stack, and providing various bluetooth services. When the accessory management service needs to acquire the target device, a scanning instruction needs to be sent to the Bluetooth apk, and the Bluetooth apk controls the Bluetooth to start a scanning state according to the received scanning instruction to scan and acquire the target device.
S202: the Bluetooth apk receives the scanning instruction and sends the scanning instruction to the BT stack.
In this embodiment, the system service of the central device further includes a BT stack, and the BT stack provides all actual operations of bluetooth, including: the Bluetooth switch, the management of Bluetooth, search management, link management, the realization of various profiles and the like, wherein the BT stack comprises profiles such as HCI, ACL, SCO, L2CAP and the like. And the Bluetooth apk sends the received scanning instruction to the BT stack, and the BT stack realizes the scanning operation of the Bluetooth bottom layer according to the scanning instruction.
S203: the BT stack receives the scan instruction and sends the scan instruction to the BTC.
In this embodiment of the present application, the center device further includes: BTC, BTC may also be referred to as a bluetooth chip or a bluetooth module. The BTC is a chip basic circuit set integrated with bluetooth function, and is used for wireless network communication, and mainly includes three types: data transmission module, bluetooth audio frequency + two unification modules of data etc.. The BT stack sends the received scanning instruction to the BTC, and the BTC executes the scanning operation.
S204: the BTC receives the scanning instruction and starts to scan the external equipment.
In the embodiment of the application, before the external device is connected with the central device, the external device sends broadcast data to the central device, wherein the broadcast data comprises information of the external device. And the BTC starts scanning after receiving the scanning instruction, receives the broadcast data sent by the external equipment and extracts the information of the external equipment.
S205: and if the BTC scans the external equipment meeting the conditions, generating a scanning result and sending the scanning result to the BT stack, wherein the scanning result comprises a set of the information of the external equipment.
In some embodiments, the accessory management service may set a filter in the scan command so that the BTC scans only the external devices that meet the conditions, including, for example: an external device of a certain specific model or an external device of a certain specific manufacturer, etc. And the BTC generates scanning results of all the scanned external devices meeting the conditions and sends the scanning results to the BT stack.
S206: and the BT stack receives the scanning result and sends the scanning result to the Bluetooth apk.
S207: and the Bluetooth apk receives the scanning result and sends the scanning result to the accessory management service.
In the embodiment of the application, the scanning result is uploaded layer by layer through the BT stack and the Bluetooth apk and finally sent to the accessory management service. The accessory management service can determine whether the target device is to be connected according to the scanning result.
S208: the accessory management service determines whether the target device is included in the scan result.
In the embodiment of the application, the target device is an external device to be used by a user, that is, an external device to be connected with the central device, and the target device can be set by the user. For example, the target device may be an external device with a specific name (an external device with a name of "wireless keyboard"), or an external device with a specific model. Specifically, the scan result may include a device unique identifier of the external device, for example, a name of the device, an International Mobile Equipment Identity (IMEI), a Mobile Equipment Identity (MEID), a Serial Number (SN), and the like. The accessory management service can judge whether the external equipment is the target equipment or not through the equipment unique identifier.
S209: if the target device is included in the scanning result, the accessory management service performs a connection task with the target device.
And if the external equipment is the target equipment in the scanning result, the accessory management service executes a connection task with the target equipment. It should be noted that, if there are multiple external devices in the scanning result that satisfy the condition of the target device, the only target device that needs to be connected may be selected by setting a connection condition (e.g., a preferential connection principle). For example, the target device that the user needs to use is a wireless keyboard, but the scanning result includes 3 wireless keyboards: wireless keyboard A, wireless keyboard B and wireless keyboard C. And scanning to sequentially obtain a wireless keyboard B, a wireless keyboard A and a wireless keyboard C, selecting the wireless keyboard B as target equipment according to a priority connection principle, and connecting the tablet personal computer with the wireless keyboard B.
Fig. 10 is a flowchart of a method for connecting a center device to a target device according to an embodiment of the present application. As shown in fig. 10, in some embodiments, the process of the central device connecting with the target device through bluetooth may be implemented through the following steps S301 to S318:
s301: the accessory management service sends a first connection instruction to the Bluetooth apk, wherein the first connection instruction is used for connecting the hid profile.
In the embodiment of the present application, the process of connecting the center device and the target device includes: connect hid profile and connect private channel gatt. The accessory management service firstly connects the hid profile, and specifically, the accessory management service can send a connection hid profile instruction to the bluetooth apk by calling a standard bluetooth interface.
S302: and the Bluetooth apk receives the first connection instruction and sends the first connection instruction to the BT stack.
S303: the BT stack receives the first connection instruction and sends the first connection instruction to the BTC.
S304: the BTC receives the first connection instruction and sends the first connection instruction to the target device.
In the embodiment of the application, the first connection instruction is sequentially transmitted to the BTC through the Bluetooth apk and the BT stack, and the BTC sends the first connection instruction to the target device to perform hid profile connection.
S305: and the target equipment performs the hid profile connection according to the first connection instruction, generates a first connection result and sends the first connection result to the BTC. The first connection result is a connection result of the connection of the hid profile, and the first connection result includes: connection success or connection failure.
In the embodiment of the application, the step S301 to the step S305 may implement connection of the hid profile, generate a hid profile connection result, and determine whether the hid profile connection is successful according to the hid profile connection result, and determine whether to perform gatt connection of the private channel in the next step.
S306: the BTC receives the first connection result and sends the first connection result to the BT stack.
S307: and the BT stack receives the first connection result and sends the first connection result to the Bluetooth apk.
S308: the Bluetooth apk receives the first connection result and sends the first connection result to the accessory management service.
S309: and the accessory management service judges whether the hid profile is successfully connected according to the first connection result.
S310: if the hid profile connection is successful, the accessory management service sends a second connection instruction to the Bluetooth apk, the second connection instruction being used to connect the private channel gatt.
In the embodiment of the application, the first connection result sent by the target device is sent to the accessory management service sequentially through the BTC, the BT stack and the bluetooth apk. And the accessory management service judges whether the hid profile is successfully connected according to the first connection result. And only if the hid profile is successfully connected, the accessory management service connects the private channel gatt and sends a connection instruction for connecting the private channel gatt to the Bluetooth apk.
S311: and the Bluetooth apk receives the second connection instruction and sends the second connection instruction to the BT stack.
S312: the BT stack receives the second connection instruction and sends the second connection instruction to the BTC.
S313: the BTC receives the second connection instruction and sends the second connection instruction to the target device.
In the embodiment of the application, the second connection instruction is transmitted to the BTC sequentially through the bluetooth apk and the BT stack, and the BTC sends the second connection instruction to the target device to perform the private channel gatt connection.
S314: the target device performs private channel gatt connection according to the second connection instruction, generates and sends a second connection result to the BTC, wherein the second connection result is a connection result for connecting the private channel gatt, and the second connection result comprises: connection success or connection failure.
In the embodiment of the application, the private channel gatt can be connected through steps S310 to S314, a private channel gatt connection result is generated, and whether the connection between the central device and the external device is successful or not can be judged according to the private channel gatt connection result.
S315: the BTC receives the second connection result and sends the second connection result to the BT stack.
S316: and the BT stack receives the second connection result and sends the second connection result to the Bluetooth apk.
S317: and the Bluetooth apk receives the second connection result and sends the second connection result to the accessory management service.
S318: and the accessory management service judges whether the private channel gatt is successfully connected according to the second connection result.
In the embodiment of the application, the second connection result sent by the target device is sent to the accessory management service sequentially through the BTC, the BT stack and the bluetooth apk. And the accessory management service judges whether the private channel gatt is successfully connected according to the second connection result. If the private channel gatt connection is successful, it can also indicate that the connection between the central device and the external device has been completed by the hid profile connection and the private channel gatt connection, that is, the connection between the central device and the target device is successful.
S105: the central device judges whether the connection task is successfully completed.
In one implementation, step S105 may be implemented by an accessory management service of the central device. The accessory management service can judge whether the connection task is successfully completed according to the connection state sent by the external equipment. For example, the accessory management service may determine whether the connection task is successfully completed through the second connection result received in step S318 described above. And if the second connection result is successful connection, the accessory management service connection task is successfully completed. On the contrary, if the second connection result is a connection failure, it indicates that the accessory management service connection task is abnormal, resulting in a connection failure.
S106: if the connection task is successfully completed, the central equipment sets the state of the first event to be an initialization state.
In one implementation, step S106 can be implemented by an accessory management service of the central device. For example, after the current connection task of the accessory management service is successfully completed, the accessory management service may be in an idle state if no other events are being processed. At this time, the accessory management service may set the state of the first event to an initialization state, so that the accessory management service may immediately process the events if it receives a connection trigger event or a disconnection trigger event again, which is transmitted by the sensor. After the accessory management service completes the connection task, events sent again by the sensor can be processed in time, and the effective utilization rate of the accessory management service is further improved.
S107: the central device acquires a second event state, wherein the second event state is used for indicating the state of the next event to be processed of the central device, and the second event state comprises: an initialization state, a to-be-connected state, and a to-be-disconnected state.
In one implementation, step S107 may be implemented by an accessory management service of the central device. In some practical application scenarios, in the process of executing a connection task, if a connection trigger event or a disconnection trigger event sent by a sensor is received again, the accessory management service also processes the connection trigger event or the disconnection trigger event, so that the accessory management service can execute multiple tasks at the same time, which is easy to cause an abnormal situation in the process of executing the tasks by the accessory management service, and thus the task execution fails.
In an embodiment of the application, the accessory management service may set the second event state according to an event sent by the sensor. For example, if the sensor sent a connection trigger event, the accessory management service sets the second event state to a pending state. If the sensor sends a disconnection triggering event, the accessory management service sets the second event state to a to-be-disconnected state. When the accessory management service completes the connection task, other events sent by the sensor can be continuously processed according to the second event state by acquiring the second event state. In this way, the accessory management service can not only smoothly complete the currently executed connection task, but also not omit processing other events sent by the sensor. The accessory management service can improve the success rate and efficiency of the accessory management service in processing events by serially processing the events sent by the sensor.
In this embodiment, the second event state is used to indicate the state of the next pending event for the accessory management service. When the accessory management service has no next event to be processed and is in an idle state, the second event state is an initialization state. And when the next event to be processed of the accessory management service is a connection triggering event, the second event state is a state to be connected. And when the next event to be processed of the accessory management service is a disconnection triggering event, the second event state is a to-be-disconnected state. The accessory management service can judge whether other events need to be processed or not after the current event is processed according to the second event state.
In some embodiments, similar to the first event state, the central device may obtain the second event state by setting parameters in the code of the accessory management service. For example, the central device may set a flag bit in the code of the accessory management service: the status of the currently processed event of the accessory management service can be indicated by assigning the flag mNextSensorState differently. For example, mnextsensestate 0 indicates an initialization state, mnextsensestate 1 indicates a ready-to-connect state, and mnextsensestate 2 indicates a ready-to-disconnect state. It should be noted that the above is only an exemplary description of states represented by different values of flag mcurrentsensstate, and in some practical applications, other values of flag mnextsensstate may be used to represent other different states. For example, mn extsensorstate 3 represents an open lid to-be-connected state, mn extsensorstate 4 represents a close lid to-be-disconnected state, and the like, and a user can set an assignment according to an actual application situation.
S108: the central equipment judges whether the second event state is a to-be-disconnected state.
In one implementation, step S108 may be implemented by an accessory management service of the central device. The accessory management service completes the connection task through the steps, and the central equipment and the target equipment are already in a connection state. Therefore, if the accessory management service judges that the second event state is the initialization state or the to-be-connected state, the accessory management service does not need to process the next event. And only if the second event state is a to-be-disconnected state, the accessory management service needs to process and execute a disconnection task.
S109: and if the second event state is the to-be-disconnected state, the central equipment executes the disconnection task and sets the second event state to be the initialization state.
In one implementation, step S109 can be implemented by an accessory management service of the central device. And when the second event state is a to-be-disconnected state, the accessory management service processes the disconnection triggering event and executes a disconnection task with the target equipment. Meanwhile, since the accessory management service has processed the event according to the second event state, the next pending event indicated by the second event state is being processed. Therefore, the accessory management service restores the second event state to the initialization state, so that when the accessory management service receives the to-be-processed event sent by the sensor again, the second event state can be set again according to the to-be-processed event, and the accessory management service is prevented from missing the to-be-processed event.
In some embodiments, the process of disconnecting the hub device from the target device via bluetooth is similar to the process of connecting. The accessory management service sends a first disconnection instruction to the Bluetooth apk, and the first disconnection instruction is used for disconnecting the hid profile. The first disconnection instruction is transmitted to the BTC sequentially through the Bluetooth apk and the BT stack, and the BTC sends the first disconnection instruction to the target device to disconnect the hid profile. And the target equipment performs hid profile disconnection according to the first disconnection and connection instruction, generates a first disconnection and connection result, and transmits the first disconnection and connection result to the accessory management service through the BTC, the BT stack and the Bluetooth apk in sequence. And the accessory management service judges whether the hid profile is disconnected successfully according to the first disconnection result. And only if the hid profile is disconnected successfully, the accessory management service disconnects the private channel gatt and sends a second disconnection instruction of the disconnected private channel gatt to the Bluetooth apk. And the second disconnection instruction is transmitted to the BTC through the Bluetooth apk and the BT stack in sequence, and the BTC sends the second disconnection instruction to the target equipment so as to perform gatt disconnection of the private channel. And the target equipment performs gatt disconnection on the private channel according to the second disconnection instruction, generates a second disconnection result, and transmits the second disconnection result to the accessory management service sequentially through the BTC, the BT stack and the Bluetooth apk. And the accessory management service judges whether the private channel gatt is disconnected successfully according to the second disconnection result, namely whether the central equipment and the target equipment are disconnected successfully.
S110: and if the second event state is not the to-be-disconnected state, the central equipment does not execute the task and sets the second event state to be the initialized state.
In one implementation, step S110 can be implemented by an accessory management service of the central device. When the second event state is not the to-be-disconnected state, i.e. the initialized state or the to-be-connected state, the accessory management service does not need to process the event and execute the task because the central device and the target device are already in the connected state. Meanwhile, the second event state is restored to the initialization state, and when the accessory management service receives the to-be-processed event sent by the sensor again, the second event state can be set again according to the to-be-processed event, so that the accessory management service is prevented from missing the to-be-processed event.
S111: if the first event state is not the initialization state, the center device sets the second event state to the to-be-connected state.
In one implementation, step S111 may be implemented by an accessory management service of the central device. After receiving the connection triggering event sent by the sensor, the accessory management service determines whether to set the second event state to be a to-be-connected state according to the first processing event state. If the first event state is not the initialization state, namely the first event state is the connection state or the disconnection state, the accessory management service is indicated to execute the connection task or the disconnection task. At this time, if the accessory management service re-processes other events and simultaneously executes a plurality of tasks, an abnormal situation is likely to occur in the process of executing the tasks, resulting in a failure in executing the tasks. Accordingly, the accessory management service can set the second event state to the pending connection state based on the connection trigger event sent by the sensor. And after the current task of the accessory management service is executed, acquiring a second event state, and processing the trigger event to be connected according to the second event state. Therefore, the accessory management service can avoid the failure of executing tasks due to the abnormity of the executed tasks in a serial event processing mode. And the accessory management service can not omit other to-be-processed events sent by the processing sensor, so that the success rate and the efficiency of the accessory management service for processing the events can be improved.
According to the technical scheme, after the electronic equipment receives the trigger connection triggering event sent by the sensor, the state of the current processing event is firstly acquired, whether the event is currently processed or not is judged, and if no event is currently processed, the electronic equipment processes the trigger connection triggering event and executes a connection task. And if the current event is processed, taking the trigger connection trigger event sent by the sensor as the next event to be processed. And after the current connection task of the electronic equipment is executed, acquiring the state of the next event to be processed, and performing corresponding processing. According to the electronic equipment, the events sent by the sensors are sequentially and serially processed, so that the currently executed task can be smoothly completed, and the condition that the abnormal processing is caused by simultaneous processing of a plurality of events is avoided. In addition, other events to be processed sent by the processing sensor cannot be omitted, and the success rate and the efficiency of connection of the electronic equipment are improved.
In some practical application scenarios, an abnormal situation may occur during the process of scanning and connecting the central device and the external device, which may cause connection timeout and task failure. For example, in the process of scanning the external device, if the position of the external device exceeds the scannable range of the central device, the central device cannot scan the external device, which results in a scanning failure and a connection timeout. For another example, if the bluetooth state machine is abnormal during the process of connecting the hid profile and the private channel gatt, the central device may also fail to connect the hid profile and the private channel gatt.
In some embodiments, for the above situation that the scanning connection between the central device and the external device is overtime, the present application further provides a method for resolving the connection overtime exception, fig. 11 is a flowchart of a method for processing the connection overtime provided in the embodiments of the present application, and as shown in fig. 11, the method for processing the connection overtime exception may be implemented through the following steps S401 to S403:
s401: and if the time for executing the connection task exceeds a preset time threshold, the central equipment sets the first event state to be an initialization state and acquires a second event state.
S402: the central equipment judges whether the second event state is a to-be-disconnected state.
S403: and if the second event state is the to-be-disconnected state, the central equipment executes the disconnection task.
In one implementation, the above steps S401-S403 may be implemented by an accessory management service of the central device. For example, when the time for the accessory management service to execute the connection task exceeds a preset time threshold, the connection task is considered to be overtime, and the connection is abnormal. The time threshold is set by the user according to the actual application, and for example, the time threshold may be 30 s. Because the currently processed connection task is abnormal, the accessory management service firstly restores the first event state to the initialization state and does not process the current connection task any more. The accessory management service then obtains a second event state and determines whether to process the second event according to the second event state. Because the current connection task of the accessory management service is still in an abnormal state and cannot be executed again, the accessory management service executes the disconnection task only when the second event state is the to-be-disconnected state, so that the connection process in the abnormal state last time is disconnected, the unconnected initial state between the central equipment and the external equipment is recovered, and the purpose of solving the problem of connection timeout abnormality of the central equipment is achieved.
The specific process of the component management service executing the disconnection task may refer to the disconnection method in step S109, which is not described herein again. After the disconnection task is completed, the accessory management service can restore the second event state to the initialization state, so that when the accessory management service receives the event to be processed sent by the sensor again, the accessory management service can reset the second event state according to the event to be processed.
Fig. 12 is a flowchart of a method of another electronic device connection method according to an embodiment of the present application. Next, referring to fig. 12, steps of another electronic device connection method provided in the embodiment of the present application are specifically described.
The method provided by the embodiment of the application can also be applied to a scene that in the disconnection process of the central device (also called as first electronic device) and the external device (also called as first electronic device), the physical connection is established first, and then the physical connection is disconnected again. Specifically, the method provided in the embodiment of the present application is implemented in a central device, where the central device at least includes a system layer, a kernel layer, and a bluetooth chip (BT controller, BTC). Wherein the system layer comprises: accessory management service, bluetooth application (apk), and bluetooth protocol stack (BT stack). The inner core layer includes: and (6) driving the sensor. As shown in fig. 12, the method may be implemented by the following steps S501 to S511:
s501: and the central equipment receives the disconnection triggering event sent by the sensor.
In one implementation, step S501 may be implemented by an accessory management service of the central device. For example: if the sensor of the central equipment detects the disconnection triggering event, the disconnection triggering event is sent to the sensor drive. The sensor drive then sends the disconnect trigger event to the accessory management service. The disconnection triggering event may be a physical disconnection triggering event that triggers disconnection of the external device from the central device, for example: take-off events, pull-out events, and away events, among others. When the external device is disconnected from the central device, a take-off event is generated. When the external device is unplugged from the connection port of the central device, an unplugging event may occur. A distancing event may occur when the distance between the peripheral device and the central device exceeds a distance threshold. When the sensor detects the disconnection triggering event, it indicates that the central device needs to be triggered to execute the disconnection task with the external device.
Taking the central device as a tablet computer and the external device as a wireless keyboard as an example, when the tablet computer and the wireless keyboard are kept in an adsorption connection state through magnetic components such as coils, if a user separates the tablet computer from the wireless keyboard, a sensor of the tablet computer detects that the wireless keyboard is separated from the tablet computer, the sensor sends a separation event to an accessory management service of the tablet computer, and the accessory management service triggers disconnection of the tablet computer and the wireless keyboard according to the separation event.
S502: the method comprises the following steps that the central equipment acquires a first event state, wherein the first event state is used for indicating the state of the central equipment for processing an event currently, and the first event state comprises the following steps: an initialization state, a connection state, and a disconnection state.
In one implementation, step S502 can be implemented by an accessory management service of the central device. In this embodiment, the first event status can be a status of an event currently processed by the accessory management service. When the accessory management service is idle without any processing event, the first event state is an initialization state. When the accessory management service is currently processing the connection triggering event sent by the sensor and is in the connection state, the first event state is the connection state. When the accessory management service is currently processing an off-off trigger event sent by a sensor and is in an off-off state, the first event state is an off-off state.
S503: the center device judges whether the state of the first event is an initialization state.
In one implementation, step S503 may be implemented by an accessory management service of the central device. For example, the accessory management service determines whether to process a disconnection triggering event sent by the sensor by determining whether the state of the first event is an initialization state. And only when the first event state is the initialization state, the accessory management service can process the disconnection triggering event sent by the sensor and trigger the central equipment to execute the disconnection task with the external equipment. Therefore, the accessory management service cannot process a plurality of events at the same time, and the condition that the disconnection between the central equipment and the external equipment fails due to abnormal processing is avoided.
S504: and if the first event state is the initialization state, the central equipment executes the disconnection task according to the disconnection triggering event and sets the first event state to be the disconnection state.
In one implementation, step S504 may be implemented by an accessory management service of the central device. For example, if the first event state is an initialization state, the accessory management service processes a disconnection triggering event, i.e., triggers the central device to perform a disconnection task with the external device. Meanwhile, the first event status is set to the disconnected status. Therefore, if the accessory management service receives other events sent by the sensor again, the events cannot be processed, and the task of disconnecting the central equipment from the external equipment is smoothly completed. The specific process of the component management service performing the disconnection task may refer to the disconnection method in step S109, which is not described herein again.
S505: the central equipment judges whether the disconnection task is successfully completed.
In one implementation, step S505 may be implemented by an accessory management service of the central device. The accessory management service can judge whether the disconnection task is successfully completed according to the disconnection state sent by the external equipment. For example, the accessory management service may determine whether the disconnection task is successfully completed by receiving a disconnection result sent by the external device during the execution of the disconnection task. And if the disconnection result is that the disconnection is successful, indicating that the disconnection task of the accessory management service is successfully completed. On the contrary, if the disconnection result is disconnection failure, the situation that the disconnection task of the accessory management service is abnormal is shown, and the failure is caused.
S506: and if the disconnection task is successfully completed, the central equipment sets the state of the first event to be an initialization state.
In one implementation, step S506 can be implemented by an accessory management service of the central device. For example, after the current disconnect task is successfully completed, the accessory management service may be idle if no other events are being processed. At this time, the accessory management service sets the first event state to be an initialization state, so that when the connection trigger event or disconnection trigger event sent by the sensor is received again, the accessory management service can immediately process the events, the situation that the accessory management service cannot process the events sent by the sensor again after completing the disconnection task is prevented, and the effective utilization rate of the accessory management service is further improved.
S507: the central device acquires a second event state, wherein the second event state is used for indicating the state of the next event to be processed of the central device, and the second event state comprises: an initialization state, a to-be-connected state, and a to-be-disconnected state.
In one implementation, step S507 may be implemented by an accessory management service of the central device. In this embodiment, the second event state is used to indicate the state of the next pending event for the accessory management service. When the accessory management service has no next event to be processed and is in an idle state, the second event state is an initialization state. And when the next event to be processed of the accessory management service is a trigger event to be connected, the second event state is a state to be connected. And when the next event to be processed of the accessory management service is a to-be-disconnected triggering event, the second event state is a to-be-disconnected state. The accessory management service can judge whether other events need to be processed or not after the current event processing is finished according to the second event state.
S508: the central equipment judges whether the second event state is a state to be connected.
In one implementation, step S508 can be implemented by an accessory management service of the central device. The accessory management service completes the disconnection task through the steps, and the central equipment and the target equipment are in a disconnection state. Therefore, if the accessory management service judges that the second event state is the initialization state or the to-be-disconnected state, the accessory management service does not need to process the next event. And only if the second event state is a to-be-connected state, the accessory management service needs to process and execute a connection task.
S509: and if the second event state is the state to be connected, the central equipment executes the connection task and sets the second event state to be the initialization state.
In one implementation, step S509 may be implemented by an accessory management service of the central device. And when the second event state is a to-be-connected state, the accessory management service processes the connection triggering event and executes a connection task with the target equipment. At the same time, since the accessory management service has processed the event according to the second event state, the next pending event represented by the second event state is being processed. Therefore, the accessory management service restores the second event state to the initialization state, so that when the accessory management service receives the to-be-processed event sent by the sensor again, the second event state can be set again according to the to-be-processed event, and the accessory management service is prevented from missing the to-be-processed event. The specific process of the accessory management service performing the connection task may refer to the connection method in steps S301 to S318, which is not described herein.
S510: and if the second event state is not the state to be connected, the central equipment does not execute the task and sets the second event state to be the initialization state.
In one implementation, step S510 may be implemented by an accessory management service of the central device. And when the second event state is not the state to be connected, the second event state is the initialized state or the state to be disconnected. Because the central device and the target device are already in the disconnected state, the accessory management service does not need to process events and execute tasks. Meanwhile, the second event state is restored to the initialization state, and when the accessory management service receives the to-be-processed event sent by the sensor again, the second event state can be set again according to the to-be-processed event, so that the accessory management service is prevented from missing the to-be-processed event.
S511: if the first event state is not the initialization state, the central equipment sets the second event state as the to-be-disconnected state.
In one implementation, step S511 may be implemented by an accessory management service of the central device. After receiving the disconnection triggering event sent by the sensor, the accessory management service determines whether to set the second event state as a to-be-disconnected state according to the first processing event state. If the first event state is not the initialization state, namely the first event state is the connection state or the disconnection state, the accessory management service is indicated to execute the connection task or the disconnection task. At this time, if the accessory management service re-processes other events and simultaneously executes a plurality of tasks, an abnormal situation is likely to occur in the process of executing the tasks, resulting in a failure in executing the tasks. Accordingly, the accessory management service can set the second event state to the pending disconnect state based on the disconnect trigger event sent by the sensor. And after the current task of the accessory management service is executed, acquiring a second event state, and processing the to-be-disconnected triggering event according to the second event state. Therefore, the accessory management service can avoid the failure of executing tasks due to the abnormity of the executed tasks in a serial event processing mode. And the accessory management service can not omit other to-be-processed events sent by the processing sensor, so that the success rate and the efficiency of the accessory management service for processing the events can be improved.
According to the technical scheme, after the electronic equipment receives the disconnection triggering event sent by the sensor, the state of the current processing event is firstly acquired, whether the event is currently processed is judged, and if no event is currently processed, the electronic equipment processes the disconnection triggering event and executes the disconnection task. And if the current event is being processed, the electronic equipment takes the trigger connection trigger event sent by the sensor as the next event to be processed. And after the current connection task is executed, acquiring the state of the next event to be processed, and performing corresponding processing. According to the electronic equipment, the events sent by the sensors are sequentially and serially processed, so that the currently executed task can be smoothly completed, and the condition that the abnormal processing is caused by simultaneous processing of a plurality of events is avoided. In addition, other events to be processed sent by the processing sensor can not be omitted, and the success rate and the efficiency of connection of the electronic equipment are improved.
In some practical application scenarios, an abnormal condition may occur during disconnection of the central device from the external device, which may cause disconnection timeout and task failure. For example, during the process of disconnecting the hid profile and connecting the private channel gatt, if the bluetooth state machine is abnormal, the connect hid profile and the connect private channel gatt may also fail.
In some embodiments, for the above situation that the disconnection between the central device and the external device is overtime, the present application further provides a method for resolving an abnormal disconnection timeout, fig. 13 is a flowchart of a method for processing the abnormal disconnection timeout provided in the embodiments of the present application, and as shown in fig. 13, the processing of the abnormal disconnection timeout may be implemented through the following steps S601 to S603:
s601: and if the time for executing the disconnection task exceeds a preset time threshold, the central equipment sets the first event state to be an initialization state and acquires a second event state.
S602: the central equipment judges whether the second event state is a state to be connected.
S603: and if the second event state is the state to be connected, the central equipment executes the connection task.
In one implementation, the above steps S601-S603 may be implemented by an accessory management service of the central device. When the time for the accessory management service to execute the disconnection task exceeds a preset time threshold, the disconnection task is considered to be overtime, and the disconnection is abnormal. The time threshold is set by the user according to the actual application, and for example, the time threshold may be 30 s.
Because the currently processed disconnection task is abnormal, the accessory management service firstly restores the first event state to the initialization state and does not process the current disconnection task any more. The accessory management service then obtains a second event status and determines whether to process the second event based on the second event status. Because the current disconnection task of the accessory management service is still in an abnormal state, the disconnection task cannot be executed again. Therefore, only when the second processing event state is the state to be connected, the accessory management service executes the connection task to connect the disconnection process in the abnormal condition last time, so that the initial state of connection between the central equipment and the external equipment is recovered, and the purpose of solving the abnormal disconnection overtime problem of the central equipment is achieved.
The specific process of the accessory management service executing the connection task may refer to the connection method in steps S301 to S318, which is not described herein again. After the accessory management service completes the connection task, the second event state can be restored to the initialization state, and thus, when the accessory management service receives the to-be-processed event sent by the sensor again, the accessory management service can reset the second event state according to the to-be-processed event.
Correspondingly, corresponding to the method described above, an embodiment of the present application provides an electronic device, including: a memory and a processor, the processor and the memory coupled; the memory comprises program instructions, and the program instructions, when executed by the processor, enable the electronic equipment to execute the electronic equipment connection method.
The electronic device provided in the embodiment of the present application may correspond to the first electronic device, and a processor and the like in the electronic device may implement the functions of the first electronic device and/or various steps and methods implemented, which are not described herein again for brevity.
In particular implementation, the present application provides a computer-readable storage medium, in which computer program instructions are stored, and when the computer program instructions are executed, all or part of the steps in the method embodiments may be implemented. The storage medium of the computer readable medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM).
It should be understood that, in the various embodiments of the present application, the size of the serial number of each process does not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments.
All parts of the specification are described in a progressive mode, the same and similar parts of all embodiments can be referred to each other, and each embodiment is mainly introduced to be different from other embodiments. In particular, as to the apparatus and system embodiments, since they are substantially similar to the method embodiments, the description is relatively simple and reference may be made to the description of the method embodiments in relevant places.
The above-mentioned embodiments, objects, technical solutions and advantages of the present invention are further described in detail, it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made on the basis of the technical solutions of the present invention should be included in the scope of the present invention.

Claims (22)

1. An electronic device connection method, the method comprising:
the method includes that a first electronic device responds to a connection triggering event, a first event state is obtained, the connection triggering event is generated when the first electronic device detects that the first electronic device and a second electronic device meet a connection triggering condition, the first event state is used for indicating a state that the first electronic device processes an event currently, and the first event state comprises: an initialization state, a connection state and a disconnection state;
the first electronic equipment judges whether the state of the first event is an initialization state;
if the first event state is an initialization state, the first electronic equipment executes a connection task with the second electronic equipment according to the connection triggering event, and sets the first event state to be a connection state;
if the first event state is not the initialization state, the first electronic device sets a second event state to be a to-be-connected state, the second event state is used for indicating the state of the next to-be-processed event of the first electronic device, and the second event state comprises: an initialization state, a to-be-connected state, and a to-be-disconnected state.
2. The method of claim 1, wherein after performing the connection task with the second electronic device, further comprising:
the first electronic equipment judges whether the connection task is successfully completed;
and if the connection task is successfully completed, the first electronic equipment sets the state of the first event to be an initialization state.
3. The method of claim 2, wherein after the first electronic device sets the first event state to an initialization state, further comprising:
the first electronic equipment acquires the second event state;
the first electronic equipment judges whether the second event state is a to-be-disconnected state or not;
and if the second event state is a to-be-disconnected state, the first electronic equipment executes a disconnection task with the second electronic equipment, and sets the second event state to be an initialization state.
4. The method of claim 3, further comprising:
and if the second event state is not the to-be-disconnected state, the first electronic equipment does not execute the task and sets the second event state to be the initialized state.
5. The method of claim 1, wherein the step of the first electronic device performing the connection task with the second electronic device comprises:
the first electronic equipment sends a first connection instruction to the second electronic equipment, wherein the first connection instruction is used for indicating the second electronic equipment to carry out standard hid profile connection with the first electronic equipment;
the first electronic equipment receives a first connection result sent by the second electronic equipment, wherein the first connection result is the result of the hid profile connection;
the first electronic equipment judges whether the hid profile connection is successful according to the first connection result;
and if the hid profile is successfully connected, the first electronic equipment sends a second connection instruction to the second electronic equipment, wherein the second connection instruction is used for indicating the second electronic equipment to carry out private channel general attribute specification gatt connection with the first electronic equipment.
6. The method of claim 5, further comprising:
the first electronic equipment receives a second connection result sent by the second electronic equipment, wherein the second connection result is the result of the gatt connection;
the first electronic equipment judges whether the connection task is successfully completed or not according to the second connection result;
if the second connection result is that the connection is successful, the first electronic equipment determines that the connection task is successfully completed;
and if the second connection result is connection failure, the first electronic equipment determines that the connection task fails.
7. The method of claim 1, further comprising:
the first electronic equipment acquires the connection time of the connection task;
if the connection time exceeds a preset time threshold, the first electronic equipment sets a first event state to an initialization state and acquires the second event state;
the first electronic equipment judges whether the second event state is a to-be-disconnected state or not;
and if the second event state is a to-be-disconnected state, the first electronic equipment executes a disconnection task with the second electronic equipment.
8. The method of claim 1, further comprising: the first electronic device obtains a first event state through a first flag, and the first flag is set in the first electronic device.
9. The method of claim 2, further comprising: and the first electronic equipment acquires a second event state through a second zone bit, and the second zone bit is arranged in the first electronic equipment.
10. The method of claim 1, wherein the connection trigger condition comprises: the first electronic device is adsorbed to the second electronic device through a coil, or the first electronic device is connected to the second electronic device through a connection port, or the distance between the first electronic device and the second electronic device is smaller than a preset distance threshold.
11. An electronic device connection method, the method comprising:
the method comprises the steps that a first electronic device responds to a disconnection triggering event, a first event state is obtained, the disconnection triggering event is generated when the first electronic device detects that the first electronic device and a second electronic device meet disconnection triggering conditions, and the first event state comprises the following steps: an initialization state, a connection state and a disconnection state;
the first electronic equipment judges whether the first event state is an initialization state;
if the first event state is an initialization state, the first electronic equipment executes the disconnection task with the second electronic equipment according to the disconnection triggering event, and sets the first event state as a disconnection state;
if the first event state is not the initialization state, the first electronic device sets a second event state to a to-be-disconnected state, where the second event state is used to indicate a state of a next to-be-processed event of the first electronic device, and the second event state includes: an initialization state, a to-be-connected state, and a to-be-disconnected state.
12. The method of claim 11, wherein after the performing the disconnection task with the second electronic device, further comprising:
the first electronic equipment judges whether the disconnection task is successfully completed or not;
and if the disconnection task is successfully completed, the first electronic equipment sets the state of the first event to be an initialization state.
13. The method of claim 12, wherein after the first electronic device sets the first event state to an initialization state, further comprising:
the first electronic equipment acquires the second event state;
the first electronic equipment judges whether the second event state is a to-be-connected state;
and if the second event state is a to-be-connected state, the first electronic equipment executes a connection task with the second electronic equipment, and sets the second event state to be an initialization state.
14. The method of claim 13, further comprising:
and if the second event state is not the state to be connected, the first electronic equipment does not execute the task and sets the second event state to be the initialization state.
15. The method of claim 11, wherein the step of the first electronic device performing a disconnect task with the second electronic device comprises:
the first electronic equipment sends a first disconnection instruction to the second electronic equipment, wherein the first disconnection instruction is used for indicating the second electronic equipment to perform man-machine interface equipment specification (hid) profile disconnection with the first electronic equipment;
the first electronic equipment receives a first disconnection result sent by the second electronic equipment, wherein the first disconnection result is the disconnection result of the hid profile;
the first electronic equipment judges whether the hid profile is disconnected successfully or not according to the first disconnection result;
and if the hid profile is disconnected successfully, the first electronic equipment sends a second disconnection instruction to the second electronic equipment, and the second disconnection instruction is used for indicating the second electronic equipment to perform private channel generic attribute specification gatt disconnection with the first electronic equipment.
16. The method of claim 15, further comprising:
the first electronic equipment receives a second disconnection result sent by the second electronic equipment, wherein the second disconnection result is a gatt disconnection result;
the first electronic equipment judges whether the disconnection task is successfully completed or not according to the second disconnection result;
if the second disconnection result is that the disconnection is successful, the first electronic equipment determines that the disconnection task is successfully completed;
and if the second disconnection result is disconnection failure, the first electronic equipment determines that the disconnection task fails.
17. The method of claim 11, further comprising:
the first electronic equipment acquires disconnection time of the disconnection task;
if the disconnection time exceeds a preset time threshold, the first electronic equipment sets a first event state to an initialization state, and acquires the second event state;
the first electronic equipment judges whether the second event state is a to-be-connected state;
and if the second event state is a to-be-connected state, the first electronic equipment executes a connection task with the second electronic equipment.
18. The method of claim 11, further comprising: the first electronic device obtains a first event state through a first flag, and the first flag is set in the first electronic device.
19. The method of claim 12, further comprising: and the first electronic equipment acquires a second event state through a second zone bit, and the second zone bit is arranged in the first electronic equipment.
20. The method of claim 11, wherein the disconnect trigger condition comprises: the first electronic device and the second electronic device are disconnected from adsorption, or the second electronic device is separated from the first electronic device through a connecting port, or the distance between the first electronic device and the second electronic device is larger than a preset distance threshold.
21. An electronic device, comprising: a memory and a processor, the processor and the memory coupled; wherein the memory includes program instructions that, when executed by the processor, cause the electronic device to perform the method of any of claims 1-20.
22. A computer-readable storage medium, having stored thereon computer program instructions, which, when executed, implement the method of any one of claims 1-20.
CN202210113163.5A 2022-01-30 2022-01-30 Electronic equipment connection method and electronic equipment Active CN114143906B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210113163.5A CN114143906B (en) 2022-01-30 2022-01-30 Electronic equipment connection method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210113163.5A CN114143906B (en) 2022-01-30 2022-01-30 Electronic equipment connection method and electronic equipment

Publications (2)

Publication Number Publication Date
CN114143906A CN114143906A (en) 2022-03-04
CN114143906B true CN114143906B (en) 2022-06-17

Family

ID=80381768

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210113163.5A Active CN114143906B (en) 2022-01-30 2022-01-30 Electronic equipment connection method and electronic equipment

Country Status (1)

Country Link
CN (1) CN114143906B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116701101A (en) * 2022-12-30 2023-09-05 荣耀终端有限公司 Abnormality detection method of SensorHUB and electronic equipment

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107079256A (en) * 2016-12-30 2017-08-18 深圳市大疆灵眸科技有限公司 Method and apparatus for automatic matching
EP3654540B1 (en) * 2017-08-31 2023-04-05 Huawei Technologies Co., Ltd. Pairing method, unpairing method, terminal device and externally-connected device
CN108966198A (en) * 2018-08-30 2018-12-07 Oppo广东移动通信有限公司 Method for connecting network, device, intelligent glasses and storage medium
CN111614524A (en) * 2019-02-26 2020-09-01 华为技术有限公司 Multi-intelligent-device linkage control method, device and system
CN111050199B (en) * 2019-11-19 2022-01-28 海信视像科技股份有限公司 Display device and scheduling method of Bluetooth communication resources of display device
CN113965895B (en) * 2021-12-16 2022-09-02 深圳市晨北科技有限公司 Bluetooth connection switching method, equipment and storage medium

Also Published As

Publication number Publication date
CN114143906A (en) 2022-03-04

Similar Documents

Publication Publication Date Title
CN110471639B (en) Display method and related device
CN113613238B (en) SIM module management method and electronic equipment
KR102152754B1 (en) Communication connecting method for bluetooth device and apparatus therefor
CN112399390B (en) Bluetooth connection method and related device
WO2022042656A1 (en) Interface display method, and device
CN110737493A (en) theme switching method and device
CN111464987B (en) Method for displaying Bluetooth device identification and electronic device
CN113961157B (en) Display interaction system, display method and equipment
CN114461239B (en) Software upgrading system and software upgrading method
WO2022068483A1 (en) Application startup method and apparatus, and electronic device
WO2022048500A1 (en) Display method, and device
CN112130788A (en) Content sharing method and device
CN112789934B (en) Bluetooth service query method and electronic equipment
WO2022156535A1 (en) Distributed application processing method and apparatus
CN114461240A (en) Software upgrading method, software upgrading system and electronic equipment
CN114143906B (en) Electronic equipment connection method and electronic equipment
CN111132047A (en) Network connection method and device
CN114201738B (en) Unlocking method and electronic equipment
WO2022206848A1 (en) Method and device for displaying application widget
CN114531741A (en) Method, device, equipment and storage medium for connecting external equipment and terminal
CN114816463A (en) Upgrade prompting method, terminal device and computer readable storage medium
WO2022052907A1 (en) Display method and electronic device
WO2024067170A1 (en) Device management method and electronic device
CN110764808B (en) Client upgrade detection method, device and computer readable storage medium
CN117289807A (en) Communication method, communication system and mouse

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant