Log levels refactoring

This commit is contained in:
Ben Meadors
2022-12-29 20:41:37 -06:00
parent 979d12d607
commit 0b5cae5393
90 changed files with 1053 additions and 1051 deletions

View File

@@ -71,7 +71,7 @@ void run_codec2(void* parameter)
// 4 bytes of header in each frame hex c0 de c2 plus the bitrate
memcpy(audioModule->tx_encode_frame,&audioModule->tx_header,sizeof(audioModule->tx_header));
DEBUG_MSG("Starting codec2 task\n");
LOG_DEBUG("Starting codec2 task\n");
while (true) {
uint32_t tcount = ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(10000));
@@ -86,7 +86,7 @@ void run_codec2(void* parameter)
if (audioModule->tx_encode_frame_index == (audioModule->encode_frame_size + sizeof(audioModule->tx_header)))
{
DEBUG_MSG("Sending %d codec2 bytes\n", audioModule->encode_frame_size);
LOG_DEBUG("Sending %d codec2 bytes\n", audioModule->encode_frame_size);
audioModule->sendPayload();
audioModule->tx_encode_frame_index = sizeof(audioModule->tx_header);
}
@@ -127,7 +127,7 @@ AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP),
// moduleConfig.audio.ptt_pin = 39;
if ((moduleConfig.audio.codec2_enabled) && (myRegion->audioPermitted)) {
DEBUG_MSG("Setting up codec2 in mode %u", (moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1);
LOG_DEBUG("Setting up codec2 in mode %u", (moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1);
codec2 = codec2_create((moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1);
memcpy(tx_header.magic,c2_magic,sizeof(c2_magic));
tx_header.mode = (moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1;
@@ -136,10 +136,10 @@ AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP),
encode_frame_num = (Constants_DATA_PAYLOAD_LEN - sizeof(tx_header)) / encode_codec_size;
encode_frame_size = encode_frame_num * encode_codec_size; // max 233 bytes + 4 header bytes
adc_buffer_size = codec2_samples_per_frame(codec2);
DEBUG_MSG(" using %d frames of %d bytes for a total payload length of %d bytes\n", encode_frame_num, encode_codec_size, encode_frame_size);
LOG_DEBUG(" using %d frames of %d bytes for a total payload length of %d bytes\n", encode_frame_num, encode_codec_size, encode_frame_size);
xTaskCreate(&run_codec2, "codec2_task", 30000, NULL, 5, &codec2HandlerTask);
} else {
DEBUG_MSG("Codec2 disabled (AudioModule %d, Region %s, permitted %d)\n", moduleConfig.audio.codec2_enabled, myRegion->name, myRegion->audioPermitted);
LOG_DEBUG("Codec2 disabled (AudioModule %d, Region %s, permitted %d)\n", moduleConfig.audio.codec2_enabled, myRegion->name, myRegion->audioPermitted);
}
}
@@ -173,7 +173,7 @@ int32_t AudioModule::runOnce()
esp_err_t res;
if (firstTime) {
// Set up I2S Processor configuration. This will produce 16bit samples at 8 kHz instead of 12 from the ADC
DEBUG_MSG("Initializing I2S SD: %d DIN: %d WS: %d SCK: %d\n", moduleConfig.audio.i2s_sd, moduleConfig.audio.i2s_din, moduleConfig.audio.i2s_ws, moduleConfig.audio.i2s_sck);
LOG_DEBUG("Initializing I2S SD: %d DIN: %d WS: %d SCK: %d\n", moduleConfig.audio.i2s_sd, moduleConfig.audio.i2s_din, moduleConfig.audio.i2s_ws, moduleConfig.audio.i2s_sck);
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | (moduleConfig.audio.i2s_sd ? I2S_MODE_RX : 0) | (moduleConfig.audio.i2s_din ? I2S_MODE_TX : 0)),
.sample_rate = 8000,
@@ -189,7 +189,7 @@ int32_t AudioModule::runOnce()
};
res = i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
if(res != ESP_OK)
DEBUG_MSG("Failed to install I2S driver: %d\n", res);
LOG_DEBUG("Failed to install I2S driver: %d\n", res);
const i2s_pin_config_t pin_config = {
.bck_io_num = moduleConfig.audio.i2s_sck,
@@ -199,16 +199,16 @@ int32_t AudioModule::runOnce()
};
res = i2s_set_pin(I2S_PORT, &pin_config);
if(res != ESP_OK)
DEBUG_MSG("Failed to set I2S pin config: %d\n", res);
LOG_DEBUG("Failed to set I2S pin config: %d\n", res);
res = i2s_start(I2S_PORT);
if(res != ESP_OK)
DEBUG_MSG("Failed to start I2S: %d\n", res);
LOG_DEBUG("Failed to start I2S: %d\n", res);
radio_state = RadioState::rx;
// Configure PTT input
DEBUG_MSG("Initializing PTT on Pin %u\n", moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN);
LOG_DEBUG("Initializing PTT on Pin %u\n", moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN);
pinMode(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN, INPUT);
firstTime = false;
@@ -217,17 +217,17 @@ int32_t AudioModule::runOnce()
// Check if PTT is pressed. TODO hook that into Onebutton/Interrupt drive.
if (digitalRead(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN) == HIGH) {
if (radio_state == RadioState::rx) {
DEBUG_MSG("PTT pressed, switching to TX\n");
LOG_DEBUG("PTT pressed, switching to TX\n");
radio_state = RadioState::tx;
e.frameChanged = true;
this->notifyObservers(&e);
}
} else {
if (radio_state == RadioState::tx) {
DEBUG_MSG("PTT released, switching to RX\n");
LOG_DEBUG("PTT released, switching to RX\n");
if (tx_encode_frame_index > sizeof(tx_header)) {
// Send the incomplete frame
DEBUG_MSG("Sending %d codec2 bytes (incomplete)\n", tx_encode_frame_index);
LOG_DEBUG("Sending %d codec2 bytes (incomplete)\n", tx_encode_frame_index);
sendPayload();
}
tx_encode_frame_index = sizeof(tx_header);
@@ -258,7 +258,7 @@ int32_t AudioModule::runOnce()
}
return 100;
} else {
DEBUG_MSG("Audio Module Disabled\n");
LOG_DEBUG("Audio Module Disabled\n");
return INT32_MAX;
}

View File

@@ -53,10 +53,10 @@ int32_t RangeTestModule::runOnce()
firstTime = 0;
if (moduleConfig.range_test.sender) {
DEBUG_MSG("Initializing Range Test Module -- Sender\n");
LOG_DEBUG("Initializing Range Test Module -- Sender\n");
return (5000); // Sending first message 5 seconds after initilization.
} else {
DEBUG_MSG("Initializing Range Test Module -- Receiver\n");
LOG_DEBUG("Initializing Range Test Module -- Receiver\n");
return (INT32_MAX);
// This thread does not need to run as a receiver
}
@@ -65,19 +65,19 @@ int32_t RangeTestModule::runOnce()
if (moduleConfig.range_test.sender) {
// If sender
DEBUG_MSG("Range Test Module - Sending heartbeat every %d ms\n", (senderHeartbeat));
LOG_DEBUG("Range Test Module - Sending heartbeat every %d ms\n", (senderHeartbeat));
DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
DEBUG_MSG("fixed_position() %d\n", config.position.fixed_position);
LOG_DEBUG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
LOG_DEBUG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
LOG_DEBUG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
LOG_DEBUG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
LOG_DEBUG("fixed_position() %d\n", config.position.fixed_position);
// Only send packets if the channel is less than 25% utilized.
if (airTime->channelUtilizationPercent() < 25) {
rangeTestModuleRadio->sendPayload();
} else {
DEBUG_MSG("rangeTest - Channel utilization is >25 percent. Skipping this opportunity to send.\n");
LOG_DEBUG("rangeTest - Channel utilization is >25 percent. Skipping this opportunity to send.\n");
}
return (senderHeartbeat);
@@ -90,7 +90,7 @@ int32_t RangeTestModule::runOnce()
}
} else {
DEBUG_MSG("Range Test Module - Disabled\n");
LOG_DEBUG("Range Test Module - Disabled\n");
}
#endif
@@ -135,7 +135,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
/*
auto &p = mp.decoded;
DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
LOG_DEBUG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
nodeDB.getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes);
*/
@@ -148,33 +148,33 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
/*
NodeInfo *n = nodeDB.getNode(getFrom(&mp));
DEBUG_MSG("-----------------------------------------\n");
DEBUG_MSG("p.payload.bytes \"%s\"\n", p.payload.bytes);
DEBUG_MSG("p.payload.size %d\n", p.payload.size);
DEBUG_MSG("---- Received Packet:\n");
DEBUG_MSG("mp.from %d\n", mp.from);
DEBUG_MSG("mp.rx_snr %f\n", mp.rx_snr);
DEBUG_MSG("mp.hop_limit %d\n", mp.hop_limit);
// DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Depricated
// DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Depricated
DEBUG_MSG("---- Node Information of Received Packet (mp.from):\n");
DEBUG_MSG("n->user.long_name %s\n", n->user.long_name);
DEBUG_MSG("n->user.short_name %s\n", n->user.short_name);
DEBUG_MSG("n->user.macaddr %X\n", n->user.macaddr);
DEBUG_MSG("n->has_position %d\n", n->has_position);
DEBUG_MSG("n->position.latitude_i %d\n", n->position.latitude_i);
DEBUG_MSG("n->position.longitude_i %d\n", n->position.longitude_i);
DEBUG_MSG("---- Current device location information:\n");
DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
DEBUG_MSG("-----------------------------------------\n");
LOG_DEBUG("-----------------------------------------\n");
LOG_DEBUG("p.payload.bytes \"%s\"\n", p.payload.bytes);
LOG_DEBUG("p.payload.size %d\n", p.payload.size);
LOG_DEBUG("---- Received Packet:\n");
LOG_DEBUG("mp.from %d\n", mp.from);
LOG_DEBUG("mp.rx_snr %f\n", mp.rx_snr);
LOG_DEBUG("mp.hop_limit %d\n", mp.hop_limit);
// LOG_DEBUG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Depricated
// LOG_DEBUG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Depricated
LOG_DEBUG("---- Node Information of Received Packet (mp.from):\n");
LOG_DEBUG("n->user.long_name %s\n", n->user.long_name);
LOG_DEBUG("n->user.short_name %s\n", n->user.short_name);
LOG_DEBUG("n->user.macaddr %X\n", n->user.macaddr);
LOG_DEBUG("n->has_position %d\n", n->has_position);
LOG_DEBUG("n->position.latitude_i %d\n", n->position.latitude_i);
LOG_DEBUG("n->position.longitude_i %d\n", n->position.longitude_i);
LOG_DEBUG("---- Current device location information:\n");
LOG_DEBUG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
LOG_DEBUG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
LOG_DEBUG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
LOG_DEBUG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
LOG_DEBUG("-----------------------------------------\n");
*/
}
} else {
DEBUG_MSG("Range Test Module Disabled\n");
LOG_DEBUG("Range Test Module Disabled\n");
}
#endif
@@ -188,36 +188,36 @@ bool RangeTestModuleRadio::appendFile(const MeshPacket &mp)
NodeInfo *n = nodeDB.getNode(getFrom(&mp));
/*
DEBUG_MSG("-----------------------------------------\n");
DEBUG_MSG("p.payload.bytes \"%s\"\n", p.payload.bytes);
DEBUG_MSG("p.payload.size %d\n", p.payload.size);
DEBUG_MSG("---- Received Packet:\n");
DEBUG_MSG("mp.from %d\n", mp.from);
DEBUG_MSG("mp.rx_snr %f\n", mp.rx_snr);
DEBUG_MSG("mp.hop_limit %d\n", mp.hop_limit);
// DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Depricated
// DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Depricated
DEBUG_MSG("---- Node Information of Received Packet (mp.from):\n");
DEBUG_MSG("n->user.long_name %s\n", n->user.long_name);
DEBUG_MSG("n->user.short_name %s\n", n->user.short_name);
DEBUG_MSG("n->user.macaddr %X\n", n->user.macaddr);
DEBUG_MSG("n->has_position %d\n", n->has_position);
DEBUG_MSG("n->position.latitude_i %d\n", n->position.latitude_i);
DEBUG_MSG("n->position.longitude_i %d\n", n->position.longitude_i);
DEBUG_MSG("---- Current device location information:\n");
DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
DEBUG_MSG("-----------------------------------------\n");
LOG_DEBUG("-----------------------------------------\n");
LOG_DEBUG("p.payload.bytes \"%s\"\n", p.payload.bytes);
LOG_DEBUG("p.payload.size %d\n", p.payload.size);
LOG_DEBUG("---- Received Packet:\n");
LOG_DEBUG("mp.from %d\n", mp.from);
LOG_DEBUG("mp.rx_snr %f\n", mp.rx_snr);
LOG_DEBUG("mp.hop_limit %d\n", mp.hop_limit);
// LOG_DEBUG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Depricated
// LOG_DEBUG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Depricated
LOG_DEBUG("---- Node Information of Received Packet (mp.from):\n");
LOG_DEBUG("n->user.long_name %s\n", n->user.long_name);
LOG_DEBUG("n->user.short_name %s\n", n->user.short_name);
LOG_DEBUG("n->user.macaddr %X\n", n->user.macaddr);
LOG_DEBUG("n->has_position %d\n", n->has_position);
LOG_DEBUG("n->position.latitude_i %d\n", n->position.latitude_i);
LOG_DEBUG("n->position.longitude_i %d\n", n->position.longitude_i);
LOG_DEBUG("---- Current device location information:\n");
LOG_DEBUG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
LOG_DEBUG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
LOG_DEBUG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
LOG_DEBUG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
LOG_DEBUG("-----------------------------------------\n");
*/
if (!FSBegin()) {
DEBUG_MSG("An Error has occurred while mounting the filesystem\n");
LOG_DEBUG("An Error has occurred while mounting the filesystem\n");
return 0;
}
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
DEBUG_MSG("Filesystem doesn't have enough free space. Aborting write.\n");
LOG_DEBUG("Filesystem doesn't have enough free space. Aborting write.\n");
return 0;
}
@@ -229,16 +229,16 @@ bool RangeTestModuleRadio::appendFile(const MeshPacket &mp)
File fileToWrite = FSCom.open("/static/rangetest.csv", FILE_WRITE);
if (!fileToWrite) {
DEBUG_MSG("There was an error opening the file for writing\n");
LOG_DEBUG("There was an error opening the file for writing\n");
return 0;
}
// Print the CSV header
if (fileToWrite.println(
"time,from,sender name,sender lat,sender long,rx lat,rx long,rx elevation,rx snr,distance,hop limit,payload")) {
DEBUG_MSG("File was written\n");
LOG_DEBUG("File was written\n");
} else {
DEBUG_MSG("File write failed\n");
LOG_DEBUG("File write failed\n");
}
fileToWrite.close();
@@ -248,7 +248,7 @@ bool RangeTestModuleRadio::appendFile(const MeshPacket &mp)
File fileToAppend = FSCom.open("/static/rangetest.csv", FILE_APPEND);
if (!fileToAppend) {
DEBUG_MSG("There was an error opening the file for appending\n");
LOG_DEBUG("There was an error opening the file for appending\n");
return 0;
}

