Android Question MLWifi 3.07 and wifi fingerprint in order to use to position device on a floor map

mike1967

Active Member
Licensed User
Longtime User
Hello, i found this code on github in python: https://github.com/aaaahern/WiFiLocalization where is exposed the algorithm for mapping and finding a device in a map based on wifi fingerprint of tha access point around. Can some one help me to apply this to b4a ? I'am not experience with the mathematical concept introduced . Thanks in advances
 

mike1967

Active Member
Licensed User
Longtime User
Another example with excel sheet for calculate the positions:
Map:
import subprocess
import numpy

def read_values():
    proc = subprocess.Popen(["airport -s | grep BlackPearl | awk '{ print $1, $2, $3 }'"], stdout=subprocess.PIPE, shell=True)
    (out, err) = proc.communicate()
    ssid, bssid, rssi = out.split(" ")
    return (ssid, bssid, rssi)

def main():
    results = []
    to_continue = True

    while to_continue:
        position = raw_input('Position num: ')
        angles = []
        ssid = ''
        bssid = ''
   
        for n in range(4):
            print('Angle {0}'.format(n))
            ssid, bssid, rssi = read_values()
            angles.append(int(rssi.replace('\n','')))
            if n != 3:
                raw_input('Turn yourself 90 degrees and press enter...')

        angles.append(numpy.mean(angles))
        results.append((position, ssid, bssid, angles))

        if raw_input('Continue (y/n)? ') == 'n':
            save_results(results)
            raise SystemExit(0)

def save_results(results):
    f = open('map.csv', 'w')
    for r in results:
        pos, ssid, bssid, angles = r
        f.write('{0},{1},{2},{3},{4},{5},{6},{7}\n'.format(pos, ssid, bssid, angles[0], angles[1], angles[2], angles[3], angles[4]))
    f.close()

if __name__ == '__main__':
    main()

Read:
import subprocess
import numpy

def read_values():
    proc = subprocess.Popen(["airport -s | grep BlackPearl | awk '{ print $1, $2, $3 }'"], stdout=subprocess.PIPE, shell=True)
    (out, err) = proc.communicate()
    ssid, bssid, rssi = out.split(" ")
    return (ssid, bssid, rssi)

def main():
    results = []
    to_continue = True

    while to_continue:
        position = raw_input('Position num: ')
        ssid, bssid, rssi = read_values()
        results.append((position, ssid, bssid, int(rssi.replace('\n',''))))

        if raw_input('Continue (y/n)? ') == 'n':
            save_results(results)
            raise SystemExit(0)

def save_results(results):
    f = open('read.csv', 'w')
    for r in results:
        pos, ssid, bssid, rssi = r
        f.write('{0},{1},{2},{3}\n'.format(pos, ssid, bssid, rssi))
    f.close()

if __name__ == '__main__':
    main()

Can someone help me with B4A ? Thanks in advances
 

Attachments

  • floorplan.jpg
    floorplan.jpg
    179.7 KB · Views: 147
  • Home Wifi Measurements.xlsx.txt
    11.7 KB · Views: 159
  • map.csv.txt
    537 bytes · Views: 145
  • read.csv.txt
    216 bytes · Views: 148
Upvote 0
Top