Skip to content

Commit

Permalink
Changed log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-bs committed Nov 13, 2024
1 parent 0da8cd1 commit 6aa96b1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 54 deletions.
11 changes: 4 additions & 7 deletions BresserWeatherSensorLW.ino
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ int16_t lwActivate(void)
state = RADIOLIB_ERR_NETWORK_NOT_JOINED;
while (state != RADIOLIB_LORAWAN_NEW_SESSION)
{
log_d("Join ('login') to the LoRaWAN Network");
log_i("Join ('login') to the LoRaWAN Network");
state = node.activateOTAA();

// ##### save the join counters (nonces) to permanent store
Expand All @@ -453,7 +453,7 @@ int16_t lwActivate(void)

if (state != RADIOLIB_LORAWAN_NEW_SESSION)
{
log_d("Join failed: %d", state);
log_i("Join failed: %d", state);

// how long to wait before join attempts. This is an interim solution pending
// implementation of TS001 LoRaWAN Specification section #7 - this doc applies to v1.0.4 & v1.1
Expand All @@ -468,7 +468,7 @@ int16_t lwActivate(void)
} // if activateOTAA state
} // while join

log_d("Joined");
log_i("Joined");

// reset the failed join count
bootCountSinceUnsuccessfulJoin = 0;
Expand Down Expand Up @@ -581,11 +581,8 @@ void setup()

preferences.begin("BWS-LW", false);
prefs.sleep_interval = preferences.getUShort("sleep_int", SLEEP_INTERVAL);
log_d("Preferences: sleep_interval: %u s", prefs.sleep_interval);
prefs.sleep_interval_long = preferences.getUShort("sleep_int_long", SLEEP_INTERVAL_LONG);
log_d("Preferences: sleep_interval_long: %u s", prefs.sleep_interval_long);
prefs.lw_stat_interval = preferences.getUChar("lw_stat_int", LW_STATUS_INTERVAL);
log_d("Preferences: lw_stat_interval: %u cycles", prefs.lw_stat_interval);
preferences.end();

uint16_t voltage = getBatteryVoltage();
Expand All @@ -606,7 +603,7 @@ void setup()
int16_t state = 0; // return value for calls to RadioLib

// setup the radio based on the pinmap (connections) in config.h
log_v("Initalise the radio");
log_v("Initalise radio");
radio.reset();
state = radio.begin();
debug(state != RADIOLIB_ERR_NONE, "Initalise radio failed", state, true);
Expand Down
23 changes: 10 additions & 13 deletions BresserWeatherSensorLWCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ uint8_t decodeDownlink(uint8_t port, uint8_t *payload, size_t size)
{
if ((port == CMD_GET_DATETIME) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get date/time");
log_i("Get date/time");
return CMD_GET_DATETIME;
}

Expand All @@ -111,15 +111,15 @@ uint8_t decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

localtime_r(&set_time, &timeinfo);
strftime(tbuf, 25, "%Y-%m-%d %H:%M:%S", &timeinfo);
log_d("Set date/time: %s", tbuf);
log_i("Set date/time: %s", tbuf);
#endif
return 0;
}