View File

@@ -28,20 +28,20 @@ int32_t StoreForwardModule::runOnce()
StoreAndForward sf = StoreAndForward_init_zero;
sf.rr = StoreAndForward_RequestResponse_ROUTER_PING;
storeForwardModule->sendMessage(this->busyTo, sf);
DEBUG_MSG("*** S&F - Done. (ROUTER_PING)\n");
LOG_DEBUG("*** S&F - Done. (ROUTER_PING)\n");
this->packetHistoryTXQueue_index = 0;
this->busy = false;
} else {
this->packetHistoryTXQueue_index++;
}
} else {
DEBUG_MSG("*** Channel utilization is too high. Retrying later.\n");
LOG_DEBUG("*** Channel utilization is too high. Retrying later.\n");
}
DEBUG_MSG("*** SF bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
LOG_DEBUG("*** SF bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
} else if ((millis() - lastHeartbeat > (heartbeatInterval * 1000)) && (airTime->channelUtilizationPercent() < polite_channel_util_percent)) {
lastHeartbeat = millis();
DEBUG_MSG("*** Sending heartbeat\n");
LOG_DEBUG("*** Sending heartbeat\n");
StoreAndForward sf = StoreAndForward_init_zero;
sf.rr = StoreAndForward_RequestResponse_ROUTER_HEARTBEAT;
sf.which_variant = StoreAndForward_heartbeat_tag;
@@ -65,7 +65,7 @@ void StoreForwardModule::populatePSRAM()
https://learn.upesy.com/en/programmation/psram.html#psram-tab
*/
DEBUG_MSG("*** Before PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreePsram(), ESP.getPsramSize());
LOG_DEBUG("*** Before PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreePsram(), ESP.getPsramSize());
this->packetHistoryTXQueue =
static_cast<PacketHistoryStruct *>(ps_calloc(this->historyReturnMax, sizeof(PacketHistoryStruct)));
@@ -78,8 +78,8 @@ void StoreForwardModule::populatePSRAM()
this->packetHistory = static_cast<PacketHistoryStruct *>(ps_calloc(numberOfPackets, sizeof(PacketHistoryStruct)));
DEBUG_MSG("*** After PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreePsram(), ESP.getPsramSize());
DEBUG_MSG("*** numberOfPackets for packetHistory - %u\n", numberOfPackets);
LOG_DEBUG("*** After PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreePsram(), ESP.getPsramSize());
LOG_DEBUG("*** numberOfPackets for packetHistory - %u\n", numberOfPackets);
}
void StoreForwardModule::historySend(uint32_t msAgo, uint32_t to)
@@ -87,11 +87,11 @@ void StoreForwardModule::historySend(uint32_t msAgo, uint32_t to)
uint32_t queueSize = storeForwardModule->historyQueueCreate(msAgo, to);
if (queueSize) {
DEBUG_MSG ("*** S&F - Sending %u message(s)\n", queueSize);
LOG_DEBUG ("*** S&F - Sending %u message(s)\n", queueSize);
this->busy = true; // runOnce() will pickup the next steps once busy = true.
this->busyTo = to;
} else {
DEBUG_MSG ("*** S&F - No history to send\n");
LOG_DEBUG ("*** S&F - No history to send\n");
}
StoreAndForward sf = StoreAndForward_init_zero;
sf.rr = StoreAndForward_RequestResponse_ROUTER_HISTORY;
@@ -108,13 +108,13 @@ uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to)
for (int i = 0; i < this->packetHistoryCurrent; i++) {
/*
DEBUG_MSG("SF historyQueueCreate\n");
DEBUG_MSG("SF historyQueueCreate - time %d\n", this->packetHistory[i].time);
DEBUG_MSG("SF historyQueueCreate - millis %d\n", millis());
DEBUG_MSG("SF historyQueueCreate - math %d\n", (millis() - msAgo));
LOG_DEBUG("SF historyQueueCreate\n");
LOG_DEBUG("SF historyQueueCreate - time %d\n", this->packetHistory[i].time);
LOG_DEBUG("SF historyQueueCreate - millis %d\n", millis());
LOG_DEBUG("SF historyQueueCreate - math %d\n", (millis() - msAgo));
*/
if (this->packetHistory[i].time && (this->packetHistory[i].time < (millis() - msAgo))) {
DEBUG_MSG("*** SF historyQueueCreate - Time matches - ok\n");
LOG_DEBUG("*** SF historyQueueCreate - Time matches - ok\n");
/*
Copy the messages that were received by the router in the last msAgo
to the packetHistoryTXQueue structure.
@@ -133,8 +133,8 @@ uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to)
Constants_DATA_PAYLOAD_LEN);
this->packetHistoryTXQueue_size++;
DEBUG_MSG("*** PacketHistoryStruct time=%d\n", this->packetHistory[i].time);
DEBUG_MSG("*** PacketHistoryStruct msg=%s\n", this->packetHistory[i].payload);
LOG_DEBUG("*** PacketHistoryStruct time=%d\n", this->packetHistory[i].time);
LOG_DEBUG("*** PacketHistoryStruct msg=%s\n", this->packetHistory[i].payload);
}
}
}
@@ -164,7 +164,7 @@ MeshPacket *StoreForwardModule::allocReply()
void StoreForwardModule::sendPayload(NodeNum dest, uint32_t packetHistory_index)
{
DEBUG_MSG("*** Sending S&F Payload\n");
LOG_DEBUG("*** Sending S&F Payload\n");
MeshPacket *p = allocReply();
p->to = dest;
@@ -227,7 +227,7 @@ void StoreForwardModule::statsSend(uint32_t to)
sf.variant.stats.return_max = this->historyReturnMax;
sf.variant.stats.return_window = this->historyReturnWindow;
DEBUG_MSG("*** Sending S&F Stats\n");
LOG_DEBUG("*** Sending S&F Stats\n");
storeForwardModule->sendMessage(to, sf);
}
@@ -241,7 +241,7 @@ ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
if (mp.decoded.portnum == PortNum_TEXT_MESSAGE_APP) {
storeForwardModule->historyAdd(mp);
DEBUG_MSG("*** S&F stored. Message history contains %u records now.\n", this->packetHistoryCurrent);
LOG_DEBUG("*** S&F stored. Message history contains %u records now.\n", this->packetHistoryCurrent);
} else if (mp.decoded.portnum == PortNum_STORE_FORWARD_APP) {
auto &p = mp.decoded;
@@ -251,7 +251,7 @@ ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &StoreAndForward_msg, &scratch)) {
decoded = &scratch;
} else {
DEBUG_MSG("Error decoding protobuf module!\n");
LOG_DEBUG("Error decoding protobuf module!\n");
// if we can't decode it, nobody can process it!
return ProcessMessage::STOP;
}
@@ -281,7 +281,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
if(is_server) {
// stop sending stuff, the client wants to abort or has another error
if ((this->busy) && (this->busyTo == getFrom(&mp))) {
DEBUG_MSG("*** Client in ERROR or ABORT requested\n");
LOG_DEBUG("*** Client in ERROR or ABORT requested\n");
this->packetHistoryTXQueue_index = 0;
this->busy = false;
}
@@ -291,11 +291,11 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
case StoreAndForward_RequestResponse_CLIENT_HISTORY:
if(is_server) {
requests_history++;
DEBUG_MSG("*** Client Request to send HISTORY\n");
LOG_DEBUG("*** Client Request to send HISTORY\n");
// Send the last 60 minutes of messages.
if (this->busy) {
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY);
DEBUG_MSG("*** S&F - Busy. Try again shortly.\n");
LOG_DEBUG("*** S&F - Busy. Try again shortly.\n");
} else {
if ((p->which_variant == StoreAndForward_history_tag) && (p->variant.history.window > 0)){
storeForwardModule->historySend(p->variant.history.window * 60000, getFrom(&mp)); // window is in minutes
@@ -308,7 +308,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
case StoreAndForward_RequestResponse_CLIENT_PING:
if(is_server) {
DEBUG_MSG("*** StoreAndForward_RequestResponse_CLIENT_PING\n");
LOG_DEBUG("*** StoreAndForward_RequestResponse_CLIENT_PING\n");
// respond with a ROUTER PONG
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_PONG);
}
@@ -316,7 +316,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
case StoreAndForward_RequestResponse_CLIENT_PONG:
if(is_server) {
DEBUG_MSG("*** StoreAndForward_RequestResponse_CLIENT_PONG\n");
LOG_DEBUG("*** StoreAndForward_RequestResponse_CLIENT_PONG\n");
// The Client is alive, update NodeDB
nodeDB.updateFrom(mp);
}
@@ -324,10 +324,10 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
case StoreAndForward_RequestResponse_CLIENT_STATS:
if(is_server) {
DEBUG_MSG("*** Client Request to send STATS\n");
LOG_DEBUG("*** Client Request to send STATS\n");
if (this->busy) {
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY);
DEBUG_MSG("*** S&F - Busy. Try again shortly.\n");
LOG_DEBUG("*** S&F - Busy. Try again shortly.\n");
} else {
storeForwardModule->statsSend(getFrom(&mp));
}
@@ -337,7 +337,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
case StoreAndForward_RequestResponse_ROUTER_ERROR:
case StoreAndForward_RequestResponse_ROUTER_BUSY:
if(is_client) {
DEBUG_MSG("*** StoreAndForward_RequestResponse_ROUTER_BUSY\n");
LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_BUSY\n");
// retry in messages_saved * packetTimeMax ms
retry_delay = millis() + packetHistoryCurrent * packetTimeMax * (StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1);
}
@@ -352,13 +352,13 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
heartbeatInterval = p->variant.heartbeat.period;
}
lastHeartbeat = millis();
DEBUG_MSG("*** StoreAndForward Heartbeat received\n");
LOG_DEBUG("*** StoreAndForward Heartbeat received\n");
}
break;
case StoreAndForward_RequestResponse_ROUTER_PING:
if(is_client) {
DEBUG_MSG("*** StoreAndForward_RequestResponse_ROUTER_PING\n");
LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_PING\n");
// respond with a CLIENT PONG
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_CLIENT_PONG);
}
@@ -366,7 +366,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
case StoreAndForward_RequestResponse_ROUTER_STATS:
if(is_client) {
DEBUG_MSG("*** Router Response STATS\n");
LOG_DEBUG("*** Router Response STATS\n");
// These fields only have informational purpose on a client. Fill them to consume later.
if (p->which_variant == StoreAndForward_stats_tag) {
this->packetHistoryMax = p->variant.stats.messages_total;
@@ -386,7 +386,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
// These fields only have informational purpose on a client. Fill them to consume later.
if (p->which_variant == StoreAndForward_history_tag) {
this->historyReturnWindow = p->variant.history.window / 60000;
DEBUG_MSG("*** Router Response HISTORY - Sending %d messages from last %d minutes\n", p->variant.history.history_messages, this->historyReturnWindow);
LOG_DEBUG("*** Router Response HISTORY - Sending %d messages from last %d minutes\n", p->variant.history.history_messages, this->historyReturnWindow);
}
}
break;
@@ -418,7 +418,7 @@ StoreForwardModule::StoreForwardModule()
// Router
if ((config.device.role == Config_DeviceConfig_Role_ROUTER) || (config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) {
DEBUG_MSG("*** Initializing Store & Forward Module in Router mode\n");
LOG_DEBUG("*** Initializing Store & Forward Module in Router mode\n");
if (ESP.getPsramSize() > 0) {
if (ESP.getFreePsram() >= 1024 * 1024) {
@@ -444,19 +444,19 @@ StoreForwardModule::StoreForwardModule()
this->populatePSRAM();
is_server = true;
} else {
DEBUG_MSG("*** Device has less than 1M of PSRAM free.\n");
DEBUG_MSG("*** Store & Forward Module - disabling server.\n");
LOG_DEBUG("*** Device has less than 1M of PSRAM free.\n");
LOG_DEBUG("*** Store & Forward Module - disabling server.\n");
}
} else {
DEBUG_MSG("*** Device doesn't have PSRAM.\n");
DEBUG_MSG("*** Store & Forward Module - disabling server.\n");
LOG_DEBUG("*** Device doesn't have PSRAM.\n");
LOG_DEBUG("*** Store & Forward Module - disabling server.\n");
}
// Client
}
if ((config.device.role == Config_DeviceConfig_Role_CLIENT) || (config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) {
is_client = true;
DEBUG_MSG("*** Initializing Store & Forward Module in Client mode\n");
LOG_DEBUG("*** Initializing Store & Forward Module in Client mode\n");
}
}
#endif