| Algorithm 1 The basic algorithm | |
| Input: scan interval and scan duration | |
| Output: beacon with the highest measure RSSI signal strength | |
| 1: | set scan interval |
| 2: | set scan duration |
| 3: | functionbeacon_scanner |
| 4: | loop |
| 5: | if scan interval not over |
| 6: | call listen_for_beacons |
| 7: | functionlisten_for_beacons |
| 8: | init results array |
| 9: | while scan duration not over |
| 10: | if beacon detected |
| 11: | if beacon already detected |
| 12: | override beacon data |
| 13: | else |
| 14: | push beacon data into the results array |
| 15: | call beacon_scanner |
| 16: | if results array not empty |
| 17: | return beacon with the highest measured RSSI signal strength |
| 18: | else |
| 19: | return null; |