A method and apparatus for connecting a terminal to a device in a local area network
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-14
- Publication Date
- 2026-08-11
AI Technical Summary
[0004]但是,目前的VR头显与局域网内遥操机器人建立连接的方案,多机器人同网段时难以快速选对目标,误选率高;DHCP导致IP变化时,连接体验不稳定;此外,用户每次都要重新查找并选择目标
[0022]本申请实施例提供的一种终端与局域网内设备的连接方法及装置,终端在局域网内执行服务发现,获取来自设备的至少一个候选服务响应,终端通过近距离无线通信扫描获取至少一个近场广播信号,并从近场广播信号中解析得到设备ID,并基于设备ID得到近场广播候选表,基于设备ID将候选服务响应和近场广播候选表进行关联,得到对应的候选目标集合,获取终端与设备的历史连接记录,并基于历史连接记录得到历史连接记录集合,基于预设的筛选策略在候选目标集合中选择探测目标子集合,对探测目标子集合中的候选IP地址执行可达性探测,得到对应的链路质量指标,从近场广播信号中解析得到信号强度指标,基于历史连接记录集合、链路质量指标和信号强度指标计算探测目标子集合中每一个候选IP地址的综合评分,并基于综合评分对候选IP地址进行排序后输出排序后的IP地址推荐列表,并在用户界面中显示。本申请,终端即VR头显在局域网内执行服务发现获取候选服务响应,通过近距离无线通信扫描获取近场广播信号并解析得到设备ID,基于设备ID将两者进行关联得到候选目标集合,结合历史连接记录集合、链路质量指标和信号强度指标计算每一个候选IP地址的综合评分并进行排序后输出IP地址推荐列表。由此,终端在局域网中可以快速得到可连接设备IP候选,可以快速选对目标,降低了误选率,且结合近场信号与历史连接记录对候选目标进行重排,无需每次都要重新查找并选择目标,提升了终端与设备的连接效率与准确性。
Smart Images