if ((port == CMD_SET_SLEEP_INTERVAL) && (size == 2))
{
prefs.sleep_interval = (payload[0] << 8) | payload[1];
log_d("Set sleep_interval: %u s", prefs.sleep_interval);
log_i("Set sleep_interval: %u s", prefs.sleep_interval);
preferences.begin("BWS-LW", false);
preferences.putUShort("sleep_int", prefs.sleep_interval);
preferences.end();
Expand All @@ -129,7 +129,7 @@ uint8_t decodeDownlink(uint8_t port, uint8_t *payload, size_t size)
if ((port == CMD_SET_SLEEP_INTERVAL_LONG) && (size == 2))
{
prefs.sleep_interval_long = (payload[0] << 8) | payload[1];
log_d("Set sleep_interval_long: %u s", prefs.sleep_interval_long);
log_i("Set sleep_interval_long: %u s", prefs.sleep_interval_long);
preferences.begin("BWS-LW", false);
preferences.putUShort("sleep_int_long", prefs.sleep_interval_long);
preferences.end();
Expand All @@ -139,7 +139,7 @@ uint8_t decodeDownlink(uint8_t port, uint8_t *payload, size_t size)
if ((port == CMD_SET_LW_STATUS_INTERVAL) && (size == 1))
{
prefs.lw_stat_interval = payload[0];
log_d("Set lw_stat_interval: %u", prefs.lw_stat_interval);
log_i("Set lw_stat_interval: %u", prefs.lw_stat_interval);
preferences.begin("BWS-LW", false);
preferences.putUChar("lw_stat_int", prefs.lw_stat_interval);
preferences.end();
Expand All @@ -148,13 +148,13 @@ uint8_t decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_LW_CONFIG) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get config");
log_i("Get config");
return CMD_GET_LW_CONFIG;
}

if ((port == CMD_GET_LW_STATUS) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get device status");
log_i("Get device status");
return CMD_GET_LW_STATUS;
}

Expand All @@ -177,7 +177,7 @@ void encodeCfgUplink(uint8_t port, uint8_t *uplinkPayload, uint8_t &payloadSize,

if (uplinkReq == CMD_GET_DATETIME)
{
log_d("Date/Time");
log_i("Date/Time");
time_t t_now = rtc.getLocalEpoch();
encoder.writeUint8((t_now >> 24) & 0xff);
encoder.writeUint8((t_now >> 16) & 0xff);
Expand All @@ -188,7 +188,7 @@ void encodeCfgUplink(uint8_t port, uint8_t *uplinkPayload, uint8_t &payloadSize,
}
else if (uplinkReq == CMD_GET_LW_CONFIG)
{
log_d("LoRaWAN Config");
log_i("LoRaWAN Config");
encoder.writeUint8(prefs.sleep_interval >> 8);
encoder.writeUint8(prefs.sleep_interval & 0xFF);
encoder.writeUint8(prefs.sleep_interval_long >> 8);
Expand All @@ -198,7 +198,7 @@ void encodeCfgUplink(uint8_t port, uint8_t *uplinkPayload, uint8_t &payloadSize,
else if (uplinkReq == CMD_GET_LW_STATUS)
{
uint8_t status = longSleep ? 1 : 0;
log_d("Device Status: U_batt=%u mV, longSleep=%u", getBatteryVoltage(), status);
log_i("Device Status: U_batt=%u mV, longSleep=%u", getBatteryVoltage(), status);
encoder.writeUint16(getBatteryVoltage());
encoder.writeUint8(status);
#if defined(ARDUINO_ESP32S3_POWERFEATHER)
Expand Down Expand Up @@ -316,8 +316,5 @@ void encodeCfgUplink(uint8_t port, uint8_t *uplinkPayload, uint8_t &payloadSize,
#else
delay(delayMs);
#endif
//log_d("Sending configuration uplink now.");
payloadSize = encoder.getLength();
//int16_t state = node.sendReceive(uplinkPayload, encoder.getLength(), port);
//debug((state != RADIOLIB_LORAWAN_NO_DOWNLINK) && (state != RADIOLIB_ERR_NONE), "Error in sendReceive", state, false);
}
52 changes: 26 additions & 26 deletions src/AppLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)
#ifdef RAINDATA_EN
if (payload[0] & 0xF)
{
log_d("Reset rain statistics - flags: 0x%X", payload[0]);
log_i("Reset rain statistics - flags: 0x%X", payload[0]);
rainGauge.reset(payload[0] & 0xF);
}
#endif
#ifdef LIGHTNINGSENSOR_EN
if (payload[0] & 0x10)
{
log_d("Reset lightning statistics");
log_i("Reset lightning statistics");
lightningProc.reset();
}
#endif
Expand All @@ -160,7 +160,7 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_SCAN_SENSORS) && (size == 1))
{
log_d("Scan sensors - time: %u s", payload[0]);
log_i("Scan sensors - time: %u s", payload[0]);
// 1. Set flag in Preferences to trigger sensor scan and set scan time
// 2. If flag is set, perform sensors scan instead of normal operation in
// PayloadBresser::begin(void)
Expand All @@ -174,13 +174,13 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_WS_TIMEOUT) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get weathersensor_timeout");
log_i("Get weathersensor_timeout");
return CMD_GET_WS_TIMEOUT;
}

if ((port == CMD_SET_WS_TIMEOUT) && (size == 1))
{
log_d("Set ws_timeout: %u s", payload[0]);
log_i("Set ws_timeout: %u s", payload[0]);
appPrefs.begin("BWS-LW-APP", false);
appPrefs.putUChar("ws_timeout", payload[0]);
appPrefs.end();
Expand All @@ -189,13 +189,13 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_APP_STATUS_INTERVAL) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get App status interval");
log_i("Get App status interval");
return CMD_GET_APP_STATUS_INTERVAL;
}

if ((port == CMD_SET_APP_STATUS_INTERVAL) && (size == 1))
{
log_d("Set App status interval: %u frames", payload[0]);
log_i("Set App status interval: %u frames", payload[0]);
appPrefs.begin("BWS-LW-APP", false);
appPrefs.putUChar("app_stat_int", payload[0]);
appPrefs.end();
Expand All @@ -204,22 +204,22 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_SENSORS_STAT) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get sensors' status");
log_i("Get sensors' status");
return CMD_GET_SENSORS_STAT;
}

if ((port == CMD_GET_SENSORS_INC) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get sensors include list");
log_i("Get sensors include list");
return CMD_GET_SENSORS_INC;
}

if ((port == CMD_SET_SENSORS_INC) && (size % 4 == 0))
{
log_d("Set sensors include list");
log_i("Set sensors include list");
for (size_t i = 0; i < size; i += 4)
{
log_d("%08X:",
log_i("%08X:",
(payload[i] << 24) |
(payload[i + 1] << 16) |
(payload[i + 2] << 8) |
Expand All @@ -231,16 +231,16 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_SENSORS_EXC) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get sensors exclude list");
log_i("Get sensors exclude list");
return CMD_GET_SENSORS_EXC;
}

if ((port == CMD_SET_SENSORS_EXC) && (size % 4 == 0))
{
log_d("Set sensors exclude list");
log_i("Set sensors exclude list");
for (size_t i = 0; i < size - 1; i += 4)
{
log_d("%08X:",
log_i("%08X:",
(payload[i] << 24) |
(payload[i + 1] << 16) |
(payload[i + 2] << 8) |
Expand All @@ -252,13 +252,13 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_SENSORS_CFG) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get sensors configuration");
log_i("Get sensors configuration");
return CMD_GET_SENSORS_CFG;
}

if ((port == CMD_SET_SENSORS_CFG) && (size == 3))
{
log_d("Set sensors configuration - max_sensors: %u, rx_flags: %u, en_decoders: %u",
log_i("Set sensors configuration - max_sensors: %u, rx_flags: %u, en_decoders: %u",
payload[0], payload[1], payload[2]);
weatherSensor.setSensorsCfg(payload[0], payload[1], payload[2]);
return 0;
Expand All @@ -267,7 +267,7 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)
#if defined(MITHERMOMETER_EN) || defined(THEENGSDECODER_EN)
if ((port == CMD_GET_BLE_CONFIG) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get BLE config");
log_i("Get BLE config");
return CMD_GET_BLE_CONFIG;
}

Expand All @@ -282,16 +282,16 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_BLE_ADDR) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get BLE sensors MAC addresses");
log_i("Get BLE sensors MAC addresses");
return CMD_GET_BLE_ADDR;
}

if ((port == CMD_SET_BLE_ADDR) && (size % 6 == 0))
{
log_d("Set BLE sensors MAC addresses");
log_i("Set BLE sensors MAC addresses");
for (size_t i = 0; i < size - 1; i += 6)
{
log_d("%02X:%02X:%02X:%02X:%02X:%02X",
log_i("%02X:%02X:%02X:%02X:%02X:%02X",
payload[i],
payload[i + 1],
payload[i + 2],
Expand All @@ -308,20 +308,20 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size)

if ((port == CMD_GET_APP_PAYLOAD_CFG) && (payload[0] == 0x00) && (size == 1))
{
log_d("Get AppLayer payload configuration");
log_i("Get AppLayer payload configuration");
return CMD_GET_APP_PAYLOAD_CFG;
}

if ((port == CMD_SET_APP_PAYLOAD_CFG) && (size == 24))
{
log_d("Set AppLayer payload configuration");
log_i("Set AppLayer payload configuration");
for (size_t i = 0; i < 16; i++)
{
log_d("Type%02d: 0x%X", i, payload[i]);
log_i("Type%02d: 0x%X", i, payload[i]);
}
log_d("1-Wire: 0x%04X", payload[16] << 8 | payload[17]);
log_d("Analog: 0x%04X", (payload[18] << 8) | payload[19]);
log_d("Digital: 0x%08X", (payload[20] << 24) | (payload[21] << 16) | (payload[22] << 8) | payload[23]);
log_i("1-Wire: 0x%04X", payload[16] << 8 | payload[17]);
log_i("Analog: 0x%04X", (payload[18] << 8) | payload[19]);
log_i("Digital: 0x%08X", (payload[20] << 24) | (payload[21] << 16) | (payload[22] << 8) | payload[23]);

setAppPayloadCfg(payload, APP_PAYLOAD_CFG_SIZE);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/LoadNodeCfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void loadNodeCfg(
#endif
))
{
log_d("Could not initialize LittleFS.");
log_e("Could not initialize LittleFS.");
}
else
{
Expand All @@ -83,7 +83,7 @@ void loadNodeCfg(
DeserializationError error = deserializeJson(doc, file);
if (error)
{
log_d("Failed to read JSON file, using defaults.");
log_e("Failed to read JSON file, using defaults.");
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/LoadSecrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void loadSecrets(bool requireNwkKey, uint64_t &joinEUI, uint64_t &devEUI, uint8_
#endif
))
{
log_d("Could not initialize LittleFS.");
log_e("Could not initialize LittleFS.");
return;
}

Expand All @@ -73,7 +73,7 @@ void loadSecrets(bool requireNwkKey, uint64_t &joinEUI, uint64_t &devEUI, uint8_

if (error)
{
log_d("Failed to read JSON file, using defaults.");
log_e("Failed to read JSON file, using defaults.");
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/PayloadOneWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ float PayloadOneWire::getOneWireTemperature(uint8_t index)
// Check if reading was successful
if (tempC != DEVICE_DISCONNECTED_C)
{
log_d("Temperature = %.2f°C", tempC);
log_i("Temperature = %.2f°C", tempC);
}
else
{
log_d("Error: Could not read temperature data");
log_i("Error: Could not read temperature data");
}

return tempC;
Expand Down Expand Up @@ -95,12 +95,12 @@ void PayloadOneWire::encodeOneWire(uint8_t *appPayloadCfg, LoraEncoder &encoder)
// Check if reading was successful
if (tempC != DEVICE_DISCONNECTED_C)
{
log_d("Temperature[%d] = %.2f°C", index, tempC);
log_i("Temperature[%d] = %.2f°C", index, tempC);
encoder.writeTemperature(tempC);
}
else
{
log_d("Error: Could not read temperature[%d] data", index);
log_i("Error: Could not read temperature[%d] data", index);
encoder.writeTemperature(INV_TEMP);
}

Expand Down

0 comments on commit 6aa96b1

Please sign in to comment.