From 0894afae1adf2a2e4251bf4c87226221053057d4 Mon Sep 17 00:00:00 2001 From: "Server (Shared Users)" <shmd01.iptime.org> Date: Wed, 4 Dec 2019 10:09:18 +0000 Subject: [PATCH] revise ' --- RPi_Client/CoAPthon3/coapclient.py | 20 +++++++++---------- RPi_Client/CoAPthon3/piBeacon.py | 2 +- Server_Vue_Express/backend/models/tracking.js | 1 + Server_Vue_Express/backend/routes/api.js | 6 +++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/RPi_Client/CoAPthon3/coapclient.py b/RPi_Client/CoAPthon3/coapclient.py index e4eacaf..cd68d49 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 b437143..427b5a2 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 24a3fe6..5c9ab9e 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 f913472..5b148bf 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){ -- GitLab