From 01fb7c53b4e44719bfd95a896ddcb5c62f347451 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sat, 5 Oct 2019 15:03:15 +0200 Subject: [PATCH] randomize time sync seq nr --- include/timesync.h | 1 + src/paxcounter.conf | 3 +-- src/timesync.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/timesync.h b/include/timesync.h index 8b8c42bc..bf74700e 100644 --- a/include/timesync.h +++ b/include/timesync.h @@ -9,6 +9,7 @@ //#define TIME_SYNC_TRIGGER 100 // threshold for time sync [milliseconds] #define TIME_SYNC_FRAME_LENGTH 0x07 // timeserver answer frame length [bytes] #define TIME_SYNC_FIXUP 4 // calibration to fixup processing time [milliseconds] +#define TIMEREQUEST_MAX_SEQNO 0xf0 // threshold for wrap around seqno void timesync_init(void); void send_timesync_req(void); diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 02a53508..1ba4db3e 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -16,7 +16,7 @@ // 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 -#define BLECOUNTER 1 // set it to 1 if you want to use BLE count, at expense of power & memory +#define BLECOUNTER 0 // set it to 1 if you want to use BLE count, at expense of power & memory #define WIFICOUNTER 1 // set it to 0 if you want to switch off WIFI count // BLE scan parameters @@ -99,7 +99,6 @@ #define BATTPORT 8 // battery voltage #define TIMEPORT 9 // time query and response #define TIMEDIFFPORT 13 // time adjust diff -#define TIMEREQUEST_MAX_SEQNO 250 // time answer, start of port range #define SENSOR1PORT 10 // user sensor #1 #define SENSOR2PORT 11 // user sensor #2 #define SENSOR3PORT 12 // user sensor #3 diff --git a/src/timesync.cpp b/src/timesync.cpp index e0c0dbb3..e77897cf 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -25,7 +25,7 @@ typedef std::chrono::duration> TaskHandle_t timeSyncReqTask = NULL; -static uint8_t time_sync_seqNo = 0; +static uint8_t time_sync_seqNo = (uint8_t)random(TIMEREQUEST_MAX_SEQNO); static bool timeSyncPending = false; static myClock_timepoint time_sync_tx[TIME_SYNC_SAMPLES]; static myClock_timepoint time_sync_rx[TIME_SYNC_SAMPLES];