code comment updates, variable update in pingFDRSEspNow

pull/193/head
Jeff Lehman 4 weeks ago
parent d514d6a049
commit 216657b8c9

@ -380,7 +380,7 @@ bool transmitLoRaAsync(uint16_t *destAddr, DataReading *dr, uint8_t len)
return true;
}
// write a function to return the number of consecutive DRs in the DR Queue that have the same destination address
// return the number of consecutive DRs in the DR Queue that have the same destination address
uint transmitSameAddrLoRa() {
uint count = 0;
@ -668,7 +668,8 @@ crcResult LoRaTxRxOperation()
return crcReturned;
}
// FDRS Sensor pings address and listens for a defined amount of time for a reply
// FDRS Sensor pings address and listens for a defined amount of time for a reply if no tx in process
// otherwise queues up a ping in the SP Buffer.
int pingRequestLoRa(uint16_t address, uint32_t timeout)
{
int pingResult = -1;

@ -121,15 +121,14 @@ void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len)
}
// FDRS node pings gateway and listens for a defined amount of time for a reply
// Asynchonous call so does not wait for a reply so we do not know how long the ping takes
// ESP-NOW is on the order of 10 milliseconds so happens very quickly. Not sure Async is warranted.
// ESP-NOW is on the order of 10 milliseconds so happens very quickly.
int pingFDRSEspNow(uint8_t *dstaddr, uint32_t timeout) {
SystemPacket sys_packet = {.cmd = cmd_ping, .param = ping_request};
unsigned long pingTime = 0;
pingFlag = false;
pingTime = millis();
DBG1("ESP-NOW ping sent to 0x" + String(*(espNowPing.address + 5),HEX));
DBG1("ESP-NOW ping sent to 0x" + String(*(dstaddr + 5),HEX));
esp_now_send(dstaddr, (uint8_t *)&sys_packet, sizeof(SystemPacket));
while(pingFlag == false && (millis() - pingTime < timeout)) {
yield();
@ -138,10 +137,10 @@ int pingFDRSEspNow(uint8_t *dstaddr, uint32_t timeout) {
if(pingFlag == true) {
pingTime = millis() - pingTime;
DBG1("ESP-NOW Ping Reply in " + String(pingTime) + "ms from 0x" + String(espNowPing.address[5], HEX));
DBG1("ESP-NOW Ping Reply in " + String(pingTime) + "ms from 0x" + String(*(dstaddr + 5), HEX));
}
else {
DBG1("No ESP-NOW ping returned within " + String(espNowPing.timeout) + "ms.");
DBG1("No ESP-NOW ping returned within " + String(timeout) + "ms.");
pingTime = -1;
}
pingFlag = false;

@ -1,6 +1,6 @@
#include <sys/time.h>
#define MIN_TS 1709000000 // Time in Unit timestamp format should be greater than this number to be valid
#define MIN_TS 1714000000 // Time in Unit timestamp format should be greater than this number to be valid
#define MAX_TS 3318000000 // time in Unit timestamp format should be less than this number to be valid
#define VALID_TS(_unixts) ( (_unixts > MIN_TS && _unixts < MAX_TS) ? true : false )

Loading…
Cancel
Save