Skip to main content
. 2020 Apr 20;20(8):2336. doi: 10.3390/s20082336
Algorithm 2 The proposed algorithm
Input: scan interval, scan duration, number of measurements, acceleration magnitude threshold
Output: beacon with the strongest signal strength based on the calculated running averages for all detected beacons in the detectable area
1: ObjectDetectedBeacon
2: id,
3: major,
4: minor,
5: rssiMeasurements[],
6: averageSignalStrength
7: set scan duration
8: set acceleration magnitude threshold
9: set number of stored signal detections
10: init scan interval
11: init listOfBeacons[DetectedBeacon]
12: background service
13: loop
14:   calculate acceleration
15:   if calculate acceleration > acceleration magnitude threshold
16:    update scan interval
17: functionbeacon_scanner
18: loop
19:   if scan interval not over
20:    call listen_for_beacons
21: functionlisten_for_beacons
22: init results array
23: while scan duration not over
24:   if beacon detected
25:    if beacon already detected
26:     update rssiMeasurements array of beacon
27:     calculate_running_average(beacon)
28:     else
29:     add beacon to listOfBeacons array
30:     calculate_running_average (beacon)
31:   call beacon_scanner
32:   if listOfBeacons not empty
33:    return beacon with the highest calculated average RSSI signal strength value
34:    else
35:    return null;
36: function calculate_running_average(DetectedBeacon)
37:  calculate running average for beacon
38:  save new calculation to specified beacon