randomize time sync seq nr

This commit is contained in:
Verkehrsrot 2019-10-05 15:03:15 +02:00
parent 3d0c6f3249
commit 01fb7c53b4
3 changed files with 3 additions and 3 deletions

View File

@ -9,6 +9,7 @@
//#define TIME_SYNC_TRIGGER 100 // threshold for time sync [milliseconds] //#define TIME_SYNC_TRIGGER 100 // threshold for time sync [milliseconds]
#define TIME_SYNC_FRAME_LENGTH 0x07 // timeserver answer frame length [bytes] #define TIME_SYNC_FRAME_LENGTH 0x07 // timeserver answer frame length [bytes]
#define TIME_SYNC_FIXUP 4 // calibration to fixup processing time [milliseconds] #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 timesync_init(void);
void send_timesync_req(void); void send_timesync_req(void);

View File

@ -16,7 +16,7 @@
// Set this to include BLE counting and vendor filter functions, or to switch off WIFI counting // 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 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 #define WIFICOUNTER 1 // set it to 0 if you want to switch off WIFI count
// BLE scan parameters // BLE scan parameters
@ -99,7 +99,6 @@
#define BATTPORT 8 // battery voltage #define BATTPORT 8 // battery voltage
#define TIMEPORT 9 // time query and response #define TIMEPORT 9 // time query and response
#define TIMEDIFFPORT 13 // time adjust diff #define TIMEDIFFPORT 13 // time adjust diff
#define TIMEREQUEST_MAX_SEQNO 250 // time answer, start of port range
#define SENSOR1PORT 10 // user sensor #1 #define SENSOR1PORT 10 // user sensor #1
#define SENSOR2PORT 11 // user sensor #2 #define SENSOR2PORT 11 // user sensor #2
#define SENSOR3PORT 12 // user sensor #3 #define SENSOR3PORT 12 // user sensor #3

View File

@ -25,7 +25,7 @@ typedef std::chrono::duration<long long int, std::ratio<1, 1000>>
TaskHandle_t timeSyncReqTask = NULL; 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 bool timeSyncPending = false;
static myClock_timepoint time_sync_tx[TIME_SYNC_SAMPLES]; static myClock_timepoint time_sync_tx[TIME_SYNC_SAMPLES];
static myClock_timepoint time_sync_rx[TIME_SYNC_SAMPLES]; static myClock_timepoint time_sync_rx[TIME_SYNC_SAMPLES];