Search

US-12628212-B2 - Neighborhood aware network-based device connection method and device

US12628212B2US 12628212 B2US12628212 B2US 12628212B2US-12628212-B2

Abstract

This application provides network-based device connection methods and devices. One method includes: receiving a first broadcast message from a second device and a second broadcast message from a third device, in response to determining that a quantity of available Wi-Fi connections of the second device is not greater than zero, and the second device is not connected to the first device through Wi-Fi, determining, based on connected device information of the second device and available Wi-Fi connection information of the third device, that the third device is connected to the second device through Wi-Fi and that a quantity of available Wi-Fi connections of the third device is greater than zero, and establishing a Wi-Fi link between the first device and the third device for the third device to forward the first packet received from the first device to the second device through a Wi-Fi link between the third device and the second device.

Inventors

  • Chao Yang
  • Zhongyin Jiang
  • Bo Ling
  • Keyang Yin

Assignees

  • HUAWEI TECHNOLOGIES CO., LTD.

Dates

Publication Date
20260512
Application Date
20210312
Priority Date
20200430

Claims (20)

  1. 1 . A method performed by a first device comprising: receiving a first broadcast message from a second device, wherein the first broadcast message comprises connected device information of the second device and Wi-Fi connection information of the second device, and the connected device information indicates a device to which the second device is connected through Wi-Fi; receiving a second broadcast message from a third device, wherein the second broadcast message comprises Wi-Fi connection information of the third device, and wherein the first and second broadcast messages are received over a Wi-Fi Neighbor Awareness Networking (NAN) protocol; determining that the second device is a target device; in response to determining that a quantity of available Wi-Fi connections of the second device is not greater than zero, and the second device is not a device to which the first device is connected through Wi-Fi, determining, without an involvement of any centralized coordination device and based on the connected device information of the second device and available Wi-Fi connection information of the third device, that the third device belongs to the device to which the second device is connected through Wi-Fi and that a quantity of available Wi-Fi connections of the third device is greater than zero, wherein the quantity of available Wi-Fi connections of the second device is determined based on the Wi-Fi connection information of the second device; sending a Wi-Fi link establishment request to the third device to establish a Wi-Fi link between the first device and the third device; and sending, to the third device through the Wi-Fi link between the first device and the third device, a first packet for the third device to forward to the second device through a Wi-Fi link between the third device and the second device.
  2. 2 . The method according to claim 1 , wherein the method further comprises: in response to determining that the quantity of available Wi-Fi connections of the second device is greater than zero, and the second device is not the device to which the first device is connected through Wi-Fi, sending a Wi-Fi link establishment request to the second device to establish a Wi-Fi link between the first device and the second device.
  3. 3 . The method according to claim 1 , wherein the first broadcast message further comprises a first service identifier indicating a service that can be provided by the second device; and the determining that the second device is the target device comprises: searching a local service interest list for a service identifier corresponding to the first service identifier, wherein the local service interest list comprises at least one service identifier indicating at least one service required by the first device; and in response to identifying the service identifier corresponding to the first service identifier in the local service interest list, determining that the second device is the target device.
  4. 4 . The method according to claim 1 , wherein the first broadcast message further comprises identifier information of the second device; and the determining that the second device is the target device comprises: displaying a first interface, wherein the first interface comprises a first function area corresponding to the identifier information; and in response to an operation for the first function area, determining that the second device is the target device.
  5. 5 . The method according to claim 1 , wherein the Wi-Fi connection information of the second device comprises a maximum quantity of Wi-Fi connections of the second device or the quantity of available Wi-Fi connections of the second device, wherein when the Wi-Fi connection information of the second device comprises the maximum quantity of Wi-Fi connections of the second device, the quantity of available Wi-Fi connections of the second device is determined based on the maximum quantity of Wi-Fi connections of the second device and the connected device information of the second device.
  6. 6 . The method according to claim 1 , wherein the Wi-Fi connection information of the third device comprises a maximum quantity of Wi-Fi connections of the third device or the quantity of available Wi-Fi connections of the third device, wherein when the Wi-Fi connection information of the third device comprises the maximum quantity of Wi-Fi connections of the third device, the second broadcast message further comprises connected device information of the third device, and the quantity of available Wi-Fi connections of the third device is determined based on the maximum quantity of Wi-Fi connections of the third device and the connected device information of the third device.
  7. 7 . The method according to claim 1 , wherein the connected device information of the second device comprises a MAC address of the device to which the second device is connected through Wi-Fi.
  8. 8 . The method according to claim 1 , wherein at least one of the first broadcast message or the second broadcast message belongs to a Bluetooth broadcast frame.
  9. 9 . An electronic device that comprises at least one processor and a memory, wherein the memory stores computer instructions for execution by the at least one processor to perform operations comprising: receiving a first broadcast message from a second device, wherein the first broadcast message comprises connected device information of the second device and Wi-Fi connection information of the second device, and the connected device information is used to represent a device to which the second device is connected through Wi-Fi; receiving a second broadcast message from a third device, wherein the second broadcast message comprises Wi-Fi connection information of the third device, and wherein the first and second broadcast messages are received over a Wi-Fi Neighbor Awareness Networking (NAN) protocol; determining that the second device is a target device; in response to determining that a quantity of available Wi-Fi connections of the second device is not greater than zero, and the second device is not a device to which the electronic device is connected through Wi-Fi, determining, without an involvement of any centralized coordination device and based on the connected device information of the second device and available Wi-Fi connection information of the third device, that the third device belongs to the device to which the second device is connected through Wi-Fi and that a quantity of available Wi-Fi connections of the third device is greater than zero, wherein the quantity of available Wi-Fi connections of the second device is determined based on the Wi-Fi connection information of the second device; sending a Wi-Fi link establishment request to the third device to establish a Wi-Fi link between the electronic device and the third device; and sending, to the third device through the Wi-Fi link between the electronic device and the third device, a first packet for the third device to forward to the second device through a Wi-Fi link between the third device and the second device.
  10. 10 . The electronic device according to claim 9 , wherein the operations further comprising: in response to determining that the quantity of available Wi-Fi connections of the second device is greater than zero, and the second device is not the device to which the electronic device is connected through Wi-Fi, sending a Wi-Fi link establishment request to the second device to establish a Wi-Fi link between the electronic device and the second device.
  11. 11 . The electronic device according to claim 9 , wherein the first broadcast message further comprises a first service identifier indicating a service that can be provided by the second device; and the operations further comprising: searching a local service interest list for a service identifier corresponding to the first service identifier, wherein the local service interest list comprises at least one service identifier indicating at least one service required by the electronic device; and in response to identifying the service identifier corresponding to the first service identifier in the local service interest list, determining that the second device is the target device.
  12. 12 . The electronic device according to claim 9 , wherein the first broadcast message further comprises identifier information of the second device; and the operations further comprising: displaying a first interface, wherein the first interface comprises a first function area corresponding to the identifier information; and in response to an operation for the first function area, determining that the second device is the target device.
  13. 13 . The electronic device according to claim 9 , wherein the Wi-Fi connection information of the second device comprises a maximum quantity of Wi-Fi connections of the second device or the quantity of available Wi-Fi connections of the second device, wherein when the Wi-Fi connection information of the second device comprises the maximum quantity of Wi-Fi connections of the second device, the quantity of available Wi-Fi connections of the second device is determined based on the maximum quantity of Wi-Fi connections of the second device and the connected device information of the second device.
  14. 14 . The electronic device according to claim 9 , wherein the Wi-Fi connection information of the third device comprises a maximum quantity of Wi-Fi connections of the third device or the quantity of available Wi-Fi connections of the third device, wherein when the Wi-Fi connection information of the third device comprises the maximum quantity of Wi-Fi connections of the third device, the second broadcast message further comprises connected device information of the third device, and the quantity of available Wi-Fi connections of the third device is determined based on the maximum quantity of Wi-Fi connections of the third device and the connected device information of the third device.
  15. 15 . The electronic device according to claim 9 , wherein the connected device information of the second device comprises a MAC address of the device to which the second device is connected through Wi-Fi.
  16. 16 . The electronic device according to claim 9 , wherein at least one of the first broadcast message or the second broadcast message belongs to a Bluetooth broadcast frame.
  17. 17 . A non-transitory computer readable medium storing computer instructions executable by at least one processor of an electronic device to perform operations comprising: receiving a first broadcast message from a second device, wherein the first broadcast message comprises connected device information of the second device and Wi-Fi connection information of the second device, and the connected device information is used to represent a device to which the second device is connected through Wi-Fi; receiving a second broadcast message from a third device, wherein the second broadcast message comprises Wi-Fi connection information of the third device, and wherein the first and second broadcast messages are received over a Wi-Fi Neighbor Awareness Networking (NAN) protocol; determining that the second device is a target device; in response to determining that a quantity of available Wi-Fi connections of the second device is not greater than zero, and the second device is not a device to which the electronic device is connected through Wi-Fi, determining, without an involvement of any centralized coordination device and based on the connected device information of the second device and available Wi-Fi connection information of the third device, that the third device belongs to the device to which the second device is connected through Wi-Fi and that a quantity of available Wi-Fi connections of the third device is greater than zero, wherein the quantity of available Wi-Fi connections of the second device is determined based on the Wi-Fi connection information of the second device; sending a Wi-Fi link establishment request to the third device to establish a Wi-Fi link between the electronic device and the third device; and sending, to the third device through the Wi-Fi link between the electronic device and the third device, a first packet for the third device to forward to the second device through a Wi-Fi link between the third device and the second device.
  18. 18 . The non-transitory computer readable medium according to claim 17 , wherein the operations further comprising: in response to determining that the quantity of available Wi-Fi connections of the second device is greater than zero, and the second device is not the device to which the electronic device is connected through Wi-Fi, sending a Wi-Fi link establishment request to the second device, to establish a Wi-Fi link between the electronic device and the second device.
  19. 19 . The non-transitory computer readable medium according to claim 17 , wherein the first broadcast message further comprises a first service identifier indicating a service that can be provided by the second device; and the operations further comprising: searching a local service interest list for a service identifier corresponding to the first service identifier, wherein the local service interest list comprises at least one service identifier indicating at least one service required by the electronic device; and in response to identifying the service identifier corresponding to the first service identifier in the local service interest list, determining that the second device is the target device.
  20. 20 . The non-transitory computer readable medium according to claim 17 , wherein the first broadcast message further comprises identifier information of the second device; and the operations further comprising: displaying a first interface, wherein the first interface comprises a first function area corresponding to the identifier information; and in response to an operation for the first function area, determining that the second device is the target device.

