Equipment connection method and device, electronic equipment and storage medium
By using broadcasting to send information on the channel where the device is located in wireless screen projection technology, and establishing a communication connection on the channel after receiving the connection request, the limitations of the existing technology relying on the Bluetooth module are solved, and rapid and applicable are achieved device connection.
Patent Information
- Application Number
- CN202310988074.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-07
- Publication Date
- 2025-02-14
AI Technical Summary
The existing wireless screen projection technology relies on Bluetooth modules and cannot establish a communication connection when the device does not have a Bluetooth module or Bluetooth is turned off, which has limitations.
Information on the channel where the device is located is transmitted through broadcast, communication connection is established on the channel after receiving the connection request, and wireless fidelity peripheral perception is performed using WiFi Aware protocol.
It realizes the rapid establishment of communication connections between devices without relying on Bluetooth modules, and improves connection speed and applicability.
Smart Images

Figure CN119450801A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of communication technology, and in particular to a device connection method, apparatus, electronic device and storage medium. Background Art
[0002] Wireless screen projection is to display the screen of one electronic device in "real time" on the screen of another electronic device through some technical method. Before screen projection, a communication connection needs to be established between the two electronic devices. In the related technology, two electronic devices establish a communication connection through Bluetooth, which depends on the Bluetooth module. When the electronic device does not have a Bluetooth module or the Bluetooth function is not turned on, the communication connection cannot be established, which has limitations. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a device connection method, an apparatus, an electronic device and a storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a device connection method is provided, which is performed by a first device, and the method includes:
[0005] Sending first information by broadcasting, where the first information includes information about a first channel occupied by the first device during communication;
[0006] A connection request is received from a second device, wherein the connection request is sent by the second device after the second device receives the first information, scans the first device on the first channel, and sends the first device through the first channel, and the connection request is used to request to establish a communication connection between the first device and the second device.
[0007] In some embodiments, the first information further includes service set identification information of the first device;
[0008] The connection request is sent through the first channel after the first device is scanned on the first channel when the service set identification information matches a preset service set identification condition.
[0009] In some embodiments, sending the first information by broadcasting includes:
[0010] In response to an instruction to start the screen projection function, the first information is sent via broadcasting at every first preset time interval.
[0011] In some embodiments, the method further comprises:
[0012] In response to the connection request, returning confirmation connection information to the second device;
[0013] Establishing a communication connection with the second device.
[0014] In some embodiments, sending the first information by broadcasting includes:
[0015] Based on the Wireless Fidelity Peripheral Awareness WiFi Aware protocol, the first information is sent through the broadcasting method.
[0016] In some embodiments, the first device and the second device belong to the same neighbor aware network cluster, and the neighbor aware network cluster includes at least one first device and at least one second device.
[0017] According to a second aspect of an embodiment of the present disclosure, a device connection method is provided, which is performed by a second device, and the method includes:
[0018] receiving first information, where the first information is sent by a first device in a broadcasting manner, and the first information includes information about a first channel occupied by the first device during communication;
[0019] In response to an instruction to start the screen projection function, scanning on the first channel;
[0020] A connection request is sent to the scanned first device, where the connection request is used to request to establish a communication connection between the first device and the second device.
[0021] In some embodiments, the receiving the first information includes:
[0022] Based on the Wireless Fidelity Peripheral Awareness WiFi Awareness protocol, enabling a preset service, wherein the preset service is to add the second device to the neighbor awareness network cluster where the first device is located;
[0023] Based on the preset service, the first information is received.
[0024] In some embodiments, the method further comprises:
[0025] Each time the first information is received, the first information is updated and stored.
[0026] In some embodiments, the method further comprises:
[0027] When the first information is not updated for more than a second preset time period, the stored first information is deleted.
[0028] In some embodiments, the number of the first devices is multiple, and the first information further includes service set identification information of the first devices;
[0029] When there are multiple first devices, the step of responding to the instruction to enable the screen projection function and scanning on the first channel includes:
[0030] In response to an instruction to start the screen projection function, selecting service set identification information that matches a preset service set identification condition from the stored service set identification information of the plurality of first devices;
[0031] Scanning is performed on a first channel where the first device corresponding to the selected service set identification information is located.
[0032] In some embodiments, the preset service set identification condition includes preset information, and the selecting service set identification information matching the preset service set identification condition from the stored service set identification information of the plurality of first devices includes at least one of the following:
[0033] Selecting, from a plurality of service set identification information of a plurality of first devices, service set identification information that is completely identical to the preset information;
[0034] Selecting service set identification information that is partially identical to the preset information from a plurality of service set identification information of a plurality of first devices.
[0035] In some embodiments, the method further comprises:
[0036] A condition setting interface is displayed, and the preset service set identification condition is set in the condition setting interface.
[0037] In some embodiments, after sending the connection request to the scanned first device, the method further includes:
[0038] When the connection confirmation information returned by the first device is received, a communication connection is established with the first device.
[0039] According to a third aspect of an embodiment of the present disclosure, there is provided a device connection apparatus, which is configured on a first device, and the apparatus includes:
[0040] an information sending module, configured to send first information by broadcasting, wherein the first information includes information about a first channel occupied by the first device during communication;
[0041] A connection request receiving module is configured to receive a connection request sent by a second device. The connection request is sent by the second device after the second device receives the first information, scans the first device on the first channel and sends it through the first channel. The connection request is used to request to establish a communication connection between the first device and the second device.
[0042] In some embodiments, the first information further includes service set identification information of the first device;
[0043] The connection request is sent through the first channel after the first device is scanned on the first channel when the service set identification information matches a preset service set identification condition.
[0044] In some embodiments, the information sending module is configured to:
[0045] In response to an instruction to start the screen projection function, the first information is sent via broadcasting at every first preset time interval.
[0046] In some embodiments, the apparatus further comprises:
[0047] a confirmation information sending module, configured to return confirmation connection information to the second device in response to the connection request;
[0048] The connection establishment module is configured to establish a communication connection with the second device.
[0049] In some embodiments, the information sending module is configured to:
[0050] Based on the Wireless Fidelity Peripheral Awareness WiFi Aware protocol, the first information is sent through the broadcasting method.
[0051] In some embodiments, the first device and the second device belong to the same neighbor aware network cluster, and the neighbor aware network cluster includes at least one first device and at least one second device.
[0052] According to a fourth aspect of an embodiment of the present disclosure, there is provided a device connection apparatus, which is configured on a second device, and the apparatus includes:
[0053] an information receiving module, configured to receive first information, where the first information is sent by a first device in a broadcast manner, and the first information includes information about a first channel occupied by the first device during communication;
[0054] a channel scanning module, configured to scan on the first channel in response to an instruction to start the screen projection function;
[0055] The connection request sending module is configured to send a connection request to the scanned first device, where the connection request is used to request to establish a communication connection between the first device and the second device.
[0056] In some embodiments, the information receiving module is configured to:
[0057] Based on the Wireless Fidelity Peripheral Awareness WiFi Awareness protocol, enabling a preset service, wherein the preset service is to add the second device to the neighbor awareness network cluster where the first device is located;
[0058] Based on the preset service, the first information is received.
[0059] In some embodiments, the apparatus further comprises:
[0060] The information storage module is configured to update and store the first information each time the first information is received.
[0061] In some embodiments, the apparatus further comprises:
[0062] The information deletion module is configured to delete the stored first information when the first information has not been updated for more than a second preset time period.
[0063] In some embodiments, the number of the first devices is multiple, and the first information further includes service set identification information of the first devices;
[0064] When the number of the first devices is multiple, the channel scanning module is configured as follows:
[0065] In response to an instruction to start the screen projection function, selecting service set identification information that matches a preset service set identification condition from the stored service set identification information of the plurality of first devices;
[0066] Scanning is performed on a first channel where the first device corresponding to the selected service set identification information is located.
[0067] In some embodiments, the preset service set identification condition includes preset information, and the channel scanning module is configured to perform at least one of the following:
[0068] Selecting, from a plurality of service set identification information of a plurality of first devices, service set identification information that is completely identical to the preset information;
[0069] Selecting service set identification information that is partially identical to the preset information from a plurality of service set identification information of a plurality of first devices.
[0070] In some embodiments, the apparatus further comprises:
[0071] The condition device module is configured to display a condition setting interface, and set the preset service set identification condition in the condition setting interface.
[0072] In some embodiments, the apparatus further comprises:
[0073] The connection establishing module is configured to establish a communication connection with the first device upon receiving the connection confirmation information returned by the first device.
[0074] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0075] processor;
[0076] a memory for storing processor-executable instructions;
[0077] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure, or the processor is configured to execute the method as described in the second aspect of the embodiment of the present disclosure.
[0078] According to the fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in the first aspect of the embodiment of the present disclosure, or the electronic device is enabled to execute the method described in the second aspect of the embodiment of the present disclosure.
[0079] The above method of the present disclosure has the following beneficial effects:
[0080] In the method provided by the embodiment of the present disclosure, when a communication connection needs to be established between a first device and a second device, the first device sends a first message by broadcasting, and the first message includes information about a first channel occupied by the first device during communication. After receiving the first message, the second device scans the first device on the first channel and sends a connection request through the first channel. The first device receives the connection request, thereby establishing a communication connection between the first device and the second device. When broadcasting the channel where the first device is located, it does not rely on a Bluetooth module and is more applicable, and the second device directly scans on the channel where the first device is located, which shortens the scanning time and increases the speed of establishing a communication connection between the first device and the second device.
[0081] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0083] Figure 1 is a schematic diagram of a screen projection system according to an exemplary embodiment;
[0084] Figure 2 is a schematic diagram of a neighbor awareness network cluster according to an exemplary embodiment;
[0085] Figure 3is a flow chart showing a device connection method according to an exemplary embodiment;
[0086] Figure 4 is a flow chart showing another device connection method according to an exemplary embodiment;
[0087] Figure 5 is a flow chart showing another device connection method according to an exemplary embodiment;
[0088] Figure 6 is a flow chart showing another device connection method according to an exemplary embodiment;
[0089] Figure 7 is a flow chart showing another device connection method according to an exemplary embodiment;
[0090] Figure 8 is a block diagram of a device connection apparatus according to an exemplary embodiment;
[0091] Fig. 9 is a block diagram of another device connection apparatus according to an exemplary embodiment;
[0092] Fig.10 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0093] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0094] Wireless screen projection, also known as wireless screen sharing, flying screen, and screen sharing, is a way to display the screen of mobile device A on the screen of another device B in real time through some technical methods. The content output by wireless screen projection includes various media information and real-time operation pictures.
[0095] In the related technology, when screen projection is needed, device B sends the information of the channel where device B is located through BLE (Bluetooth Low Energy) broadcasting, but this method needs to rely on the Bluetooth module. If there is no Bluetooth module on the device or Bluetooth is turned off, the information of the channel where the device is located cannot be sent. Alternatively, device B sends the information of the channel where device B is located through the LAN mDNS (Multicast Domain Name System) multicast method, but in this method, the WiFi (Wireless Fidelity) connected to device B and mobile device A needs to be connected to the same LAN before a communication connection can be established, and the application scenario has great limitations.
[0096] In response to the problems in the above-mentioned related technologies, an embodiment of the present disclosure provides a device connection method, in which a first device sends a first message by broadcasting, and the first message includes information about a first channel occupied by the first device during communication. After receiving the first message, the second device scans the first device on the first channel and sends a connection request through the first channel. The first device receives the connection request, thereby establishing a communication connection between the first device and the second device. This method of the embodiment of the present disclosure broadcasts the channel where the first device is located, avoiding the limitation of needing to establish a local area network connection, and does not rely on a Bluetooth module, which is more applicable, and the second device directly scans on the channel where the first device is located, shortening the scanning time and increasing the speed of establishing a communication connection between the first device and the second device.
[0097] Before introducing the device connection method, the screen projection system involved in the embodiment of the present disclosure is first described. Figure 1 The screen projection system includes a first device and a second device, the first device may also be referred to as a screen projection device GO (Group Owner), and the second device may also be referred to as a screen projection device GC (Group Client). The first device may be a mobile phone, tablet computer, notebook, computer or other device, and the second device may be a tablet computer, laptop computer, desktop computer, TV, TV box, all-in-one machine, projector or other device.
[0098] For an electronic device, in some scenarios, the electronic device can be used as a screen projection device GO, and in other scenarios, the electronic device can also be used as a screen projection device GC, that is, the screen projection device GO and the screen projection device GC are a role of the electronic device. For example, if the electronic device is a tablet computer, when the screen of the tablet computer is projected to the screen of a TV, the tablet computer is the screen projection device GC, and when the screen of a mobile phone is projected to the tablet computer, the tablet computer is the screen projection device GO.
[0099] Optionally, when the electronic device is used as a screen projection device GO, the electronic device can establish a communication connection with one or more screen projection devices GC. When the electronic device is used as a screen projection device GC, the electronic device can establish a communication connection with one screen projection device GO.
[0100] In some embodiments, the screen projection system may include multiple first devices and one second device. Figure 2 The projection system is a NAN (Neighbor Awareness Networking) cluster, which includes four NAN Devives (devices): TV, computer, TV box, mobile phone or tablet computer, where every two NAN Devives (except TV and TV box) can communicate with each other. Figure 2 In the example, the TV, computer, or TV box is the first device, and the mobile phone or tablet is the second device.
[0101] Below through Figure 3 and Figure 4 The illustrated embodiment describes the device connection process from the perspectives of the first device and the second device, respectively.
[0102] Figure 3 is a flowchart of a device connection method according to an exemplary embodiment, which is executed by a first device, see Figure 3 , the method comprises the following steps:
[0103] Step S301: Send first information by broadcasting, where the first information includes information about a first channel occupied by a first device during communication.
[0104] In the embodiment of the present disclosure, before the first device needs to establish a communication connection with other devices, the first device sends the first information by broadcasting, so that other devices can receive the first information. Sending the first information by broadcasting means sending the first information to other devices in the same network range as the first device, and the first device and other devices are connected to the same network.
[0105] The first information includes information about the first channel occupied by the first device during communication, that is, the first channel is a channel used by the first device to transmit information. The first information includes information about the first channel, and the first information is sent out by broadcasting, so that other devices can obtain the first information.
[0106] Step S302, receiving a connection request sent by the second device. The connection request is sent by the second device through the first channel after the second device receives the first information and scans the first device on the first channel. The connection request is used to request to establish a communication connection between the first device and the second device.
[0107] After receiving the first information, the second device obtains the first channel occupied by the first device from the first information. Then, when the second device needs to connect to the first device, it can quickly scan the first device on the first channel and send a connection request to the first device through the first channel. The connection request is used to request to establish a communication connection between the first device and the second device. The first device receives the connection request and can then establish a communication connection with the second device based on the connection request, thereby realizing device connection.
[0108] In the method provided by the embodiment of the present disclosure, when a communication connection needs to be established between a first device and a second device, the first device sends a first message by broadcasting, and the first message includes information about a first channel occupied by the first device during communication. After receiving the first message, the second device scans the first device on the first channel and sends a connection request through the first channel. The first device receives the connection request, thereby establishing a communication connection between the first device and the second device. When broadcasting the channel where the first device is located, the limitation of needing to establish a local area network is avoided, and it does not rely on a Bluetooth module, which is more applicable. The second device directly scans on the channel where the first device is located, which shortens the scanning time and increases the speed of establishing a communication connection between the first device and the second device.
[0109] Figure 4 is a flowchart of another device connection method according to an exemplary embodiment, which is executed by the second device. Figure 4 , the method comprises the following steps:
[0110] Step S401: receiving first information, where the first information is sent by a first device in a broadcasting manner, and the first information includes information about a first channel occupied by the first device during communication.
[0111] After the first device sends the first information in a broadcasting manner, the second device receives the first information, wherein the second device and the first device are connected to the same network.
[0112] Step S402, in response to an instruction to start the screen projection function, scanning is performed on the first channel.
[0113] For the second device, after receiving the first information, the second device can determine the first channel occupied by the first device. When the second device needs to project the screen, that is, the second device responds to the instruction to turn on the screen projection function, and scans on the first channel, thereby quickly scanning the first device. Among them, the instruction to turn on the screen projection function is used to indicate that the screen projection function has been turned on and needs to be connected to other devices for screen projection.
[0114] Step S403: Send a connection request to the scanned first device, where the connection request is used to request to establish a communication connection between the first device and the second device.
[0115] The second device sends a connection request to the first device through the first channel. The connection request is used to request to establish a communication connection between the first device and the second device. The first device receives the connection request and can then establish a communication connection with the second device based on the connection request, thereby realizing device connection.
[0116] In the method provided by the embodiment of the present disclosure, when a communication connection needs to be established between a first device and a second device, the first device sends a first message by broadcasting, and the first message includes information about a first channel occupied by the first device during communication. After receiving the first message, the second device scans the first device on the first channel and sends a connection request through the first channel. The first device receives the connection request, thereby establishing a communication connection between the first device and the second device. When broadcasting the channel where the first device is located, the limitation of needing to establish a local area network is avoided, and it does not rely on a Bluetooth module, which is more applicable. The second device directly scans on the channel where the first device is located, which shortens the scanning time and increases the speed of establishing a communication connection between the first device and the second device.
[0117] Figure 5 is a flowchart of another device connection method according to an exemplary embodiment, which is executed by a first device and a second device. Figure 5 , the method comprises the following steps:
[0118] Step S501, in response to an instruction to start the screen projection function, the first device sends first information by broadcasting based on the WiFi Aware protocol, where the first information includes information about a first channel occupied by the first device during communication.
[0119] In the disclosed embodiment, when the first device detects an instruction to turn on the screen projection function, it indicates that the first device can perform screen projection. Therefore, in response to the instruction to turn on the screen projection function, based on the WiFi Aware (Wireless Fidelity Peripheral Awareness) protocol, the first information is sent by broadcasting, so that other devices can receive the first information, thereby quickly discovering the first device. Among them, the instruction to turn on the screen projection function is used to indicate that the screen projection function has been turned on and needs to be connected to other devices for screen projection; the WiFi Aware protocol is a protocol that allows devices including WiFi modules to discover each other. Based on the WiFi Aware protocol, devices including WiFi modules can sense each other's existence, and even connect together to establish a short-range connection between devices to share information, and can transmit information, pictures, videos and other content to each other. The WiFi Aware protocol can send information by broadcasting.
[0120] In some embodiments, the first device is provided with a screen projection control, and in response to a user triggering operation on the screen projection control, an instruction to start the screen projection function is detected.
[0121] It should be noted that step S501 is explained by taking the sending of the first information once as an example. In another embodiment, the first device responds to the instruction to turn on the screen projection function, and based on the WiFi Aware protocol, sends the first information by broadcasting at intervals of a first preset duration. The first preset duration is a pre-set duration, for example, the first preset duration is 5 minutes, 10 minutes or other durations. This method of sending the first information once at intervals of the first preset duration can increase the possibility of other devices receiving the first information, and is conducive to other devices obtaining the latest first information of the first device. That is to say, in the process of the first device sending the first information, the first channel where the first device is located may change. In this case, the first information is sent once at intervals of the first preset duration, and the information of the changed first channel can be sent out in time, so that other devices can obtain accurate channel information in time, avoiding other devices from scanning on the wrong channel later.
[0122] Another point that needs to be explained is that step S501 is to send the first information in response to an instruction to turn on the screen projection function. In another embodiment, the first information can be sent directly by broadcasting based on the WiFi Aware protocol without having to be sent when an instruction to turn on the screen projection function is detected.
[0123] Step S502: The second device enables a preset service based on the WiFi Aware protocol, and receives first information based on the preset service.
[0124] In the disclosed embodiment, the first device sends the first information based on the WiFi Aware protocol, and correspondingly, the second device also receives the first information based on the WiFi Aware protocol. In order to receive the first information, the second device first enables a preset service based on the WiFi Aware protocol, that is, subscribes to the preset service. The preset service is to add the second device to the NAN cluster where the first device is located. After starting the preset service, the second device adds the first device to the NAN cluster where the first device is located. Devices in the same NAN cluster can receive the sent information from each other. Therefore, the second device can receive the first information based on the preset service.
[0125] It should be noted that the first device and the second device belong to the same NAN cluster, which includes at least one first device and at least one second device, that is, the NAN cluster may include multiple devices. In the embodiment of the present disclosure, there is no limit on the number of devices in the NAN cluster.
[0126] Step S503: the second device stores the first information.
[0127] After receiving the first information, the second device stores the first information so that when the second device needs to connect to the first device, it can obtain the first channel where the first device is located from the stored first information, thereby quickly scanning the first device on the first channel to increase the scanning speed.
[0128] In some embodiments, before the second device stores the first information, if the second device already stores the first information of the first device, the first information is updated and stored. Updating and storing the first information means replacing the first information stored by the second device with the latest received first information. This method of updating the first information in real time can ensure that the first information stored by the second device is the latest information, avoid the problem that the first information sent by the first device has changed, while the second device is still scanning based on the original first information, which is conducive to more accurate scanning by the second device.
[0129] Optionally, after receiving the first information, the second device parses the first information, obtains information about the first channel in the first information, and stores the information about the first channel.
[0130] Optionally, the second device stores the first information or the information of the first channel in a local database of the second device.
[0131] In some embodiments, when the first information is not updated for more than a second preset time, the stored first information is deleted. The second preset time is a pre-set time, for example, the second preset time is 30 minutes, 1 hour, 2 hours or other time. When the first information is not updated for more than the second preset time, it means that the first device may no longer support establishing a communication connection with other devices. At this time, if scanning is still performed based on the first information, there is a high probability that the first device cannot be scanned. Therefore, the stored first information is deleted to ensure the validity of the information, avoid useless scanning, and save scanning time.
[0132] It should be noted that steps S502 and S503 are described by taking the process of receiving and storing the first information once as an example. In another embodiment, the second device updates and stores the first information each time it receives the first information.
[0133] Step S504: The second device scans on the first channel in response to an instruction to start the screen projection function.
[0134] For the second device, after receiving the first information, the second device can determine the first channel occupied by the first device. When the second device needs to project the screen, that is, the second device responds to the instruction to turn on the projection function, and scans on the first channel, thereby quickly scanning the first device. Among them, the instruction to turn on the projection function is used to indicate that the projection function has been turned on and needs to be connected to other devices for projection. When the second device turns on the projection function, the screen of the second device is displayed on the screen of the other device in real time.
[0135] In some embodiments, after the second device scans the first device on the first channel, the first device returns a scan reply frame to the second device, where the reply frame is used to indicate that the second device has scanned the first device.
[0136] Optionally, the second device performs a P2P (point-to-point wireless connection) scan on the first channel.
[0137] Step S505: The second device sends a connection request to the scanned first device.
[0138] The second device scans on the first channel and may scan the first device. After scanning the first device, the second device sends a connection request to the first device, where the connection request is used to request to establish a communication connection between the first device and the second device.
[0139] Step S506: The first device receives the connection request sent by the second device, and returns connection confirmation information to the second device in response to the connection request.
[0140] After receiving the connection request, if the first device determines that it can establish a communication connection with the second device, it returns confirmation connection information to the second device and establishes a communication connection with the second device. The confirmation connection information is used to indicate that the second device can establish a communication connection with the first device.
[0141] It should be noted that the embodiment of the present disclosure is explained by taking the example of the first device returning confirmation connection information to the second device. In another embodiment, if the first device cannot establish a communication connection with the second device, a rejection connection information is returned to the second device. The rejection connection information is used to indicate that the second device cannot establish a communication connection with the first device.
[0142] Step S507: When the second device receives the connection confirmation information returned by the first device, the second device establishes a communication connection with the first device.
[0143] When the second device receives the connection confirmation information returned by the first device, it determines that the first device can establish a communication connection with the second device, and therefore starts to establish a communication connection with the first device until the communication connection is established.
[0144] In some embodiments, a P2P connection is established between the first device and the second device.
[0145] It should be noted that after the first device establishes a communication connection with the second device, the first device and the second device perform screen projection, that is, the second device projects the displayed image to the screen of the first device in real time for display. The specific process of screen projection is not repeated here.
[0146] According to the method provided by the embodiment of the present disclosure, when a communication connection needs to be established between a first device and a second device, the first device sends first information by broadcasting based on the WiFi Aware protocol, the first information including information of a first channel occupied by the first device during communication, after receiving the first information, the second device scans the first device on the first channel and sends a connection request through the first channel, the first device receives the connection request, and thus a communication connection is established between the first device and the second device. Broadcasting the channel where the first device is located based on the WiFi Aware protocol is more applicable, and the second device directly scans on the channel where the first device is located without scanning on all channels, thereby shortening the scanning time and improving the speed of establishing a communication connection between the first device and the second device.
[0147] In addition, the second device stores the first information sent by the first device. When the second device needs to connect to other devices, it can obtain the first channel where the first device is located from the stored first information, thereby quickly scanning the first device on the first channel to improve the scanning speed.
[0148] Figure 6 is a flowchart of another device connection method according to an exemplary embodiment, which is executed by a first device and a second device. Figure 6 , the method comprises the following steps:
[0149] In step S601, in response to an instruction to start the screen projection function, the first device sends first information by broadcasting based on the WiFi Aware protocol. The first information includes information about the first channel occupied by the first device during communication and the SSID information of the first device.
[0150] The difference between step S601 and the above step S501 is that in step S601, the first information also includes SSID (Service Set Identifier) information of the first device, and the SSID information is used to characterize the network to which the first device is connected. For example, the SSID is the name of the wireless hotspot to which the first device is connected.
[0151] Step S602: The second device enables a preset service based on the WiFi Aware protocol, and receives first information based on the preset service.
[0152] Step S603: the second device stores the first information.
[0153] The implementation of steps S602 and S603 refers to the above steps S502 and S503, which will not be described in detail here.
[0154] It should be noted that in step S603, when storing the first information, not only the information of the first channel occupied by the first device during communication is stored, but also the SSID information of the first device is stored. Optionally, after receiving the first information, the second device parses the first information, obtains the information of the first channel and the SSID information in the first information, and stores the information of the first channel and the SSID information.
[0155] Step S604: When there are multiple first devices, the second device responds to an instruction to start the screen projection function and selects SSID information that matches the preset SSID condition from the SSID information of multiple stored first devices.
[0156] In the disclosed embodiment, there are multiple first devices, and the multiple first devices respectively send first information by broadcasting based on the WiFi Aware protocol. In this case, the second device can receive the first information sent by the multiple first devices. When the second device detects an instruction to turn on the screen projection function, it can scan the first channel where each first device in the multiple first devices is located.
[0157] In order to reduce the number of channels to be scanned, at least one first channel is selected from multiple first channels for scanning using SSID information. Specifically, the second device is provided with a preset SSID condition, and SSID information matching the preset SSID condition is selected from the stored SSID information of multiple first devices. The preset SSID condition is used to characterize the SSID information of the device that the user expects to scan.
[0158] In some embodiments, the preset SSID condition includes preset information, and selecting SSID information matching the preset SSID condition from the stored SSID information of multiple first devices includes at least one of the following: selecting SSID information that is completely identical to the preset information from multiple SSID information of multiple first devices; selecting SSID information that is partially identical to the preset information from multiple SSID information of multiple first devices. For example, the preset information is a preset SSID, and the SSID information that is completely identical to the preset information means that the preset SSID is consistent with the SSID of the first device, and the SSID information that is partially identical to the preset information means that the preset SSID is partially identical to the SSID of the first device.
[0159] In some embodiments, a condition setting interface is displayed, and a preset SSID condition is set in the condition setting interface. For example, a condition setting area is displayed in the condition setting interface, and the user enters a preset SSID in the condition setting area as the preset SSID condition.
[0160] Step S605: The second device scans on the first channel where the first device corresponding to the selected SSID information is located.
[0161] The SSID information selected by the second device may be one or more. When the selected SSID information is one, scanning is performed on the first channel where the first device corresponding to the SSID information is located, and the scanned device is the first device corresponding to the SSID information; when multiple SSID information is selected, scanning is performed on the first information where the first devices corresponding to the multiple SSID information are located in sequence until the first device corresponding to any of the multiple SSID information is scanned.
[0162] Step S606: The second device sends a connection request to the scanned first device.
[0163] Step S607: The first device receives the connection request sent by the second device, and returns connection confirmation information to the second device in response to the connection request.
[0164] Step S608: When the second device receives the connection confirmation information returned by the first device, the second device establishes a communication connection with the first device.
[0165] The implementation of steps S606-S608 refers to the above steps S505-S507, which will not be repeated here.
[0166] It should be noted that in Figure 6 In the illustrated embodiment, only the example of a plurality of first devices is used for illustration. In another embodiment, even if the number of the first device is one, it is possible to determine whether the SSID information of the first device matches the preset SSID condition, that is, when the SSID information of the second device matches the preset SSID condition, the second device scans the first device on the first channel and sends a connection request through the first channel. When the SSID information of the second device does not match the preset SSID condition, the second device no longer performs scanning.
[0167] According to the method provided by the embodiment of the present disclosure, when a communication connection needs to be established between a first device and a second device, the first device sends first information by broadcasting based on the WiFi Aware protocol, the first information including information of a first channel occupied by the first device during communication, after receiving the first information, the second device scans the first device on the first channel and sends a connection request through the first channel, the first device receives the connection request, and thus a communication connection is established between the first device and the second device. Broadcasting the channel where the first device is located based on the WiFi Aware protocol is more applicable, and the second device directly scans on the channel where the first device is located without scanning on all channels, thereby shortening the scanning time and improving the speed of establishing a communication connection between the first device and the second device.
[0168] Furthermore, by setting a preset SSID condition, the second device can select a first device that meets the preset SSID condition from multiple first devices, thereby scanning on the channel where the first device that meets the preset SSID condition is located, reducing the number of scanned channels and further improving the scanning speed.
[0169] One thing that needs to be explained is that in the above embodiment, the first device is used as the screen projection device GO and the second device is used as the screen projection device GC. In another embodiment, the first device can be used as the screen projection device GC and the second device can be used as the screen projection device GO, that is, the first device can execute the steps executed by the above second device, and the second device can execute the steps executed by the above first device.
[0170] That is, the second device sends the second information by broadcasting based on the WiFi Aware protocol, and the second information includes the information of the second channel occupied by the second device during the communication process. The first device receives the first information, and in response to the quality of turning on the screen projection function, scans on the second channel and sends a connection request to the scanned second device. The second device receives the connection request sent by the first device, and the first device and the second device are connected in communication. For the specific implementation method, please refer to the above embodiment and will not be repeated here.
[0171] Figure 7 is a flowchart of another device connection method according to an exemplary embodiment, which is executed by the screen projection device GO and the screen projection device GC, see Figure 7 , the method comprises the following steps:
[0172] Step S701, the screen projection device GO regularly broadcasts the channel and SSID information of the screen projection device GO through WiFi Aware.
[0173] Among them, regular broadcasting is broadcasting according to a preset period.
[0174] Step S702, the screen projection device GC subscribes to the preset service through WiFi Aware and receives the broadcast message of the screen projection device GO.
[0175] The broadcast message is the above-mentioned first information.
[0176] Step S703, the screen projection device GC saves the channel and SSID information of the screen projection device GO.
[0177] Step S704, the screen projection device GC defines a second preset duration, regularly detects the saved channel and SSID information of the screen projection device GO, and removes the channel and SSID information that has not been updated for more than the second preset duration.
[0178] Step S705, the projection device GC saves the set preset SSID conditions.
[0179] Step S706: The projection device GC selects a matching channel from the saved channels and SSID information according to the preset SSID conditions, and initiates a P2P scan on the matching channel.
[0180] Step S707, the screen projection device GC receives the reply frame sent by the screen projection device GO, determines that the screen projection device GO is scanned, and then initiates a connection request and starts to establish a P2P connection. After the P2P connection is established, the screen projection is performed.
[0181] Figure 7 The implementation of the embodiment shown is described above. Figure 5 and Figure 6, I will not go into details here.
[0182] Figure 8 is a block diagram of a device connection apparatus according to an exemplary embodiment, which is configured in a first device, see Figure 8 , the device comprises:
[0183] The information sending module 801 is configured to send first information by broadcasting, where the first information includes information about a first channel occupied by a first device during communication;
[0184] The connection request receiving module 802 is configured to receive a connection request sent by the second device. The connection request is sent by the second device after the second device receives the first information, scans the first device on the first channel and sends it through the first channel. The connection request is used to request to establish a communication connection between the first device and the second device.
[0185] In the apparatus provided by the embodiment of the present disclosure, when a communication connection needs to be established between a first device and a second device, the first device sends a first message by broadcasting, and the first message includes information about a first channel occupied by the first device during communication. After receiving the first message, the second device scans the first device on the first channel and sends a connection request through the first channel. The first device receives the connection request, thereby establishing a communication connection between the first device and the second device. When broadcasting the channel where the first device is located, the limitation of needing to establish a local area network is avoided, and it does not rely on a Bluetooth module, which is more applicable. The second device directly scans on the channel where the first device is located, which shortens the scanning time and increases the speed of establishing a communication connection between the first device and the second device.
[0186] In some embodiments, the first information further includes service set identification information of the first device;
[0187] The connection request is to scan the first device on the first channel and send it through the first channel when the service set identification information matches the preset service set identification condition.
[0188] In some embodiments, the information sending module 801 is configured to:
[0189] In response to an instruction to start the screen projection function, first information is sent via broadcasting at every first preset time interval.
[0190] In some embodiments, the apparatus further comprises:
[0191] a confirmation information sending module, configured to return confirmation connection information to the second device in response to the connection request;
[0192] The connection establishment module is configured to establish a communication connection with the second device.
[0193] In some embodiments, the information sending module 801 is configured to:
[0194] Based on the Wireless Fidelity Peripheral Awareness WiFi Aware protocol, the first information is sent through the broadcasting method.
[0195] In some embodiments, the first device and the second device belong to the same neighbor awareness network cluster, and the neighbor awareness network cluster includes at least one first device and at least one second device.
[0196] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0197] Fig. 9 is a block diagram of another device connection apparatus according to an exemplary embodiment, which is configured in a second device, see Fig. 9 , the device comprises:
[0198] The information receiving module 901 is configured to receive first information, where the first information is sent by a first device in a broadcast manner, and the first information includes information about a first channel occupied by the first device during communication;
[0199] The channel scanning module 902 is configured to scan on the first channel in response to an instruction to start the screen projection function;
[0200] The connection request sending module 903 is configured to send a connection request to the scanned first device, where the connection request is used to request to establish a communication connection between the first device and the second device.
[0201] In the apparatus provided by the embodiment of the present disclosure, when a communication connection needs to be established between a first device and a second device, the first device sends a first message by broadcasting, and the first message includes information about a first channel occupied by the first device during communication. After receiving the first message, the second device scans the first device on the first channel and sends a connection request through the first channel. The first device receives the connection request, thereby establishing a communication connection between the first device and the second device. When broadcasting the channel where the first device is located, it does not rely on a Bluetooth module and is more applicable, and the second device directly scans on the channel where the first device is located, which shortens the scanning time and increases the speed of establishing a communication connection between the first device and the second device.
[0202] In some embodiments, the information receiving module 901 is configured to:
[0203] Based on the wireless fidelity surrounding awareness WiFi Aware protocol, enabling a preset service, the preset service is to add the second device to the neighbor awareness network cluster where the first device is located;
[0204] Based on a preset service, first information is received.
[0205] In some embodiments, the apparatus further comprises:
[0206] The information storage module is configured to update and store the first information each time the first information is received.
[0207] In some embodiments, the apparatus further comprises:
[0208] The information deletion module is configured to delete the stored first information when the first information has not been updated for more than a second preset time period.
[0209] In some embodiments, the number of the first devices is multiple, and the first information further includes service set identification information of the first devices;
[0210] When there are multiple first devices, the channel scanning module 902 is configured as follows:
[0211] In response to an instruction to start the screen projection function, selecting service set identification information that matches a preset service set identification condition from the service set identification information of the plurality of first devices stored;
[0212] Scanning is performed on a first channel where a first device corresponding to the selected service set identification information is located.
[0213] In some embodiments, the preset service set identification condition includes preset information, and the channel scanning module 902 is configured to perform at least one of the following:
[0214] Selecting, from a plurality of service set identification information of a plurality of first devices, service set identification information that is completely identical to the preset information;
[0215] The service set identification information which is identical to the preset information is selected from the plurality of service set identification information of the plurality of first devices.
[0216] In some embodiments, the apparatus further comprises:
[0217] The conditional device module is configured to display a conditional setting interface and set a preset service set identification condition in the conditional setting interface.
[0218] In some embodiments, the apparatus further comprises:
[0219] The connection establishing module is configured to establish a communication connection with the first device upon receiving the connection confirmation information returned by the first device.
[0220] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0221] An embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the device connection method in the above embodiment.
[0222] Fig.10 is a block diagram of an electronic device 1000 according to an exemplary embodiment.
[0223] Reference Fig.10 , the electronic device 1000 may include one or more of the following components: a processing component 1002 , a memory 1004 , a power component 1006 , a multimedia component 1008 , an audio component 1010 , an input / output (I / O) interface 1012 , a sensor component 1014 , and a communication component 1016 .
[0224] The processing component 1002 generally controls the overall operation of the electronic device 1000, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1002 may include one or more processors 1020 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1002 may include one or more modules to facilitate the interaction between the processing component 1002 and other components. For example, the processing component 1002 may include a multimedia module to facilitate the interaction between the multimedia component 1008 and the processing component 1002.
[0225] The memory 1004 is configured to store various types of data to support operations on the electronic device 1000. Examples of such data include instructions for any application or method operating on the electronic device 1000, contact data, phone book data, messages, pictures, videos, etc. The memory 1004 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0226] The power supply component 1006 provides power to various components of the electronic device 1000. The power supply component 1006 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1000.
[0227] The multimedia component 1008 includes a screen that provides an output interface between the electronic device 1000 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1008 includes a front camera and / or a rear camera. When the electronic device 1000 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0228] The audio component 1010 is configured to output and / or input audio signals. For example, the audio component 1010 includes a microphone (MIC), and when the electronic device 1000 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1004 or sent via the communication component 1016. In some embodiments, the audio component 1010 also includes a speaker for outputting audio signals.
[0229] I / O interface 1012 provides an interface between processing component 1002 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0230] The sensor assembly 1014 includes one or more sensors for providing various aspects of status assessment for the electronic device 1000. For example, the sensor assembly 1014 can detect the open / closed state of the electronic device 1000, the relative positioning of components, such as the display and keypad of the electronic device 1000, and the sensor assembly 1014 can also detect the position change of the electronic device 1000 or a component of the electronic device 1000, the presence or absence of user contact with the electronic device 1000, the orientation or acceleration / deceleration of the electronic device 1000, and the temperature change of the electronic device 1000. The sensor assembly 1014 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 1014 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1014 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0231] The communication component 1016 is configured to facilitate wired or wireless communication between the electronic device 1000 and other devices. The electronic device 1000 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1016 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1016 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0232] In an exemplary embodiment, the electronic device 1000 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0233] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1004 including instructions, and the instructions can be executed by the processor 1020 of the electronic device 1000 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0234] The embodiments of the present disclosure also provide a non-temporary computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the device connection method in the above embodiments.
[0235] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this disclosure. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0236] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A device connection method, characterized in that: Executed by a first device, the method includes: Sending first information by broadcasting, where the first information includes information about a first channel occupied by the first device during communication; A connection request is received from a second device, wherein the connection request is sent by the second device after the second device receives the first information, scans the first device on the first channel, and sends the first device through the first channel, and the connection request is used to request to establish a communication connection between the first device and the second device.
2. The method according to claim 1, characterized in that The first information also includes service set identification information of the first device; The connection request is sent through the first channel after the first device is scanned on the first channel when the service set identification information matches a preset service set identification condition.
3. The method according to claim 1, characterized in that The sending of the first information by broadcasting includes: In response to an instruction to start the screen projection function, the first information is sent via broadcasting at every first preset time interval.
4. The method according to claim 1, characterized in that: The method further comprises: In response to the connection request, returning confirmation connection information to the second device; Establishing a communication connection with the second device.
5. The method according to claim 1, characterized in that The sending of the first information by broadcasting includes: Based on the Wireless Fidelity Peripheral Awareness WiFi Aware protocol, the first information is sent through the broadcasting method.
6. The method according to claim 1, characterized in that The first device and the second device belong to the same neighbor awareness network cluster, and the neighbor awareness network cluster includes at least one first device and at least one second device.
7. A device connection method, characterized in that: Executed by a second device, the method includes: receiving first information, where the first information is sent by a first device in a broadcasting manner, and the first information includes information about a first channel occupied by the first device during communication; In response to an instruction to start the screen projection function, scanning on the first channel; A connection request is sent to the scanned first device, where the connection request is used to request to establish a communication connection between the first device and the second device.
8. The method according to claim 7, characterized in that The receiving of the first information comprises: Based on the Wireless Fidelity Peripheral Awareness WiFi Awareness protocol, enabling a preset service, wherein the preset service is to add the second device to the neighbor awareness network cluster where the first device is located; Based on the preset service, the first information is received.
9. The method according to claim 7, characterized in that: The method further comprises: Each time the first information is received, the first information is updated and stored.
10. The method according to claim 9, characterized in that The method further comprises: When the first information is not updated for more than a second preset time period, the stored first information is deleted.
11. The method according to claim 9, characterized in that There is a plurality of first devices, and the first information further includes service set identification information of the first devices; When there are multiple first devices, the step of responding to the instruction to enable the screen projection function and scanning on the first channel includes: In response to an instruction to start the screen projection function, selecting service set identification information that matches a preset service set identification condition from the stored service set identification information of the plurality of first devices; Scanning is performed on a first channel where the first device corresponding to the selected service set identification information is located.
12. The method according to claim 11, characterized in that The preset service set identification condition includes preset information, and the selecting, from the stored service set identification information of the plurality of first devices, service set identification information matching the preset service set identification condition includes at least one of the following: Selecting, from a plurality of service set identification information of a plurality of first devices, service set identification information that is completely identical to the preset information; Selecting service set identification information that is partially identical to the preset information from a plurality of service set identification information of a plurality of first devices.
13. The method according to claim 11, characterized in that The method further comprises: A condition setting interface is displayed, and the preset service set identification condition is set in the condition setting interface.
14. The method according to any one of claims 7 to 13, characterized in that: After sending the connection request to the scanned first device, the method further includes: When the connection confirmation information returned by the first device is received, a communication connection is established with the first device.
15. A device connection device, characterized in that: Configured in a first device, the apparatus comprises: an information sending module, configured to send first information by broadcasting, wherein the first information includes information about a first channel occupied by the first device during communication; A connection request receiving module is configured to receive a connection request sent by a second device. The connection request is sent by the second device after the second device receives the first information, scans the first device on the first channel and sends it through the first channel. The connection request is used to request to establish a communication connection between the first device and the second device.
16. A device connection device, characterized in that: The device is configured in a second device, and includes: an information receiving module, configured to receive first information, where the first information is sent by a first device in a broadcast manner, and the first information includes information about a first channel occupied by the first device during communication; a channel scanning module, configured to scan on the first channel in response to an instruction to start the screen projection function; The connection request sending module is configured to send a connection request to the scanned first device, where the connection request is used to request to establish a communication connection between the first device and the second device.
17. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 6, or the processor is configured to execute the method according to any one of claims 7 to 14.
18. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as described in any one of claims 1 to 6, or the electronic device is enabled to execute the method as described in any one of claims 7 to 14.