Geofence generation method, matching method, cloud device, and electronic device
By utilizing Wi-Fi signal scanning capabilities to generate geofences, the problems of low positioning accuracy and high power consumption in existing technologies are solved, achieving high-precision indoor positioning.
Patent Information
- Application Number
- CN202311375923.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-20
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2043-10-20
AI Technical Summary
Existing geofencing technology suffers from low positioning accuracy, high power consumption, and is not suitable for indoor locations.
By leveraging the Wi-Fi signal scanning capabilities of electronic devices, multiple Wi-Fi scan lists are acquired, similarity clustering is performed to generate Wi-Fi list clusters, the feature weights and matching thresholds of BSSIDs are calculated, and a high-precision geofence is generated, suitable for indoor positioning.
It reduces the power consumption of geofencing, improves positioning accuracy, and enables its effective application in indoor environments.
Smart Images

Figure CN119906953B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of location service technology, and in particular to a geofence generation method, a matching method, a cloud device, an electronic device, and a computer-readable storage medium. Background Technology
[0002] Geo-fencing is a new application based on location-based services (LBS), which uses a virtual fence to demarcate a virtual geographic boundary. It can be understood as a location-aware technology used for recommendation services related to location.
[0003] Currently, most existing geofencing technologies are generated by collecting location data using network positioning technology or Global Navigation Satellite System (GNSS) positioning technology. However, network positioning technology generally has a large error, while GNSS positioning technology has high power consumption and cannot locate indoor locations. As a result, the generated geofencing has low accuracy, high power consumption, and is not suitable for indoor locations. Summary of the Invention
[0004] This application provides a geofence generation method, a matching method, a cloud device, an electronic device, and a computer-readable storage medium to solve problems such as high power consumption, low positioning accuracy, and inability to locate indoor locations in existing geofences.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] Firstly, a geofence generation method is provided, which is applied to cloud devices and includes:
[0007] The cloud device acquires multiple Wi-Fi scan lists. Each Wi-Fi scan list includes the BSSID and RSSI of one or more Wi-Fi access points obtained from a single scan by an electronic device. The cloud device then performs similarity clustering on these multiple Wi-Fi scan lists, resulting in multiple Wi-Fi list clusters that each include one or more Wi-Fi scan lists. Based on the frequency of each BSSID within a Wi-Fi list cluster and its corresponding RSSI, the cloud device calculates the feature weight for each BSSID in the Wi-Fi list cluster. According to the feature weights of each BSSID in the Wi-Fi list cluster, a first matching score is calculated between each Wi-Fi scan list and the Wi-Fi list cluster. Based on these first matching scores, a matching threshold for the Wi-Fi list cluster is determined. Finally, the cloud device generates a geofence corresponding to the Wi-Fi list cluster. The generated geofence includes: the multiple BSSIDs in the Wi-Fi list cluster, the feature weights of each BSSID, and the matching threshold for the Wi-Fi list cluster.
[0008] In the first aspect, since Wi-Fi technology is widely used, most electronic devices have Wi-Fi signal scanning capabilities. Therefore, using the Wi-Fi signal scanning capabilities of electronic devices to scan and collect the BSSID and RSSI of Wi-Fi access points as location data for geofencing eliminates the need to use existing network positioning, GNSS positioning, or other technologies to collect location data, thus avoiding high error rates and high power consumption. Furthermore, since Wi-Fi devices are typically installed indoors and the coverage area of their Wi-Fi signals is limited, Wi-Fi can serve as a high-precision geographic fingerprint for indoor positioning. Therefore, in the first aspect, generating geofences using information such as the BSSID and RSSI of Wi-Fi access points not only avoids high power consumption issues but also generates high-precision geofences suitable for indoor positioning.
[0009] In one possible implementation of the first aspect, due to the wide coverage or penetrability of Wi-Fi signals, electronic devices not currently in the indoor location may scan for Wi-Fi signals in that indoor location, resulting in the presence of the same BSSID in two Wi-Fi scan lists obtained from scans at different indoor locations. Therefore, to eliminate interference from identical BSSIDs and to separate Wi-Fi scan lists from different indoor locations as much as possible to generate more accurate geofencing, similarity clustering is performed on multiple Wi-Fi scan lists to obtain multiple Wi-Fi list clusters. This can include: for every two Wi-Fi scan lists, first calculating the similarity of the RSSIs corresponding to the same BSSID in each of the two Wi-Fi scan lists; then calculating the sum of the similarities of the RSSIs corresponding to each identical BSSID in the two Wi-Fi scan lists as the similarity of the two Wi-Fi scan lists; and finally, based on the similarity of every two Wi-Fi scan lists, performing similarity clustering on these multiple Wi-Fi scan lists to obtain multiple Wi-Fi list clusters.
[0010] Because electronic devices closer to a Wi-Fi device will generate a higher RSSI for that Wi-Fi device, clustering based on the similarity of RSSIs corresponding to the same BSSID in two Wi-Fi scan lists can improve clustering accuracy. This allows for more precise geofencing for different indoor locations. For example, if the similarity of two RSSIs corresponding to the same BSSID is low, even if these two Wi-Fi scan lists contain the same BSSID, they will not be considered to have been scanned from the same indoor location and will not be grouped together. Compared to directly grouping two Wi-Fi scan lists containing the same BSSID into one cluster, this clustering is more accurate, further ensuring the accuracy of geofencing.
[0011] In one possible implementation of the first aspect, since a larger difference between two RSSIs indicates a greater disparity between them, and correspondingly, the two RSSIs are less similar, the similarity of the two RSSIs can be determined by the signal strength difference between them. Therefore, for each pair of Wi-Fi scan lists in multiple Wi-Fi scan lists, calculating the similarity of RSSIs corresponding to the same BSSID in the two Wi-Fi scan lists can include: calculating a first signal strength difference and a first signal strength weight for RSSIs corresponding to the same BSSID in each pair of Wi-Fi scan lists in multiple Wi-Fi scan lists; multiplying the difference between the first signal strength difference and the second signal strength difference by the first signal strength weight as the similarity of RSSIs corresponding to the same BSSID; wherein, the first signal strength difference is negatively correlated with the first difference, which is the difference between RSSIs corresponding to the same BSSID, and the first signal strength weight is positively correlated with any RSSI corresponding to the same BSSID; the second signal strength difference is negatively correlated with the second difference, which is the difference between any RSSI corresponding to the same BSSID and a preset RSSI.
[0012] In one possible implementation of the first aspect, the first signal strength difference and the first signal strength weight can be calculated using the following formula:
[0013]
[0014] Where q(x) i,b ,x j,b ) represents the first signal strength difference of RSSI corresponding to the same BSSID, x i,b This represents the RSSI corresponding to BSSID b in the i-th Wi-Fi scan list; x j,b This represents the RSSI corresponding to BSSID b in the j-th Wi-Fi scan list; k q and d q k is a preset parameter. q =0.052160; d q =0.2;Ⅱ(x) i,b <x j,b () represents an indicator function, which is used when the input condition x is met. i,b <x j,b When true, the function value is 1; otherwise, the function value is 0.
[0015]
[0016] Where p(x) represents the first signal strength weight of any RSSI corresponding to the same BSSID, x = x i,b or x j,b , including p(x i,b) or p(x j , b ), p(x i,b ) represents the first signal strength weight of the RSSI corresponding to BSSID b in the i-th Wi-Fi scan list, p(x j , b ) represents the first signal strength weight of the RSSI corresponding to BSSID b in the j-th Wi-Fi scan list; k p and b p k is a preset parameter. p =0.130401; b p = -65.
[0017] In one possible implementation of the first aspect, the similarity of RSSIs corresponding to the same BSSID can be calculated using the following formula:
[0018] p(x)(q(x i,b x j,b )-q(x,c x ))
[0019] Where p(x) represents the first signal strength weight of any RSSI corresponding to the same BSSID, including p(x) i,b ) or p(x j,b );q(x i,b ,x j,b ) represents the first signal strength difference of RSSI corresponding to the same BSSID; q(x,c x ) represents the second signal strength difference of any RSSI corresponding to the same BSSID, including q(x i,b ,c x ) or q(x j,b ,c x ), c x This indicates the default RSSI.
[0020] Therefore, the similarity between two Wi-Fi scan lists can be calculated using the following formula:
[0021]
[0022] Where w(x) i ,x j ) represents the similarity between the i-th Wi-Fi scan list and the j-th Wi-Fi scan list; B i ∩B j Indicates the i-th Wi-F i-scan list B i and the j-th Wi-F i scan list B j The set of identical BSSIDs in B, b∈B i ∩Bj .
[0023] In one possible implementation of the first aspect, the feature weights include: the median value of the Wi-Fi signal strength, the frequency weight of the Wi-Fi signal strength, and the reference feature of the Wi-Fi signal strength. Therefore, based on the occurrence frequency of each BSSID in the Wi-Fi list cluster and the RSSI corresponding to each BSSID, the feature weight corresponding to each BSSID in the Wi-Fi list cluster can be obtained. This can include: calculating the median value of all RSSSIs corresponding to the same BSSID in the Wi-Fi list cluster as the median value of the Wi-Fi signal strength corresponding to the BSSID; calculating the product of the second signal strength weight and the occurrence frequency as the frequency weight of the Wi-Fi signal strength corresponding to the BSSID; wherein, the occurrence frequency is the ratio of the number of times the BSSID appears in the Wi-Fi list cluster to the number of Wi-Fi scan lists in the Wi-Fi list cluster; the second signal strength weight is positively correlated with the median value of the Wi-Fi signal strength; calculating the third signal strength difference as the baseline feature of the Wi-Fi signal strength corresponding to the BSSID; wherein, the third signal strength difference is negatively correlated with the third difference value, and the third difference value is the difference between the median value of the Wi-Fi signal strength and the preset RSSSI.
[0024] In one possible implementation of the first aspect, the first matching score can be calculated using the following formula:
[0025]
[0026] Where score(y,x) represents the first matching score between Wi-Fi list cluster y and Wi-Fi scan list x; B represents the set of identical BSSIDs in Wi-Fi list cluster y and Wi-Fi scan list x, b∈B; y b,f0 The frequency weight f0 represents the Wi-Fi signal strength corresponding to BSSID b in the Wi-Fi list cluster y; q(y b,i0 ,x b ) represents y b,i0 and x b Poor signal strength, y b,i0 This represents the median value i0, x of the Wi-Fi signal strength corresponding to BSSID b in Wi-Fi list cluster y. b This represents the RSSI of BSSID b in the Wi-Fi scan list x; y b,f1 f1 represents the Wi-Fi signal strength baseline feature f1 corresponding to BSSID b in the Wi-Fi list cluster y.
[0027] In one possible implementation of the first aspect, in order to ensure that the determined matching threshold can serve as a judgment threshold for whether most Wi-Fi data matches a geofence, and since the median value can usually reflect the central tendency of the data and avoid the influence of outliers, the matching threshold can be determined by the median value of the matching scores of the Wi-Fi list cluster and multiple Wi-Fi scan lists. Based on this, determining the matching threshold of the Wi-Fi list cluster based on multiple first matching scores can include: calculating the median value of multiple first matching scores, using the product of the median value of the multiple first matching scores and a preset score weight as a matching threshold reference value; and among the multiple first matching scores, using the first matching score that is greater than or equal to the matching threshold reference value and has the smallest score as the matching threshold of the Wi-Fi list cluster.
[0028] In one possible implementation of the first aspect, when the number of Wi-Fi scan lists clustered together is large, the amount of BSSID data within the Wi-Fi list cluster will also be relatively large, resulting in a large amount of geofencing data. Therefore, to reduce the amount of geofencing data, before determining the matching threshold of the Wi-Fi list cluster based on the feature weights corresponding to each BSSID in the Wi-Fi list cluster, the method may further include: filtering out BSSIDs within the Wi-Fi list cluster according to the feature weights corresponding to each BSSID in the Wi-Fi list cluster, to obtain Wi-Fi list clusters with a BSSID count that meets a preset requirement.
[0029] Since only high-frequency, high-signal-strength BSSIDs are typically useful in geofencing, a portion of the data is filtered out from the Wi-Fi list cluster based on feature weights. This reduces the amount of geofencing data while retaining the more useful data.
[0030] Secondly, to enable location-based information push services using the geofences generated in the first aspect, this second aspect primarily provides a geofence matching method applied to electronic devices. The electronic device stores one or more geofences, each geofence comprising multiple BSSIDs and corresponding feature weights for each BSSID, as well as a matching threshold. The method includes: the electronic device scanning the Wi-Fi signals at its current location to obtain a set of Wi-Fi data; each set of Wi-Fi data includes the Basic Service Set Identifier (BSSID) and RSSI of one or more Wi-Fi access points. Then, the electronic device calculates a second matching score between the Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence. If the second matching score is greater than or equal to the matching threshold, the electronic device determines that the Wi-Fi data matches the geofence. The aforementioned feature weights are based on the frequency of occurrence of each BSSID in the Wi-Fi list cluster corresponding to the geofence and the RSSI corresponding to each BSSID; the Wi-Fi list cluster includes one or more clustered Wi-Fi scan lists, each Wi-Fi scan list including the BSSID and RSSI of one or more Wi-Fi access points obtained by the electronic device in a single scan.
[0031] In one possible implementation of the second aspect, to save power consumption and storage space occupied by geofencing in electronic devices, the geofencing matching method may further include: acquiring location information, determining the administrative region corresponding to the current location based on the location information; wherein, the location information is the location information of the electronic device acquired at a preset period, including latitude and longitude, cellular identifiers, or any one or more of these; and downloading one or more geofencing corresponding to the administrative region from the cloud device and saving them locally. Thus, by downloading the geofencing corresponding to the administrative region where the electronic device is located using location information, it is ensured that the electronic device only stores the geofencing required for its current location, thereby meeting matching requirements while reducing power consumption and saving storage space.
[0032] In one possible implementation of the second aspect, in order to prevent the increase in storage space and power consumption caused by the cumulative downloading and saving of geofences, the geofence matching method may further include: setting an expiration date for the downloaded and saved geofences; and deleting the geofences whose expiration dates have expired locally when the expiration date has expired.
[0033] In one possible implementation of the second aspect, the geofence matching method may further include: expanding the area outward from the location information as the center point to obtain a fence judgment area; if a geofence exists within the fence judgment area, registering a Wi-Fi scanning callback function; after obtaining a set of Wi-Fi data by scanning the Wi-Fi signal at the current location, executing the Wi-Fi scanning callback function; executing the Wi-Fi scanning callback function includes: calculating a second matching score between the Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence; if the second matching score is greater than or equal to the matching threshold, then determining that the Wi-Fi data matches the geofence.
[0034] In this implementation, the key processing steps of geofence matching are encapsulated into a Wi-Fi scanning callback function. This Wi-Fi scanning callback function is only registered and effective when a geofence exists around the electronic device, so that the electronic device can perform geofence matching. This avoids the electronic device being in a geofence matching state all the time and prevents the matching power consumption from increasing.
[0035] In one possible implementation of the second aspect, to prevent the Wi-Fi scanning callback function from remaining registered and causing the electronic device to be in a continuous matching state, resulting in increased power consumption, the geofence matching method may further include: unregistering the registered Wi-Fi scanning callback function when no geofence exists within the geofence determination area.
[0036] In one possible implementation of the second aspect, calculating a second matching score between Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence may include: calculating a fourth signal strength difference for the same BSSID in the geofence and Wi-Fi data; wherein the fourth signal strength difference is negatively correlated with a fourth difference value; the fourth difference value is the difference between the median value of the Wi-Fi signal strength corresponding to the same BSSID in the geofence and the RSSI value corresponding to the same BSSID in the Wi-Fi data; calculating a matching score for the same BSSID in the geofence and Wi-Fi data based on the fourth signal strength difference, the frequency weights of the Wi-Fi signal strength corresponding to the same BSSID in the geofence, and the baseline features of the Wi-Fi signal strength; calculating a second matching score for the geofence and Wi-Fi data; the second matching score is the sum of the matching scores for all the same BSSIDs in the geofence and Wi-Fi data.
[0037] In one possible implementation of the second aspect, after the electronic device completes the geofence matching, it can implement location-based information push services based on the matched geofence. Therefore, the geofence matching method may also include: receiving or sending information pushes based on the matched geofence.
[0038] Thirdly, embodiments of this application provide a cloud device, including: a communication module, one or more processors, and a memory; the communication module, the memory, and the processor are coupled; the memory stores one or more computer program codes, the computer program codes including computer instructions; when the processor executes the computer instructions, the cloud device performs the following steps:
[0039] Multiple Wi-Fi scan lists are obtained; each Wi-Fi scan list includes the Basic Service Set Identifier (BSSID) and Signal Strength Index (RSSI) of one or more Wi-Fi access points obtained from a single scan by an electronic device; the multiple Wi-Fi scan lists are clustered based on similarity to obtain multiple Wi-Fi list clusters; each Wi-Fi list cluster includes one or more Wi-Fi scan lists; based on the frequency of occurrence of each BSSID in the Wi-Fi list cluster and the RSSI corresponding to each BSSID, the feature weight corresponding to each BSSID in the Wi-Fi list cluster is obtained; according to the feature weight corresponding to each BSSID in the Wi-Fi list cluster, the first matching score between each Wi-Fi scan list and the Wi-Fi list cluster is calculated; based on the multiple first matching scores, the matching threshold of the Wi-Fi list cluster is determined; a geofence corresponding to the Wi-Fi list cluster is generated, the geofence including: multiple BSSIDs in the Wi-Fi list cluster and the feature weight corresponding to each BSSID, and the matching threshold of the Wi-Fi list cluster.
[0040] In one possible implementation of the third aspect, when the aforementioned computer instructions are executed by the processor, the cloud server further performs the following steps:
[0041] For every two Wi-Fi scan lists, calculate the similarity of RSSIs corresponding to the same BSSID in the two Wi-Fi scan lists;
[0042] Calculate the similarity between two Wi-Fi scan lists; where the similarity between two Wi-Fi scan lists is equal to the sum of the similarity of the RSSIs corresponding to the same BSSID in the two Wi-Fi scan lists;
[0043] Based on the similarity between every two Wi-Fi scan lists, multiple Wi-Fi scan lists are clustered to obtain multiple Wi-Fi list clusters.
[0044] In one possible implementation of the third aspect, when the aforementioned computer instructions are executed by the processor, the cloud server further performs the following steps:
[0045] Calculate the first signal strength difference and the first signal strength weight of RSSI corresponding to the same BSSID in each of the multiple Wi-Fi scan lists; wherein, the first signal strength difference is negatively correlated with the first difference value, the first difference value is the difference of RSSI corresponding to the same BSSID, and the first signal strength weight is positively correlated with any RSSI corresponding to the same BSSID.
[0046] The product of the difference between the first signal strength difference and the second signal strength difference and the first signal strength weight is used as the similarity of RSSIs corresponding to the same BSSID; wherein, the second signal strength difference is negatively correlated with the second difference, and the second difference is the difference between any RSSI corresponding to the same BSSID and the preset RSSI.
[0047] In one possible implementation of the third aspect, when the aforementioned computer instructions are executed by the processor, the cloud server further performs the following steps:
[0048] The first signal strength difference and the first signal strength weight are calculated using the following formulas:
[0049]
[0050] Where q(x) i,b ,x j,b ) represents the first signal strength difference of RSS I corresponding to the same BSSID, x i,b This represents the RSS ID corresponding to BSSID b in the i-th Wi-Fi scan list; x j,b This represents the RSS ID corresponding to BSSID b in the j-th Wi-Fi scan list; k q and d q k is a preset parameter. q =0.052160; d q =0.2;Ⅱ(x) i,b <x j,b () represents an indicator function, which is used when the input condition x is met. i,b <x j,b The function value is 1 when the condition is true, otherwise the function value is 0.
[0051]
[0052] Where p(x) represents the first signal strength weight of any RSSI corresponding to the same BSSID, x = x i,b or x j,b , including p(x i,b ) or p(x j,b ), p(x i,b) represents the first signal strength weight of the RSSI corresponding to BSSID b in the i-th Wi-Fi scan list, p(x j,b ) represents the first signal strength weight of the RSSI corresponding to BSSID b in the j-th Wi-Fi scan list; k p and b p k is a preset parameter. p =0.130401; b p = -65.
[0053] In one possible implementation of the third aspect, when the aforementioned computer instructions are executed by the processor, the cloud server further performs the following steps:
[0054] The similarity of RSSIs corresponding to the same BSSID is calculated using the following formula:
[0055] p(x)(q(x i,b x j,b )-q(x,c x ))
[0056] Where p(x) represents the first signal strength weight of any RSSI corresponding to the same BSSID, including p(x) i,b ) or p(x j,b );q(x i,b ,x j,b ) represents the first signal strength difference of RSSI corresponding to the same BSSID; q(x,c x ) represents the second signal strength difference of any RSSI corresponding to the same BSSID, including q(x i,b ,c x ) or q(x j,b ,c x ), c x Indicates the default RSSI;
[0057] The similarity between two Wi-Fi scan lists is calculated using the following formula:
[0058]
[0059] Where w(x) i ,x j B represents the similarity between the i-th Wi-Fi scan list and the j-th Wi-Fi scan list; i ∩B j Represents the i-th Wi-Fi scan list B i and the j-th Wi-Fi scan list B j The set of identical BSSIDs in B, b∈B i ∩B j .
[0060] In one possible implementation of the third aspect, the feature weights include: the median value of Wi-Fi signal strength, the frequency weight of Wi-Fi signal strength, and the baseline feature of Wi-Fi signal strength; when the above computer instructions are executed by the processor, the cloud server further performs the following steps:
[0061] Calculate the median value of all RSSIs corresponding to the same BSSID in the Wi-Fi list cluster, and use it as the median value of the Wi-Fi signal strength corresponding to the BSSID;
[0062] The product of the second signal strength weight and the occurrence frequency is calculated as the Wi-Fi signal strength frequency weight corresponding to the BSSID; where the occurrence frequency is the ratio of the number of times the BSSID appears in the Wi-Fi list cluster to the number of Wi-Fi scan lists in the Wi-Fi list cluster; the second signal strength weight is positively correlated with the median value of the Wi-Fi signal strength;
[0063] The third signal strength difference is calculated as the reference feature of Wi-Fi signal strength corresponding to BSSID; wherein, the third signal strength difference is negatively correlated with the third difference value, and the third difference value is the difference between the median value of Wi-Fi signal strength and the preset RSSI.
[0064] In one possible implementation of the third aspect, when the aforementioned computer instructions are executed by the processor, the cloud server further performs the following steps:
[0065] The first match score is calculated using the following formula:
[0066]
[0067] Where score(y,x) represents the first matching score between Wi-Fi list cluster y and Wi-Fi scan list x; B represents the set of Wi-Fi list cluster y and Wi-Fi scan list x with the same BSSID, b∈B; y b,f0 f0 represents the frequency weight of the Wi-Fi signal strength corresponding to BSSID b in the Wi-Fi list cluster y; q(y b,i0 ,x b ) represents y b,i0 and x b Poor signal strength, y b,i0 This represents the median value i0, x of the Wi-Fi signal strength corresponding to BSSID b in Wi-Fi list cluster y. b This represents the RSSI of BSSID b in the Wi-Fi scan list x; y b,f1 f1 represents the Wi-Fi signal strength baseline feature f1 corresponding to BSSID b in the Wi-Fi list cluster y.
[0068] In one possible implementation of the third aspect, when the aforementioned computer instructions are executed by the processor, the cloud server further performs the following steps:
[0069] Calculate the median value of multiple first matching scores, and use the product of the median value of multiple first matching scores and the preset score weight as the matching threshold reference value;
[0070] Among multiple first match scores, the first match score that is greater than or equal to the match threshold reference value and has the smallest score is used as the match threshold for the Wi-Fi list cluster.
[0071] In one possible implementation of the third aspect, when the aforementioned computer instructions are executed by the processor, the cloud server further performs the following steps:
[0072] Based on the feature weights corresponding to each BSSID in the Wi-Fi list cluster, the BSSIDs in the Wi-Fi list cluster are filtered out to obtain a Wi-Fi list cluster with a number of BSSIDs that meets the preset requirement.
[0073] Fourthly, this application provides an electronic device, including: a communication module, one or more processors, and a memory; the communication module, the memory, and the processor are coupled; the memory stores one or more computer program codes, the computer program codes including computer instructions; when the processor executes the computer instructions, the electronic device performs the following steps:
[0074] Scan the Wi-Fi signals at the current location to obtain a set of Wi-Fi data; each set of Wi-Fi data includes the Basic Service Set Identifier (BSSID) and the Signal Strength Index (RSSI) of one or more Wi-Fi access points;
[0075] Based on the feature weights corresponding to each BSSID in the geofence, a second matching score between the Wi-Fi data and the geofence is calculated. The feature weights are obtained based on the frequency of occurrence of each BSSID in the Wi-Fi list cluster corresponding to the geofence and the RSSI corresponding to each BSSID. The Wi-Fi list cluster includes one or more Wi-Fi scan lists obtained by clustering. Each Wi-Fi scan list includes the BSSID and RSSI of one or more Wi-Fi access points obtained by one electronic device in one scan.
[0076] If the second matching score is greater than or equal to the matching threshold, then the Wi-Fi data is determined to match the geofence.
[0077] In one possible implementation of the fourth aspect, when the aforementioned computer instructions are executed by the processor, the electronic device further performs the following steps:
[0078] Obtain location information and determine the administrative region corresponding to the current location based on the location information; wherein, the location information is the location information of the electronic device obtained according to a preset period, including latitude and longitude, cell identifier or one or more of them;
[0079] Download one or more geofences corresponding to the administrative region from the cloud device and save them locally.
[0080] In one possible implementation of the fourth aspect, when the aforementioned computer instructions are executed by the processor, the electronic device further performs the following steps:
[0081] Set an expiration date for downloaded and saved geofences; delete the expired geofences locally when their expiration date arrives.
[0082] In one possible implementation of the fourth aspect, when the aforementioned computer instructions are executed by the processor, the electronic device further performs the following steps:
[0083] The area is expanded outward from the location information as the center point to obtain the fenced area.
[0084] If the fence determines that a geofence exists within the area, register a Wi-Fi scanning callback function;
[0085] After obtaining a set of Wi-Fi data by scanning the Wi-Fi signal at the current location, the Wi-Fi scanning callback function is executed. The execution of the Wi-Fi scanning callback function includes: calculating the second matching score between the Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence; if the second matching score is greater than the matching threshold, it is determined that the Wi-Fi data matches the geofence.
[0086] In one possible implementation of the fourth aspect, when the aforementioned computer instructions are executed by the processor, the electronic device further performs the following steps: when there is no geofence within the fence determination area, the registered Wi-Fi scanning callback function is deregistered.
[0087] In one possible implementation of the fourth aspect, when the aforementioned computer instructions are executed by the processor, the electronic device further performs the following steps:
[0088] Calculate the fourth signal strength difference for the same BSSID in the geofence and Wi-Fi data; where the fourth signal strength difference is negatively correlated with the fourth difference; the fourth difference is the difference between the median Wi-Fi signal strength corresponding to the same BSSID in the geofence and the RSSI corresponding to the same BSSID in the Wi-Fi data.
[0089] Based on the fourth signal strength difference, the frequency weight of Wi-Fi signal strength corresponding to the same BSSID in the geofence, and the Wi-Fi signal strength baseline characteristics, calculate the matching score of the same BSSID in the geofence and Wi-Fi data.
[0090] Calculate the second matching score between the geofence and the Wi-Fi data; the second matching score is the sum of the matching scores for all identical BSSIDs in the geofence and the Wi-Fi data.
[0091] In one possible implementation of the fourth aspect, when the aforementioned computer instructions are executed by the processor, the electronic device further performs the following steps: receiving or sending information push based on the matching geofence.
[0092] Fifthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor in a cloud device, causes the cloud device to perform a geofence generation method as described in the first aspect and any possible design thereof. Alternatively, when executed by a processor in an electronic device, the computer program causes the electronic device to perform a geofence matching method as described in the second aspect and any possible design thereof.
[0093] Sixthly, this application provides a computer program product that, when run on a computer, causes the computer to execute a geofence generation method as described in the first aspect and any possible design thereof, wherein the computer may be the aforementioned cloud device. Alternatively, when run on a computer, the computer program product causes the computer to execute a geofence matching method as described in the second aspect and any possible design thereof, wherein the computer may be the aforementioned electronic device.
[0094] Understandably, the beneficial effects that can be achieved by the cloud device of any of the possible designs of the third aspect, the electronic device of any of the possible designs of the fourth aspect, the computer-readable storage medium of the fifth aspect, and the computer program product of the sixth aspect can be referred to as the beneficial effects of the first aspect and any of its possible designs, the second aspect and any of its possible designs, which will not be repeated here. Attached Figure Description
[0095] Figure 1 A schematic diagram of a system architecture for a Wi-Fi-based geofencing technology provided in this application embodiment;
[0096] Figure 2 This application provides an example of an interaction intent based on an electronic device and a cloud device.
[0097] Figure 3This is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application;
[0098] Figure 4 A schematic flowchart illustrating a geofence generation method provided in this application embodiment;
[0099] Figure 5 A schematic diagram of a Wi-Fi list provided in an embodiment of this application;
[0100] Figure 6 A schematic flowchart illustrating a geofence matching method provided in an embodiment of this application;
[0101] Figure 7 A flowchart illustrating another geofence matching method provided in this application embodiment;
[0102] Figure 8 This is a hardware and software structure block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0103] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. In the description of the embodiments of this application, the terminology used in the following embodiments is only for the purpose of describing specific embodiments and is not intended to limit the application. Furthermore, to facilitate a clear description of the technical solutions of the embodiments of this application, the terms "first," "second," etc., are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and that "first," "second," etc., are not necessarily different. Also, in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0104] Geofencing is a new application based on location services, essentially using a virtual fence to define a virtual geographic boundary. It can be understood as a location-aware technology used for location-related service recommendations. When an electronic device (e.g., a mobile phone) enters or leaves a specific geofence, or moves within that geofence area, the device can receive or send corresponding push notifications. These notifications can include automatic notifications, warnings, and triggering pre-subscribed activities to obtain customized location-related services.
[0105] Currently, most existing geofencing technologies generate geofencing by collecting location data using techniques such as network positioning and GNSS positioning. However, network positioning technology has a relatively large error, typically reaching hundreds of meters, which can easily reduce the accuracy of geofencing due to this error. While GNSS positioning technology has a smaller error, it requires higher power consumption and cannot be used for indoor location positioning, thus making it unsuitable for accurate indoor scenarios due to its high power consumption.
[0106] Based on this, in order to improve the accuracy of geofencing, reduce the power consumption required for geofencing generation, and enable geofencing to be accurately applied to indoor locations and other scenarios, this application provides a geofencing generation method, which is mainly based on Wi-Fi (wireless fidelity) related data.
[0107] Since Wi-Fi technology is now widely used, most electronic devices have Wi-Fi signal scanning capabilities. Therefore, utilizing the Wi-Fi signal scanning capabilities of electronic devices to scan and collect information from Wi-Fi access points as location data for generating geofences avoids the high errors of network positioning and the high power consumption of GNSS positioning compared to traditional location data collection technologies like network positioning and GNSS positioning, thus reducing errors and power consumption. Furthermore, most existing Wi-Fi devices (such as routers) are installed and deployed indoors. Therefore, Wi-Fi can be used as a geographic fingerprint for indoor positioning. Moreover, because the coverage area of Wi-Fi signals formed by Wi-Fi devices is limited, Wi-Fi positioning accuracy is relatively high, reaching up to ten meters. Therefore, the Wi-Fi-based geofence generation method provided in this application not only reduces power consumption and solves the problem of high device power consumption, but also generates geofences suitable for indoor location positioning with high accuracy.
[0108] like Figure 1 As shown in the diagram, this application provides a system architecture diagram applicable to a Wi-Fi-based geofence generation method. The following, in conjunction with... Figure 1 The system architecture shown provides a brief introduction to the geofence generation method provided in this application embodiment.
[0109] refer to Figure 1 The system architecture provided in this application mainly includes electronic device 100. Figure 1(Taking a mobile phone as an example), cloud device 102, and Wi-Fi device 103. Wi-Fi device 103 can form a signal coverage area 104 corresponding to the Wi-Fi access point. Electronic devices 100 located in the signal coverage area 104 corresponding to the Wi-Fi access point can scan the Wi-Fi signal corresponding to the Wi-Fi device 103, and thus obtain the information of the corresponding Wi-Fi access point (AP).
[0110] In this system, electronic device 100 can be understood as the application end of the geofencing, used to scan and collect Wi-Fi data and provide it to cloud device 102. Electronic device 100 can also be used to match geofences and provide information push services based on the matched geofences, thereby enabling the receiving or sending of corresponding information pushes. Cloud device 102 can be understood as the server end of electronic device 100, such as a cloud server, primarily used to generate geofences based on the Wi-Fi data uploaded by electronic device 100. Simultaneously, cloud device 102 possesses big data storage and processing capabilities, enabling it to manage and update all geofences.
[0111] It should be understood that, Figure 1 The number of electronic devices 100, cloud devices 102, and Wi-Fi devices 103 in the system architecture shown is merely for illustrative purposes in this application embodiment, and can be any number depending on actual needs and the actual deployment of the devices. For example, cloud device 102 can be a single cloud server or a cloud server cluster composed of multiple servers. The number of Wi-Fi devices 103 can mainly depend on the number installed in the actual application scenario.
[0112] Specifically, electronic device 100 can scan nearby Wi-Fi signals at a certain frequency to obtain a Wi-Fi scan list. Alternatively, electronic device 100 can respond to user operations by scanning nearby Wi-Fi signals to obtain a Wi-Fi scan list. The electronic device can simultaneously scan for Wi-Fi signals corresponding to one or more Wi-Fi devices 103, with each Wi-Fi signal corresponding to a Wi-Fi access point. Thus, electronic device 100 can obtain information about one or more Wi-Fi access points in a single scan. Therefore, the Wi-Fi scan list includes information about one or more Wi-Fi access points scanned by electronic device 100. The information of a Wi-Fi access point may include: Basic Service Set Identifier (BSSID), Received Signal Strength Indication (RSSI), and Service Set Identifier (SSID). In this embodiment, the information of the Wi-Fi access point includes at least the Basic Service Set Identifier (BSSID) and the Received Signal Strength Indication (RSSI).
[0113] Then, the electronic device 100 can upload the obtained Wi-Fi scan list to the cloud device 102 via the network, and the cloud device 102 can generate a geofence based on the Wi-Fi scan list.
[0114] Optionally, to ensure the validity of the Wi-Fi access point information, the electronic device 100 can preprocess the collected Wi-Fi scan list before uploading it to the cloud device 102. For example, preprocessing the Wi-Fi scan list could involve filtering out invalid Wi-Fi access point information, filtering out Wi-Fi access points with null parameters, or filtering out Wi-Fi access points with excessively low RSSI values. By filtering the information in the Wi-Fi scan list, the validity of the Wi-Fi data in the Wi-Fi scan list uploaded to the cloud device 102 can be ensured.
[0115] Therefore, it can be seen that the way the cloud device 102 obtains the Wi-Fi scan list required for geofence generation in this embodiment of the application is mainly completed by the electronic device 100 in a crowdsourcing manner (i.e., by multiple electronic devices collecting data).
[0116] Optionally, to expedite the uploading of Wi-Fi data, the electronic device 100 can upload the collected Wi-Fi scan list to the cloud device 102 using a mobile network or a Wi-Fi network after acquiring the Wi-Fi scan list. Alternatively, to conserve the user's mobile network traffic, the electronic device 100 can also upload the collected Wi-Fi scan list to the cloud device 102 using a Wi-Fi network only when connected to a Wi-Fi network.
[0117] Of course, the electronic device 100 can also upload the collected Wi-Fi scan list under other circumstances that do not affect the user's use of the electronic device 100. In other words, the specific timing of the electronic device 100 uploading the Wi-Fi scan list can be set according to actual needs, and this application embodiment does not impose any limitations on this.
[0118] After cloud device 102 receives the Wi-Fi scan lists uploaded by each electronic device 100, it can load these Wi-Fi scan lists to generate a Wi-Fi-based geofence.
[0119] Specifically, cloud device 102 first performs similarity clustering on multiple Wi-Fi scan lists. This clustering divides the multiple Wi-Fi scan lists uploaded by electronic device 100 into clusters, resulting in Wi-Fi list clusters. Depending on the actual clustering, each Wi-Fi list cluster includes one or more Wi-Fi scan lists. The similarity clustering is primarily based on the similarity between the Wi-Fi scan lists. The similarity between Wi-Fi scan lists is determined by measuring the similarity of the RSSIs corresponding to the same BSSID in the Wi-Fi scan lists.
[0120] After obtaining the Wi-Fi list cluster, the cloud device 102, due to similarity clustering, may find the same BSSID in different Wi-Fi scan lists within the Wi-Fi list cluster. Therefore, one BSSID may correspond to multiple RSSIs. In this case, it is impossible to measure the signal strength of a BSSID using only one RSSI. Therefore, the cloud device 102 further extracts features based on the frequency of each BSSID within the Wi-Fi list cluster and the corresponding RSSI, obtaining the feature weight for each BSSID within the Wi-Fi list cluster.
[0121] It should be understood that when different electronic devices scan Wi-Fi signals at the same location, the similarity of the resulting Wi-Fi scan lists will be higher. In this embodiment, only Wi-Fi scan lists with high similarity can be grouped into a single Wi-Fi list cluster. Therefore, the Wi-Fi scan lists in each Wi-Fi list cluster can be considered as having been obtained from scanning at the same location, reflecting the characteristics of the Wi-Fi signals at these locations. Thus, in this embodiment, a geofence is subsequently generated for each Wi-Fi list cluster based on the Wi-Fi scan lists within that cluster. Applying this geofence to the identification of entry into the corresponding location / venue can improve the accuracy of identifying electronic devices entering the geofence.
[0122] Next, to ensure that electronic device 100 can effectively match the geofence generated by cloud device 102 based on Wi-Fi list clusters in practical applications, and to provide electronic device 100 with a threshold for determining whether it matches the geofence, cloud device 102 further determines the matching threshold for the Wi-Fi list clusters. Cloud device 102 calculates the first matching score between each Wi-Fi scan list and the Wi-Fi list cluster based on the feature weights of each BSSID in the Wi-Fi list cluster, and determines the matching threshold for the Wi-Fi list cluster based on these multiple first matching scores. After calculating the matching scores between the Wi-Fi list cluster and different Wi-Fi scan lists using the feature weights of BSSIDs, determining an appropriate matching threshold based on these multiple matching scores ensures that the determined matching threshold can be used as a judgment threshold for matching most different Wi-Fi data with the geofence, thereby improving the accuracy of the matching determination.
[0123] Finally, the cloud device 102 generates geofences corresponding to the Wi-Fi list clusters. In this embodiment, there is a one-to-one correspondence between Wi-Fi list clusters and geofences; only one geofence can be generated for each Wi-Fi list cluster. Therefore, the generated geofence includes multiple BSSIDs in the Wi-Fi list cluster and the feature weights corresponding to each BSSID. Simultaneously, the cloud device 102 uses the matching threshold of this Wi-Fi list cluster as the matching threshold for the corresponding geofence. Therefore, the geofence also includes the matching threshold for the corresponding Wi-Fi list cluster, facilitating subsequent geofence matching and judgment by the electronic device 100 based on this matching threshold.
[0124] At this point, cloud device 102 has completed the generation of the geofence. Afterwards, electronic device 100 can download and save the geofence generated by cloud device 102 to its local machine. Electronic device 100 can then match and determine the geofence corresponding to its current location among these geofences, thereby enabling geofence-based information push services.
[0125] Based on this, this application also provides a geofence matching method applied to an electronic device 100. The following, in conjunction with... Figure 1 The system architecture shown provides a brief introduction to the geofence matching method provided in the embodiments of this application.
[0126] Specifically, when electronic device 100 needs to match a geofence, it first scans the Wi-Fi signals at its current location to obtain a set of Wi-Fi data. Since one or more Wi-Fi devices 103 can be located at the current location, the electronic device can simultaneously scan for one or more Wi-Fi signals corresponding to that location. Therefore, the set of Wi-Fi data obtained by the electronic device includes the BSSID and RSSI of one or more Wi-Fi access points. Thus, the set of Wi-Fi data scanned by electronic device 100 during the matching process is equivalent to the Wi-Fi scan list uploaded by electronic device 100 to cloud device 102 for generating the geofence. The only difference between the two is the timing of the scanning and collection by electronic device 100; the data content is the same, both including BSSID, RSSI, and SSID.
[0127] Then, the electronic device 100 calculates the matching score between this set of Wi-Fi data and each geofence based on the feature weights corresponding to each BSSID stored locally, obtaining a second matching score. Finally, the electronic device 100 compares the second matching score corresponding to each geofence with the matching threshold. When the second matching score corresponding to a geofence is greater than or equal to the matching threshold, it is determined that this set of Wi-Fi data matches the geofence corresponding to this second matching score. This geofence that matches the Wi-Fi data is the geofence corresponding to the current location of the electronic device.
[0128] Furthermore, after the electronic device 100 matches the geofence corresponding to the current location, it can implement information push service based on the matched geofence, and the electronic device can receive or send the corresponding information push.
[0129] like Figure 2 As shown, this is a schematic diagram illustrating the interaction between an electronic device and a cloud device. Figure 2 The interaction process between electronic devices and cloud devices is illustrated using two electronic devices (electronic device A and electronic device B) as examples.
[0130] The following, combined with Figure 2 The interaction process between the electronic device and the cloud device in the embodiments of this application is described.
[0131] First, electronic devices A and B scan nearby Wi-Fi signals, acquiring Wi-Fi scan lists including the BSSIDs and RSSIs of one or more Wi-Fi access points. Electronic devices A and B then upload these Wi-Fi scan lists to a cloud device. Next, after receiving the Wi-Fi scan lists uploaded by electronic devices A and B, the cloud device executes a geofencing generation method to generate a geofencing. This geofencing generation method may include: after acquiring multiple Wi-Fi scan lists, the cloud device performs similarity clustering on these lists to obtain multiple Wi-Fi list clusters. Then, based on the frequency of each BSSID in the Wi-Fi list cluster and the corresponding RSSI, the cloud device obtains the feature weight corresponding to each BSSID in the Wi-Fi list cluster. Finally, based on the feature weights corresponding to each BSSID in the Wi-Fi list cluster, the cloud device calculates a first matching score between each Wi-Fi scan list and the Wi-Fi list cluster, and determines a matching threshold for the Wi-Fi list cluster based on these first matching scores. Subsequently, the cloud device generates a geofence that includes multiple BSSIDs in this Wi-Fi list cluster, the feature weights corresponding to each BSSID, and the matching threshold of this Wi-Fi list cluster.
[0132] After a geofence is generated by a cloud device, electronic devices A and B download the generated geofence from the cloud device. The electronic devices then execute a geofence matching method. By executing this method, the electronic devices can match the geofence corresponding to their current location from the downloaded geofences. The geofences downloaded by electronic devices A and B each include multiple BSSIDs, feature weights for each BSSID, and a matching threshold for that geofence. The geofence matching method can include: electronic devices A and B scanning the Wi-Fi signal at their current location to obtain a set of Wi-Fi data; then, based on the feature weights corresponding to each BSSID in the geofence, calculating the matching score between the Wi-Fi data and the geofence; and finally, geofences with matching scores greater than or equal to the matching threshold are considered as matched geofences.
[0133] The aforementioned electronic device 100 may be, in addition to being a mobile phone including a Wi-Fi module, at least one of the following: a foldable electronic device including a Wi-Fi module, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device, or a smart city device.
[0134] This application does not impose any special restrictions on the specific type of the electronic device 100.
[0135] For example, such as Figure 3 As shown in the figure, this application provides a schematic diagram of the structure of an electronic device 100.
[0136] Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) connector 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera module 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The wireless communication module 160 includes a Wi-Fi module 161, used to scan Wi-Fi signals to obtain information about Wi-Fi access points and access Wi-Fi networks. The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.
[0137] The processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU).
[0138] Different processing units can be independent devices or integrated into one or more processors. The processor can generate operation control signals based on the instruction opcode and timing signals to control the instruction fetching and execution.
[0139] Specifically, in this embodiment of the application, the processor 110 of the electronic device 100 can collect the Wi-Fi scan list. That is, the processor 110 can control the Wi-Fi module 161 to scan Wi-Fi signals at different times to obtain information of the corresponding Wi-Fi access points (including at least BSSID and RSSI), thereby obtaining the Wi-Fi scan list.
[0140] The processor 110 of the electronic device 100 can also execute a geofence matching method to achieve geofence matching. Specifically, the processor 110 controls the Wi-Fi module 161 to scan the Wi-Fi signals at the current location, obtaining information including one or more Wi-Fi access points (at least including BSSID and RSSI). Then, the processor 110 calculates a second matching score between the Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence downloaded from the cloud device. Finally, the processor 110 determines that the Wi-Fi data matches a geofence with a second matching score greater than or equal to a matching threshold.
[0141] The processor 110 may also include a memory for storing instructions and data. For example, the memory may be used to store geofences downloaded from the cloud device 200, including multiple BSSIDs and feature weights corresponding to each BSSID, as well as geofence matching thresholds. In some embodiments, the memory in the processor 110 may be a cache memory. This memory can store instructions or data that the processor 110 has used or frequently used. If the processor 110 needs to use the instruction or data, it can directly retrieve it from this memory. This avoids repeated accesses, reduces the processor 110's waiting time, and thus improves system efficiency.
[0142] In some embodiments, the processor 110 may include one or more interfaces. These interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc. The processor 110 can connect to modules such as touch sensors, audio modules, wireless communication modules, displays, and camera components through at least one of these interfaces.
[0143] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0144] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card, or music, video, and other files can be transferred from the electronic device 100 to the external memory card.
[0145] Internal memory 121 can be used to store computer executable program code, including instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phone book, etc.). In addition, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional methods or data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory disposed in the processor.
[0146] The charging management module 140 receives charging input from the charger and charges the battery 142. While charging the battery 142, the charging management module 140 can also supply power to the electronic device 100 through the power management module 141.
[0147] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, internal memory 121, display screen 194, camera module 193, wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0148] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0149] Antennas 1 and 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0150] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0151] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), Bluetooth Low Energy (BLE), ultra-wideband (UWB), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies.
[0152] The wireless communication module 160 may be one or more devices integrating at least one communication processing module (in this embodiment, it includes at least one Wi-Fi module). The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates and filters the electromagnetic wave signal, and sends the processed signal to the processor 110. The wireless communication module 160 may also receive signals to be transmitted from the processor 110, modulate and amplify them, and then convert them into electromagnetic waves for radiation via the antenna 2.
[0153] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other electronic devices via wireless communication technology. This wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0154] Electronic device 100 can implement display functions through a GPU, display screen 194, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information. Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel.
[0155] The electronic device 100 can implement camera functions through a camera module 193, ISP, video codec, GPU, display screen 194, and application processor (AP), neural network processor (NPU), etc. In some embodiments, the camera module 193 may consist of a color camera module and a 3D sensing module. The electronic device may include one or more camera modules 193. Specifically, the electronic device may include one front-facing camera module 193 and one rear-facing camera module 193.
[0156] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0157] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0158] like Figure 4 The diagram illustrates an interactive flow of a geofence generation method applied to cloud devices. The following section combines... Figure 4 The geofence generation method provided in the embodiments of this application will be described in detail, including steps S401-S405.
[0159] S401, retrieve multiple Wi-Fi scan lists.
[0160] The Wi-Fi scan list is obtained by scanning with an electronic device. An electronic device can scan one or more Wi-Fi signals simultaneously in a single scan. Therefore, a Wi-Fi scan list includes information about one or more Wi-Fi access points obtained by an electronic device in a single scan. In this embodiment, the Wi-Fi access point information must include at least the BSSID and RSSI. After the electronic device scans and collects the Wi-Fi scan list, it uploads this Wi-Fi scan list to a cloud device.
[0161] For example, an electronic device scans nearby Wi-Fi signals using its Wi-Fi module, obtaining the BSSID and RSSI of the Wi-Fi access point corresponding to each signal, thus creating a Wi-Fi scan list. Then, at an appropriate time (e.g., when the electronic device connects to a Wi-Fi network), the electronic device uploads this scanned Wi-Fi scan list to a cloud device. Upon receiving a Wi-Fi scan list uploaded by an electronic device, the cloud device can store this list in its local database. When the cloud device needs to generate a geofence or update a generated geofence, it can load and retrieve multiple stored Wi-Fi scan lists from its local database.
[0162] For example, the Wi-Fi scan list stored by a cloud device can form a Wi-Fi list set. Figure 5 The diagram shows a list of Wi-Fi networks.
[0163] Figure 5 The Wi-Fi list set X shown includes three samples: samples ①, ②, and ③. Each sample is a Wi-Fi scan list, and each list item in the Wi-Fi scan list contains information about a scanned Wi-Fi access point, including its BSSID and RSSI.
[0164] S402, perform similarity clustering on multiple Wi-Fi scan lists to obtain multiple Wi-Fi list clusters.
[0165] In this embodiment, Wi-Fi scan lists are clustered based on similarity to separate Wi-Fi access points for different indoor locations. This facilitates the accurate generation of geofences for each indoor location based on its corresponding Wi-Fi scan list. After clustering multiple Wi-Fi scan lists using similarity, each Wi-Fi list cluster obtained by the cloud device can include one or more Wi-Fi scan lists. Wi-Fi scan lists within the same Wi-Fi list cluster are considered similar by the clustering algorithm.
[0166] This can be understood as follows: the information of Wi-Fi access points included in the Wi-Fi scan list within a Wi-Fi list cluster represents the information of the Wi-Fi access points corresponding to an indoor location. Subsequently, a geofence corresponding to this indoor location can be generated based on this Wi-Fi list cluster. In other words, the geofence subsequently generated in this embodiment covers the area covered by the signals of each Wi-Fi access point included in the Wi-Fi scan list within the corresponding Wi-Fi list cluster.
[0167] The Wi-Fi scan list acquired by the cloud device can be information on Wi-Fi access points scanned by any electronic device at any location. However, the signal coverage area of a Wi-Fi access point is typically limited. Therefore, when two locations are far apart, the similarity of Wi-Fi access point information between two Wi-Fi scan lists collected by an electronic device at those locations will be relatively low. Conversely, when the two locations are close enough, or when two Wi-Fi scan lists are collected by different electronic devices at the same location, the similarity of Wi-Fi access point information between these two Wi-Fi scan lists will be relatively high.
[0168] For example, if electronic device A collects Wi-Fi scan list A from store A and Wi-Fi scan list B from store B, the similarity of the Wi-Fi access point information included in Wi-Fi scan list A and Wi-Fi scan list B will be relatively low if stores A and B are far enough apart. However, if Wi-Fi scan list A collected by electronic device A from store A and Wi-Fi scan list B collected by electronic device B from store A, the similarity of the Wi-Fi access point information between these two Wi-Fi scan lists will be relatively high because they are collected from the same store.
[0169] Therefore, in some embodiments, Wi-Fi scan list clustering can be achieved by considering the similarity of Wi-Fi access point information between two Wi-Fi scan lists, thereby ensuring the accuracy of Wi-Fi scan list clustering. That is, to improve the accuracy of Wi-Fi scan list clustering, embodiments of this application can primarily rely on the similarity of Wi-Fi access point information within the Wi-Fi scan lists to achieve Wi-Fi scan list clustering.
[0170] In this embodiment, the information of Wi-Fi access points mainly includes BSSID and RSSI. Furthermore, the clustering in this embodiment primarily distinguishes Wi-Fi scan lists corresponding to different indoor locations. Therefore, the similarity between the information of Wi-Fi access points in two Wi-Fi scan lists can be measured using BSSID and RSSI.
[0171] In some embodiments, since Wi-Fi devices are typically installed indoors, electronic devices located outdoors or in other indoor locations (not within the same room where the Wi-Fi device is installed) may also be able to scan the Wi-Fi signal of this device due to wide Wi-Fi signal coverage or signal penetration. This means that the same BSSID may appear in the scan lists of two Wi-Fi devices scanned from different indoor locations. However, generally speaking, the closer an electronic device is to the Wi-Fi device, the higher the RSSI corresponding to that Wi-Fi device will be.
[0172] Therefore, in order to accurately distinguish the Wi-Fi scan lists of different indoor locations, clustering can be performed based on the similarity of RSSI corresponding to the same BSSID, thereby achieving the effect of more accurate geofencing for different indoor locations.
[0173] Based on this, S402 may include: for every two Wi-Fi scan lists in multiple Wi-Fi scan lists, calculating the similarity of RSSIs corresponding to the same BSSID in the two Wi-Fi scan lists; calculating the sum of the similarity of RSSIs corresponding to each of the same BSSIDs in the two Wi-Fi scan lists to obtain the similarity of the two Wi-Fi scan lists; and clustering the multiple Wi-Fi scan lists based on the similarity of every two Wi-Fi scan lists to obtain multiple Wi-Fi list clusters.
[0174] Specifically, for any two Wi-Fi scan lists, the fewer identical BSSIDs they contain, the lower the likelihood that the two Wi-Fi scan lists were scanned in the same indoor location or in two indoor locations that are close to each other. Conversely, the more identical BSSIDs two Wi-Fi scan lists contain, the higher the likelihood that the two Wi-Fi scan lists were scanned in the same indoor location or in two indoor locations that are close to each other.
[0175] Therefore, to improve the accuracy of geofencing generation based on different indoor locations, the similarity between two Wi-Fi scan lists in this embodiment can depend on the similarity of RSSIs corresponding to the same BSSID in the two Wi-Fi scan lists. Furthermore, the more identical BSSIDs there are in the two Wi-Fi scan lists, and the higher the similarity of the RSSIs corresponding to the same BSSIDs, the higher the similarity between the two Wi-Fi scan lists will be.
[0176] After calculating the similarity of RSSIs corresponding to the same BSSID in two Wi-Fi scan lists, the cloud device sums the similarity of RSSIs corresponding to the same BSSID in the two Wi-Fi scan lists. This sum of similarity is the similarity between the two Wi-Fi scan lists.
[0177] For example, with Figure 5 Taking the Wi-Fi scan lists shown as an example, for Wi-Fi scan lists ① and ②, the common BSSIDs include: "04:d3:b5:b7:37:d4", "1c:28:af:9c:82:a2", and "1c:28:af:9c:82:a4". For Wi-Fi scan lists ① and ③, the common BSSIDs include: "04:d3:b5:b7:37:d5", "1c:28:af:9c:82:a2", "1c:28:af:9c:82:a4", and "1c:28:af:9c:82:b1". Similarly, for Wi-Fi scan lists ② and ③, the corresponding common BSSIDs can be determined in the same way as above, which will not be repeated here. The following uses Wi-Fi scan lists ① and ② as examples to illustrate the similarity calculation process of Wi-Fi scan lists.
[0178] In other words, to calculate the similarity between the two Wi-Fi scan lists ① and ②, the cloud device first needs to calculate the similarity of the two RSSIs corresponding to "04:d3:b5:b7:37:d4" (hereinafter referred to as the first similarity), "1c:28:af:9c:82:a2" (hereinafter referred to as the second similarity), and "1c:28:af:9c:82:a4" (hereinafter referred to as the third similarity). Then, the cloud device will sum the first, second, and third similarities, and the sum of the similarities is the similarity between the two Wi-Fi scan lists ① and ②.
[0179] In some embodiments, the similarity of RSSIs corresponding to the same BSSID in every two Wi-Fi scan lists may include: calculating a first signal strength difference and a first signal strength weight for the RSSIs corresponding to the same BSSID in every two Wi-Fi scan lists; and using the product of the difference between the first signal strength difference and the second signal strength difference and the first signal strength weight as the similarity of the RSSIs corresponding to the same BSSID. Specifically, the first signal strength difference is negatively correlated with a first difference value, which is the difference between the RSSIs corresponding to the same BSSID; the first signal strength weight is positively correlated with any RSSI corresponding to the same BSSID; and the second signal strength difference is negatively correlated with a second difference value, which is the difference between any RSSI corresponding to the same BSSID and a preset RSSI.
[0180] Specifically, the cloud device first calculates the first signal strength difference based on the first difference of the RSSI corresponding to the same BSSID. Simultaneously, the cloud device calculates the first signal strength weight based on any RSSI corresponding to the same BSSID.
[0181] In some embodiments, the first signal strength difference can be calculated using the following formula.
[0182]
[0183] Where q(x) i,b ,x j,b ) represents the first signal strength difference of RSSI corresponding to the same BSSID, x i,b This represents the RSSI corresponding to BSSID b in the i-th Wi-Fi scan list; x j,b This represents the RSSI corresponding to BSSID b in the j-th Wi-Fi scan list; k q and d q k is a preset parameter. q =0.052160; d q =0.2;Ⅱ(x) i,b <x j,b () represents an indicator function, which is used when the input condition x is met. i,b <x j,b When true, the function value is 1; otherwise, the function value is 0. According to the formula for calculating the first signal strength difference, the first difference |x| between RSSIs corresponding to the same BSSID is... i,b -x j,b The larger | is, the greater the difference in the first signal strength q(x) i,b ,x j,b The smaller the value, the better. Therefore, the first signal strength difference is negatively correlated with the first difference value.
[0184] In some embodiments, the first signal strength weight can be calculated using the following formula:
[0185]
[0186] Where p(x) represents the first signal strength weight of any RSSI corresponding to the same BSSID, x = x i,b or x j,b Therefore, p(x) = p(x) i,b ) or p(x j,b ), p(x i,b ) represents the first signal strength weight of the RSSI corresponding to BSSID b in the i-th Wi-Fi scan list, p(x j,b ) represents the first signal strength weight of the RSSI corresponding to BSSID b in the j-th Wi-Fi scan list; k p and b p k is a preset parameter. p =0.130401; b p = -65.
[0187] According to the formula for calculating the first signal strength weight, the larger the RSSI (i.e., x...), the more... i,b or x j,b The larger the value, the greater the weight of the first signal strength (i.e., p(x)). i,b ) or p(x j,b The larger the value, the greater the weight of the first signal strength. Therefore, the first signal strength weight is positively correlated with RSSI.
[0188] In the embodiments of this application, k q d q k p and b p The fixed values of these four preset parameters are determined based on actual needs. They are obtained by substituting multiple sets of different preset values into the experimental calculations and then determining the effects presented by the different calculation results corresponding to different values.
[0189] After the cloud device calculates the first signal strength difference and the first signal strength weight of the RSSI corresponding to the same BSSID in the two Wi-Fi scan lists, it calculates the similarity of the RSSI corresponding to the same BSSID in the two Wi-Fi scan lists based on the first signal strength difference and the first signal strength weight.
[0190] Specifically, the cloud device first calculates the difference between any RSSI corresponding to the same BSSID and a preset RSSI, obtaining a second difference. Then, a second signal strength difference is calculated based on this second difference. The product of the difference between the first and second signal strength differences and the first signal strength weight is used as the similarity of the RSSIs corresponding to the same BSSID. The preset RSSI is a pre-defined RSSI used for signal strength comparison and can be set according to actual needs and experience. In this embodiment, the preset RSSI = -105.
[0191] In some embodiments, the similarity of RSSIs corresponding to the same BSSID can be calculated using the following formula:
[0192] p(x)(q(x i,b x j,b )-q(x,c x ))
[0193] Where p(x) represents the first signal strength weight of any RSSI corresponding to the same BSSID, including p(x) i,b ) or p(x j,b );q(x i,b ,x j,b ) represents the first signal strength difference of RSSI corresponding to the same BSSID; q(x,c x ) represents the second signal strength difference of any RSSI corresponding to the same BSSID, including q(x i,b ,c x ) or q(x j,b ,c x ), c x This indicates the default RSSI.
[0194] After calculating the similarity of RSSIs corresponding to all identical BSSIDs in the two Wi-Fi scan lists using the above formula, the cloud device sums the similarity of RSSIs corresponding to all identical BSSIDs to obtain the similarity of the two Wi-Fi scan lists.
[0195] In some embodiments, the similarity between two Wi-Fi scan lists can be calculated using the following formula:
[0196]
[0197] Where w(x) i ,x j B represents the similarity between the i-th Wi-Fi scan list and the j-th Wi-Fi scan list; i ∩B j Represents the i-th Wi-Fi scan list B iand the j-th Wi-Fi scan list B j The set of identical BSSIDs in B, b∈B i ∩B j .
[0198] Then, the cloud device performs similarity clustering on the multiple Wi-Fi scan lists based on the similarity between every two Wi-Fi scan lists, resulting in multiple Wi-Fi list clusters. For example, by clustering similarity, Wi-Fi scan lists ① and ② are grouped into one cluster, and the resulting Wi-Fi list cluster includes both Wi-Fi scan lists ① and ②.
[0199] It should be noted that any RSSI mentioned above refers to selecting one RSSI from those corresponding to the same BSSID for calculating signal strength weights or signal strength differences. This is because existing clustering algorithms typically select cluster centers first, with the number of selected centers equal to the number of clusters obtained after clustering. After determining the cluster centers, all data requiring clustering is grouped based on their similarity to the cluster centers. In other words, when performing similarity clustering, the similarity between other data and each cluster center is usually calculated based on the cluster centers. The cluster corresponding to this data is then determined based on its similarity to the cluster centers. Therefore, in this embodiment, any RSSI corresponding to a BSSID mainly depends on the cluster centers selected during the actual clustering process. This selected RSSI refers to the RSSI corresponding to the same BSSID in the Wi-Fi scan list that serves as the cluster center.
[0200] For example, suppose the i-th Wi-Fi scan list is Figure 5 The Wi-Fi scan list shown ① is shown below. The j-th Wi-Fi scan list is... Figure 5 The Wi-Fi scan list ② is shown. When performing similarity clustering, if the clustering algorithm selects Wi-Fi scan list ① as the cluster center, then the first signal strength weight p(x) needs to be calculated as the signal strength weight of the RSSI corresponding to the same BSSID in Wi-Fi scan list ①, i.e., p(x) i,b Meanwhile, the aforementioned second signal intensity difference q(x,c) x What actually needs to be calculated is q(x) i,b ,c x ).
[0201] Conversely, if the clustering algorithm selects Wi-Fi scan list ② as the cluster center, then the first signal strength weight p(x) mentioned above needs to be calculated based on the signal strength weight of the RSSI corresponding to the same BSSID in Wi-Fi scan list ②, i.e., p(x)j,b Meanwhile, the aforementioned second signal intensity difference q(x,c) x What actually needs to be calculated is q(x) j,b ,c x ).
[0202] In some embodiments, the main purpose of similarity clustering of the Wi-Fi scan list is to accurately divide different indoor locations into corresponding geofences. Therefore, the specific number of geofences cannot be preset when the actual Wi-Fi device installation is unknown. Consequently, the number of clusters cannot be configured in advance. Therefore, the clustering algorithm selected in this embodiment can be a density-based clustering method. This is because density-based clustering does not require pre-determining the number of clusters. That is, the cloud device can perform density clustering based on the similarity between the Wi-Fi scan lists to obtain Wi-Fi list clusters.
[0203] Furthermore, although the embodiments of this application can preset the number of clusters solely based on the requirement for the number of geofences without considering the actual distribution of Wi-Fi devices, and thus select a clustering algorithm that requires pre-determined cluster numbers for similarity clustering, density-based clustering methods primarily cluster based on the density of sample distribution. They mainly group points with sufficiently dense feature spaces into the same cluster. Samples classified into the same category through density clustering are closely connected, and the shape of the clusters can be arbitrary. Therefore, considering that densely distributed Wi-Fi devices may correspond to multiple Wi-Fi devices in the same indoor location, choosing a density-based clustering method is more suitable for generating Wi-Fi-based geofences in the embodiments of this application, thereby improving both the clustering effect and the accuracy of the geofence.
[0204] The density-based clustering method selected in this application embodiment may include any one or more of the following combined: a density-based spatial clustering of applications with noise (DBSCAN), a clustering algorithm that determines the clustering structure by ranking points (OPTICS), and a clustering algorithm based on a set of density distribution functions (DENCLUE).
[0205] In summary, in this embodiment, clustering the Wi-Fi scan lists based on the signal strength RSSI of the same Wi-Fi access point in different Wi-Fi scan lists can accurately divide the Wi-Fi list clusters corresponding to different indoor locations. Subsequently, geofencing can be determined based on these Wi-Fi list clusters, thereby improving the accuracy of geofencing generation. Simultaneously, subsequent geofencing matching by electronic devices based on the geofencing generated from these Wi-Fi list clusters can also achieve accurate delivery of different services offered to different indoor locations.
[0206] S403. Based on the frequency of occurrence of each BSSID in the Wi-Fi list cluster and the RSSI corresponding to each BSSID, the feature weight corresponding to each BSSID in the Wi-Fi list cluster is obtained.
[0207] Once the cloud device obtains the Wi-Fi list cluster, it essentially has the Wi-Fi information corresponding to different indoor locations. Therefore, the cloud device can directly generate corresponding geofences based on the Wi-Fi list cluster. However, since a Wi-Fi list cluster may contain multiple Wi-Fi scan lists, and in this embodiment, these multiple Wi-Fi scan lists are clustered together based on the similarity of RSSIs corresponding to the same BSSID, the same BSSID may exist in different Wi-Fi scan lists within the Wi-Fi list cluster. Therefore, within this Wi-Fi list cluster, a BSSID may correspond to multiple different RSSIs.
[0208] For example, suppose Figure 5 After Wi-Fi scan list ① and Wi-Fi scan list ② are clustered together, the RSSI corresponding to BSSID: 04:d3:b5:b7:37:d4 in the Wi-Fi list cluster will include -79 and -80.
[0209] In this situation, it would be inaccurate to use only one RSSI to measure the signal strength of the Wi-Fi access point corresponding to the BSSID. Furthermore, when electronic devices perform geofencing matching, they need to measure the similarity based on the RSSI corresponding to the BSSID within the geofence to determine whether a match has been made.
[0210] Therefore, in order to accurately obtain the RSSI that can measure the signal status of BSSIDs in the Wi-Fi list cluster, the cloud device, after obtaining the Wi-Fi list cluster, further extracts the feature weights of each BSSID in the Wi-Fi list cluster based on the frequency of occurrence of BSSIDs in the Wi-Fi list cluster and the RSSI corresponding to the BSSIDs.
[0211] In some embodiments, the feature weights of BSSIDs in a Wi-Fi list cluster include the median Wi-Fi signal strength, the frequency weight of Wi-Fi signal strength, and the baseline feature of Wi-Fi signal strength. The frequency weight and the baseline feature are both calculated using the median Wi-Fi signal strength as the baseline signal strength.
[0212] Therefore, the cloud device first needs to determine the median Wi-Fi signal strength for each BSSID in the Wi-Fi list cluster. Specifically, the cloud device first calculates the median of all RSSIs corresponding to the same BSSID in the Wi-Fi list cluster, and uses this median as the median Wi-Fi signal strength for that BSSID. In other words, the cloud device essentially first determines all RSSIs corresponding to the same BSSID in the Wi-Fi list cluster, then calculates the median of all RSSIs corresponding to the same BSSID, and uses this calculated median as the median Wi-Fi signal strength for that BSSID.
[0213] Furthermore, in this embodiment, if the median value of the calculated Wi-Fi signal strength of the determined BSSID is not an integer, a rounding operation can be performed on this median value. The rounding operation can involve omitting the decimal places.
[0214] For example, suppose Figure 5 The three Wi-Fi scan lists shown represent a cluster of Wi-Fi lists obtained through clustering. The RSSI corresponding to BSSID:04:d3:b5:b7:37:d4 includes -79 and -80. The cloud device calculates the median value between -79 and -80. The median value is -79.5, and after rounding, the median value is -79. Therefore, the median Wi-Fi signal strength corresponding to BSSID:04:d3:b5:b7:37:d4 in this Wi-Fi list cluster is -79, which can be represented as i0 = -79.
[0215] Then, the cloud device calculates the Wi-Fi signal strength frequency weight and Wi-Fi signal strength baseline characteristics of the obtained BSSID based on the Wi-Fi signal strength characteristics of the BSSID.
[0216] The frequency weight of the Wi-Fi signal strength for a BSSID is the product of its occurrence frequency and a second signal strength weight. The occurrence frequency is the ratio of the number of times this BSSID appears in a Wi-Fi list cluster to the number of Wi-Fi scan lists in that cluster. The second signal strength weight is the median value of the Wi-Fi signal strength corresponding to this BSSID, and it is positively correlated with the median Wi-Fi signal strength.
[0217] The calculation of the second signal strength weight can be achieved using the p function mentioned above, i.e., calculating p(i0). The specific calculation process and principle can be found in the calculation process and principle of p(x) above, and will not be repeated here.
[0218] For example, also with Figure 5 Taking the three Wi-Fi scan lists shown as a single Wi-Fi list cluster, the median Wi-Fi signal strength i0 corresponding to BSSID:04:d3:b5:b7:37:d4 is -79. Since this Wi-Fi list cluster includes three Wi-Fi scan lists, and two of these lists contain BSSID:04:d3:b5:b7:37:d4, BSSID:04:d3:b5:b7:37:d4 appears twice, therefore its frequency is 2 / 3. Thus, the frequency weight of the Wi-Fi signal strength corresponding to BSSID:04:d3:b5:b7:37:d4 is f0 = p(-79) × 2 / 3. Substituting the parameters, the calculated result f0 = 0.092508.
[0219] The Wi-Fi signal strength reference characteristic of a BSSID is the difference between the median Wi-Fi signal strength corresponding to that BSSID and a preset RSSI. This signal strength difference is referred to as the third signal strength difference in this embodiment. The third signal strength difference is negatively correlated with a third difference value, which is the difference between the median Wi-Fi signal strength corresponding to the BSSID and c. x The difference between the three signal strengths. The calculation of the third signal strength difference can be achieved using the q function mentioned above, i.e., third signal strength difference = q(i0, c). x ).
[0220] For example, Figure 5 The baseline characteristic of the Wi-Fi signal strength of BSSID:04:d3:b5:b7:37:d4 is f1=q(-79,-105), and the result after substituting it into the calculation is f1=0.257646.
[0221] S404, based on the feature weights corresponding to each BSSID in the Wi-Fi list cluster, calculate the first matching score between each Wi-Fi scanning list and the Wi-Fi list cluster in multiple Wi-Fi scanning lists, and determine the matching threshold of the Wi-Fi list cluster based on multiple first matching scores.
[0222] In this embodiment, after generating a geofence based on a Wi-Fi list cluster, a threshold is provided to determine whether the geofence matches. The cloud device obtains the feature weights corresponding to each BSSID in the Wi-Fi list cluster, and then calculates the matching score between the Wi-Fi list cluster and each Wi-Fi scan list based on the feature weights of each BSSID in the Wi-Fi list cluster, thus obtaining the first matching score.
[0223] Then, the cloud device determines the corresponding matching threshold for this Wi-Fi list cluster based on multiple first matching scores, and this matching threshold can be used as the matching threshold for the geofence corresponding to this Wi-Fi list cluster.
[0224] The Wi-Fi scan lists used for calculating the first matching score with the Wi-Fi list cluster mentioned above are those Wi-Fi scan lists uploaded by the electronic device to the cloud device. It should be understood that each Wi-Fi scan list mentioned here is not limited to all Wi-Fi scan lists stored by the cloud device. To improve the accuracy of the matching threshold, the cloud device can calculate the first matching score with each stored Wi-Fi scan list individually. However, to save computational resources and reduce cloud device consumption, a subset of Wi-Fi scan lists can be selected from the stored Wi-Fi scan lists and used to calculate the first matching score with this Wi-Fi list cluster. The specific settings can be configured according to actual needs, and this embodiment does not impose any limitations on this.
[0225] In some embodiments, the first matching score can be calculated using the following formula:
[0226]
[0227] Where score(y,x) represents the first matching score between Wi-Fi list cluster y and Wi-Fi scan list x; B represents the set of identical BSSIDs in Wi-Fi list cluster y and Wi-Fi scan list x, b∈B; y b,f0 The frequency weight f0 represents the Wi-Fi signal strength corresponding to BSSID b in the Wi-Fi list cluster y; q(y b,i0 ,x b ) represents y b,i0 and x b Poor signal strength, y b,i0This represents the median value i0, x of the Wi-Fi signal strength corresponding to BSSID b in Wi-Fi list cluster y. b This represents the RSSI of BSSID b in the Wi-Fi scan list x; y b,f1 f1 represents the Wi-Fi signal strength baseline feature f1 corresponding to BSSID b in the Wi-Fi list cluster y.
[0228] In some embodiments, determining the matching threshold of a Wi-Fi list cluster based on multiple first matching scores may include: calculating the median value of multiple first matching scores, using the product of the median value of multiple first matching scores and a preset score weight as a matching threshold reference value; and using the first matching score that is greater than or equal to the matching threshold reference value and has the smallest score among the multiple first matching scores as the matching threshold of the Wi-Fi list cluster.
[0229] That is, after calculating the first matching score between the Wi-Fi list cluster and each Wi-Fi scan list using the aforementioned formula, the cloud device first takes the median value among these multiple first matching scores to obtain a matching score that comprehensively reflects the matching situation of the Wi-Fi list cluster with different Wi-Fi scan lists. Then, the cloud device calculates the product of the median value of the first matching score and a preset score weight, and uses this product as a reference value for the matching threshold. The preset score weight k is a preset parameter that can be set according to actual matching needs; in this embodiment, k = 0.6.
[0230] The cloud device determines a first matching score as the matching threshold from all first matching scores, based on a matching threshold reference value. In this embodiment, the first matching score determined as the matching threshold must be greater than or equal to the matching threshold and be the first matching score with the smallest score.
[0231] For example, suppose a Wi-Fi list cluster and Figure 5 The first matching scores for the three Wi-Fi scan lists shown are 1.248771, 1.404265, and 1.808534, respectively. Therefore, 0.6 times the median of the first matching score is 0.842558. Based on the condition that the first matching score is greater than or equal to the matching threshold of 0.842558 and is the smallest, we can determine that the first matching score of 1.248771 is the matching threshold for this Wi-Fi list cluster.
[0232] S405, generate the geofence corresponding to the Wi-Fi list cluster.
[0233] The geofencing includes: multiple BSSIDs in the Wi-Fi list cluster and the feature weights corresponding to each BSSID, as well as the matching threshold for the Wi-Fi list cluster.
[0234] Specifically, after the cloud device clusters the Wi-Fi scan list and obtains the feature weights of each BSSID in the Wi-Fi list cluster, it can generate geofences corresponding to different indoor locations based on the Wi-Fi list cluster. Accordingly, the geofence generated for this Wi-Fi list cluster includes: multiple BSSIDs in the Wi-Fi list cluster and the feature weights corresponding to each BSSID. Simultaneously, the cloud device uses the matching threshold of this Wi-Fi list cluster as the matching threshold for this geofence, providing a matching reference for subsequent electronic devices when matching geofences. Therefore, the geofence also includes the matching threshold corresponding to the Wi-Fi list cluster.
[0235] For example, assuming that the cloud device obtains three Wi-Fi list clusters through clustering, it can generate three geofences accordingly, and the three Wi-Fi list clusters correspond one-to-one with the three geofences, with different geofences corresponding to different indoor locations.
[0236] For example, suppose Figure 5 The Wi-Fi scan list ① and Wi-Fi scan list ② are divided into a Wi-Fi list cluster. After extracting the feature weights corresponding to each BSSID in this Wi-Fi list cluster and calculating and determining the matching threshold of this Wi-Fi list cluster, the geofence corresponding to this Wi-Fi list cluster can be shown in Table 1 below.
[0237] The specific values of the feature weights and matching thresholds corresponding to each BSSID in Table 1 below are for illustrative purposes only and may not be completely accurate calculation results.
[0238] Table 1
[0239]
[0240] In some embodiments, when the number of Wi-Fi scan lists clustered together is large, the amount of BSSID data within each Wi-Fi list cluster will also be relatively large, resulting in a large amount of data for the generated geofence. However, since Wi-Fi signal strength can reflect its distance to Wi-Fi devices, it can also indirectly reflect its distance to indoor locations. Therefore, when generating geofences for indoor locations, only high-frequency, high-signal-strength BSSIDs are typically truly useful. Therefore, to reduce the amount of BSSID data included in the geofence while ensuring that the BSSIDs retained within the geofence are valid and practically useful, a portion of the BSSIDs can be further filtered out from the geofence based on their feature weights.
[0241] Based on this, before S404, it may also include: filtering out BSSIDs in the Wi-Fi list cluster according to the feature weights corresponding to each BSSID in the Wi-Fi list cluster, so as to obtain a Wi-Fi list cluster with a number of BSSIDs that meets the preset number requirement.
[0242] The preset quantity requirement limits the amount of BSSID data within a geofence. For example, the number of BSSID data corresponding to one geofence can be limited to 30. Therefore, cloud devices can filter out a portion of BSSIDs based on the preset quantity requirement, according to any one or more of the following feature weights: the median Wi-Fi signal strength i0, the Wi-Fi signal strength frequency weight f0, or the Wi-Fi signal strength baseline feature f1. This reduces the amount of data while retaining the truly useful BSSIDs.
[0243] For example, taking the geofence and Wi-Fi signal strength frequency weight f0 shown in Table 1 as an example, the cloud device can filter out BSSIDs according to f0 from small to large until the number of BSSIDs remaining meets the preset requirement. Assuming that five BSSIDs are filtered out, the geofence data remaining after filtering out these five BSSIDs in Table 1 can be referred to in Table 2 below.
[0244] Table 2
[0245]
[0246] Alternatively, multiple feature weights can be combined to filter out BSSIDs. For example, when the f0 values corresponding to two or more BSSIDs are equal, the BSSIDs to be filtered out can be determined from these two or more BSSIDs based on the i0 or f1 values corresponding to the BSSIDs. As shown in Tables 1 and 2 above, through data filtering, the amount of geofencing data can be reduced from twelve to seven, thus retaining valid data while reducing the amount of geofencing data.
[0247] After the cloud device generates the geofence according to the method described in the above embodiments, the electronic device can then match the geofence based on the geofence generated by the cloud device.
[0248] like Figure 6 The diagram illustrates an interactive flow of a geofence matching method applied to electronic devices. The following section, in conjunction with... Figure 6 The geofence matching method provided in the embodiments of this application is described in detail, including steps S601-S605.
[0249] S601, Obtain location information and determine the administrative region corresponding to the current location based on the location information.
[0250] S602 downloads one or more geofences corresponding to administrative regions from the cloud device and saves them locally.
[0251] The location information refers to the location information used to trigger the download of the geofence, which is obtained according to a preset period. It may include latitude and longitude, cell identifier, or any one or more of these. Latitude and longitude can be obtained through the GPS module in the electronic device. The cell identifier may be the cell identity (CID), location area code (LAC), or tracking area code (TAC) of the cell to which the electronic device is connected. The specific identifier can be set according to the actual application scenario requirements, and this embodiment does not limit it here.
[0252] Administrative divisions can be first-level provincial-level administrative divisions (including provinces, autonomous regions, municipalities directly under the central government, and special administrative regions), second-level prefecture-level administrative divisions (including prefecture-level cities, regions, autonomous prefectures, and leagues), third-level county-level administrative divisions (including urban districts, county-level cities, counties, autonomous counties, banners, autonomous banners, special zones, and forest areas), or fourth-level township-level administrative divisions (including subdistricts, towns, townships, ethnic townships, sumu, ethnic sumu, and county-level districts).
[0253] Specifically, electronic devices acquire location information, which can be latitude and longitude or cellular identifiers, according to a preset period. The preset period can be set according to actual needs.
[0254] For example, the preset period can be set according to the level of the administrative region. Generally, users with electronic devices usually reside in a second-level prefecture-level administrative region for a long period. Therefore, when the administrative region for downloading the geofence is set to a first-level provincial administrative region or a second-level prefecture-level administrative region, the location information acquisition period can be set longer because the user is less likely to move frequently between provinces or prefectures. However, when users with electronic devices enter a third-level county-level administrative region or a fourth-level township-level administrative region, the likelihood of the user moving between counties or townships is relatively greater. Therefore, when the administrative region for downloading the geofence is set to a third-level county-level administrative region or a fourth-level township-level administrative region, the preset period can be set relatively shorter to ensure that the electronic device can acquire the geofence of the area in a timely manner.
[0255] Then, after the electronic device determines its current administrative region based on the location information, it can download one or more geofences within that region from the cloud. The geofence downloaded by the electronic device includes: multiple BSSIDs and the feature weights corresponding to each BSSID, as well as the matching threshold for the geofence. The location information corresponding to the BSSID in the geofence can be the location information of the Wi-Fi scan list corresponding to that BSSID. The location information of the Wi-Fi scan list can be the location information when the electronic device scans and obtains this Wi-Fi scan list; this location information can be collected and uploaded to the cloud along with the Wi-Fi scan list.
[0256] Furthermore, when an electronic device downloads a geofence from a cloud device, it can determine the administrative region where the geofence is located based on the location information of the BSSID within the geofence, and thus download the geofence within that administrative region.
[0257] For example, when an electronic device determines, based on location information, that it has entered a specific province or prefecture-level city, it can trigger communication with the cloud to download the geofences within that province or prefecture-level city. The downloaded geofences are then used by the electronic device for subsequent geofence matching within that administrative region.
[0258] Of course, without considering the storage space and load of electronic devices, it is also possible to choose to download all generated geofences from the cloud device according to actual needs. However, in this embodiment, downloading a portion of the geofences after determining the administrative region through location information can ensure that the local storage has the required geofences while reducing the power consumption load of the electronic device and saving the storage space of the electronic device.
[0259] In some embodiments, if a geofence is downloaded to an electronic device and stored therefore for an extended period, the accumulated downloads will result in an ever-increasing amount of geofence data stored on the device, still occupying storage space and increasing power consumption.
[0260] Therefore, to prevent the cumulative increase in downloaded geofences, electronic devices download the corresponding geofences from the cloud and then set an expiration date for each downloaded geofence. The electronic device then monitors the expiration dates of locally stored geofences. If a geofence has expired, it is deleted locally.
[0261] In this embodiment, by setting an expiration date and periodically clearing expired geofences, the storage space of electronic devices can be prevented from being occupied by an increasing number of geofences. Simultaneously, since the electronic device obtains location information and downloads geofences at a fixed preset period, even if the electronic device clears out still useful geofences, it can still trigger a re-download via location information. In other words, this application's periodic clearing does not affect geofence matching.
[0262] S603, scan the Wi-Fi signal at the current location to obtain a set of Wi-Fi data.
[0263] S604. Calculate the second matching score between the Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence.
[0264] S605, if the second matching score is greater than or equal to the matching threshold, then the Wi-Fi data is determined to match the geofence.
[0265] Specifically, electronic devices can scan the Wi-Fi signals at their current location at a certain frequency to obtain a set of Wi-Fi data. Each set of Wi-Fi data includes the BSSID and RSSI of one or more Wi-Fi access points.
[0266] Furthermore, if the electronic device locally stores the geofence, since the Wi-Fi data includes BSSID and RSSI, and the geofence includes BSSID and feature weights used to characterize the signal condition of this BSSID, the electronic device can calculate the matching score between this set of Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence and the RSSI corresponding to the BSSID in the Wi-Fi data, thus obtaining a second matching score.
[0267] Then, the electronic device determines the geofence that matches this set of Wi-Fi data based on the second matching score. In this embodiment, the matching condition is that the second matching score must be greater than or equal to the matching threshold corresponding to the geofence. That is, when the second matching score is greater than or equal to the matching threshold, the corresponding Wi-Fi data is determined to match the geofence.
[0268] In some embodiments, the calculation principle of the second matching score is the same as that of the first matching score described above, and the specific calculation method can refer to the calculation formula of the first matching score described above. The difference is that the parameters substituted into the calculation of the first matching score and the second matching score are different. Simply put, the calculation of the second matching score in the embodiments of this application includes:
[0269] The electronic device first calculates the signal strength difference for the same BSSID in the geofence and Wi-Fi data, obtaining a fourth signal strength difference. This fourth signal strength difference is negatively correlated with the fourth difference value, which is the difference between the median Wi-Fi signal strength corresponding to the same BSSID in the geofence and the RSSI corresponding to the same BSSID in the Wi-Fi data.
[0270] Then, the electronic device calculates the matching score for the same BSSID in the geofence and Wi-Fi data based on the fourth signal strength difference, the frequency weight of the Wi-Fi signal strength corresponding to the same BSSID in the geofence, and the Wi-Fi signal strength baseline characteristics. Specifically, the electronic device first calculates the difference between the fourth signal strength difference and the Wi-Fi signal strength baseline characteristics, and then multiplies this difference by the frequency weight of the Wi-Fi signal strength corresponding to the same BSSID in the geofence, using this product as the matching score for the same BSSID in the geofence and Wi-Fi data. Finally, the electronic device calculates the sum of the matching scores for all the same BSSIDs in the geofence and Wi-Fi data to obtain the second matching score for the geofence and Wi-Fi data.
[0271] Subsequently, if the second matching score is determined to be greater than or equal to the matching threshold of the geofence, it means that the Wi-Fi data matches the geofence, indicating that the electronic device has now entered the area covered by the geofence.
[0272] In some embodiments, because the Wi-Fi module of existing electronic devices typically scans for surrounding Wi-Fi signals at a certain frequency with relatively small intervals after being enabled, and most users habitually keep the Wi-Fi module of their electronic devices running continuously, this can lead to the electronic device constantly matching the collected Wi-Fi data with a geofence each time it scans for a Wi-Fi signal. This can result in the electronic device being in a geofence matching state indefinitely, increasing its power consumption. Therefore, to avoid the electronic device being in a geofence matching state for an extended period, a specific event can be set to trigger geofence matching.
[0273] like Figure 7 The diagram shown illustrates the interactive flow of another geofence matching method. The following section combines... Figure 7 The geofence matching method provided in the embodiments of this application will be described in detail.
[0274] In the embodiments of this application, Figure 6In the illustrated geographic matching method, S604 and S605 are encapsulated as callback functions, serving as Wi-Fi scanning callback functions. After the electronic device obtains location information, in addition to downloading the geofence for the corresponding administrative region based on the location information, the electronic device also expands the area outward from the location information as the center point to obtain a geofence judgment area. Then, the electronic device determines whether a geofence exists within this geofence judgment area. If a geofence exists, the electronic device registers the defined Wi-Fi scanning callback function.
[0275] Specifically, the electronic device uses the location information as a center point (similar to the center of a circle) to expand outwards, determining the expanded area, which is the resulting fence detection area. The size of the expanded area can be set based on actual needs. For example, if latitude and longitude are used as location information, the electronic device can expand outwards by 100 meters from this center point. The circular area with the latitude and longitude as the center and a radius of 100 meters is then the fence detection area after the expansion.
[0276] If the cell identifier is used as the location information, taking the cell number as an example, the electronic device can use the area covered by the base station signal corresponding to this cell number as the fence area obtained after expanding the area. Alternatively, the electronic device can also use the location of the base station corresponding to this cell number as the center point and expand outwards by 100 meters to obtain the fence area.
[0277] After determining the geofence detection area through area expansion, the electronic device can further determine whether the geofence is within this geofence detection area by using the location information of the BSSID in the geofence, thus determining whether a geofence exists within the geofence detection area. If the electronic device determines that a geofence exists within the geofence detection area, it registers a Wi-Fi scanning callback function.
[0278] Once the electronic device has registered its Wi-Fi scanning callback function, if it scans for Wi-Fi signals at its current location and obtains a set of Wi-Fi data, the device executes the registered Wi-Fi scanning callback function. This function includes calculating a second matching score between the Wi-Fi data and the geofence based on the feature weights corresponding to each BSSID in the geofence. If the second matching score is greater than or equal to a matching threshold, the Wi-Fi data is determined to match the geofence. Thus, the electronic device achieves geofence matching by executing the Wi-Fi scanning callback function.
[0279] In other words, after encapsulating the key steps of the geofence matching method into a Wi-Fi scan callback function in this embodiment, the electronic device can only execute the geofence matching calculation steps to achieve geofence matching when this Wi-Fi scan callback function is registered and activated. Therefore, if the electronic device has not registered the Wi-Fi scan callback function, even if it scans and collects a set of Wi-Fi data, it will not trigger the matching of the Wi-Fi data with the geofence, thereby reducing the power consumption of the matching process. Only when the electronic device determines that a geofence exists nearby and completes the registration of the Wi-Fi scan callback function will it perform geofence matching based on the scanned Wi-Fi data, avoiding the electronic device being in a geofence matching state continuously and reducing the power consumption of the electronic device.
[0280] In some embodiments, to avoid increasing power consumption due to the electronic device remaining in a pairing state for an extended period, this application embodiment sets a condition requiring the registration of a Wi-Fi scanning callback function. However, even after the Wi-Fi scanning callback function is registered, if it is not deregistered based on actual circumstances, the increased power consumption caused by continuous pairing cannot be avoided. Therefore, the electronic device also needs to trigger the deregistration of the Wi-Fi scanning callback function based on location information.
[0281] In other words, if the electronic device determines that there is no geofence within the area determined by the area expansion based on location information, it will further deregister the registered Wi-Fi scanning callback function. After the Wi-Fi scanning callback function is deregistered, even if the electronic device scans Wi-Fi signals and collects a set of Wi-Fi data, it will not know the key processing steps for geofence matching because it has not registered a Wi-Fi scanning callback function. Consequently, the electronic device cannot perform the matching operation between this set of Wi-Fi data and the geofence.
[0282] In simple terms, if an electronic device determines, based on its location information, that a geofence exists within the extended geofence area A, it will register a Wi-Fi scanning callback function. Subsequently, if the electronic device scans and collects Wi-Fi data, it can sequentially match this Wi-Fi data with the geofence by executing the Wi-Fi scanning callback function. However, if the electronic device determines, based on the latest location information, that it has left geofence area A, and there is no geofence within the geofence area B determined by the latest location information, the electronic device needs to deregister the Wi-Fi scanning callback function. Afterward, even if the electronic device scans and collects Wi-Fi data, it will not trigger the matching process between this Wi-Fi data and the geofence. This prevents the electronic device from continuously matching the scanned Wi-Fi data with the geofence, thereby reducing power consumption.
[0283] In some embodiments, after the electronic device determines the geofence that matches its current location, it can receive or send information push notifications based on the matching geofence.
[0284] Specifically, after an electronic device identifies a matching geofence, it can receive information push notifications from the server device corresponding to that indoor location. For example, taking a shop or store as an example, when a user enters a shop or store with their electronic device, the device can scan for Wi-Fi signals in and around the shop or store to obtain Wi-Fi data. Then, the electronic device calculates a second matching score by comparing this Wi-Fi data scan list with the geofence within the administrative region corresponding to the shop or store. Based on this second matching score, it can match the geofence corresponding to the shop or store. Finally, based on the matched geofence, the electronic device can report its arrival at the shop or store to the corresponding server device (indicating that the user has arrived at the store).
[0285] Once the server receives the "received in-store" notification from the electronic device, it can precisely push relevant in-store services to the device based on the user of that device. For example, it can push store activity information, store coupons, or store notices to the electronic device, thereby achieving precise delivery of different services offered for different indoor locations through geofencing matching.
[0286] like Figure 8 The diagram shown illustrates the hardware and software architecture of an electronic device. The following is a description of this hardware and software structure. Figure 8 The hardware and software structure diagram shown illustrates the geofence matching method provided in the embodiments of this application.
[0287] in, Figure 8 The hardware and software architecture diagram shown includes a layered software architecture and a hardware layer. In this embodiment, the hardware layer includes at least hardware modules such as GPS, SIM card, and Wi-Fi module.
[0288] A layered software architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: applications, application framework, hardware abstraction layer (HAL), and kernel.
[0289] The application layer can include a series of applications. For example... Figure 8As shown in the embodiments of this application, the application layer includes at least a sensing application and a service application that requires information push services. The service application can be an online shopping application launched by a merchant with a physical store, such as an online shopping application launched by a coffee shop or fried chicken shop. The service application can also be a recommendation application, a payment application, etc. It should be understood that, depending on actual needs, the application layer can also include basic applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS, and this application does not impose any limitations on this.
[0290] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions. For example... Figure 8 As shown in this embodiment, the application framework layer includes a Wi-Fi manager and a location information acquisition module. The Wi-Fi manager is used to register and execute Wi-Fi scan callback functions to obtain geofence matching results. The location information acquisition module is used to acquire location information.
[0291] The Hardware Abstraction Layer (HAL) runs in user space, encapsulates kernel-level drivers, and provides calling interfaces to higher layers. For example... Figure 8 As shown, the hardware abstraction layer in this application embodiment includes at least Wi-Fi HAL, GPS HAL, and cellular HAL.
[0292] The Wi-Fi manager can interact with the Wi-Fi HAL. The Wi-Fi HAL, through a Wi-Fi driver, interacts with the Wi-Fi module in the electronic device that scans for Wi-Fi signals, transmitting the Wi-Fi data collected by the module, including BSSID and RSSI, to the Wi-Fi manager. The location information acquisition module interacts with the GPS and SIM card in the electronic device to obtain location information such as latitude and longitude and cell identifiers used for positioning. Furthermore, depending on actual needs, the HAL layer can also include a display HAL, audio HAL, camera HAL, Bluetooth HAL, etc., and this application does not impose any limitations on this.
[0293] The kernel layer is the layer between hardware and software. For example... Figure 8 As shown, the kernel layer of this application embodiment includes at least a GPS driver, a cellular driver, and a Wi-Fi driver. Additionally, depending on actual needs, the kernel layer may also include a display driver, a camera driver, an audio driver, a Bluetooth driver, etc., and this application implementation does not impose any limitations on this.
[0294] Specifically, in this embodiment, the location information acquisition module obtains latitude and longitude from the GPS module of the electronic device via GPS HAL and GPS driver. Simultaneously, it obtains the cell identifier from the SIM card via cellular HAL and cellular driver. Then, the location information acquisition module reports the acquired latitude and longitude, cell identifier, and other location information as location information to the sensing application.
[0295] On the other hand, the Wi-Fi module of the electronic device transmits the scanned Wi-Fi data to the Wi-Fi manager through the Wi-Fi driver and Wi-Fi HAL.
[0296] Furthermore, when the sensing application determines that a geofence exists within the current area of the electronic device based on the location information reported by the location acquisition module, it calls the Wi-Fi manager to register a Wi-Fi scanning callback function. Additionally, the sensing application can also call the Wi-Fi manager to unregister the registered Wi-Fi scanning callback function based on the location information.
[0297] After registering the Wi-Fi scanning callback function based on the call from the sensing application, the Wi-Fi manager will execute the registered Wi-Fi scanning callback function if it receives Wi-Fi data reported by the Wi-Fi module again. It will then match this reported Wi-Fi data with the geofence downloaded from the cloud device. Finally, the Wi-Fi manager will return the matched geofence to the sensing application. The sensing application can then transmit this geofence matching result to other applications, such as an online shopping application. This online shopping application can then push information to the electronic device's screen, thus providing a precise information push service to the user holding the electronic device.
[0298] Another embodiment of this application provides a cloud device, including: a communication module, one or more processors, and a memory. The communication module and the memory are respectively coupled to the processor; the memory stores one or more computer program codes, the computer program codes including computer instructions; when the processor executes the computer instructions, the cloud device implements the geofence generation method described in any of the above embodiments.
[0299] Another embodiment of this application provides an electronic device, including: a communication module, one or more processors, and a memory. The communication module and the memory are respectively coupled to the processor; the memory stores one or more computer program codes, the computer program codes including computer instructions; when the processor executes the computer instructions, the electronic device implements the geofence matching method described in any of the above embodiments.
[0300] Another embodiment of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor in an electronic device, causes the electronic device to implement the geofence generation method and geofence matching method described in any of the above embodiments.
[0301] This application also provides a computer program product that, when run on a computer, causes the computer to perform the various functions or steps described in the above method embodiments.
[0302] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0303] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0304] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0305] Furthermore, 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. The integrated unit can be implemented in hardware or as a software functional unit.
[0306] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of 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, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0307] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope 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 for generating geofences, characterized in that, The application is applied to a cloud device, comprising: obtaining a plurality of Wi-Fi scan lists; wherein each Wi-Fi scan list comprises basic service set identifiers (BSSIDs) and received signal strength indicators (RSSIs) of one or more Wi-Fi access points obtained by an electronic device in one scan; performing similarity clustering on the plurality of Wi-Fi scan lists to obtain a plurality of Wi-Fi list clusters; wherein each Wi-Fi list cluster comprises one or more Wi-Fi scan lists; obtaining a feature weight corresponding to each BSSID in the Wi-Fi list cluster based on a frequency of occurrence of the BSSID in the Wi-Fi list cluster and an RSSI corresponding to the BSSID; calculating a first matching score of each Wi-Fi scan list in the plurality of Wi-Fi scan lists and the Wi-Fi list cluster according to the feature weight corresponding to each BSSID in the Wi-Fi list cluster, and determining a matching threshold of the Wi-Fi list cluster based on a plurality of first matching scores; generating a geofence corresponding to the Wi-Fi list cluster, wherein the geofence comprises a plurality of BSSIDs in the Wi-Fi list cluster and a feature weight corresponding to each BSSID, and a matching threshold of the Wi-Fi list cluster.
2. The method of claim 1, wherein, The similarity clustering on the plurality of Wi-Fi scan lists to obtain a plurality of Wi-Fi list clusters comprises: calculating a similarity of RSSIs corresponding to the same BSSIDs in each two Wi-Fi scan lists in the plurality of Wi-Fi scan lists; calculating a similarity of the two Wi-Fi scan lists; wherein the similarity of the two Wi-Fi scan lists is equal to a sum of the similarities of the RSSIs corresponding to each same BSSID in the two Wi-Fi scan lists; performing similarity clustering on the plurality of Wi-Fi scan lists based on the similarity of each two Wi-Fi scan lists in the plurality of Wi-Fi scan lists to obtain the plurality of Wi-Fi list clusters.
3. The method of claim 2, wherein, The calculating a similarity of RSSIs corresponding to the same BSSIDs in each two Wi-Fi scan lists in the plurality of Wi-Fi scan lists comprises: calculating a first signal strength difference and a first signal strength weight of the RSSIs corresponding to the same BSSIDs in each two Wi-Fi scan lists in the plurality of Wi-Fi scan lists; wherein the first signal strength difference is negatively correlated with a first difference value, the first difference value is a difference value of the RSSIs corresponding to the same BSSIDs, and the first signal strength weight is positively correlated with any RSSI corresponding to the same BSSID; The product of the difference between the first signal strength difference and the second signal strength difference and the first signal strength weight is taken as the similarity of the RSSIs corresponding to the same BSSID; the second signal strength difference is negatively correlated with a second difference value, and the second difference value is the difference between any RSSI corresponding to the same BSSID and a preset RSSI.
4. The method of claim 3, wherein, The calculation of the first signal strength difference and the first signal strength weight of the RSSIs corresponding to the same BSSID in each two Wi-Fi scan lists in the plurality of Wi-Fi scan lists comprises: The first signal strength difference and the first signal strength weight are calculated by using the following formula: in, q ( x i,b , x j,b () represents the first signal strength difference of RSSI corresponding to the same BSSID. x i,b Indicates the first i The BSSID in the Wi-Fi scan list is b The corresponding RSSI; x j,b Indicates the first j The BSSID in the Wi-Fi scan list is b The corresponding RSSI; k q and d q These are preset parameters. k q =0.052160; d q =0.2; Ⅱ( x i,b < x j,b () indicates an indicator function, which is invoked when the input condition is met. x i,b < x j,b The function value is 1 when the condition is true, otherwise the function value is 0. wherein, p x represents a first signal strength weight of any one RSSI corresponding to the same BSSID, x x i,b or x j,b , including p x i,b or p x j,b , p x i,b represents a first signal strength weight of RSSI corresponding to the BSSID i in the i-th Wi-Fi scan list, b p x j,b represents a first signal strength weight of RSSI corresponding to the BSSID j in the i-th Wi-Fi scan list; b k p and b p is a preset parameter, k p = 0.130401; b p = -65. 5. The method of claim 3, wherein, The product of the difference between the first signal strength difference and the second signal strength difference and the first signal strength weight is taken as the similarity of the RSSIs corresponding to the same BSSID, which comprises: The similarity of the RSSIs corresponding to the same BSSID is calculated by using the following formula: wherein, p x ) represents a first signal strength weight of any one RSSI corresponding to the same BSSID, including p x i,b ) or p x j,b ; q x i,b x j,b ) represents a first signal strength difference of RSSI corresponding to the same BSSID; q x c x ) represents a second signal strength difference of any one RSSI corresponding to the same BSSID, including q x i,b c x ) or q x j,b c x , c x represents a preset RSSI; The calculation of the similarity of the two Wi-Fi scan lists comprises: The similarity of the two Wi-Fi scan lists is calculated by using the following formula: wherein, w x i ,x j denotes the similarity of the i-th Wi-Fi scan list and the j-th Wi-Fi scan list; i j B i B j denotes the set of identical BSSIDs in the i-th Wi-Fi scan list i B i and the j-th Wi-Fi scan list j B j b B i B j . 6. The method according to any one of claims 1-5, characterized in that, The feature weight comprises: a Wi-Fi signal strength median value, a Wi-Fi signal strength frequency weight and a Wi-Fi signal strength reference feature; The calculation of the feature weight corresponding to each BSSID in the Wi-Fi list cluster based on the frequency of occurrence of each BSSID in the Wi-Fi list cluster and the RSSI corresponding to each BSSID comprises: The median value of all the RSSIs corresponding to the same BSSID in the Wi-Fi list cluster is calculated as the Wi-Fi signal strength median value corresponding to the BSSID; The product of a second signal strength weight and the frequency of occurrence is calculated as the Wi-Fi signal strength frequency weight corresponding to the BSSID; the frequency of occurrence is the ratio of the number of occurrences of the BSSID in the Wi-Fi list cluster to the number of Wi-Fi scan lists in the Wi-Fi list cluster; the second signal strength weight is positively correlated with the Wi-Fi signal strength median value; A third signal strength difference is calculated as the Wi-Fi signal strength reference feature corresponding to the BSSID; the third signal strength difference is negatively correlated with a third difference value, and the third difference value is the difference between the Wi-Fi signal strength median value and a preset RSSI.
7. The method of claim 6, wherein, The calculation of the first matching score of each Wi-Fi scan list in the plurality of Wi-Fi scan lists and the Wi-Fi list cluster according to the feature weight corresponding to each BSSID in the Wi-Fi list cluster comprises: The first matching score is calculated by using the following formula: wherein, score y,x represents the Wi-Fi list cluster y and the first matching score of the Wi-Fi scan list x ; B represents the Wi-Fi list cluster y and the set of same BSSIDs in the Wi-Fi scan list x , b ∈ B ; y b,f0 represents the Wi-Fi list cluster y and the corresponding Wi-Fi signal strength frequency weight b 0 for the BSSID f ; q y b,i0 ,x b represents the signal strength difference y b,i0 and x b y b,i0 represents the Wi-Fi list cluster y and the corresponding Wi-Fi signal strength median value b 0 for the BSSID i ; x b represents the RSSI of the Wi-Fi scan list x for the BSSID b ; y b,f1 represents the Wi-Fi list cluster y and the corresponding Wi-Fi signal strength baseline feature b 1 for the BSSID f . 8. The method according to any one of claims 1-5, characterized in that, The determination of the matching threshold of the Wi-Fi list cluster based on the plurality of first matching scores comprises: The median value of the plurality of first matching scores is calculated, and the product of the median value of the plurality of first matching scores and a preset score weight is taken as a matching threshold reference value; In the plurality of first matching scores, a first matching score greater than or equal to the matching threshold reference value and smallest is taken as the matching threshold of the Wi-Fi list cluster.
9. The method according to any one of claims 1-5, characterized in that, Before the matching threshold of the Wi-Fi list cluster is determined based on the plurality of first matching scores, the method further comprises: According to the feature weight corresponding to each BSSID in the Wi-Fi list cluster, the BSSIDs in the Wi-Fi list cluster are screened out to obtain a Wi-Fi list cluster whose number of BSSIDs meets a preset number requirement.
10. A geo-fencing matching method, characterized by, The method is applied to an electronic device, and the electronic device stores one or more geofences, wherein each geofence includes a plurality of BSSIDs, a feature weight corresponding to each BSSID, and a matching threshold of the geofence; the feature weight is obtained based on the frequency of each BSSID in a Wi-Fi list cluster corresponding to the geofence and the RSSI corresponding to the BSSID; the Wi-Fi list cluster includes one or more Wi-Fi scan lists obtained by clustering, and each Wi-Fi scan list includes one or more BSSIDs and RSSIs of Wi-Fi access points scanned by an electronic device at one time; and the method comprises: Scanning Wi-Fi signals at a current location to obtain a set of Wi-Fi data; wherein each set of Wi-Fi data includes one or more basic service set identifiers (BSSIDs) and signal strengths (RSSIs) of Wi-Fi access points; According to the feature weight corresponding to each BSSID in the geofence, a second matching score of the Wi-Fi data and the geofence is calculated; If the second matching score is greater than or equal to the matching threshold, it is determined that the Wi-Fi data matches the geofence.
11. The method of claim 10, wherein, The method further comprises: Obtaining positioning information, and determining an administrative region corresponding to the current location according to the positioning information; wherein the positioning information is the location information of the electronic device obtained at a preset period, including any one or more of latitude, longitude, and cell identifier; Downloading one or more geofences corresponding to the administrative region from a cloud device to a local device.
12. The method of claim 11, wherein, The method further comprises: Setting an expiration date for the downloaded geofence, and deleting the geofence whose expiration date has expired in the local device.
13. The method of claim 11, wherein, The method further comprises: Expanding the area around the positioning information as a center point to obtain a fence judgment area; If there is a geofence in the fence judgment area, a Wi-Fi scan callback function is registered. The Wi-Fi scanning callback function is executed after scanning Wi-Fi signals at a current location to obtain a set of Wi-Fi data; and the Wi-Fi scanning callback function includes: calculating a second matching score of the Wi-Fi data and the geo-fence according to feature weights corresponding to each BSSID in the geo-fence; and determining that the Wi-Fi data matches the geo-fence if the second matching score is greater than the matching threshold.
14. The method of claim 13, wherein, The method further includes: When there is no geo-fence in the fence judgment area, unregistering the registered Wi-Fi scanning callback function.
15. The method according to any one of claims 10 to 14, characterized in that, The calculating of the second matching score of the Wi-Fi data and the geo-fence according to the feature weights corresponding to each BSSID in the geo-fence includes: calculating a fourth signal strength difference of the same BSSID in the geo-fence and the Wi-Fi data; wherein the fourth signal strength difference is negatively correlated with a fourth difference value; and the fourth difference value is a difference between a median value of Wi-Fi signal strengths corresponding to the same BSSID in the geo-fence and an RSSI corresponding to the same BSSID in the Wi-Fi data; calculating a matching score of the same BSSID in the geo-fence and the Wi-Fi data according to the fourth signal strength difference, a Wi-Fi signal strength frequency weight corresponding to the same BSSID in the geo-fence, and a Wi-Fi signal strength reference feature; calculating a second matching score of the geo-fence and the Wi-Fi data; and the second matching score is a sum of the matching scores of all the same BSSIDs in the geo-fence and the Wi-Fi data.
16. The method according to any one of claims 10-14, characterized in that, The method further includes: receiving or sending information push according to the matched geo-fence.
17. A cloud device, comprising: The method further includes: a communication module, one or more processors, and a memory; the communication module and the memory are respectively coupled with the processor; the memory stores one or more computer program codes including computer instructions; and when the processor executes the computer instructions, the cloud device performs the geo-fence generation method according to any one of claims 1-9.
18. An electronic device, comprising: The method further includes: a communication module, one or more processors, and a memory; the communication module and the memory are respectively coupled with the processor; the memory stores one or more computer program codes including computer instructions; and when the processor executes the computer instructions, the electronic device performs the geo-fence matching method according to any one of claims 10-16.
19. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor of the cloud device, so that the cloud device performs the geo-fence generation method according to any one of claims 1-9; or the computer program is executed by the processor of the electronic device, so that the electronic device performs the geo-fence matching method according to any one of claims 10-16.
Citation Information
Patent Citations
Geo-fence generation method and device, positioning method and device, medium and equipment
CN113891240A
Virtual card pop-up method, electronic equipment and storage medium
CN116055630A