diff --git a/RPi_Client/CoAPthon3/coapclient.py b/RPi_Client/CoAPthon3/coapclient.py index e4eacaf070e55b48098b0718b1de6c5873bbe4ba..cd68d4964e8e016b8add505c2dc65cb1eb52cb25 100644 --- a/RPi_Client/CoAPthon3/coapclient.py +++ b/RPi_Client/CoAPthon3/coapclient.py @@ -139,7 +139,6 @@ class CoapClient(): path = "/bleInfoPath" payload = [] - temp = [] path = "coap://" + self.ip + path host, port, path = parse_uri(path) @@ -154,18 +153,17 @@ class CoapClient(): try: while True : payload = [] - temp = [] - returnedList = blescan.parse_events(self.sock, 100) + returnedList = blescan.parse_events(self.sock, 50) for beacon in returnedList: beaconInfo = [str(x) for x in beacon.split(',') if x.strip()] - if not beaconInfo[0] in temp: - temp.append(beaconInfo[0]) - if beaconInfo[1][:8] == "52528282": - print("scanned : "+ str(beaconInfo)) - regiRelThread = threading.Thread(target = self.regiRelWithNewPi, args=([beaconInfo])) - regiRelThread.start() - continue - payload.append(self.mkJsonbeaconInfo(beaconInfo)) + if beaconInfo[1][:8] == "52528282": + print("scanned : "+ str(beaconInfo)) + regiRelThread = threading.Thread(target = self.regiRelWithNewPi, args=([beaconInfo])) + regiRelThread.start() + continue + jsonpayload = self.mkJsonbeaconInfo(beaconInfo) + if jsonpayload.distance < 60: + payload.append(jsonpayload) response = client.put(path, json.dumps(payload)) print((response.pretty_print())) diff --git a/RPi_Client/CoAPthon3/piBeacon.py b/RPi_Client/CoAPthon3/piBeacon.py index b43714397cf65282943e409f5ef002967ac806f2..427b5a207b200cb1723c1a264b4577481e943161 100644 --- a/RPi_Client/CoAPthon3/piBeacon.py +++ b/RPi_Client/CoAPthon3/piBeacon.py @@ -17,7 +17,7 @@ bct_IBEACONPROFIX = "1E 02 01 1A 1A FF 4C 00 02 15" bct_UUID = " 00 00 00 AC E8 B4 E0 C2 7D 20 B6 11 B6 11 C7 74" bct_MAJOR = "00 01" bct_MINOR = "00 02" -bct_POWER = "C8 00" +bct_POWER = "CB 00" class BeaconEmit(): def __init__(self): self.beacon_TX_config("up") diff --git a/Server_Vue_Express/backend/models/tracking.js b/Server_Vue_Express/backend/models/tracking.js index 24a3fe646f989b622ae08563aafb8ea2bd38185e..5c9ab9ebe3af8166fc45275b9c9065d16ed382b6 100644 --- a/Server_Vue_Express/backend/models/tracking.js +++ b/Server_Vue_Express/backend/models/tracking.js @@ -3,6 +3,7 @@ const Schema = mongoose.Schema; const trackingSchema = new Schema({ rpuuid: { type: String, default: "" }, + userMAC: { type: String, default: "" }, useruuid: { type: String, default: "" }, distance: { type: Number, default: 0 }, updateTime : { type: Number, default: 0 } diff --git a/Server_Vue_Express/backend/routes/api.js b/Server_Vue_Express/backend/routes/api.js index f9134728b6b09e320b86ae231aacfa67c723cab2..5b148bf128472231e68a4b030c098053d74c8c02 100644 --- a/Server_Vue_Express/backend/routes/api.js +++ b/Server_Vue_Express/backend/routes/api.js @@ -178,13 +178,13 @@ router.get('/aggregateByRPUUID/:id', function(req, res, next) { '$match': { 'rpuuid': output.rpuuid, 'updateTime': { - '$gt': lastUpdateTime + '$gt': lastUpdateTime - 10 }, - distance: {'$lt': 10, '$gt' : 0.1} + distance: {'$lt': 10} } }, { '$group': { - '_id': '$useruuid' + '_id': '$userMAC' } } ],function(rr,ra){