How to distinguish beacons?

  beacon, bluetooth-lowenergy, python, raspberry-pi

My raspberry code for one beacon:

while True:
    try:
        devices = scanner.scan(1)
        for beacon in devices:
            if beacon.addr == 'd0:f0:18:44:0b:82':
                bc = "{}|{:d}".format(beacon.addr,beacon.rssi)
                sock.sendto(bc.encode(), server_address)
    except:
        print("Error")
        pass

Windows code for one beacon:

while True:
    bc, address = sock.recvfrom(4096)  # buffer size
    adres, sygnal = bc.split(b'|') # split
    print(adres, sygnal)

This code works perfectly for one beacon. I don’t know how to do it for multiple beacons. I would like a UDP server on Windows to be able to distinguish between beacons so that I can complete this project: Tools to determine exact location when using ibeacons

code:

float xa = beacon1.locationX;
float ya = beacon1.locationY;
float xb = beacon2.locationX;
float yb = beacon2.locationY;
float xc = beacon3.locationX;
float yc = beacon3.locationY;
float ra = beacon1.filteredDistance;
float rb = beacon2.filteredDistance;
float rc = beacon3.filteredDistance;

float S = (pow(xc, 2.) - pow(xb, 2.) + pow(yc, 2.) - pow(yb, 2.) + pow(rb, 2.) - pow(rc, 2.)) / 2.0;
float T = (pow(xa, 2.) - pow(xb, 2.) + pow(ya, 2.) - pow(yb, 2.) + pow(rb, 2.) - pow(ra, 2.)) / 2.0;
float y = ((T * (xb - xc)) - (S * (xb - xa))) / (((ya - yb) * (xb - xc)) - ((yc - yb) * (xb - xa)));
float x = ((y * (ya - yb)) - T) / (xb - xa);

CGPoint point = CGPointMake(x, y);
return point;
}

Source: Python Questions

LEAVE A COMMENT