code sanitizations (eleminate compiler warnings)

This commit is contained in:
Klaus K Wilting 2020-03-15 13:04:03 +01:00
parent a85f84ede4
commit 10c96759f4
3 changed files with 13 additions and 14 deletions

View File

@ -103,10 +103,10 @@ void init_display(bool verbose) {
#if (HAS_LORA) #if (HAS_LORA)
// generate DEVEUI as QR code and text // generate DEVEUI as QR code and text
uint8_t buf[8]; uint8_t buf[8], *p = buf;
char deveui[17]; char deveui[17];
os_getDevEui((u1_t *)buf); os_getDevEui((u1_t *)buf);
snprintf(deveui, 17, "%016llX", *((uint64_t *)&buf)); snprintf(deveui, 17, "%016llX", (*(uint64_t *)(p)));
// display DEVEUI as QR code on the left // display DEVEUI as QR code on the left
oledSetContrast(&ssoled, 30); oledSetContrast(&ssoled, 30);

View File

@ -10,7 +10,6 @@ static const char TAG[] = __FILE__;
TinyGPSPlus gps; TinyGPSPlus gps;
TinyGPSCustom gpstime(gps, "GPZDA", 1); // field 1 = UTC time TinyGPSCustom gpstime(gps, "GPZDA", 1); // field 1 = UTC time
static const String ZDA_Request = "$EIGPQ,ZDA*39\r\n"; static const String ZDA_Request = "$EIGPQ,ZDA*39\r\n";
static gpsStatus_t gps_status = {0};
TaskHandle_t GpsTask; TaskHandle_t GpsTask;
#ifdef GPS_SERIAL #ifdef GPS_SERIAL

View File

@ -178,30 +178,30 @@ void IRAM_ATTR timesync_serverAnswer(void *pUserData, int flag) {
ostime_t rxTime = osticks2ms(os_getTime()); ostime_t rxTime = osticks2ms(os_getTime());
int rc = 0; int rc = 0;
uint8_t rcv_seqNo = *(uint8_t *)pUserData; // cast back function void parameter to a pointer
uint8_t *p = (uint8_t *)pUserData, rcv_seqNo = *p;
uint16_t timestamp_msec = 0; uint16_t timestamp_msec = 0;
uint32_t timestamp_sec = 0; uint32_t timestamp_sec = 0;
#if (TIME_SYNC_LORASERVER) #if (TIME_SYNC_LORASERVER)
// pUserData: contains pointer to payload buffer // pUserData: contains pointer (32bit) to payload buffer
// flag: length of buffer // flag: length of buffer
// Store the instant the time request of the node was received on the gateway // Store the instant the time request of the node was received on the gateway
timesync_store(rxTime, timesync_rx); timesync_store(rxTime, timesync_rx);
// parse timesync_answer: // parse pUserData:
// byte meaning // p type meaning
// 0 sequence number (taken from node's time_sync_req) // +0 uint8_t sequence number (taken from node's time_sync_req)
// 1..4 current second (from UTC epoch) // +1 uint32_t current second (from UTC epoch)
// 5 1/250ths fractions of current second // +4 uint8_t 1/250ths fractions of current second
// swap byte order from msb to lsb, note: this is a platform dependent hack // swap byte order from msb to lsb, note: this is a platform dependent hack
timestamp_sec = __builtin_bswap32(*(uint32_t *)(pUserData + 1)); timestamp_sec = __builtin_bswap32(*(uint32_t *)(++p));
// one step being 1/250th sec * 1000 = 4msec // one step being 1/250th sec * 1000 = 4msec
timestamp_msec = *(uint8_t *)(pUserData + 5); timestamp_msec = *(p += 4) * 4;
timestamp_msec *= 4;
// if no time is available or spurious buffer then exit // if no time is available or spurious buffer then exit
if (flag != TIME_SYNC_FRAME_LENGTH) { if (flag != TIME_SYNC_FRAME_LENGTH) {
@ -218,7 +218,7 @@ void IRAM_ATTR timesync_serverAnswer(void *pUserData, int flag) {
#elif (TIME_SYNC_LORAWAN) #elif (TIME_SYNC_LORAWAN)
// pUserData: contains pointer to SeqNo // pUserData: contains pointer to SeqNo (not needed here)
// flag: indicates if we got a recent time from the network // flag: indicates if we got a recent time from the network
if (flag != 1) { if (flag != 1) {