Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eloquentarduino/d5bf7291351181a101324497ddcd62a0 to your computer and use it in GitHub Desktop.
Save eloquentarduino/d5bf7291351181a101324497ddcd62a0 to your computer and use it in GitHub Desktop.
Wifi indoor positioning for PC/Raspberry Pi
import json
from rssi import RSSI_Scan
from time import sleep
if __name__ == '__main__':
scanner = RSSI_Scan('wlp2s0')
lines = []
while True:
location = input('Enter location (leave empty to exit): ')
if not location:
print('No location entered, exiting...')
break
repeat = int(input('How many samples will you take? '))
for i in range(repeat):
print('scanning %d/%d' % (i + 1, repeat))
networks = scanner.getAPinfo(sudo=True)
rssis = {network['ssid']: network['signal'] for network in networks}
rssis.update(__location=location)
lines.append(json.dumps(rssis))
print(lines[-1])
print('Here comes the data for port_wifi_indoor_positioning()')
[print(line) for line in lines]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment