adding and changing debug messages

pull/194/head
Timm Bogner 4 months ago
parent 92d3da53d4
commit 2d2a8d50c9

@ -118,12 +118,25 @@ void beginFDRS()
Serial.begin(115200); Serial.begin(115200);
UART_IF.begin(115200, SERIAL_8N1, RXD2, TXD2); UART_IF.begin(115200, SERIAL_8N1, RXD2, TXD2);
#endif #endif
#ifdef USE_OLED #ifdef USE_OLED
init_oled(); init_oled();
DBG("Display initialized!"); DBG("Display initialized!");
DBG("Hello, World!"); DBG("Hello, World!");
#endif #endif
DBG("Address:" + String(UNIT_MAC, HEX)); DBG("");
DBG("Initializing FDRS Gateway!");
DBG("Address: " + String(UNIT_MAC, HEX));
#ifdef USE_ESPNOW
DBG1("ESPNOW_NEIGHBOR_1: " + String(ESPNOW_NEIGHBOR_1, HEX));
DBG1("ESPNOW_NEIGHBOR_2: " + String(ESPNOW_NEIGHBOR_2, HEX));
#endif // USE_ESPNOW
#ifdef USE_LORA
DBG1("LORA_NEIGHBOR_1: " + String(LORA_NEIGHBOR_1, HEX));
DBG1("LORA_NEIGHBOR_2: " + String(LORA_NEIGHBOR_2, HEX));
#endif // USE_LORA
DBG("Debugging verbosity level: " + String(DBG_LEVEL));
#ifdef USE_LORA #ifdef USE_LORA
begin_lora(); begin_lora();
scheduleFDRS(asyncReleaseLoRaFirst, FDRS_LORA_INTERVAL); scheduleFDRS(asyncReleaseLoRaFirst, FDRS_LORA_INTERVAL);

@ -44,7 +44,7 @@ void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len)
memcpy(&incMAC, mac, sizeof(incMAC)); memcpy(&incMAC, mac, sizeof(incMAC));
if (len < sizeof(DataReading)) if (len < sizeof(DataReading))
{ {
DBG("ESP-NOW System Packet"); DBG1("ESP-NOW System Packet");
memcpy(&theCmd, incomingData, sizeof(theCmd)); memcpy(&theCmd, incomingData, sizeof(theCmd));
memcpy(&incMAC, mac, sizeof(incMAC)); memcpy(&incMAC, mac, sizeof(incMAC));
return; return;
@ -140,7 +140,7 @@ int find_espnow_peer()
// Returns the index of the peer list array element that contains the provided MAC address, -1 if not found // Returns the index of the peer list array element that contains the provided MAC address, -1 if not found
int getFDRSPeer(uint8_t *mac) int getFDRSPeer(uint8_t *mac)
{ {
DBG1("Getting peer #"); DBG2("Getting peer #");
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
@ -157,12 +157,12 @@ int getFDRSPeer(uint8_t *mac)
void add_espnow_peer() void add_espnow_peer()
{ {
DBG("Device requesting peer registration"); DBG1("Device requesting peer registration");
int peer_num = getFDRSPeer(&incMAC[0]); int peer_num = getFDRSPeer(&incMAC[0]);
if (peer_num == -1) // if the device isn't registered if (peer_num == -1) // if the device isn't registered
{ {
int open_peer = find_espnow_peer(); // find open spot in peer_list int open_peer = find_espnow_peer(); // find open spot in peer_list
DBG1("New device will be registered as " + String(open_peer)); DBG("Registering new peer. Slot: " + String(open_peer));
memcpy(&peer_list[open_peer].mac, &incMAC, 6); // save MAC to open spot memcpy(&peer_list[open_peer].mac, &incMAC, 6); // save MAC to open spot
peer_list[open_peer].last_seen = millis(); peer_list[open_peer].last_seen = millis();
#if defined(ESP32) #if defined(ESP32)

@ -82,10 +82,22 @@ void beginFDRS()
DBG("Display initialized!"); DBG("Display initialized!");
DBG("Hello, World!"); DBG("Hello, World!");
#endif #endif
DBG("FDRS User Node initializing..."); DBG("");
DBG(" Reading ID " + String(READING_ID)); DBG("Initializing FDRS Node!");
DBG(" Gateway: " + String(GTWY_MAC, HEX)); DBG("Reading ID " + String(READING_ID));
DBG("Gateway: " + String(GTWY_MAC, HEX));
DBG("Debugging verbosity level: " + String(DBG_LEVEL));
#ifdef USE_ESPNOW
DBG1("ESP-NOW is enabled.");
#endif
#ifdef USE_LORA
DBG1("LoRa is enabled.");
#endif
#ifdef DEEP_SLEEP
DBG1("Deep sleep is enabled.");
#endif
#ifdef POWER_CTRL #ifdef POWER_CTRL
DBG1("Power control is enabled on pin " + String(POWER_CTRL));
DBG("Powering up the sensor array!"); DBG("Powering up the sensor array!");
pinMode(POWER_CTRL, OUTPUT); pinMode(POWER_CTRL, OUTPUT);
digitalWrite(POWER_CTRL, 1); digitalWrite(POWER_CTRL, 1);
@ -131,13 +143,13 @@ void beginFDRS()
memcpy(peerInfo.peer_addr, broadcast_mac, 6); memcpy(peerInfo.peer_addr, broadcast_mac, 6);
if (esp_now_add_peer(&peerInfo) != ESP_OK) if (esp_now_add_peer(&peerInfo) != ESP_OK)
{ {
DBG("Failed to add peer bcast"); DBG(" Failed to add peer bcast");
return; return;
} }
memcpy(peerInfo.peer_addr, gatewayAddress, 6); memcpy(peerInfo.peer_addr, gatewayAddress, 6);
if (esp_now_add_peer(&peerInfo) != ESP_OK) if (esp_now_add_peer(&peerInfo) != ESP_OK)
{ {
DBG("Failed to add peer"); DBG(" Failed to add peer");
return; return;
} }
#endif #endif

Loading…
Cancel
Save