Figure CN122554986A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of local area network (LAN) communication technology, and more specifically, to a method and apparatus for connecting a terminal to devices within a LAN. Background Technology
[0002] Connecting VR headsets to robots within a local area network to achieve precise remote control is a systems engineering project that integrates robotics, computer graphics, and networking technologies. Its core objective is to create a seamless sense of immersion, making the operator feel as if they are right next to the robot.
[0003] Currently, when existing VR headsets establish connections with remotely operated robots within a local area network, the common solutions mainly include the following categories: (1) connection solutions based on local area network service discovery; (2) connection solutions based on manual input or static configuration of IP; and (3) short-range wireless assisted identification solutions.
[0004] However, current solutions for establishing connections between VR headsets and remotely controlled robots within a local area network suffer from several drawbacks. When multiple robots are on the same network segment, it's difficult to quickly select the correct target, resulting in a high rate of misselection. Furthermore, IP address changes due to DHCP cause connection instability. Additionally, users must repeatedly search for and select the target each time. Therefore, connection efficiency and accuracy are generally poor. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a method and apparatus for connecting a terminal to devices within a local area network (LAN). The terminal, i.e., a VR headset, performs service discovery within the LAN to obtain candidate service responses. It acquires near-field broadcast signals through near-field wireless communication scanning and parses them to obtain device IDs. Based on the device IDs, it associates the two to obtain a set of candidate targets. Combining historical connection records, link quality indicators, and signal strength indicators, it calculates a comprehensive score for each candidate IP address, sorts them, and outputs a recommended IP address list. Thus, the terminal can quickly obtain connectable device IP candidate addresses within the LAN, enabling rapid target selection and reducing the false selection rate. Furthermore, by combining near-field signals and historical connection records to rearrange candidate targets, it eliminates the need to search and select targets repeatedly, improving the connection efficiency and accuracy between the terminal and devices.
[0006] In a first aspect, embodiments of this application provide a method for connecting a terminal to a device within a local area network, the method comprising: The terminal performs service discovery within the local area network and obtains at least one candidate service response from the device; wherein the fields in the candidate service response include at least device ID, IP address, and port; The terminal acquires at least one near-field broadcast signal through near-field wireless communication scanning, parses the device ID from the near-field broadcast signal, and obtains a near-field broadcast candidate table based on the device ID; wherein, the terminal does not need to establish a pairing connection with the device during the scanning process; the near-field broadcast candidate table includes at least the device ID, IP address, and port; The candidate service response and the near-field broadcast candidate table are associated based on the device ID to obtain a corresponding candidate target set; wherein, the candidate target set includes at least one candidate target, and each candidate target corresponds to at least one candidate IP address; Obtain the historical connection records between the terminal and the device, and obtain a set of historical connection records based on the historical connection records; Based on a preset filtering strategy, a subset of probe targets is selected from the candidate target set, and reachability detection is performed on the candidate IP addresses in the probe target subset to obtain the corresponding link quality indicators. The signal strength index is parsed from the near-field broadcast signal. Based on the historical connection record set, the link quality index, and the signal strength index, a comprehensive score is calculated for each candidate IP address in the target subset. The candidate IP addresses are then sorted based on the comprehensive score, and a sorted IP address recommendation list is output and displayed in the user interface.
[0007] In one possible implementation, the terminal performs service discovery within the local area network, obtaining at least one candidate service response from the device, including: The device starts the service and generates corresponding metadata, and constructs a corresponding service discovery text record based on the metadata; wherein, the service discovery text record includes at least the device ID, IP address, and port; Based on the service discovery text record, the device initiates a corresponding multicast announcement to transmit the corresponding broadcast packet through the local area network; The terminal listens to the corresponding specific service type, receives the broadcast packet sent by the device, parses the broadcast packet to obtain the metadata in the broadcast packet, and obtains the corresponding candidate service response based on the metadata.
[0008] In one possible implementation, the signal strength indicators include an average signal strength indicator and an instantaneous signal strength indicator; the terminal acquires at least one near-field broadcast signal through near-field wireless communication scanning, and parses the device ID from the near-field broadcast signal, including: After the terminal enables near-field wireless communication scanning, when the terminal receives the broadcast packet, it reads the fields of the broadcast packet to obtain the device ID; If the device ID is valid, then a corresponding cache entry is created or updated based on the device ID to obtain the instantaneous signal strength index and the average signal strength index; The signal strength index field in the broadcast packet is updated based on the instantaneous signal strength index and the average signal strength index to obtain the corresponding near-field broadcast candidates. At the end of the scan, the corresponding near-field broadcast candidate table is obtained based on the output of all near-field broadcast candidates.
[0009] In one possible implementation, associating the candidate service response with the near-field broadcast candidate table based on the device ID to obtain the corresponding candidate target set includes: Using the device ID as a key, a first index of the candidate service response and a second index of the near-field broadcast candidate table are constructed respectively, and the key union of the device ID is obtained based on the key corresponding to the first index and the key corresponding to the second index; Based on the key union, traverse each device ID, and merge the candidate service response and the near-field broadcast candidate table based on the traversal results to obtain the candidate target set.
[0010] In one possible implementation, the method further includes: If the candidate target set contains multiple IP addresses or multiple ports for the same device ID, then the results are merged into a multi-endpoint list for that device ID or split into multiple candidates, and the final candidate target set is output; or, If the candidate target set does not contain multiple IP addresses or multiple ports for the same device ID, the candidate structure of the candidate target set is maintained, and the final candidate target set is output.
[0011] In one possible implementation, obtaining the historical connection records between the terminal and the device, and obtaining a set of historical connection records based on the historical connection records, includes: If a history database exists in the history database medium, load the history database index from the history database, and read the historical connection records between the terminal and the device according to the device ID; The historical connection records are processed based on the missing fields, and the multi-dimensional validity of the processed historical connection records is verified. Expired records in the historical connection records are removed to obtain a set of historical connection records. The multi-dimensional validity includes at least timestamp range, IP format, or success rate range.
[0012] In one possible implementation, performing reachability probing on candidate IP addresses in the subset of probe targets to obtain corresponding link quality metrics includes: Based on the candidate target set, a detection target subset and a detection strategy are selected. Based on the detection target subset and the detection strategy, each candidate IP address in the detection target subset is traversed to generate a corresponding detection plan. Determine the protocol type of the detection plan, and calculate the corresponding link quality index based on the protocol type.
[0013] Secondly, embodiments of this application also provide a connection device between a terminal and a device within a local area network, the device comprising: The first acquisition module is used by the terminal to perform service discovery within the local area network and acquire at least one candidate service response from the device; wherein the fields in the candidate service response include at least device ID, IP address, and port; The second acquisition module is used for the terminal to acquire at least one near-field broadcast signal through near-field wireless communication scanning, and to parse the device ID from the near-field broadcast signal and obtain a near-field broadcast candidate table based on the device ID; wherein, the terminal does not need to establish a pairing connection with the device during the scanning process; the near-field broadcast candidate table includes at least the device ID, IP address, and port; The third acquisition module is used to associate the candidate service response with the near-field broadcast candidate table based on the device ID to obtain a corresponding candidate target set; wherein, the candidate target set includes at least one candidate target, and each candidate target corresponds to at least one candidate IP address; The fourth acquisition module is used to acquire the historical connection records between the terminal and the device, and to obtain a set of historical connection records based on the historical connection records; The fifth acquisition module is used to select a subset of probe targets from the candidate target set based on a preset filtering strategy, perform reachability detection on the candidate IP addresses in the probe target subset, and obtain the corresponding link quality indicators. The calculation module is used to parse the signal strength index from the near-field broadcast signal, calculate the comprehensive score of each candidate IP address in the target subset based on the historical connection record set, the link quality index, and the signal strength index, sort the candidate IP addresses based on the comprehensive score, output the sorted IP address recommendation list, and display it in the user interface.
[0014] In one possible implementation, the first acquisition module is specifically used for: The device starts the service and generates corresponding metadata, and constructs a corresponding service discovery text record based on the metadata; wherein, the service discovery text record includes at least the device ID, IP address, and port; Based on the service discovery text record, the device initiates a corresponding multicast announcement to transmit the corresponding broadcast packet through the local area network; The terminal listens to the corresponding specific service type, receives the broadcast packet sent by the device, parses the broadcast packet to obtain the metadata in the broadcast packet, and obtains the corresponding candidate service response based on the metadata.
[0015] In one possible implementation, the signal strength index includes an average signal strength index and an instantaneous signal strength index; the second acquisition module is specifically used for: After the terminal enables near-field wireless communication scanning, when the terminal receives the broadcast packet, it reads the fields of the broadcast packet to obtain the device ID; If the device ID is valid, then a corresponding cache entry is created or updated based on the device ID to obtain the instantaneous signal strength index and the average signal strength index; The signal strength index field in the broadcast packet is updated based on the instantaneous signal strength index and the average signal strength index to obtain the corresponding near-field broadcast candidates. At the end of the scan, the corresponding near-field broadcast candidate table is obtained based on the output of all near-field broadcast candidates.
[0016] In one possible implementation, the third acquisition module is specifically used for: Using the device ID as a key, a first index of the candidate service response and a second index of the near-field broadcast candidate table are constructed respectively, and the key union of the device ID is obtained based on the key corresponding to the first index and the key corresponding to the second index; Based on the key union, traverse each device ID, and merge the candidate service response and the near-field broadcast candidate table based on the traversal results to obtain the candidate target set.
[0017] In one possible implementation, the device further includes: The fifth acquisition module is used to, in response to the existence of multiple IP addresses or multiple ports for the same device ID in the candidate target set, either merge them into a multi-endpoint list for that device ID or split them into multiple candidates, and output the final candidate target set; or, The sixth acquisition module is used to maintain the candidate structure of the candidate target set and output the final candidate target set if the candidate target set does not have multiple IP addresses or multiple ports for the same device ID.
[0018] In one possible implementation, the fourth acquisition module is specifically used for: If a history database exists in the history database medium, load the history database index from the history database, and read the historical connection records between the terminal and the device according to the device ID; The historical connection records are processed based on the missing fields, and the multi-dimensional validity of the processed historical connection records is verified. Expired records in the historical connection records are removed to obtain a set of historical connection records. The multi-dimensional validity includes at least timestamp range, IP format, or success rate range.
[0019] In one possible implementation, the fifth acquisition module is specifically used for: Based on the candidate target set, a detection target subset and a detection strategy are selected. Based on the detection target subset and the detection strategy, each candidate IP address in the detection target subset is traversed to generate a corresponding detection plan. Determine the protocol type of the detection plan, and calculate the corresponding link quality index based on the protocol type.
[0020] Thirdly, embodiments of this application provide an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the connection method between a terminal and a device within a local area network as described in any of the first aspects.
[0021] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the connection method between a terminal and a device within a local area network as described in any of the first aspects.
[0022] This application provides a method and apparatus for connecting a terminal to devices within a local area network (LAN). The terminal performs service discovery within the LAN, acquiring at least one candidate service response from the device. The terminal scans for at least one near-field broadcast (NFC) signal via near-field wireless communication, parses the device ID from the NFC signal, and obtains a NFC candidate list based on the device ID. The terminal associates the candidate service responses with the NFC candidate list based on the device ID to obtain a corresponding candidate target set. It acquires historical connection records between the terminal and the device, and obtains a historical connection record set based on these records. Based on a preset filtering strategy, it selects a probe target subset from the candidate target set, performs reachability probing on the candidate IP addresses in the probe target subset, and obtains the corresponding link quality index. It parses the signal strength index from the NFC signal, calculates a comprehensive score for each candidate IP address in the probe target subset based on the historical connection record set, the link quality index, and the signal strength index, and sorts the candidate IP addresses based on the comprehensive score, outputting a sorted IP address recommendation list, which is then displayed in the user interface. In this application, the terminal, i.e., the VR headset, performs service discovery within a local area network (LAN) to obtain candidate service responses. It acquires near-field broadcast signals through near-field wireless communication scanning and parses them to obtain the device ID. Based on the device ID, it associates the two to obtain a set of candidate targets. Combining historical connection records, link quality indicators, and signal strength indicators, it calculates a comprehensive score for each candidate IP address, sorts them, and outputs a recommended IP address list. Therefore, the terminal can quickly obtain connectable device IP candidate addresses within the LAN, enabling rapid target selection and reducing the false selection rate. Furthermore, by combining near-field signals and historical connection records to reorder candidate targets, it eliminates the need to search and select targets repeatedly, improving the connection efficiency and accuracy between the terminal and devices.
[0023] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0024] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart of a method for connecting a terminal to a device within a local area network according to an embodiment of this application; Figure 2 This is a schematic diagram of the local area network candidate acquisition process; Figure 3This is a schematic diagram of the near-field assistance information acquisition process; Figure 4 This is a schematic diagram of the connection device between a terminal and a device within a local area network according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0027] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0028] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0029] Connecting VR headsets to robots within a local area network for precise remote control is a complex systems engineering project that integrates robotics, computer graphics, and networking technologies. Its core objective is to create a seamless sense of immersion, making the operator feel as if they are right next to the robot.
[0030] Currently, when existing VR headsets establish connections with remotely operated robots within a local area network, the common solutions mainly include the following categories: (1) connection solutions based on local area network service discovery; (2) connection solutions based on manual input or static configuration of IP; and (3) short-range wireless assisted identification solutions.
[0031] However, current solutions for establishing connections between VR headsets and remotely controlled robots within a local area network suffer from several drawbacks. When multiple robots are on the same network segment, it's difficult to quickly select the correct target, resulting in a high rate of misselection. Furthermore, IP address changes due to DHCP cause connection instability. Additionally, users must repeatedly search for and select the target each time. Therefore, connection efficiency and accuracy are generally poor.
[0032] To address this issue, this application provides a method and apparatus for connecting a terminal to devices within a local area network (LAN). The terminal, i.e., a VR headset, performs service discovery within the LAN to obtain candidate service responses. It acquires near-field broadcast signals through near-field wireless communication scanning and parses them to obtain device IDs. Based on the device IDs, it associates the two to obtain a set of candidate targets. Combining historical connection records, link quality indicators, and signal strength indicators, it calculates a comprehensive score for each candidate IP address, sorts them, and outputs a recommended IP address list. Thus, the terminal can quickly obtain connectable device IP candidate addresses within the LAN, enabling rapid target selection and reducing the false selection rate. Furthermore, by combining near-field signals and historical connection records to rearrange candidate targets, it eliminates the need to search and select targets repeatedly, improving the efficiency and accuracy of the connection between the terminal and devices.
[0033] Figure 1 This is a flowchart illustrating a method for connecting a terminal to a device within a local area network, according to an embodiment of this application. For example... Figure 1 As shown in the embodiments of this application, the method for connecting a terminal to a device within a local area network may specifically include: S101. The terminal performs service discovery within the local area network and obtains at least one candidate service response from the device.
[0034] S102. The terminal obtains at least one near-field broadcast signal through near-field wireless communication scanning, parses the device ID from the near-field broadcast signal, and obtains a near-field broadcast candidate table based on the device ID.
[0035] S103. Associate the candidate service response with the near-field broadcast candidate table based on the device ID to obtain the corresponding candidate target set.
[0036] S104. Obtain the historical connection records of the terminal and the device, and obtain a set of historical connection records based on the historical connection records.
[0037] S105. Based on the preset filtering strategy, select a subset of probe targets from the candidate target set, perform reachability detection on the candidate IP addresses in the probe target subset, and obtain the corresponding link quality indicators.
[0038] S106. Obtain the signal strength index from the near-field broadcast signal, calculate the comprehensive score of each candidate IP address in the target subset based on the historical connection record set, link quality index, and signal strength index, sort the candidate IP addresses based on the comprehensive score, output the sorted IP address recommendation list, and display it in the user interface.
[0039] In the aforementioned method for connecting the terminal to devices within a local area network (LAN), the terminal (VR headset) performs service discovery within the LAN to obtain candidate service responses. It acquires near-field broadcast signals through near-field wireless communication scanning and parses them to obtain the device ID. Based on the device ID, it associates the two to obtain a set of candidate targets. Combining historical connection records, link quality indicators, and signal strength indicators, it calculates a comprehensive score for each candidate IP address, sorts them, and outputs a recommended IP address list. Therefore, the terminal can quickly obtain connectable device IP candidate addresses within the LAN, enabling it to quickly select the correct target, reducing the false selection rate. Furthermore, by combining near-field signals and historical connection records to rearrange candidate targets, it eliminates the need to search and select targets repeatedly, improving the efficiency and accuracy of the connection between the terminal and devices.
[0040] The exemplary steps described above in the embodiments of this application are illustrated below with specific examples: S101, the terminal performs service discovery within the local area network and obtains at least one candidate service response from the device.
[0041] It should be noted that the device in this application is a device that provides a discoverable service endpoint (IP / port) within a local area network and can also emit near-field broadcast signals (such as BLE broadcast). That is, any device that meets these requirements can be used for the connection method between the terminal and the device within the local area network in this application. For example, a remote-controlled robot within the local area network. This application uses a remote-controlled robot as an example of the device and a VR headset as an example of the terminal, but this does not constitute a limitation.
[0042] In this embodiment, the candidate service response is also known as the candidate endpoint or the local area network (LAN) candidate list. The fields in the candidate service response include at least the device ID (using Robot ID as an example in this application), IP address, and port. The terminal, i.e., the VR headset, performs service discovery within the LAN, obtaining at least one candidate service response from devices within the LAN for subsequent processing. For example, ... Figure 2 As shown.
[0043] Optionally, when performing service discovery within the local area network and obtaining at least one candidate service response from the device, the device starts the service and generates corresponding metadata, and constructs a corresponding service discovery text record based on the metadata. Based on the service discovery text record, the device initiates a corresponding multicast announcement to transmit the corresponding broadcast packet over the local area network. The broadcast packet is the packet corresponding to the multicast announcement, and its fields include at least the device ID, IP address, and port.
[0044] Specifically, for example, such as Figure 2 As shown, the robot-side device (Ubuntu / Linux) starts the service and generates metadata, constructs a DNS-SD (DNS-Based Service Discovery) TXT record, initiates a multicast announcement via Avahi, and transmits broadcast packets (Mdns / DNS-SD broadcast packets) over the local area network (Multicast). The terminal (control terminal) listens for the specific service type _robottop._tcp, receives the multicast response packet, parses and extracts the metadata from the TXT field, and automatically obtains the device ID, IP address, port, etc.
[0045] S102, the terminal acquires at least one near-field broadcast signal through near-field wireless communication scanning, parses the device ID from the near-field broadcast signal, and obtains a near-field broadcast candidate table based on the device ID.
[0046] In this embodiment, no device establishes a pairing connection during the scanning process; the near-field broadcast candidate list includes at least a device ID, IP address, and port; the near-field broadcast signal (BLE broadcast scan) is also known as near-field assistance information or near-field broadcast information. The terminal (VR headset) acquires at least one near-field broadcast signal through near-field wireless communication scanning (e.g., BLE Scan), parses the near-field broadcast signal to obtain the device ID, and obtains the near-field broadcast candidate list based on the device ID for subsequent processing. For example, such as... Figure 3 As shown.
[0047] In some implementations, after the terminal initiates near-field wireless communication scanning, when it receives a broadcast packet, it reads the fields of the broadcast packet to obtain the device ID. If the device ID is valid, it establishes or updates the corresponding cache entry based on the device ID to obtain the instantaneous signal strength index and the average signal strength index. Based on the instantaneous signal strength index and the average signal strength index, it updates the signal strength index field in the broadcast packet to obtain the corresponding near-field broadcast candidates. At the end of the scan, it outputs the corresponding near-field broadcast candidate table based on all the near-field broadcast candidates. For example, such as... Figure 3As shown, RSSI (Received Signal Strength Indicator) processing is performed, from which instantaneous signal strength index and average signal strength index can be obtained.
[0048] S103, associate the candidate service response with the near-field broadcast candidate table based on the device ID to obtain the corresponding candidate target set.
[0049] In this embodiment, the candidate target set includes at least one candidate target, and each candidate target corresponds to at least one candidate IP address. The candidate service response obtained in step S101 (device ID association step) and the near-field broadcast candidate table obtained in step S102 are associated to obtain the candidate target set for subsequent processing. In some embodiments, the device ID is used as a key to construct a first index for the candidate service response and a second index for the near-field broadcast candidate table. The key union of the device IDs is obtained based on the key corresponding to the first index and the key corresponding to the second index. Each device ID is traversed based on the key union, and the candidate service response and the near-field broadcast candidate table are merged based on the traversal results to obtain the candidate target set. For example, based on the candidate service response (LAN candidate list), a first index Map_N is constructed using RobotID as the key, and a second index Map_B is constructed based on the near-field broadcast candidate table using RobotID as the key. The union of RobotIDs is taken as Keys = Keys(Map_N) ∪ Keys(Map_B). Each RobotID is traversed to determine whether it exists in both Map_N and Map_B. Based on the determination result (both exist in Map_N and Map_B / only exist in Map_N / only exist in Map_B), the corresponding candidate target set is obtained. For example, if RobotID exists in both Map_N and Map_B, the merged information is written into the candidate target set.
[0050] It should be noted that, in response to the existence of multiple IP addresses or multiple ports for the same device ID in the candidate target set, the targets are either merged into a multi-endpoint list for that device ID or split into multiple candidates, and the final candidate target set is output. Alternatively, in response to the existence of multiple IP addresses or multiple ports for the same device ID in the candidate target set, the candidate structure of the candidate target set is maintained, and the final candidate target set is output. For example, to determine whether there are multiple IP addresses / ports for the same RobotID in the candidate target set, if so, the targets are merged / expanded according to the following strategy: 1) merged into a multi-endpoint list for the same RobotID, 2) or split into multiple candidates; if not, the current candidate structure is maintained, and thus, the candidate target set is output, with each candidate target corresponding to at least one IP address.
[0051] S104, obtain the historical connection records of the terminal and the device, and obtain the historical connection record set based on the historical connection records.
[0052] In this embodiment of the application, the fields of the historical connection record include at least one of the following: device ID and the IP address of the most recently successfully connected device, the most recent connection time, the connection success rate, the number of times it was used, and the failure cooldown time. The historical connection record set is obtained through the historical connection records of the terminal and the device for subsequent processing.
[0053] In some implementations, when a historical database exists in the historical database medium, the historical database index is loaded from the historical database, and historical connection records between the terminal and the device are read according to the device ID. The historical connection records are then processed based on any missing fields, and the multi-dimensional validity of the processed historical connection records is verified. Expired records are removed, resulting in a set of historical connection records. The multi-dimensional validity includes at least the timestamp range, IP format, or success rate range.
[0054] For example, determine the location / media of the history database (local DB / file / key-value), check if the history database exists, and if it exists, load the history database index / connection, read the record fields according to RobotID, and check if the record is missing any fields. If not missing, keep the original record; if missing, complete the fields / set default values. Next, verify the validity of the records (timestamp range / IP format / success rate range). When expired / invalid records exist, clean up / mark expired records; when no expired / invalid records exist, retain the records. This constructs a history connection record set (HistoryMap).
[0055] S105: Based on a preset filtering strategy, select a subset of probe targets from the candidate target set, perform reachability detection on the candidate IP addresses in the probe target subset, and obtain the corresponding link quality indicators.
[0056] In this embodiment, the filtering strategy is a strategy for selecting a subset of candidate targets from the candidate target set, such as Top-K, unprobeged, non-cooldown period, and LAN-only priority. Link quality indicators include at least one of handshake success, round-trip time (RTT), packet loss rate, or application layer response time. Based on the filtering strategy, a subset of candidate targets is selected from the candidate target set as a probe target subset. Reachability probing (i.e., link quality probing) is performed on the candidate IP addresses in the probe target subset to obtain link quality indicators for subsequent processing. Optionally, when performing reachability probing on the candidate IP addresses in the probe target subset and obtaining the corresponding link quality indicators, a probe target subset and a probe strategy are selected based on the candidate target set. Each candidate IP address in the probe target subset is traversed based on the probe target subset and the probe strategy to generate a corresponding probe plan. The protocol type of the probe plan is determined, and the corresponding link quality indicator is calculated based on the protocol type. For example, during reachability / link quality probing, a set of candidate targets is input, and a subset C' (at least partially) is selected for probing. The strategy is to prioritize Top-K, unprobing, non-cooling-off period, and LAN-only targets. For each candidate target i∈C, a probing plan is generated with the protocol type being TCP / UDP / application layer. Then, the probing is performed, and corresponding processing is carried out based on the protocol type. The corresponding metrics are recorded, and finally, the link quality metrics (LinkMetricsMap) are output.
[0057] The target subset is obtained from a subset of candidate IP addresses in the candidate target set; the probe plan corresponds to a protocol type; different protocol types correspond to different link quality indicators.
[0058] S106: Obtain the signal strength index from the near-field broadcast signal, calculate the comprehensive score of each candidate IP address in the target subset based on the historical connection record set, link quality index, and signal strength index, sort the candidate IP addresses based on the comprehensive score, output the sorted IP address recommendation list, and display it in the user interface.
[0059] In this embodiment, the Signal Strength Index (RSSI) includes an average signal strength index and an instantaneous signal strength index; the comprehensive score includes at least historical connection record information, LAN reachability / link quality index, and near-field signal strength index, and the ranking is rearranged or weighted; the signal strength index can be parsed from the above near-field broadcast signal, and the comprehensive score of each candidate IP address in the target subset is calculated based on the above historical connection record set, link quality index, and signal strength index, and the candidate IP addresses are ranked and then a recommended IP address list is output.
[0060] Optionally, the historical connection score, link quality score, and near-field signal score of the candidate IP address are calculated based on the historical connection record set, link quality index, and signal strength index; and the comprehensive score of the candidate IP address is calculated based on the historical connection score, link quality score, and near-field signal score.
[0061] It should be noted that the comprehensive score of candidate target i ( The overall formula is as follows:
[0062] in, The historical connection score is a normalized combination of factors such as the last successfully hit IP, recent usage time decay, success rate, and number of uses. This represents the local area network reachability / link quality score (a normalized combination of factors such as successful handshake, RTT, packet loss rate, and application layer response time). This represents the proximity score (RSSI normalized). The stronger the RSSI, the higher the score.
[0063] The historical connectivity score is calculated using the following formula:
[0064] in, Indicates whether the previously successfully accessed IP address was matched. This indicates the time difference since the last successful connection. Time decay constant; This indicates the historical success rate (number of successes / number of attempts). ; The link quality score is calculated using the following formula:
[0065] in, A successful handshake is 1, and a failed handshake is 0 (if it fails, the entire item is 0, dropping directly to the bottom). Detected RTT; Maximum acceptable RTT (for normalization); Packet loss rate; The near-field signal component is calculated using the following formula:
[0066] in, This indicates the strength of the received signal (usually a negative value, the closer to 0 the stronger); : Considered a “very close” RSSI (e.g., -45dBm); RSSI considered "very far" (e.g., -90dBm).
[0067] The RSSI distance determination range is shown in Table 1 below: Table 1
[0068] The connection method between a terminal and devices within a local area network (LAN) provided in this application embodiment involves the terminal performing service discovery within the LAN, obtaining at least one candidate service response from the device, acquiring at least one near-field broadcast signal through near-field wireless communication scanning, parsing the device ID from the near-field broadcast signal, obtaining a near-field broadcast candidate table based on the device ID, associating the candidate service response with the near-field broadcast candidate table based on the device ID to obtain a corresponding candidate target set, acquiring historical connection records between the terminal and the device, obtaining a historical connection record set based on the historical connection records, selecting a probe target subset from the candidate target set based on a preset filtering strategy, performing reachability probes on the candidate IP addresses in the probe target subset to obtain the corresponding link quality index, parsing the signal strength index from the near-field broadcast signal, calculating a comprehensive score for each candidate IP address in the probe target subset based on the historical connection record set, link quality index, and signal strength index, sorting the candidate IP addresses based on the comprehensive score, outputting a sorted IP address recommendation list, and displaying it in the user interface. The connection method between the terminal and devices within a local area network (LAN) disclosed in this application involves the terminal (VR headset) performing service discovery within the LAN to obtain candidate service responses. It acquires near-field broadcast signals through near-field wireless communication scanning and parses them to obtain device IDs. Based on the device IDs, it associates the two to obtain a set of candidate targets. Combining historical connection records, link quality indicators, and signal strength indicators, it calculates a comprehensive score for each candidate IP address, sorts them, and outputs a recommended IP address list. Therefore, the terminal can quickly obtain connectable device IP candidate addresses within the LAN, enabling rapid target selection and reducing the false selection rate. Furthermore, by combining near-field signals and historical connection records to rearrange candidate targets, it eliminates the need to search and select targets repeatedly, improving the connection efficiency and accuracy between the terminal and devices.
[0069] In summary, this application uses a method of "local area network service discovery as the primary method and near-field signal as the secondary method" to generate and sort the device IP list: the VR headset obtains candidate endpoints containing RobotID, IP and port through service discovery within the local area network, and at the same time resolves RobotID and RSSI through near-field wireless scanning without pairing. Then, based on RobotID, the two types of information are associated to form a candidate set, and a comprehensive score is calculated and sorted by combining historical connection records and link reachability / quality detection results to output recommended connection items.
[0070] Based on the above solution, this application has the following advantages over the prior art: 1. In multi-device scenarios, it is easier to select the correct target, reducing misselection and connection attempts; This application reduces the probability of misselection and the number of connection attempts by obtaining RSSI and weighting / rearranging the ranking to make "closer devices" appear higher in the candidates.
[0071] 2. Adapt to IP changes caused by DHCP, reducing manual configuration costs.
[0072] This application automatically obtains available IP candidate endpoints on the current local area network and sorts them by combining historical information such as the last successful IP and the most recent connection time. This allows for the rapid location of connectable targets even when the IP changes, reducing manual input and repeated searches.
[0073] Figure 4 This is a schematic diagram of the connection device between a terminal and a device within a local area network according to an embodiment of this application; as shown below. Figure 4 As shown, the connection device 400 between the terminal and devices within the local area network in this embodiment of the application may specifically include: The first acquisition module 401 is used for the terminal to perform service discovery within the local area network and acquire at least one candidate service response from the device; wherein the fields in the candidate service response include at least device ID, IP address, and port.
[0074] The second acquisition module 402 is used for the terminal to acquire at least one near-field broadcast signal through near-field wireless communication scanning, and to parse the device ID from the near-field broadcast signal and obtain a near-field broadcast candidate table based on the device ID; wherein, the terminal does not need to establish a pairing connection with the device during the scanning process; the near-field broadcast candidate table includes at least the device ID, IP address, and port.
[0075] The third acquisition module 403 is used to associate the candidate service response with the near-field broadcast candidate table based on the device ID to obtain the corresponding candidate target set; wherein, the candidate target set includes at least one candidate target, and each candidate target corresponds to at least one candidate IP address.
[0076] The fourth acquisition module 404 is used to acquire the historical connection records of the terminal and the device, and to obtain a set of historical connection records based on the historical connection records.
[0077] The fifth acquisition module 405 is used to select a subset of probe targets from the candidate target set based on a preset filtering strategy, perform reachability detection on the candidate IP addresses in the probe target subset, and obtain the corresponding link quality indicators.
[0078] The calculation module 406 is used to parse the signal strength index from the near-field broadcast signal, calculate the comprehensive score of each candidate IP address in the target subset based on the historical connection record set, link quality index and signal strength index, sort the candidate IP addresses based on the comprehensive score, output the sorted IP address recommendation list and display it in the user interface.
[0079] In one possible implementation, the first acquisition module is specifically used for: The device starts the service and generates corresponding metadata, and constructs a corresponding service discovery text record based on the metadata; the service discovery text record includes at least the device ID, IP address, and port. Based on the service discovery text record, the device initiates the corresponding multicast announcement to transmit the corresponding broadcast packet over the local area network; The terminal listens for the specific service type, receives broadcast packets sent by the device, parses the broadcast packets to obtain the metadata in the broadcast packets, and obtains the corresponding candidate service response based on the metadata.
[0080] In one possible implementation, the signal strength indicators include an average signal strength indicator and an instantaneous signal strength indicator; the second acquisition module is specifically used for: After the terminal enables near-field wireless communication scanning, when the terminal receives a broadcast packet, it reads the fields of the broadcast packet to obtain the device ID; If the device ID is valid, the corresponding cache entry is created or updated based on the device ID to obtain the instantaneous signal strength index and the average signal strength index. The signal strength index field in the broadcast packet is updated based on the instantaneous signal strength index and the average signal strength index to obtain the corresponding near-field broadcast candidates. At the end of the scan, the corresponding near-field broadcast candidate table is obtained based on the output of all near-field broadcast candidates.
[0081] In one possible implementation, the third acquisition module is specifically used for: Using the device ID as a key, construct the first index of the candidate service response and the second index of the near-field broadcast candidate table, and obtain the key union of the device ID based on the key corresponding to the first index and the key corresponding to the second index; Based on the key union, each device ID is traversed, and the candidate service response and near-field broadcast candidate table are merged based on the traversal results to obtain the candidate target set.
[0082] In one possible implementation, the apparatus further includes: The fifth acquisition module is used to respond to situations where the same device ID has multiple IP addresses or multiple ports in the candidate target set. It then merges these into a multi-endpoint list for that device ID or splits them into multiple candidates, outputting the final candidate target set; or... The sixth acquisition module is used to maintain the candidate structure of the candidate target set and output the final candidate target set if the candidate target set does not contain multiple IP addresses or multiple ports for the same device ID.
[0083] In one possible implementation, the fourth acquisition module is specifically used for: If a historical database exists in the historical database medium, load the historical database index from the historical database and read the historical connection records between the terminal and the device according to the device ID; Based on the missing fields in the historical connection records, the historical connection records are processed, and the multi-dimensional validity of the processed historical connection records is verified. Expired records in the historical connection records are removed to obtain a set of historical connection records. The multi-dimensional validity includes at least the timestamp range, IP format, or success rate range.
[0084] In one possible implementation, the fifth acquisition module is specifically used for: Based on the candidate target set, a subset of probe targets and a probe strategy are selected. Based on the probe target subset and the probe strategy, each candidate IP address in the probe target subset is traversed to generate a corresponding probe plan. Determine the protocol type of the probe plan, and calculate the corresponding link quality indicators based on the protocol type.
[0085] The connection device between a terminal and a device within a local area network (LAN) provided in this application embodiment includes the following steps: The terminal performs service discovery within the LAN, obtains at least one candidate service response from the device, acquires at least one near-field broadcast signal through near-field wireless communication scanning, parses the device ID from the near-field broadcast signal, obtains a near-field broadcast candidate table based on the device ID, associates the candidate service response with the near-field broadcast candidate table based on the device ID to obtain a corresponding candidate target set, acquires historical connection records between the terminal and the device, obtains a historical connection record set based on the historical connection records, selects a probe target subset from the candidate target set based on a preset filtering strategy, performs reachability detection on the candidate IP addresses in the probe target subset to obtain the corresponding link quality index, parses the signal strength index from the near-field broadcast signal, calculates a comprehensive score for each candidate IP address in the probe target subset based on the historical connection record set, link quality index, and signal strength index, sorts the candidate IP addresses based on the comprehensive score, outputs a sorted IP address recommendation list, and displays it in the user interface. The connection device between the terminal and devices within a local area network (LAN) disclosed in this application allows the VR headset to perform service discovery within the LAN, obtaining candidate service responses. It acquires near-field broadcast signals through near-field wireless communication scanning and parses them to obtain device IDs. Based on the device IDs, it associates the two to obtain a set of candidate targets. Combining historical connection records, link quality indicators, and signal strength indicators, it calculates a comprehensive score for each candidate IP address, sorts them, and outputs a recommended IP address list. Therefore, the terminal can quickly obtain connectable device IP candidate addresses within the LAN, enabling rapid target selection and reducing the false selection rate. Furthermore, by combining near-field signals and historical connection records to rearrange candidate targets, it eliminates the need to search and select targets repeatedly, improving the connection efficiency and accuracy between the terminal and devices.
[0086] like Figure 5 As shown in the embodiment of this application, an electronic device 500 includes a processor 501, a memory 502, and a bus. The memory 502 stores machine-readable instructions that can be executed by the processor 501. When the electronic device is running, the processor 501 communicates with the memory 502 via the bus. The processor 501 executes the machine-readable instructions to perform the steps of the connection method between the terminal and the device in the local area network described above.
[0087] Specifically, the memory 502 and processor 501 can be general-purpose memory and processor, without any specific limitations. When the processor 501 runs the computer program stored in the memory 502, it can execute the connection method between the terminal and the device in the local area network.
[0088] Corresponding to the above-described method for connecting a terminal to a device within a local area network, this application also provides a computer-readable storage medium storing a computer program. When the computer program is run by a processor, it executes the steps of the above-described method for connecting a terminal to a device within a local area network.
[0089] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0090] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0091] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0092] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the deployment methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0093] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method of connecting a terminal to a device in a local area network, characterized by, The method comprises: The terminal performs service discovery in a local area network, and obtains at least one candidate service response from a device; wherein fields in the candidate service response at least include a device ID, an IP address, and a port; The terminal obtains at least one near-field broadcast signal through near-field wireless communication scanning, and obtains a device ID from the near-field broadcast signal, and obtains a near-field broadcast candidate table based on the device ID; wherein the terminal does not need to establish a pairing connection with the device during the scanning process; the near-field broadcast candidate table at least includes a device ID, an IP address, and a port; The candidate service response and the near-field broadcast candidate table are associated based on the device ID, and a corresponding candidate target set is obtained; wherein the candidate target set includes at least one candidate target, and each candidate target corresponds to at least one candidate IP address; A historical connection record set is obtained based on a historical connection record between the terminal and the device; A detection target subset is selected from the candidate target set based on a preset filtering strategy, reachability detection is performed on the candidate IP addresses in the detection target subset, and a corresponding link quality index is obtained; A signal strength index is obtained from the near-field broadcast signal, a comprehensive score of each candidate IP address in the detection target subset is calculated based on the historical connection record set, the link quality index, and the signal strength index, the candidate IP addresses are sorted based on the comprehensive score, and an IP address recommendation list after sorting is output and displayed on a user interface.
2. The method of claim 1, wherein, The terminal performs service discovery in a local area network, and obtains at least one candidate service response from a device, which comprises: The device starts a service and generates corresponding metadata, and constructs a corresponding service discovery text record based on the metadata; wherein the service discovery text record at least includes a device ID, an IP address, and a port; The device initiates a corresponding multicast announcement based on the service discovery text record, to transmit a corresponding broadcast packet through a local area network; The terminal listens to a corresponding specific service type, receives the broadcast packet sent by the device, and parses the broadcast packet to obtain the metadata in the broadcast packet, and obtains a corresponding candidate service response based on the metadata.
3. The method of claim 1, wherein, The signal strength index includes an average signal strength index and an instantaneous signal strength index; the terminal obtains at least one near-field broadcast signal through near-field wireless communication scanning, and obtains a device ID from the near-field broadcast signal, which comprises: After the terminal starts near-field wireless communication scanning, when the terminal receives the broadcast packet, fields of the broadcast packet are read to obtain the device ID; If the device ID is valid, a corresponding cache item is established or updated based on the device ID, to obtain the instantaneous signal strength index and the average signal strength index; The signal strength index field in the broadcast packet is updated based on the instantaneous signal strength index and the average signal strength index to obtain the corresponding near-field broadcast candidates. At the end of the scan, the corresponding near-field broadcast candidate table is obtained based on the output of all near-field broadcast candidates.
4. The method of claim 1, wherein, The step of associating the candidate service response with the near-field broadcast candidate table based on the device ID to obtain the corresponding candidate target set includes: Using the device ID as a key, a first index of the candidate service response and a second index of the near-field broadcast candidate table are constructed respectively, and the key union of the device ID is obtained based on the key corresponding to the first index and the key corresponding to the second index; Based on the key union, traverse each device ID, and merge the candidate service response and the near-field broadcast candidate table based on the traversal results to obtain the candidate target set.
5. The method of claim 4, wherein, The method further includes: If the candidate target set contains multiple IP addresses or multiple ports for the same device ID, then the results are merged into a multi-endpoint list for that device ID or split into multiple candidates, and the final candidate target set is output; or, If the candidate target set does not contain multiple IP addresses or multiple ports for the same device ID, the candidate structure of the candidate target set is maintained, and the final candidate target set is output.
6. The method of claim 4, wherein, The step of obtaining the historical connection records between the terminal and the device, and obtaining a set of historical connection records based on the historical connection records, includes: If a history database exists in the history database medium, load the history database index from the history database, and read the historical connection records between the terminal and the device according to the device ID; The historical connection records are processed based on the missing fields, and the multi-dimensional validity of the processed historical connection records is verified. Expired records in the historical connection records are removed to obtain a set of historical connection records. The multi-dimensional validity includes at least timestamp range, IP format, or success rate range.
7. The method of claim 4, wherein, The process of performing reachability detection on candidate IP addresses in the subset of detection targets to obtain corresponding link quality metrics includes: Based on the candidate target set, a detection target subset and a detection strategy are selected. Based on the detection target subset and the detection strategy, each candidate IP address in the detection target subset is traversed to generate a corresponding detection plan. Determine the protocol type of the detection plan, and calculate the corresponding link quality index based on the protocol type.
8. A terminal connection device to a device in a local area network, characterized in that The device includes: The first acquisition module is used by the terminal to perform service discovery within the local area network and acquire at least one candidate service response from the device; wherein the fields in the candidate service response include at least device ID, IP address, and port; The second acquisition module is used for the terminal to acquire at least one near-field broadcast signal through near-field wireless communication scanning, and to parse the device ID from the near-field broadcast signal and obtain a near-field broadcast candidate table based on the device ID; wherein, the terminal does not need to establish a pairing connection with the device during the scanning process; the near-field broadcast candidate table includes at least the device ID, IP address, and port; The third acquisition module is used to associate the candidate service response with the near-field broadcast candidate table based on the device ID to obtain a corresponding candidate target set; wherein, the candidate target set includes at least one candidate target, and each candidate target corresponds to at least one candidate IP address; The fourth acquisition module is used to acquire the historical connection records between the terminal and the device, and to obtain a set of historical connection records based on the historical connection records; The fifth acquisition module is used to select a subset of probe targets from the candidate target set based on a preset filtering strategy, perform reachability detection on the candidate IP addresses in the probe target subset, and obtain the corresponding link quality indicators. The calculation module is used to parse the signal strength index from the near-field broadcast signal, calculate the comprehensive score of each candidate IP address in the target subset based on the historical connection record set, the link quality index, and the signal strength index, sort the candidate IP addresses based on the comprehensive score, output the sorted IP address recommendation list, and display it in the user interface.
9. An electronic device, comprising: include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the connection method between the terminal and a device within a local area network as described in any one of claims 1 to 7 are performed.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method for connecting a terminal to a device within a local area network as described in any one of claims 1 to 7.