Description

CROSS-REFERENCE TO RELATED APPLICATIONS This application is a national stage of International Application No. PCT/CN2021/080527, filed March 12, 2021, which claims priority to Chinese Patent Application No. 202010367852.X, filed Apr. 30, 2020. Both of the aforementioned applications are hereby incorporated by reference in their entireties. TECHNICAL FIELD This application relates to the field of wireless network technologies, and specifically, to a neighborhood aware network-based device connection method and a device. BACKGROUND A wireless-fidelity neighborhood aware network (Wi-Fi NAN) is a point-to-point interconnection and interworking Wi-Fi wireless network mesh communication technology. This technology can bypass a network infrastructure (such as an access point (AP) or a cellular network), implement a one-to-one, one-to-many, or many-to-many Wi-Fi connection between devices in a same Wi-Fi NAN, and provide services such as file sharing and data mutual transmission. Usually, a quantity of devices to which a device can be directly connected through Wi-Fi is limited. Direct connection through Wi-Fi means that two devices are directly connected through their respective Wi-Fi interfaces without forwarding by a relay device. A maximum quantity of devices to which a device can be connected in a Wi-Fi direct connection manner may be referred to as a maximum quantity of connections of the device, and a quantity of devices that can be further connected to the device in the Wi-Fi direct connection manner is referred to as a quantity of available connections of the device. When a quantity of available connections of a device 1 is not greater than 0, that is, when a quantity of devices to which the device 1 is currently connected reaches a maximum quantity of connections, the device 1 rejects a Wi-Fi connection request from another device (for example, a device 2). Currently, when a Wi-Fi connection of the device 2 is rejected by the device 1, the device 2 may give up connecting to the device 1 through Wi-Fi. Alternatively, the user may add a wireless router, so that the device 2, the device 1, and a device to which the device 1 is connected through Wi-Fi are indirectly connected by using the wireless router. That is, the device 2 and the device 1 are connected by using a conventional Wi-Fi technology instead of a Wi-Fi NAN technology. SUMMARY Embodiments of this application provide a neighborhood aware network (Wi-Fi NAN)-based device connection method. When a target device cannot be directly connected through Wi-Fi, a device to which the target device is connected through Wi-Fi may be connected, so that the target device is connected through a multi-hop Wi-Fi link. According to a first aspect, an embodiment of this application provides a neighborhood aware network (Wi-Fi NAN)-based device connection method. The method may be performed by a first device that supports a neighborhood aware network protocol. The method includes: receiving a first broadcast message from a second device, where the first broadcast message includes connected device information of the second device and Wi-Fi connection information of the second device, and the connected device information is used to represent a device to which the second device is connected through Wi-Fi; receiving a second broadcast message from a third device, where the second broadcast message includes Wi-Fi connection information of the third device; determining that the second device is a target device; when a quantity of available Wi-Fi connections of the second device is not greater than zero, and the second device is not a device to which the first device is connected through Wi-Fi, determining, based on the connected device information of the second device and available Wi-Fi connection information of the third device, that the third device belongs to the device to which the second device is connected through Wi-Fi and that a quantity of available Wi-Fi connections of the third device is greater than zero, where the quantity of available Wi-Fi connections of the second device is determined based on the Wi-Fi connection information of the second device; sending a Wi-Fi link establishment request to the third device, to establish a Wi-Fi link between the first device and the third device; and sending, to the third device through the Wi-Fi link between the first device and the third device, a first packet whose destination is the second device, so that the third device forwards the first packet to the second device through a Wi-Fi link between the third device and the second device. In other words, the first device receives a broadcast message sent by the second device and a broadcast message sent by the third device. When the first device is intended to connect to the second device through Wi-Fi, if the second device has no available Wi-Fi interface, and the second device is not the device to which the first device is connected through Wi-Fi, it may be determined