From bc9d550b7da5585ba6d69c0e6b0a744dd3b244eb Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Mon, 11 Nov 2019 20:31:14 +0100 Subject: [PATCH] combined gps payload (issue #482) --- README.md | 21 +++++++++++---------- platformio.ini | 8 ++++---- src/configmanager.cpp | 6 +++--- src/paxcounter.conf | 1 + src/senddata.cpp | 14 +++++++++++++- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e7337789..214e9d40 100644 --- a/README.md +++ b/README.md @@ -169,17 +169,18 @@ Output of user sensor data can be switched by user remote control command 0x14 s Output of sensor and peripheral data is internally switched by a bitmask register. Default mask can be tailored by editing *cfg.payloadmask* initialization value in [*configmanager.cpp*](src/configmanager.cpp) following this scheme: -| Bit | Sensordata | -| --- | ------------- | -| 0 | GPS | -| 1 | Beacon alarm | -| 2 | BME280/680 | -| 3 | Paxcounter | -| 4 | User sensor 1 | -| 5 | User sensor 2 | -| 6 | User sensor 3 | -| 7 | Batterylevel | +| Bit | Sensordata | Default +| --- | ------------- | ------- +| 0 | GPS | off* +| 1 | Beacon alarm | on +| 2 | BME280/680 | on +| 3 | Paxcounter | on +| 4 | User sensor 1 | on +| 5 | User sensor 2 | on +| 6 | User sensor 3 | on +| 7 | Batterylevel | off +*) GPS data can also be combined with payload on port 1, #define PAYLOAD_GPS in paxcounter.conf to enable # Time sync diff --git a/platformio.ini b/platformio.ini index eac7d350..bc46b135 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,14 +11,14 @@ ;halfile = ebox.h ;halfile = eboxtube.h ;halfile = ecopower.h -halfile = heltec.h +;halfile = heltec.h ;halfile = heltecv2.h ;halfile = ttgov1.h ;halfile = ttgov2.h ;halfile = ttgov21old.h ;halfile = ttgov21new.h ;halfile = ttgofox.h -;halfile = ttgobeam.h +halfile = ttgobeam.h ;halfile = ttgobeam10.h ;halfile = fipy.h ;halfile = lopy.h @@ -43,10 +43,10 @@ description = Paxcounter is a device for metering passenger flows in realtime. I [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 1.9.8 +release_version = 1.9.81 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose -debug_level = 3 +debug_level = 4 extra_scripts = pre:build.py otakeyfile = ota.conf lorakeyfile = loraconf.h diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 9e7fb508..40d4a0a8 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -9,9 +9,9 @@ nvs_handle my_handle; esp_err_t err; #define PAYLOADMASK \ - ((GPS_DATA | ALARM_DATA | MEMS_DATA | COUNT_DATA | SENSOR1_DATA | \ - SENSOR2_DATA | SENSOR3_DATA) & \ - ~BATT_DATA) + ((ALARM_DATA | MEMS_DATA | COUNT_DATA | SENSOR1_DATA | SENSOR2_DATA | \ + SENSOR3_DATA) & \ + (~BATT_DATA) & (~GPS_DATA)) // populate cfg vars with factory settings void defaultConfig() { diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 1e39ece9..d9b2990d 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -13,6 +13,7 @@ #define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255 #define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed #define COUNTERMODE 0 // 0=cyclic, 1=cumulative, 2=cyclic confirmed +#define PAYLOAD_GPS 1 // add gps location to pax count payload: 0=no, 1=yes // Set this to include BLE counting and vendor filter functions, or to switch off WIFI counting #define VENDORFILTER 1 // set to 0 if you want to count things, not people diff --git a/src/senddata.cpp b/src/senddata.cpp index 11b0d81a..4e230cb8 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -65,9 +65,21 @@ void sendData() { #if ((WIFICOUNTER) || (BLECOUNTER)) case COUNT_DATA: payload.reset(); - payload.addCount(macs_wifi, MAC_SNIFF_WIFI); + if (cfg.wifiscan) + payload.addCount(macs_wifi, MAC_SNIFF_WIFI); if (cfg.blescan) payload.addCount(macs_ble, MAC_SNIFF_BLE); + +#if (PAYLOAD_GPS) + // send GPS position only if we have a fix + if (gps.location.isValid()) { + gpsStatus_t gps_status; + gps_storelocation(&gps_status); + payload.addGPS(gps_status); + } else + ESP_LOGD(TAG, "No valid GPS position"); +#endif + SendPayload(COUNTERPORT, prio_normal); // clear counter if not in cumulative counter mode if (cfg.countermode != 1) {