mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-10 03:47:39 +00:00
Merge branch 'develop' into nice-threads
This commit is contained in:
@@ -106,30 +106,30 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
|
||||
k.length = channelSettings.psk.size;
|
||||
if (k.length == 0) {
|
||||
if (ch.role == Channel_Role_SECONDARY) {
|
||||
DEBUG_MSG("Unset PSK for secondary channel %s. using primary key\n", ch.settings.name);
|
||||
LOG_DEBUG("Unset PSK for secondary channel %s. using primary key\n", ch.settings.name);
|
||||
k = getKey(primaryIndex);
|
||||
} else
|
||||
DEBUG_MSG("Warning: User disabled encryption\n");
|
||||
LOG_WARN("User disabled encryption\n");
|
||||
} else if (k.length == 1) {
|
||||
// Convert the short single byte variants of psk into variant that can be used more generally
|
||||
|
||||
uint8_t pskIndex = k.bytes[0];
|
||||
DEBUG_MSG("Expanding short PSK #%d\n", pskIndex);
|
||||
LOG_DEBUG("Expanding short PSK #%d\n", pskIndex);
|
||||
if (pskIndex == 0)
|
||||
k.length = 0; // Turn off encryption
|
||||
else if (oemStore.oem_aes_key.size > 1) {
|
||||
// Use the OEM key
|
||||
DEBUG_MSG("Using OEM Key with %d bytes\n", oemStore.oem_aes_key.size);
|
||||
LOG_DEBUG("Using OEM Key with %d bytes\n", oemStore.oem_aes_key.size);
|
||||
memcpy(k.bytes, oemStore.oem_aes_key.bytes , oemStore.oem_aes_key.size);
|
||||
k.length = oemStore.oem_aes_key.size;
|
||||
// Bump up the last byte of PSK as needed
|
||||
uint8_t *last = k.bytes + oemStore.oem_aes_key.size - 1;
|
||||
*last = *last + pskIndex - 1; // index of 1 means no change vs defaultPSK
|
||||
if (k.length < 16) {
|
||||
DEBUG_MSG("Warning: OEM provided a too short AES128 key - padding\n");
|
||||
LOG_WARN("OEM provided a too short AES128 key - padding\n");
|
||||
k.length = 16;
|
||||
} else if (k.length < 32 && k.length != 16) {
|
||||
DEBUG_MSG("Warning: OEM provided a too short AES256 key - padding\n");
|
||||
LOG_WARN("OEM provided a too short AES256 key - padding\n");
|
||||
k.length = 32;
|
||||
}
|
||||
} else {
|
||||
@@ -142,12 +142,12 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
|
||||
} else if (k.length < 16) {
|
||||
// Error! The user specified only the first few bits of an AES128 key. So by convention we just pad the rest of the
|
||||
// key with zeros
|
||||
DEBUG_MSG("Warning: User provided a too short AES128 key - padding\n");
|
||||
LOG_WARN("User provided a too short AES128 key - padding\n");
|
||||
k.length = 16;
|
||||
} else if (k.length < 32 && k.length != 16) {
|
||||
// Error! The user specified only the first few bits of an AES256 key. So by convention we just pad the rest of the
|
||||
// key with zeros
|
||||
DEBUG_MSG("Warning: User provided a too short AES256 key - padding\n");
|
||||
LOG_WARN("User provided a too short AES256 key - padding\n");
|
||||
k.length = 32;
|
||||
}
|
||||
}
|
||||
@@ -308,11 +308,11 @@ const char *Channels::getPrimaryName()
|
||||
bool Channels::decryptForHash(ChannelIndex chIndex, ChannelHash channelHash)
|
||||
{
|
||||
if (chIndex > getNumChannels() || getHash(chIndex) != channelHash) {
|
||||
// DEBUG_MSG("Skipping channel %d (hash %x) due to invalid hash/index, want=%x\n", chIndex, getHash(chIndex),
|
||||
// LOG_DEBUG("Skipping channel %d (hash %x) due to invalid hash/index, want=%x\n", chIndex, getHash(chIndex),
|
||||
// channelHash);
|
||||
return false;
|
||||
} else {
|
||||
DEBUG_MSG("Using channel %d (hash 0x%x)\n", chIndex, channelHash);
|
||||
LOG_DEBUG("Using channel %d (hash 0x%x)\n", chIndex, channelHash);
|
||||
setCrypto(chIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void CryptoEngine::setKey(const CryptoKey &k)
|
||||
{
|
||||
DEBUG_MSG("Using AES%d key!\n", k.length * 8);
|
||||
LOG_DEBUG("Using AES%d key!\n", k.length * 8);
|
||||
key = k;
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ void CryptoEngine::setKey(const CryptoKey &k)
|
||||
*/
|
||||
void CryptoEngine::encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes)
|
||||
{
|
||||
DEBUG_MSG("WARNING: noop encryption!\n");
|
||||
LOG_WARN("noop encryption!\n");
|
||||
}
|
||||
|
||||
void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes)
|
||||
{
|
||||
DEBUG_MSG("WARNING: noop decryption!\n");
|
||||
LOG_WARN("noop decryption!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||
bool isAck = ((c && c->error_reason == Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK
|
||||
if (isAck && p->to != getNodeNum()) {
|
||||
// do not flood direct message that is ACKed
|
||||
DEBUG_MSG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
|
||||
LOG_DEBUG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
|
||||
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
|
||||
}
|
||||
if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
|
||||
@@ -47,17 +47,17 @@ void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||
traceRouteModule->updateRoute(tosend);
|
||||
}
|
||||
|
||||
printPacket("Rebroadcasting received floodmsg to neighbors", p);
|
||||
LOG_INFO("Rebroadcasting received floodmsg to neighbors", p);
|
||||
// Note: we are careful to resend using the original senders node id
|
||||
// We are careful not to call our hooked version of send() - because we don't want to check this again
|
||||
Router::send(tosend);
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("Not rebroadcasting. Role = Role_ClientMute\n");
|
||||
LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("Ignoring a simple (0 id) broadcast\n");
|
||||
LOG_DEBUG("Ignoring a simple (0 id) broadcast\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ MeshPacket *MeshModule::allocAckNak(Routing_Error err, NodeNum to, PacketId idFr
|
||||
p->to = to;
|
||||
p->decoded.request_id = idFrom;
|
||||
p->channel = chIndex;
|
||||
DEBUG_MSG("Alloc an err=%d,to=0x%x,idFrom=0x%x,id=0x%x\n", err, to, idFrom, p->id);
|
||||
LOG_ERROR("Alloc an err=%d,to=0x%x,idFrom=0x%x,id=0x%x\n", err, to, idFrom, p->id);
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ MeshPacket *MeshModule::allocErrorResponse(Routing_Error err, const MeshPacket *
|
||||
|
||||
void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
{
|
||||
// DEBUG_MSG("In call modules\n");
|
||||
// LOG_DEBUG("In call modules\n");
|
||||
bool moduleFound = false;
|
||||
|
||||
// We now allow **encrypted** packets to pass through the modules
|
||||
@@ -96,7 +96,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
assert(!pi.myReply); // If it is !null it means we have a bug, because it should have been sent the previous time
|
||||
|
||||
if (wantsPacket) {
|
||||
DEBUG_MSG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket);
|
||||
LOG_DEBUG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket);
|
||||
|
||||
moduleFound = true;
|
||||
|
||||
@@ -134,20 +134,20 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
// any other node.
|
||||
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
|
||||
pi.sendResponse(mp);
|
||||
DEBUG_MSG("Module '%s' sent a response\n", pi.name);
|
||||
LOG_INFO("Module '%s' sent a response\n", pi.name);
|
||||
} else {
|
||||
DEBUG_MSG("Module '%s' considered\n", pi.name);
|
||||
LOG_DEBUG("Module '%s' considered\n", pi.name);
|
||||
}
|
||||
|
||||
// If the requester didn't ask for a response we might need to discard unused replies to prevent memory leaks
|
||||
if (pi.myReply) {
|
||||
DEBUG_MSG("Discarding an unneeded response\n");
|
||||
LOG_DEBUG("Discarding an unneeded response\n");
|
||||
packetPool.release(pi.myReply);
|
||||
pi.myReply = NULL;
|
||||
}
|
||||
|
||||
if (handled == ProcessMessage::STOP) {
|
||||
DEBUG_MSG("Module '%s' handled and skipped other processing\n", pi.name);
|
||||
LOG_DEBUG("Module '%s' handled and skipped other processing\n", pi.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
// Note: if the message started with the local node we don't want to send a no response reply
|
||||
|
||||
// No one wanted to reply to this requst, tell the requster that happened
|
||||
DEBUG_MSG("No one responded, send a nak\n");
|
||||
LOG_DEBUG("No one responded, send a nak\n");
|
||||
|
||||
// SECURITY NOTE! I considered sending back a different error code if we didn't find the psk (i.e. !isDecoded)
|
||||
// but opted NOT TO. Because it is not a good idea to let remote nodes 'probe' to find out which PSKs were "good" vs
|
||||
@@ -175,7 +175,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
}
|
||||
|
||||
if (!moduleFound)
|
||||
DEBUG_MSG("No modules interested in portnum=%d, src=%s\n",
|
||||
LOG_DEBUG("No modules interested in portnum=%d, src=%s\n",
|
||||
mp.decoded.portnum,
|
||||
(src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE");
|
||||
}
|
||||
@@ -199,7 +199,7 @@ void MeshModule::sendResponse(const MeshPacket &req)
|
||||
currentReply = r;
|
||||
} else {
|
||||
// Ignore - this is now expected behavior for routing module (because it ignores some replies)
|
||||
// DEBUG_MSG("WARNING: Client requested response but this module did not provide\n");
|
||||
// LOG_WARN("Client requested response but this module did not provide\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ std::vector<MeshModule *> MeshModule::GetMeshModulesWithUIFrames()
|
||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||
auto &pi = **i;
|
||||
if (pi.wantUIFrame()) {
|
||||
DEBUG_MSG("Module wants a UI Frame\n");
|
||||
LOG_DEBUG("Module wants a UI Frame\n");
|
||||
modulesWithUIFrames.push_back(&pi);
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ void MeshModule::observeUIEvents(
|
||||
Observable<const UIFrameEvent *> *observable =
|
||||
pi.getUIFrameObservable();
|
||||
if (observable != NULL) {
|
||||
DEBUG_MSG("Module wants a UI Frame\n");
|
||||
LOG_DEBUG("Module wants a UI Frame\n");
|
||||
observer->observe(observable);
|
||||
}
|
||||
}
|
||||
@@ -261,7 +261,7 @@ AdminMessageHandleResult MeshModule::handleAdminMessageForAllPlugins(const MeshP
|
||||
if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE)
|
||||
{
|
||||
// In case we have a response it always has priority.
|
||||
DEBUG_MSG("Reply prepared by module '%s' of variant: %d\n",
|
||||
LOG_DEBUG("Reply prepared by module '%s' of variant: %d\n",
|
||||
pi.name,
|
||||
response->which_payload_variant);
|
||||
handled = h;
|
||||
|
||||
@@ -106,7 +106,7 @@ bool MeshService::reloadConfig(int saveWhat)
|
||||
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
|
||||
void MeshService::reloadOwner(bool shouldSave)
|
||||
{
|
||||
// DEBUG_MSG("reloadOwner()\n");
|
||||
// LOG_DEBUG("reloadOwner()\n");
|
||||
// update our local data directly
|
||||
nodeDB.updateUser(nodeDB.getNodeNum(), owner);
|
||||
assert(nodeInfoModule);
|
||||
@@ -140,7 +140,7 @@ void MeshService::handleToRadio(MeshPacket &p)
|
||||
// Switch the port from PortNum_SIMULATOR_APP back to the original PortNum
|
||||
p.decoded.portnum = decoded->portnum;
|
||||
} else
|
||||
DEBUG_MSG("Error decoding protobuf for simulator message!\n");
|
||||
LOG_ERROR("Error decoding protobuf for simulator message!\n");
|
||||
}
|
||||
// Let SimRadio receive as if it did via its LoRa chip
|
||||
SimRadio::instance->startReceive(&p);
|
||||
@@ -148,7 +148,7 @@ void MeshService::handleToRadio(MeshPacket &p)
|
||||
}
|
||||
#endif
|
||||
if (p.from != 0) { // We don't let phones assign nodenums to their sent messages
|
||||
DEBUG_MSG("Warning: phone tried to pick a nodenum, we don't allow that.\n");
|
||||
LOG_WARN("phone tried to pick a nodenum, we don't allow that.\n");
|
||||
p.from = 0;
|
||||
} else {
|
||||
// p.from = nodeDB.getNodeNum();
|
||||
@@ -198,12 +198,12 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
||||
|
||||
if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) {
|
||||
if (positionModule) {
|
||||
DEBUG_MSG("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
||||
LOG_INFO("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
||||
positionModule->sendOurPosition(dest, wantReplies);
|
||||
}
|
||||
} else {
|
||||
if (nodeInfoModule) {
|
||||
DEBUG_MSG("Sending nodeinfo ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
||||
LOG_INFO("Sending nodeinfo ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
||||
nodeInfoModule->sendOurNodeInfo(dest, wantReplies);
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
||||
void MeshService::sendToPhone(MeshPacket *p)
|
||||
{
|
||||
if (toPhoneQueue.numFree() == 0) {
|
||||
DEBUG_MSG("NOTE: tophone queue is full, discarding oldest\n");
|
||||
LOG_WARN("ToPhone queue is full, discarding oldest\n");
|
||||
MeshPacket *d = toPhoneQueue.dequeuePtr(0);
|
||||
if (d)
|
||||
releaseToPool(d);
|
||||
@@ -262,10 +262,10 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
||||
// The GPS has lost lock, if we are fixed position we should just keep using
|
||||
// the old position
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("onGPSchanged() - lost validLocation\n");
|
||||
LOG_DEBUG("onGPSchanged() - lost validLocation\n");
|
||||
#endif
|
||||
if (config.position.fixed_position) {
|
||||
DEBUG_MSG("WARNING: Using fixed position\n");
|
||||
LOG_WARN("Using fixed position\n");
|
||||
pos = node->position;
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
||||
pos.time = getValidTime(RTCQualityGPS);
|
||||
|
||||
// In debug logs, identify position by @timestamp:stage (stage 4 = nodeDB)
|
||||
DEBUG_MSG("onGPSChanged() pos@%x, time=%u, lat=%d, lon=%d, alt=%d\n", pos.timestamp, pos.time, pos.latitude_i,
|
||||
LOG_DEBUG("onGPSChanged() pos@%x, time=%u, lat=%d, lon=%d, alt=%d\n", pos.timestamp, pos.time, pos.latitude_i,
|
||||
pos.longitude_i, pos.altitude);
|
||||
|
||||
// Update our current position in the local DB
|
||||
|
||||
@@ -86,7 +86,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
|
||||
}
|
||||
|
||||
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
|
||||
DEBUG_MSG("Setting default channel and radio preferences!\n");
|
||||
LOG_INFO("Setting default channel and radio preferences!\n");
|
||||
|
||||
channels.initDefaults();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
|
||||
// temp hack for quicker testing
|
||||
// devicestate.no_save = true;
|
||||
if (devicestate.no_save) {
|
||||
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE *****\n");
|
||||
LOG_DEBUG("***** DEVELOPMENT MODE - DO NOT RELEASE *****\n");
|
||||
|
||||
// Sleep quite frequently to stress test the BLE comms, broadcast position every 6 mins
|
||||
config.display.screen_on_secs = 10;
|
||||
@@ -114,7 +114,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
|
||||
initRegion();
|
||||
|
||||
if (didFactoryReset) {
|
||||
DEBUG_MSG("Rebooting due to factory reset");
|
||||
LOG_INFO("Rebooting due to factory reset");
|
||||
screen->startRebootScreen();
|
||||
rebootAtMsec = millis() + (5 * 1000);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
|
||||
|
||||
bool NodeDB::factoryReset()
|
||||
{
|
||||
DEBUG_MSG("Performing factory reset!\n");
|
||||
LOG_INFO("Performing factory reset!\n");
|
||||
// first, remove the "/prefs" (this removes most prefs)
|
||||
rmDir("/prefs");
|
||||
// second, install default state (this will deal with the duplicate mac address issue)
|
||||
@@ -140,7 +140,7 @@ bool NodeDB::factoryReset()
|
||||
#endif
|
||||
#ifdef ARCH_NRF52
|
||||
Bluefruit.begin();
|
||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||
LOG_INFO("Clearing bluetooth bonds!\n");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
Bluefruit.Periph.clearBonds();
|
||||
@@ -151,7 +151,7 @@ bool NodeDB::factoryReset()
|
||||
|
||||
void NodeDB::installDefaultConfig()
|
||||
{
|
||||
DEBUG_MSG("Installing default LocalConfig\n");
|
||||
LOG_INFO("Installing default LocalConfig\n");
|
||||
memset(&config, 0, sizeof(LocalConfig));
|
||||
config.version = DEVICESTATE_CUR_VER;
|
||||
config.has_device = true;
|
||||
@@ -203,7 +203,7 @@ void NodeDB::initConfigIntervals()
|
||||
|
||||
void NodeDB::installDefaultModuleConfig()
|
||||
{
|
||||
DEBUG_MSG("Installing default ModuleConfig\n");
|
||||
LOG_INFO("Installing default ModuleConfig\n");
|
||||
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
||||
|
||||
moduleConfig.version = DEVICESTATE_CUR_VER;
|
||||
@@ -230,7 +230,7 @@ void NodeDB::initModuleConfigIntervals()
|
||||
|
||||
void NodeDB::installDefaultChannels()
|
||||
{
|
||||
DEBUG_MSG("Installing default ChannelFile\n");
|
||||
LOG_INFO("Installing default ChannelFile\n");
|
||||
memset(&channelFile, 0, sizeof(ChannelFile));
|
||||
channelFile.version = DEVICESTATE_CUR_VER;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ void NodeDB::resetNodes()
|
||||
|
||||
void NodeDB::installDefaultDeviceState()
|
||||
{
|
||||
DEBUG_MSG("Installing default DeviceState\n");
|
||||
LOG_INFO("Installing default DeviceState\n");
|
||||
memset(&devicestate, 0, sizeof(DeviceState));
|
||||
|
||||
*numNodes = 0;
|
||||
@@ -275,7 +275,7 @@ void NodeDB::installDefaultDeviceState()
|
||||
|
||||
void NodeDB::init()
|
||||
{
|
||||
DEBUG_MSG("Initializing NodeDB\n");
|
||||
LOG_INFO("Initializing NodeDB\n");
|
||||
loadFromDisk();
|
||||
|
||||
uint32_t devicestateCRC = crc32Buffer(&devicestate, sizeof(devicestate));
|
||||
@@ -311,7 +311,7 @@ void NodeDB::init()
|
||||
preferences.begin("meshtastic", false);
|
||||
myNodeInfo.reboot_count = preferences.getUInt("rebootCounter", 0);
|
||||
preferences.end();
|
||||
DEBUG_MSG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count);
|
||||
LOG_DEBUG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count);
|
||||
|
||||
/* The ESP32 has a wifi radio. This will need to be modified at some point so
|
||||
* the test isn't so simplistic.
|
||||
@@ -320,7 +320,7 @@ void NodeDB::init()
|
||||
#endif
|
||||
|
||||
resetRadioConfig(); // If bogus settings got saved, then fix them
|
||||
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
||||
LOG_DEBUG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
||||
|
||||
if (devicestateCRC != crc32Buffer(&devicestate, sizeof(devicestate)))
|
||||
saveWhat |= SEGMENT_DEVICESTATE;
|
||||
@@ -352,7 +352,7 @@ void NodeDB::pickNewNodeNum()
|
||||
NodeInfo *found;
|
||||
while ((found = getNode(r)) && memcmp(found->user.macaddr, owner.macaddr, sizeof(owner.macaddr))) {
|
||||
NodeNum n = random(NUM_RESERVED, NODENUM_BROADCAST); // try a new random choice
|
||||
DEBUG_MSG("NOTE! Our desired nodenum 0x%x is in use, so trying for 0x%x\n", r, n);
|
||||
LOG_DEBUG("NOTE! Our desired nodenum 0x%x is in use, so trying for 0x%x\n", r, n);
|
||||
r = n;
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ static const char *oemConfigFile = "/oem/oem.proto";
|
||||
|
||||
|
||||
/** Load a protobuf from a file, return true for success */
|
||||
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
||||
bool NodeDB::loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
||||
{
|
||||
bool okay = false;
|
||||
#ifdef FSCom
|
||||
@@ -376,24 +376,24 @@ bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
||||
auto f = FSCom.open(filename, FILE_O_READ);
|
||||
|
||||
if (f) {
|
||||
DEBUG_MSG("Loading %s\n", filename);
|
||||
LOG_INFO("Loading %s\n", filename);
|
||||
pb_istream_t stream = {&readcb, &f, protoSize};
|
||||
|
||||
// DEBUG_MSG("Preload channel name=%s\n", channelSettings.name);
|
||||
// LOG_DEBUG("Preload channel name=%s\n", channelSettings.name);
|
||||
|
||||
memset(dest_struct, 0, objSize);
|
||||
if (!pb_decode(&stream, fields, dest_struct)) {
|
||||
DEBUG_MSG("Error: can't decode protobuf %s\n", PB_GET_ERROR(&stream));
|
||||
LOG_ERROR("Error: can't decode protobuf %s\n", PB_GET_ERROR(&stream));
|
||||
} else {
|
||||
okay = true;
|
||||
}
|
||||
|
||||
f.close();
|
||||
} else {
|
||||
DEBUG_MSG("No %s preferences found\n", filename);
|
||||
LOG_INFO("No %s preferences found\n", filename);
|
||||
}
|
||||
#else
|
||||
DEBUG_MSG("ERROR: Filesystem not implemented\n");
|
||||
LOG_ERROR("ERROR: Filesystem not implemented\n");
|
||||
#endif
|
||||
return okay;
|
||||
}
|
||||
@@ -405,10 +405,10 @@ void NodeDB::loadFromDisk()
|
||||
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
||||
} else {
|
||||
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
||||
DEBUG_MSG("Warn: devicestate %d is old, discarding\n", devicestate.version);
|
||||
LOG_WARN("Devicestate %d is old, discarding\n", devicestate.version);
|
||||
factoryReset();
|
||||
} else {
|
||||
DEBUG_MSG("Loaded saved devicestate version %d\n", devicestate.version);
|
||||
LOG_INFO("Loaded saved devicestate version %d\n", devicestate.version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,10 +416,10 @@ void NodeDB::loadFromDisk()
|
||||
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
||||
} else {
|
||||
if (config.version < DEVICESTATE_MIN_VER) {
|
||||
DEBUG_MSG("Warn: config %d is old, discarding\n", config.version);
|
||||
LOG_WARN("config %d is old, discarding\n", config.version);
|
||||
installDefaultConfig();
|
||||
} else {
|
||||
DEBUG_MSG("Loaded saved config version %d\n", config.version);
|
||||
LOG_INFO("Loaded saved config version %d\n", config.version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,10 +427,10 @@ void NodeDB::loadFromDisk()
|
||||
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
||||
} else {
|
||||
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
||||
DEBUG_MSG("Warn: moduleConfig %d is old, discarding\n", moduleConfig.version);
|
||||
LOG_WARN("moduleConfig %d is old, discarding\n", moduleConfig.version);
|
||||
installDefaultModuleConfig();
|
||||
} else {
|
||||
DEBUG_MSG("Loaded saved moduleConfig version %d\n", moduleConfig.version);
|
||||
LOG_INFO("Loaded saved moduleConfig version %d\n", moduleConfig.version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,19 +438,19 @@ void NodeDB::loadFromDisk()
|
||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||
} else {
|
||||
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
||||
DEBUG_MSG("Warn: channelFile %d is old, discarding\n", channelFile.version);
|
||||
LOG_WARN("channelFile %d is old, discarding\n", channelFile.version);
|
||||
installDefaultChannels();
|
||||
} else {
|
||||
DEBUG_MSG("Loaded saved channelFile version %d\n", channelFile.version);
|
||||
LOG_INFO("Loaded saved channelFile version %d\n", channelFile.version);
|
||||
}
|
||||
}
|
||||
|
||||
if (loadProto(oemConfigFile, OEMStore_size, sizeof(OEMStore), &OEMStore_msg, &oemStore))
|
||||
DEBUG_MSG("Loaded OEMStore\n");
|
||||
LOG_INFO("Loaded OEMStore\n");
|
||||
}
|
||||
|
||||
/** Save a protobuf from a file, return true for success */
|
||||
bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
||||
bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
||||
{
|
||||
bool okay = false;
|
||||
#ifdef FSCom
|
||||
@@ -459,11 +459,11 @@ bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *field
|
||||
filenameTmp += ".tmp";
|
||||
auto f = FSCom.open(filenameTmp.c_str(), FILE_O_WRITE);
|
||||
if (f) {
|
||||
DEBUG_MSG("Saving %s\n", filename);
|
||||
LOG_INFO("Saving %s\n", filename);
|
||||
pb_ostream_t stream = {&writecb, &f, protoSize};
|
||||
|
||||
if (!pb_encode(&stream, fields, dest_struct)) {
|
||||
DEBUG_MSG("Error: can't encode protobuf %s\n", PB_GET_ERROR(&stream));
|
||||
LOG_ERROR("Error: can't encode protobuf %s\n", PB_GET_ERROR(&stream));
|
||||
} else {
|
||||
okay = true;
|
||||
}
|
||||
@@ -471,11 +471,11 @@ bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *field
|
||||
|
||||
// brief window of risk here ;-)
|
||||
if (FSCom.exists(filename) && !FSCom.remove(filename))
|
||||
DEBUG_MSG("Warning: Can't remove old pref file\n");
|
||||
LOG_WARN("Can't remove old pref file\n");
|
||||
if (!renameFile(filenameTmp.c_str(), filename))
|
||||
DEBUG_MSG("Error: can't rename new pref file\n");
|
||||
LOG_ERROR("Error: can't rename new pref file\n");
|
||||
} else {
|
||||
DEBUG_MSG("Can't write prefs\n");
|
||||
LOG_ERROR("Can't write prefs\n");
|
||||
#ifdef ARCH_NRF52
|
||||
static uint8_t failedCounter = 0;
|
||||
failedCounter++;
|
||||
@@ -487,7 +487,7 @@ bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *field
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
DEBUG_MSG("ERROR: Filesystem not implemented\n");
|
||||
LOG_ERROR("ERROR: Filesystem not implemented\n");
|
||||
#endif
|
||||
return okay;
|
||||
}
|
||||
@@ -548,7 +548,7 @@ void NodeDB::saveToDisk(int saveWhat)
|
||||
saveChannelsToDisk();
|
||||
}
|
||||
} else {
|
||||
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
||||
LOG_DEBUG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,14 +599,14 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
||||
|
||||
if (src == RX_SRC_LOCAL) {
|
||||
// Local packet, fully authoritative
|
||||
DEBUG_MSG("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.timestamp, p.time, p.latitude_i,
|
||||
LOG_INFO("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.timestamp, p.time, p.latitude_i,
|
||||
p.longitude_i, p.altitude);
|
||||
info->position = p;
|
||||
|
||||
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.timestamp && !p.location_source) {
|
||||
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
|
||||
// (stop-gap fix for issue #900)
|
||||
DEBUG_MSG("updatePosition SPECIAL time setting time=%u\n", p.time);
|
||||
LOG_DEBUG("updatePosition SPECIAL time setting time=%u\n", p.time);
|
||||
info->position.time = p.time;
|
||||
|
||||
} else {
|
||||
@@ -615,7 +615,7 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
||||
// recorded based on the packet rxTime
|
||||
//
|
||||
// FIXME perhaps handle RX_SRC_USER separately?
|
||||
DEBUG_MSG("updatePosition REMOTE node=0x%x time=%u, latI=%d, lonI=%d\n", nodeId, p.time, p.latitude_i, p.longitude_i);
|
||||
LOG_INFO("updatePosition REMOTE node=0x%x time=%u, latI=%d, lonI=%d\n", nodeId, p.time, p.latitude_i, p.longitude_i);
|
||||
|
||||
// First, back up fields that we want to protect from overwrite
|
||||
uint32_t tmp_time = info->position.time;
|
||||
@@ -645,9 +645,9 @@ void NodeDB::updateTelemetry(uint32_t nodeId, const Telemetry &t, RxSource src)
|
||||
|
||||
if (src == RX_SRC_LOCAL) {
|
||||
// Local packet, fully authoritative
|
||||
DEBUG_MSG("updateTelemetry LOCAL\n");
|
||||
LOG_DEBUG("updateTelemetry LOCAL\n");
|
||||
} else {
|
||||
DEBUG_MSG("updateTelemetry REMOTE node=0x%x \n", nodeId);
|
||||
LOG_DEBUG("updateTelemetry REMOTE node=0x%x \n", nodeId);
|
||||
}
|
||||
info->device_metrics = t.variant.device_metrics;
|
||||
info->has_device_metrics = true;
|
||||
@@ -664,13 +664,13 @@ void NodeDB::updateUser(uint32_t nodeId, const User &p)
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_MSG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name);
|
||||
LOG_DEBUG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name);
|
||||
|
||||
bool changed = memcmp(&info->user, &p,
|
||||
sizeof(info->user)); // Both of these blocks start as filled with zero so I think this is okay
|
||||
|
||||
info->user = p;
|
||||
DEBUG_MSG("updating changed=%d user %s/%s/%s\n", changed, info->user.id, info->user.long_name, info->user.short_name);
|
||||
LOG_DEBUG("updating changed=%d user %s/%s/%s\n", changed, info->user.id, info->user.long_name, info->user.short_name);
|
||||
info->has_user = true;
|
||||
|
||||
if (changed) {
|
||||
@@ -689,7 +689,7 @@ void NodeDB::updateUser(uint32_t nodeId, const User &p)
|
||||
void NodeDB::updateFrom(const MeshPacket &mp)
|
||||
{
|
||||
if (mp.which_payload_variant == MeshPacket_decoded_tag && mp.from) {
|
||||
DEBUG_MSG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time);
|
||||
LOG_DEBUG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time);
|
||||
|
||||
NodeInfo *info = getOrCreateNode(getFrom(&mp));
|
||||
if (!info) {
|
||||
@@ -756,9 +756,9 @@ void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *f
|
||||
String lcd = String("Critical error ") + code + "!\n";
|
||||
screen->print(lcd.c_str());
|
||||
if (filename)
|
||||
DEBUG_MSG("NOTE! Recording critical error %d at %s:%lu\n", code, filename, address);
|
||||
LOG_ERROR("NOTE! Recording critical error %d at %s:%lu\n", code, filename, address);
|
||||
else
|
||||
DEBUG_MSG("NOTE! Recording critical error %d, address=0x%lx\n", code, address);
|
||||
LOG_ERROR("NOTE! Recording critical error %d, address=0x%lx\n", code, address);
|
||||
|
||||
// Record error to DB
|
||||
myNodeInfo.error_code = code;
|
||||
@@ -767,7 +767,7 @@ void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *f
|
||||
|
||||
// Currently portuino is mostly used for simulation. Make sue the user notices something really bad happend
|
||||
#ifdef ARCH_PORTDUINO
|
||||
DEBUG_MSG("A critical failure occurred, portduino is exiting...");
|
||||
LOG_ERROR("A critical failure occurred, portduino is exiting...");
|
||||
exit(2);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -125,6 +125,9 @@ class NodeDB
|
||||
|
||||
bool factoryReset();
|
||||
|
||||
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct);
|
||||
bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct);
|
||||
|
||||
private:
|
||||
/// Find a node in our DB, create an empty NodeInfo if missing
|
||||
NodeInfo *getOrCreateNode(NodeNum n);
|
||||
|
||||
@@ -14,7 +14,7 @@ PacketHistory::PacketHistory()
|
||||
bool PacketHistory::wasSeenRecently(const MeshPacket *p, bool withUpdate)
|
||||
{
|
||||
if (p->id == 0) {
|
||||
DEBUG_MSG("Ignoring message with zero id\n");
|
||||
LOG_DEBUG("Ignoring message with zero id\n");
|
||||
return false; // Not a floodable message ID, so we don't care
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ bool PacketHistory::wasSeenRecently(const MeshPacket *p, bool withUpdate)
|
||||
}
|
||||
|
||||
if (seenRecently) {
|
||||
DEBUG_MSG("Found existing packet record for fr=0x%x,to=0x%x,id=0x%x\n", p->from, p->to, p->id);
|
||||
LOG_DEBUG("Found existing packet record for fr=0x%x,to=0x%x,id=0x%x\n", p->from, p->to, p->id);
|
||||
}
|
||||
|
||||
if (withUpdate) {
|
||||
@@ -61,7 +61,7 @@ bool PacketHistory::wasSeenRecently(const MeshPacket *p, bool withUpdate)
|
||||
void PacketHistory::clearExpiredRecentPackets() {
|
||||
uint32_t now = millis();
|
||||
|
||||
DEBUG_MSG("recentPackets size=%ld\n", recentPackets.size());
|
||||
LOG_DEBUG("recentPackets size=%ld\n", recentPackets.size());
|
||||
|
||||
for (auto it = recentPackets.begin(); it != recentPackets.end(); ) {
|
||||
if ((now - it->rxTimeMsec) >= FLOOD_EXPIRE_TIME) {
|
||||
@@ -71,5 +71,5 @@ void PacketHistory::clearExpiredRecentPackets() {
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_MSG("recentPackets size=%ld (after clearing expired packets)\n", recentPackets.size());
|
||||
LOG_DEBUG("recentPackets size=%ld (after clearing expired packets)\n", recentPackets.size());
|
||||
}
|
||||
@@ -37,7 +37,7 @@ void PhoneAPI::handleStartConfig()
|
||||
// even if we were already connected - restart our state machine
|
||||
state = STATE_SEND_MY_INFO;
|
||||
|
||||
DEBUG_MSG("Starting API client config\n");
|
||||
LOG_INFO("Starting API client config\n");
|
||||
nodeInfoForPhone = NULL; // Don't keep returning old nodeinfos
|
||||
nodeDB.resetReadPointer(); // FIXME, this read pointer should be moved out of nodeDB and into this class - because
|
||||
// this will break once we have multiple instances of PhoneAPI running independently
|
||||
@@ -60,7 +60,7 @@ void PhoneAPI::checkConnectionTimeout()
|
||||
if (isConnected()) {
|
||||
bool newContact = checkIsConnected();
|
||||
if (!newContact) {
|
||||
DEBUG_MSG("Lost phone connection\n");
|
||||
LOG_INFO("Lost phone connection\n");
|
||||
close();
|
||||
}
|
||||
}
|
||||
@@ -83,20 +83,20 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
||||
return handleToRadioPacket(toRadioScratch.packet);
|
||||
case ToRadio_want_config_id_tag:
|
||||
config_nonce = toRadioScratch.want_config_id;
|
||||
DEBUG_MSG("Client wants config, nonce=%u\n", config_nonce);
|
||||
LOG_INFO("Client wants config, nonce=%u\n", config_nonce);
|
||||
handleStartConfig();
|
||||
break;
|
||||
case ToRadio_disconnect_tag:
|
||||
DEBUG_MSG("Disconnecting from phone\n");
|
||||
LOG_INFO("Disconnecting from phone\n");
|
||||
close();
|
||||
break;
|
||||
default:
|
||||
// Ignore nop messages
|
||||
// DEBUG_MSG("Error: unexpected ToRadio variant\n");
|
||||
// LOG_DEBUG("Error: unexpected ToRadio variant\n");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
DEBUG_MSG("Error: ignoring malformed toradio\n");
|
||||
LOG_ERROR("Error: ignoring malformed toradio\n");
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -119,7 +119,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
||||
size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
{
|
||||
if (!available()) {
|
||||
// DEBUG_MSG("getFromRadio=not available\n");
|
||||
// LOG_DEBUG("getFromRadio=not available\n");
|
||||
return 0;
|
||||
}
|
||||
// In case we send a FromRadio packet
|
||||
@@ -128,11 +128,11 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
// Advance states as needed
|
||||
switch (state) {
|
||||
case STATE_SEND_NOTHING:
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_NOTHING\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_NOTHING\n");
|
||||
break;
|
||||
|
||||
case STATE_SEND_MY_INFO:
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_MY_INFO\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_MY_INFO\n");
|
||||
// If the user has specified they don't want our node to share its location, make sure to tell the phone
|
||||
// app not to send locations on our behalf.
|
||||
myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info
|
||||
@@ -144,18 +144,18 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
break;
|
||||
|
||||
case STATE_SEND_NODEINFO: {
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_NODEINFO\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_NODEINFO\n");
|
||||
const NodeInfo *info = nodeInfoForPhone;
|
||||
nodeInfoForPhone = NULL; // We just consumed a nodeinfo, will need a new one next time
|
||||
|
||||
if (info) {
|
||||
DEBUG_MSG("Sending nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s\n", info->num, info->last_heard, info->user.id,
|
||||
LOG_INFO("Sending nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s\n", info->num, info->last_heard, info->user.id,
|
||||
info->user.long_name);
|
||||
fromRadioScratch.which_payload_variant = FromRadio_node_info_tag;
|
||||
fromRadioScratch.node_info = *info;
|
||||
// Stay in current state until done sending nodeinfos
|
||||
} else {
|
||||
DEBUG_MSG("Done sending nodeinfos\n");
|
||||
LOG_INFO("Done sending nodeinfos\n");
|
||||
state = STATE_SEND_CHANNELS;
|
||||
// Go ahead and send that ID right now
|
||||
return getFromRadio(buf);
|
||||
@@ -164,19 +164,19 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
}
|
||||
|
||||
case STATE_SEND_CHANNELS:
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_CHANNELS\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_CHANNELS\n");
|
||||
fromRadioScratch.which_payload_variant = FromRadio_channel_tag;
|
||||
fromRadioScratch.channel = channels.getByIndex(config_state);
|
||||
config_state++;
|
||||
// Advance when we have sent all of our Channels
|
||||
if (config_state >= MAX_NUM_CHANNELS) {
|
||||
state = STATE_SEND_CONFIG;
|
||||
config_state = Config_device_tag;
|
||||
config_state = _AdminMessage_ConfigType_MIN + 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SEND_CONFIG:
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_CONFIG\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_CONFIG\n");
|
||||
fromRadioScratch.which_payload_variant = FromRadio_config_tag;
|
||||
switch (config_state) {
|
||||
case Config_device_tag:
|
||||
@@ -215,14 +215,14 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
|
||||
config_state++;
|
||||
// Advance when we have sent all of our config objects
|
||||
if (config_state > Config_bluetooth_tag) {
|
||||
if (config_state > (_AdminMessage_ConfigType_MAX + 1)) {
|
||||
state = STATE_SEND_MODULECONFIG;
|
||||
config_state = ModuleConfig_mqtt_tag;
|
||||
config_state = _AdminMessage_ModuleConfigType_MIN + 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SEND_MODULECONFIG:
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_MODULECONFIG\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_MODULECONFIG\n");
|
||||
fromRadioScratch.which_payload_variant = FromRadio_moduleConfig_tag;
|
||||
switch (config_state) {
|
||||
case ModuleConfig_mqtt_tag:
|
||||
@@ -237,6 +237,10 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_external_notification_tag;
|
||||
fromRadioScratch.moduleConfig.payload_variant.external_notification = moduleConfig.external_notification;
|
||||
break;
|
||||
case ModuleConfig_store_forward_tag:
|
||||
fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_store_forward_tag;
|
||||
fromRadioScratch.moduleConfig.payload_variant.store_forward = moduleConfig.store_forward;
|
||||
break;
|
||||
case ModuleConfig_range_test_tag:
|
||||
fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_range_test_tag;
|
||||
fromRadioScratch.moduleConfig.payload_variant.range_test = moduleConfig.range_test;
|
||||
@@ -253,18 +257,22 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_audio_tag;
|
||||
fromRadioScratch.moduleConfig.payload_variant.audio = moduleConfig.audio;
|
||||
break;
|
||||
case ModuleConfig_remote_hardware_tag:
|
||||
fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_remote_hardware_tag;
|
||||
fromRadioScratch.moduleConfig.payload_variant.remote_hardware = moduleConfig.remote_hardware;
|
||||
break;
|
||||
}
|
||||
|
||||
config_state++;
|
||||
// Advance when we have sent all of our ModuleConfig objects
|
||||
if (config_state > ModuleConfig_audio_tag) {
|
||||
if (config_state > (_AdminMessage_ModuleConfigType_MAX + 1)) {
|
||||
state = STATE_SEND_COMPLETE_ID;
|
||||
config_state = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SEND_COMPLETE_ID:
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_COMPLETE_ID\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID\n");
|
||||
fromRadioScratch.which_payload_variant = FromRadio_config_complete_id_tag;
|
||||
fromRadioScratch.config_complete_id = config_nonce;
|
||||
config_nonce = 0;
|
||||
@@ -273,7 +281,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
|
||||
case STATE_SEND_PACKETS:
|
||||
// Do we have a message from the mesh?
|
||||
DEBUG_MSG("getFromRadio=STATE_SEND_PACKETS\n");
|
||||
LOG_INFO("getFromRadio=STATE_SEND_PACKETS\n");
|
||||
if (packetForPhone) {
|
||||
printPacket("phone downloaded packet", packetForPhone);
|
||||
|
||||
@@ -293,17 +301,17 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
// Encapsulate as a FromRadio packet
|
||||
size_t numbytes = pb_encode_to_bytes(buf, FromRadio_size, &FromRadio_msg, &fromRadioScratch);
|
||||
|
||||
DEBUG_MSG("encoding toPhone packet to phone variant=%d, %d bytes\n", fromRadioScratch.which_payload_variant, numbytes);
|
||||
LOG_DEBUG("encoding toPhone packet to phone variant=%d, %d bytes\n", fromRadioScratch.which_payload_variant, numbytes);
|
||||
return numbytes;
|
||||
}
|
||||
|
||||
DEBUG_MSG("no FromRadio packet available\n");
|
||||
LOG_DEBUG("no FromRadio packet available\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PhoneAPI::handleDisconnect()
|
||||
{
|
||||
DEBUG_MSG("PhoneAPI disconnect\n");
|
||||
LOG_INFO("PhoneAPI disconnect\n");
|
||||
}
|
||||
|
||||
void PhoneAPI::releasePhonePacket()
|
||||
@@ -337,7 +345,7 @@ bool PhoneAPI::available()
|
||||
if (!packetForPhone)
|
||||
packetForPhone = service.getForPhone();
|
||||
bool hasPacket = !!packetForPhone;
|
||||
// DEBUG_MSG("available hasPacket=%d\n", hasPacket);
|
||||
// LOG_DEBUG("available hasPacket=%d\n", hasPacket);
|
||||
return hasPacket;
|
||||
}
|
||||
default:
|
||||
@@ -365,10 +373,10 @@ int PhoneAPI::onNotify(uint32_t newValue)
|
||||
// from idle)
|
||||
|
||||
if (state == STATE_SEND_PACKETS) {
|
||||
DEBUG_MSG("Telling client we have new packets %u\n", newValue);
|
||||
LOG_INFO("Telling client we have new packets %u\n", newValue);
|
||||
onNowHasData(newValue);
|
||||
} else
|
||||
DEBUG_MSG("(Client not yet interested in packets)\n");
|
||||
LOG_DEBUG("(Client not yet interested in packets)\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
||||
|
||||
p->decoded.payload.size =
|
||||
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), fields, &payload);
|
||||
// DEBUG_MSG("did encode\n");
|
||||
// LOG_DEBUG("did encode\n");
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
||||
// it would be better to update even if the message was destined to others.
|
||||
|
||||
auto &p = mp.decoded;
|
||||
DEBUG_MSG("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d\n", name, mp.from, mp.id, p.portnum,
|
||||
LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d\n", name, mp.from, mp.id, p.portnum,
|
||||
p.payload.size);
|
||||
|
||||
T scratch;
|
||||
@@ -80,7 +80,7 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
||||
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
|
||||
decoded = &scratch;
|
||||
} else {
|
||||
DEBUG_MSG("Error decoding protobuf module!\n");
|
||||
LOG_ERROR("Error decoding protobuf module!\n");
|
||||
// if we can't decode it, nobody can process it!
|
||||
return ProcessMessage::STOP;
|
||||
}
|
||||
|
||||
@@ -68,17 +68,17 @@ bool RF95Interface::init()
|
||||
setTransmitEnable(false);
|
||||
|
||||
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, currentLimit, preambleLength);
|
||||
DEBUG_MSG("RF95 init result %d\n", res);
|
||||
LOG_INFO("RF95 init result %d\n", res);
|
||||
|
||||
DEBUG_MSG("Frequency set to %f\n", getFreq());
|
||||
DEBUG_MSG("Bandwidth set to %f\n", bw);
|
||||
DEBUG_MSG("Power output set to %d\n", power);
|
||||
LOG_INFO("Frequency set to %f\n", getFreq());
|
||||
LOG_INFO("Bandwidth set to %f\n", bw);
|
||||
LOG_INFO("Power output set to %d\n", power);
|
||||
|
||||
// current limit was removed from module' ctor
|
||||
// override default value (60 mA)
|
||||
res = lora->setCurrentLimit(currentLimit);
|
||||
DEBUG_MSG("Current limit set to %f\n", currentLimit);
|
||||
DEBUG_MSG("Current limit set result %d\n", res);
|
||||
LOG_DEBUG("Current limit set to %f\n", currentLimit);
|
||||
LOG_DEBUG("Current limit set result %d\n", res);
|
||||
|
||||
if (res == RADIOLIB_ERR_NONE)
|
||||
res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON);
|
||||
@@ -190,12 +190,12 @@ bool RF95Interface::isChannelActive()
|
||||
result = lora->scanChannel();
|
||||
|
||||
if (result == RADIOLIB_PREAMBLE_DETECTED) {
|
||||
// DEBUG_MSG("Channel is busy!\n");
|
||||
// LOG_DEBUG("Channel is busy!\n");
|
||||
return true;
|
||||
}
|
||||
assert(result != RADIOLIB_ERR_WRONG_MODEM);
|
||||
|
||||
// DEBUG_MSG("Channel is free!\n");
|
||||
// LOG_DEBUG("Channel is free!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ void initRegion()
|
||||
for (; r->code != Config_LoRaConfig_RegionCode_UNSET && r->code != config.lora.region; r++)
|
||||
;
|
||||
myRegion = r;
|
||||
DEBUG_MSG("Wanted region %d, using %s\n", config.lora.region, r->name);
|
||||
LOG_INFO("Wanted region %d, using %s\n", config.lora.region, r->name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ uint32_t RadioInterface::getPacketTime(uint32_t pl)
|
||||
|
||||
uint32_t msecs = tPacket * 1000;
|
||||
|
||||
DEBUG_MSG("(bw=%d, sf=%d, cr=4/%d) packet symLen=%d ms, payloadSize=%u, time %d ms\n", (int)bw, sf, cr, (int)(tSym * 1000),
|
||||
LOG_DEBUG("(bw=%d, sf=%d, cr=4/%d) packet symLen=%d ms, payloadSize=%u, time %d ms\n", (int)bw, sf, cr, (int)(tSym * 1000),
|
||||
pl, msecs);
|
||||
return msecs;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p)
|
||||
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &Data_msg, &p->decoded);
|
||||
uint32_t packetAirtime = getPacketTime(numbytes + sizeof(PacketHeader));
|
||||
// Make sure enough time has elapsed for this packet to be sent and an ACK is received.
|
||||
// DEBUG_MSG("Waiting for flooding message with airtime %d and slotTime is %d\n", packetAirtime, slotTimeMsec);
|
||||
// LOG_DEBUG("Waiting for flooding message with airtime %d and slotTime is %d\n", packetAirtime, slotTimeMsec);
|
||||
float channelUtil = airTime->channelUtilizationPercent();
|
||||
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
|
||||
// Assuming we pick max. of CWsize and there will be a receiver with SNR at half the range
|
||||
@@ -193,7 +193,7 @@ uint32_t RadioInterface::getTxDelayMsec()
|
||||
current channel utilization. */
|
||||
float channelUtil = airTime->channelUtilizationPercent();
|
||||
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
|
||||
// DEBUG_MSG("Current channel utilization is %f so setting CWsize to %d\n", channelUtil, CWsize);
|
||||
// LOG_DEBUG("Current channel utilization is %f so setting CWsize to %d\n", channelUtil, CWsize);
|
||||
return random(0, pow(2, CWsize)) * slotTimeMsec;
|
||||
}
|
||||
|
||||
@@ -210,14 +210,14 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||
// low SNR = small CW size (Short Delay)
|
||||
uint32_t delay = 0;
|
||||
uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
|
||||
// DEBUG_MSG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
|
||||
// LOG_DEBUG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
|
||||
if (config.device.role == Config_DeviceConfig_Role_ROUTER ||
|
||||
config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT) {
|
||||
delay = random(0, 2*CWsize) * slotTimeMsec;
|
||||
DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
|
||||
LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
|
||||
} else {
|
||||
delay = random(0, pow(2, CWsize)) * slotTimeMsec;
|
||||
DEBUG_MSG("rx_snr found in packet. Setting tx delay:%d\n", delay);
|
||||
LOG_DEBUG("rx_snr found in packet. Setting tx delay:%d\n", delay);
|
||||
}
|
||||
|
||||
return delay;
|
||||
@@ -225,47 +225,47 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||
|
||||
void printPacket(const char *prefix, const MeshPacket *p)
|
||||
{
|
||||
DEBUG_MSG("%s (id=0x%08x fr=0x%02x to=0x%02x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff,
|
||||
LOG_DEBUG("%s (id=0x%08x fr=0x%02x to=0x%02x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff,
|
||||
p->want_ack, p->hop_limit, p->channel);
|
||||
if (p->which_payload_variant == MeshPacket_decoded_tag) {
|
||||
auto &s = p->decoded;
|
||||
|
||||
DEBUG_MSG(" Portnum=%d", s.portnum);
|
||||
LOG_DEBUG(" Portnum=%d", s.portnum);
|
||||
|
||||
if (s.want_response)
|
||||
DEBUG_MSG(" WANTRESP");
|
||||
LOG_DEBUG(" WANTRESP");
|
||||
|
||||
if (s.source != 0)
|
||||
DEBUG_MSG(" source=%08x", s.source);
|
||||
LOG_DEBUG(" source=%08x", s.source);
|
||||
|
||||
if (s.dest != 0)
|
||||
DEBUG_MSG(" dest=%08x", s.dest);
|
||||
LOG_DEBUG(" dest=%08x", s.dest);
|
||||
|
||||
if (s.request_id)
|
||||
DEBUG_MSG(" requestId=%0x", s.request_id);
|
||||
LOG_DEBUG(" requestId=%0x", s.request_id);
|
||||
|
||||
/* now inside Data and therefore kinda opaque
|
||||
if (s.which_ackVariant == SubPacket_success_id_tag)
|
||||
DEBUG_MSG(" successId=%08x", s.ackVariant.success_id);
|
||||
LOG_DEBUG(" successId=%08x", s.ackVariant.success_id);
|
||||
else if (s.which_ackVariant == SubPacket_fail_id_tag)
|
||||
DEBUG_MSG(" failId=%08x", s.ackVariant.fail_id); */
|
||||
LOG_DEBUG(" failId=%08x", s.ackVariant.fail_id); */
|
||||
} else {
|
||||
DEBUG_MSG(" encrypted");
|
||||
LOG_DEBUG(" encrypted");
|
||||
}
|
||||
|
||||
if (p->rx_time != 0) {
|
||||
DEBUG_MSG(" rxtime=%u", p->rx_time);
|
||||
LOG_DEBUG(" rxtime=%u", p->rx_time);
|
||||
}
|
||||
if (p->rx_snr != 0.0) {
|
||||
DEBUG_MSG(" rxSNR=%g", p->rx_snr);
|
||||
LOG_DEBUG(" rxSNR=%g", p->rx_snr);
|
||||
}
|
||||
if (p->rx_rssi != 0) {
|
||||
DEBUG_MSG(" rxRSSI=%g", p->rx_rssi);
|
||||
LOG_DEBUG(" rxRSSI=%g", p->rx_rssi);
|
||||
}
|
||||
if (p->priority != 0)
|
||||
DEBUG_MSG(" priority=%d", p->priority);
|
||||
LOG_DEBUG(" priority=%d", p->priority);
|
||||
|
||||
DEBUG_MSG(")\n");
|
||||
LOG_DEBUG(")\n");
|
||||
}
|
||||
|
||||
RadioInterface::RadioInterface()
|
||||
@@ -273,7 +273,7 @@ RadioInterface::RadioInterface()
|
||||
assert(sizeof(PacketHeader) == 16); // make sure the compiler did what we expected
|
||||
|
||||
// Can't print strings this early - serial not setup yet
|
||||
// DEBUG_MSG("Set meshradio defaults name=%s\n", channelSettings.name);
|
||||
// LOG_DEBUG("Set meshradio defaults name=%s\n", channelSettings.name);
|
||||
}
|
||||
|
||||
bool RadioInterface::reconfigure()
|
||||
@@ -284,7 +284,7 @@ bool RadioInterface::reconfigure()
|
||||
|
||||
bool RadioInterface::init()
|
||||
{
|
||||
DEBUG_MSG("Starting meshradio init...\n");
|
||||
LOG_INFO("Starting meshradio init...\n");
|
||||
|
||||
configChangedObserver.observe(&service.configChanged);
|
||||
preflightSleepObserver.observe(&preflightSleep);
|
||||
@@ -449,13 +449,13 @@ void RadioInterface::applyModemConfig()
|
||||
saveChannelNum(channel_num);
|
||||
saveFreq(freq + config.lora.frequency_offset);
|
||||
|
||||
DEBUG_MSG("Radio freq=%.3f, config.lora.frequency_offset=%.3f\n", freq, config.lora.frequency_offset);
|
||||
DEBUG_MSG("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset, channel_num, power);
|
||||
DEBUG_MSG("Radio myRegion->freqStart -> myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart);
|
||||
DEBUG_MSG("Radio myRegion->numChannels: %d x %.3fkHz\n", numChannels, bw);
|
||||
DEBUG_MSG("Radio channel_num: %d\n", channel_num);
|
||||
DEBUG_MSG("Radio frequency: %f\n", getFreq());
|
||||
DEBUG_MSG("Slot time: %u msec\n", slotTimeMsec);
|
||||
LOG_INFO("Radio freq=%.3f, config.lora.frequency_offset=%.3f\n", freq, config.lora.frequency_offset);
|
||||
LOG_INFO("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset, channel_num, power);
|
||||
LOG_INFO("Radio myRegion->freqStart -> myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart);
|
||||
LOG_INFO("Radio myRegion->numChannels: %d x %.3fkHz\n", numChannels, bw);
|
||||
LOG_INFO("Radio channel_num: %d\n", channel_num);
|
||||
LOG_INFO("Radio frequency: %f\n", getFreq());
|
||||
LOG_INFO("Slot time: %u msec\n", slotTimeMsec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,11 +470,11 @@ void RadioInterface::limitPower()
|
||||
maxPower = myRegion->powerLimit;
|
||||
|
||||
if ((power > maxPower) && !devicestate.owner.is_licensed) {
|
||||
DEBUG_MSG("Lowering transmit power because of regulatory limits\n");
|
||||
LOG_INFO("Lowering transmit power because of regulatory limits\n");
|
||||
power = maxPower;
|
||||
}
|
||||
|
||||
DEBUG_MSG("Set radio: final power level=%d\n", power);
|
||||
LOG_INFO("Set radio: final power level=%d\n", power);
|
||||
}
|
||||
|
||||
|
||||
@@ -491,7 +491,7 @@ size_t RadioInterface::beginSending(MeshPacket *p)
|
||||
{
|
||||
assert(!sendingPacket);
|
||||
|
||||
// DEBUG_MSG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
|
||||
// LOG_DEBUG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
|
||||
assert(p->which_payload_variant == MeshPacket_encrypted_tag); // It should have already been encoded by now
|
||||
|
||||
lastTxStart = millis();
|
||||
|
||||
@@ -82,17 +82,17 @@ bool RadioLibInterface::canSendImmediately()
|
||||
|
||||
if (busyTx || busyRx) {
|
||||
if (busyTx)
|
||||
DEBUG_MSG("Can not send yet, busyTx\n");
|
||||
LOG_WARN("Can not send yet, busyTx\n");
|
||||
// If we've been trying to send the same packet more than one minute and we haven't gotten a
|
||||
// TX IRQ from the radio, the radio is probably broken.
|
||||
if (busyTx && (millis() - lastTxStart > 60000)) {
|
||||
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
|
||||
LOG_ERROR("Hardware Failure! busyTx for more than 60s\n");
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_TRANSMIT_FAILED);
|
||||
// reboot in 5 seconds when this condition occurs.
|
||||
rebootAtMsec = lastTxStart + 65000;
|
||||
}
|
||||
if (busyRx)
|
||||
DEBUG_MSG("Can not send yet, busyRx\n");
|
||||
LOG_WARN("Can not send yet, busyRx\n");
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
@@ -111,13 +111,13 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
|
||||
if (config.lora.region != Config_LoRaConfig_RegionCode_UNSET) {
|
||||
if (disabled || !config.lora.tx_enabled) {
|
||||
DEBUG_MSG("send - !config.lora.tx_enabled\n");
|
||||
LOG_WARN("send - !config.lora.tx_enabled\n");
|
||||
packetPool.release(p);
|
||||
return ERRNO_DISABLED;
|
||||
}
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("send - lora tx disable because RegionCode_Unset\n");
|
||||
LOG_WARN("send - lora tx disable because RegionCode_Unset\n");
|
||||
packetPool.release(p);
|
||||
return ERRNO_DISABLED;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
#else
|
||||
|
||||
if (disabled || !config.lora.tx_enabled) {
|
||||
DEBUG_MSG("send - !config.lora.tx_enabled\n");
|
||||
LOG_WARN("send - !config.lora.tx_enabled\n");
|
||||
packetPool.release(p);
|
||||
return ERRNO_DISABLED;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
#ifndef LORA_DISABLE_SENDING
|
||||
printPacket("enqueuing for send", p);
|
||||
|
||||
DEBUG_MSG("txGood=%d,rxGood=%d,rxBad=%d\n", txGood, rxGood, rxBad);
|
||||
LOG_DEBUG("txGood=%d,rxGood=%d,rxBad=%d\n", txGood, rxGood, rxBad);
|
||||
ErrorCode res = txQueue.enqueue(p) ? ERRNO_OK : ERRNO_UNKNOWN;
|
||||
|
||||
if (res != ERRNO_OK) { // we weren't able to queue it, so we must drop it to prevent leaks
|
||||
@@ -148,7 +148,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
|
||||
// set (random) transmit delay to let others reconfigure their radio,
|
||||
// to avoid collisions and implement timing-based flooding
|
||||
// DEBUG_MSG("Set random delay before transmitting.\n");
|
||||
// LOG_DEBUG("Set random delay before transmitting.\n");
|
||||
setTransmitDelay();
|
||||
|
||||
return res;
|
||||
@@ -162,7 +162,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
{
|
||||
bool res = txQueue.empty();
|
||||
if (!res) // only print debug messages if we are vetoing sleep
|
||||
DEBUG_MSG("radio wait to sleep, txEmpty=%d\n", res);
|
||||
LOG_DEBUG("radio wait to sleep, txEmpty=%d\n", res);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
packetPool.release(p); // free the packet we just removed
|
||||
|
||||
bool result = (p != NULL);
|
||||
DEBUG_MSG("cancelSending id=0x%x, removed=%d\n", id, result);
|
||||
LOG_DEBUG("cancelSending id=0x%x, removed=%d\n", id, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -192,27 +192,27 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
case ISR_TX:
|
||||
handleTransmitInterrupt();
|
||||
startReceive();
|
||||
// DEBUG_MSG("tx complete - starting timer\n");
|
||||
// LOG_DEBUG("tx complete - starting timer\n");
|
||||
startTransmitTimer();
|
||||
break;
|
||||
case ISR_RX:
|
||||
handleReceiveInterrupt();
|
||||
startReceive();
|
||||
// DEBUG_MSG("rx complete - starting timer\n");
|
||||
// LOG_DEBUG("rx complete - starting timer\n");
|
||||
startTransmitTimer();
|
||||
break;
|
||||
case TRANSMIT_DELAY_COMPLETED:
|
||||
// DEBUG_MSG("delay done\n");
|
||||
// LOG_DEBUG("delay done\n");
|
||||
|
||||
// If we are not currently in receive mode, then restart the random delay (this can happen if the main thread
|
||||
// has placed the unit into standby) FIXME, how will this work if the chipset is in sleep mode?
|
||||
if (!txQueue.empty()) {
|
||||
if (!canSendImmediately()) {
|
||||
// DEBUG_MSG("Currently Rx/Tx-ing: set random delay\n");
|
||||
// LOG_DEBUG("Currently Rx/Tx-ing: set random delay\n");
|
||||
setTransmitDelay(); // currently Rx/Tx-ing: reset random delay
|
||||
} else {
|
||||
if (isChannelActive()) { // check if there is currently a LoRa packet on the channel
|
||||
// DEBUG_MSG("Channel is active: set random delay\n");
|
||||
// LOG_DEBUG("Channel is active: set random delay\n");
|
||||
setTransmitDelay(); // reset random delay
|
||||
} else {
|
||||
// Send any outgoing packets we have ready
|
||||
@@ -226,7 +226,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// DEBUG_MSG("done with txqueue\n");
|
||||
// LOG_DEBUG("done with txqueue\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -249,7 +249,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
startTransmitTimer(true);
|
||||
} else {
|
||||
// If there is a SNR, start a timer scaled based on that SNR.
|
||||
DEBUG_MSG("rx_snr found. hop_limit:%d rx_snr:%f\n", p->hop_limit, p->rx_snr);
|
||||
LOG_DEBUG("rx_snr found. hop_limit:%d rx_snr:%f\n", p->hop_limit, p->rx_snr);
|
||||
startTransmitTimerSNR(p->rx_snr);
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
// If we have work to do and the timer wasn't already scheduled, schedule it now
|
||||
if (!txQueue.empty()) {
|
||||
uint32_t delay = !withDelay ? 1 : getTxDelayMsec();
|
||||
// DEBUG_MSG("xmit timer %d\n", delay);
|
||||
// LOG_DEBUG("xmit timer %d\n", delay);
|
||||
notifyLater(delay, TRANSMIT_DELAY_COMPLETED, false); // This will implicitly enable
|
||||
}
|
||||
}
|
||||
@@ -269,14 +269,14 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
// If we have work to do and the timer wasn't already scheduled, schedule it now
|
||||
if (!txQueue.empty()) {
|
||||
uint32_t delay = getTxDelayMsecWeighted(snr);
|
||||
// DEBUG_MSG("xmit timer %d\n", delay);
|
||||
// LOG_DEBUG("xmit timer %d\n", delay);
|
||||
notifyLater(delay, TRANSMIT_DELAY_COMPLETED, false); // This will implicitly enable
|
||||
}
|
||||
}
|
||||
|
||||
void RadioLibInterface::handleTransmitInterrupt()
|
||||
{
|
||||
// DEBUG_MSG("handling lora TX interrupt\n");
|
||||
// LOG_DEBUG("handling lora TX interrupt\n");
|
||||
// This can be null if we forced the device to enter standby mode. In that case
|
||||
// ignore the transmit interrupt
|
||||
if (sendingPacket)
|
||||
@@ -296,7 +296,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
|
||||
// We are done sending that packet, release it
|
||||
packetPool.release(p);
|
||||
// DEBUG_MSG("Done with send\n");
|
||||
// LOG_DEBUG("Done with send\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
|
||||
// when this is called, we should be in receive mode - if we are not, just jump out instead of bombing. Possible Race Condition?
|
||||
if (!isReceiving) {
|
||||
DEBUG_MSG("*** WAS_ASSERT *** handleReceiveInterrupt called when not in receive mode\n");
|
||||
LOG_DEBUG("*** WAS_ASSERT *** handleReceiveInterrupt called when not in receive mode\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
|
||||
int state = iface->readData(radiobuf, length);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
DEBUG_MSG("ignoring received packet due to error=%d\n", state);
|
||||
LOG_ERROR("ignoring received packet due to error=%d\n", state);
|
||||
rxBad++;
|
||||
|
||||
airTime->logAirtime(RX_ALL_LOG, xmitMsec);
|
||||
@@ -331,7 +331,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
|
||||
// check for short packets
|
||||
if (payloadLen < 0) {
|
||||
DEBUG_MSG("ignoring received packet too short\n");
|
||||
LOG_WARN("ignoring received packet too short\n");
|
||||
rxBad++;
|
||||
airTime->logAirtime(RX_ALL_LOG, xmitMsec);
|
||||
} else {
|
||||
@@ -374,7 +374,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
{
|
||||
printPacket("Starting low level send", txp);
|
||||
if (disabled || !config.lora.tx_enabled) {
|
||||
DEBUG_MSG("startSend is dropping tx packet because we are disabled\n");
|
||||
LOG_WARN("startSend is dropping tx packet because we are disabled\n");
|
||||
packetPool.release(txp);
|
||||
} else {
|
||||
setStandby(); // Cancel any already in process receives
|
||||
@@ -385,7 +385,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
|
||||
int res = iface->startTransmit(radiobuf, numbytes);
|
||||
if (res != RADIOLIB_ERR_NONE) {
|
||||
DEBUG_MSG("startTransmit failed, error=%d\n", res);
|
||||
LOG_ERROR("startTransmit failed, error=%d\n", res);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_RADIO_SPI_BUG);
|
||||
|
||||
// This send failed, but make sure to 'complete' it properly
|
||||
|
||||
@@ -22,8 +22,8 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_
|
||||
// current limit was removed from module' ctor
|
||||
// override default value (60 mA)
|
||||
state = setCurrentLimit(currentLimit);
|
||||
DEBUG_MSG("Current limit set to %f\n", currentLimit);
|
||||
DEBUG_MSG("Current limit set result %d\n", state);
|
||||
LOG_DEBUG("Current limit set to %f\n", currentLimit);
|
||||
LOG_DEBUG("Current limit set result %d\n", state);
|
||||
|
||||
// configure settings not accessible by API
|
||||
state = config();
|
||||
|
||||
@@ -42,14 +42,14 @@ bool ReliableRouter::shouldFilterReceived(const MeshPacket *p)
|
||||
auto key = GlobalPacketId(getFrom(p), p->id);
|
||||
auto old = findPendingPacket(key);
|
||||
if (old) {
|
||||
DEBUG_MSG("generating implicit ack\n");
|
||||
LOG_DEBUG("generating implicit ack\n");
|
||||
// NOTE: we do NOT check p->wantAck here because p is the INCOMING rebroadcast and that packet is not expected to be
|
||||
// marked as wantAck
|
||||
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, old->packet->channel);
|
||||
|
||||
stopRetransmission(key);
|
||||
} else {
|
||||
DEBUG_MSG("didn't find pending packet\n");
|
||||
LOG_DEBUG("didn't find pending packet\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ bool ReliableRouter::shouldFilterReceived(const MeshPacket *p)
|
||||
* flooding this ACK back to the original sender already adds redundancy. */
|
||||
if (wasSeenRecently(p, false) && p->hop_limit == HOP_RELIABLE && !MeshModule::currentReply && p->to != nodeDB.getNodeNum()) {
|
||||
// retransmission on broadcast has hop_limit still equal to HOP_RELIABLE
|
||||
DEBUG_MSG("Resending implicit ack for a repeated floodmsg\n");
|
||||
LOG_DEBUG("Resending implicit ack for a repeated floodmsg\n");
|
||||
MeshPacket *tosend = packetPool.allocCopy(*p);
|
||||
tosend->hop_limit--; // bump down the hop count
|
||||
Router::send(tosend);
|
||||
@@ -87,7 +87,7 @@ void ReliableRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||
if (p->to == ourNode) { // ignore ack/nak/want_ack packets that are not address to us (we only handle 0 hop reliability)
|
||||
if (p->want_ack) {
|
||||
if (MeshModule::currentReply)
|
||||
DEBUG_MSG("Some other module has replied to this message, no need for a 2nd ack\n");
|
||||
LOG_DEBUG("Some other module has replied to this message, no need for a 2nd ack\n");
|
||||
else
|
||||
if (p->which_payload_variant == MeshPacket_decoded_tag)
|
||||
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
|
||||
@@ -105,10 +105,10 @@ void ReliableRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||
// We intentionally don't check wasSeenRecently, because it is harmless to delete non existent retransmission records
|
||||
if (ackId || nakId) {
|
||||
if (ackId) {
|
||||
DEBUG_MSG("Received an ack for 0x%x, stopping retransmissions\n", ackId);
|
||||
LOG_DEBUG("Received an ack for 0x%x, stopping retransmissions\n", ackId);
|
||||
stopRetransmission(p->to, ackId);
|
||||
} else {
|
||||
DEBUG_MSG("Received a nak for 0x%x, stopping retransmissions\n", nakId);
|
||||
LOG_DEBUG("Received a nak for 0x%x, stopping retransmissions\n", nakId);
|
||||
stopRetransmission(p->to, nakId);
|
||||
}
|
||||
}
|
||||
@@ -190,14 +190,14 @@ int32_t ReliableRouter::doRetransmissions()
|
||||
// FIXME, handle 51 day rolloever here!!!
|
||||
if (p.nextTxMsec <= now) {
|
||||
if (p.numRetransmissions == 0) {
|
||||
DEBUG_MSG("Reliable send failed, returning a nak for fr=0x%x,to=0x%x,id=0x%x\n", p.packet->from, p.packet->to,
|
||||
LOG_DEBUG("Reliable send failed, returning a nak for fr=0x%x,to=0x%x,id=0x%x\n", p.packet->from, p.packet->to,
|
||||
p.packet->id);
|
||||
sendAckNak(Routing_Error_MAX_RETRANSMIT, getFrom(p.packet), p.packet->id, p.packet->channel);
|
||||
// Note: we don't stop retransmission here, instead the Nak packet gets processed in sniffReceived
|
||||
stopRetransmission(it->first);
|
||||
stillValid = false; // just deleted it
|
||||
} else {
|
||||
DEBUG_MSG("Sending reliable retransmission fr=0x%x,to=0x%x,id=0x%x, tries left=%d\n", p.packet->from,
|
||||
LOG_DEBUG("Sending reliable retransmission fr=0x%x,to=0x%x,id=0x%x, tries left=%d\n", p.packet->from,
|
||||
p.packet->to, p.packet->id, p.numRetransmissions);
|
||||
|
||||
// Note: we call the superclass version because we don't want to have our version of send() add a new
|
||||
@@ -226,7 +226,7 @@ void ReliableRouter::setNextTx(PendingPacket *pending)
|
||||
assert(iface);
|
||||
auto d = iface->getRetransmissionMsec(pending->packet);
|
||||
pending->nextTxMsec = millis() + d;
|
||||
DEBUG_MSG("Setting next retransmission in %u msecs: ", d);
|
||||
LOG_DEBUG("Setting next retransmission in %u msecs: ", d);
|
||||
printPacket("", pending->packet);
|
||||
setReceivedMessage(); // Run ASAP, so we can figure out our correct sleep time
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ Router::Router() : concurrency::OSThread("Router"), fromRadioQueue(MAX_RX_FROMRA
|
||||
{
|
||||
// This is called pre main(), don't touch anything here, the following code is not safe
|
||||
|
||||
/* DEBUG_MSG("Size of NodeInfo %d\n", sizeof(NodeInfo));
|
||||
DEBUG_MSG("Size of SubPacket %d\n", sizeof(SubPacket));
|
||||
DEBUG_MSG("Size of MeshPacket %d\n", sizeof(MeshPacket)); */
|
||||
/* LOG_DEBUG("Size of NodeInfo %d\n", sizeof(NodeInfo));
|
||||
LOG_DEBUG("Size of SubPacket %d\n", sizeof(SubPacket));
|
||||
LOG_DEBUG("Size of MeshPacket %d\n", sizeof(MeshPacket)); */
|
||||
|
||||
fromRadioQueue.setReader(this);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ int32_t Router::runOnce()
|
||||
perhapsHandleReceived(mp);
|
||||
}
|
||||
|
||||
// DEBUG_MSG("sleeping forever!\n");
|
||||
// LOG_DEBUG("sleeping forever!\n");
|
||||
return INT32_MAX; // Wait a long time - until we get woken for the message queue
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ PacketId generatePacketId()
|
||||
// pick a random initial sequence number at boot (to prevent repeated reboots always starting at 0)
|
||||
// Note: we mask the high order bit to ensure that we never pass a 'negative' number to random
|
||||
i = random(numPacketId & 0x7fffffff);
|
||||
DEBUG_MSG("Initial packet id %u, numPacketId %u\n", i, numPacketId);
|
||||
LOG_DEBUG("Initial packet id %u, numPacketId %u\n", i, numPacketId);
|
||||
}
|
||||
|
||||
i++;
|
||||
@@ -136,14 +136,14 @@ void Router::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelI
|
||||
|
||||
void Router::abortSendAndNak(Routing_Error err, MeshPacket *p)
|
||||
{
|
||||
DEBUG_MSG("Error=%d, returning NAK and dropping packet.\n", err);
|
||||
LOG_ERROR("Error=%d, returning NAK and dropping packet.\n", err);
|
||||
sendAckNak(Routing_Error_NO_INTERFACE, getFrom(p), p->id, p->channel);
|
||||
packetPool.release(p);
|
||||
}
|
||||
|
||||
void Router::setReceivedMessage()
|
||||
{
|
||||
// DEBUG_MSG("set interval to ASAP\n");
|
||||
// LOG_DEBUG("set interval to ASAP\n");
|
||||
setInterval(0); // Run ASAP, so we can figure out our correct sleep time
|
||||
runASAP = true;
|
||||
}
|
||||
@@ -173,10 +173,10 @@ ErrorCode Router::sendLocal(MeshPacket *p, RxSource src)
|
||||
|
||||
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
|
||||
{
|
||||
DEBUG_MSG("%s: ", label);
|
||||
LOG_DEBUG("%s: ", label);
|
||||
for (size_t i = 0; i < numbytes; i++)
|
||||
DEBUG_MSG("%02x ", p[i]);
|
||||
DEBUG_MSG("\n");
|
||||
LOG_DEBUG("%02x ", p[i]);
|
||||
LOG_DEBUG("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +193,7 @@ ErrorCode Router::send(MeshPacket *p)
|
||||
float hourlyTxPercent = airTime->utilizationTXPercent();
|
||||
if (hourlyTxPercent > myRegion->dutyCycle) {
|
||||
uint8_t silentMinutes = airTime->getSilentMinutes(hourlyTxPercent, myRegion->dutyCycle);
|
||||
DEBUG_MSG("WARNING: Duty cycle limit exceeded. Aborting send for now, you can send again in %d minutes.\n", silentMinutes);
|
||||
LOG_WARN("Duty cycle limit exceeded. Aborting send for now, you can send again in %d minutes.\n", silentMinutes);
|
||||
Routing_Error err = Routing_Error_DUTY_CYCLE_LIMIT;
|
||||
abortSendAndNak(err, p);
|
||||
return err;
|
||||
@@ -241,7 +241,7 @@ ErrorCode Router::send(MeshPacket *p)
|
||||
shouldActuallyEncrypt = false;
|
||||
}
|
||||
|
||||
DEBUG_MSG("Should encrypt MQTT?: %d\n", shouldActuallyEncrypt);
|
||||
LOG_INFO("Should encrypt MQTT?: %d\n", shouldActuallyEncrypt);
|
||||
|
||||
// the packet is currently in a decrypted state. send it now if they want decrypted packets
|
||||
if (mqtt && !shouldActuallyEncrypt)
|
||||
@@ -281,14 +281,14 @@ bool Router::cancelSending(NodeNum from, PacketId id)
|
||||
*/
|
||||
void Router::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||
{
|
||||
DEBUG_MSG("FIXME-update-db Sniffing packet\n");
|
||||
LOG_DEBUG("FIXME-update-db Sniffing packet\n");
|
||||
// FIXME, update nodedb here for any packet that passes through us
|
||||
}
|
||||
|
||||
bool perhapsDecode(MeshPacket *p)
|
||||
{
|
||||
|
||||
// DEBUG_MSG("\n\n** perhapsDecode payloadVariant - %d\n\n", p->which_payloadVariant);
|
||||
// LOG_DEBUG("\n\n** perhapsDecode payloadVariant - %d\n\n", p->which_payloadVariant);
|
||||
|
||||
if (p->which_payload_variant == MeshPacket_decoded_tag)
|
||||
return true; // If packet was already decoded just return
|
||||
@@ -312,9 +312,9 @@ bool perhapsDecode(MeshPacket *p)
|
||||
// Take those raw bytes and convert them back into a well structured protobuf we can understand
|
||||
memset(&p->decoded, 0, sizeof(p->decoded));
|
||||
if (!pb_decode_from_bytes(bytes, rawSize, &Data_msg, &p->decoded)) {
|
||||
DEBUG_MSG("Invalid protobufs in received mesh packet (bad psk?)!\n");
|
||||
LOG_ERROR("Invalid protobufs in received mesh packet (bad psk?)!\n");
|
||||
} else if (p->decoded.portnum == PortNum_UNKNOWN_APP) {
|
||||
DEBUG_MSG("Invalid portnum (bad psk?)!\n");
|
||||
LOG_ERROR("Invalid portnum (bad psk?)!\n");
|
||||
} else {
|
||||
// parsing was successful
|
||||
p->which_payload_variant = MeshPacket_decoded_tag; // change type to decoded
|
||||
@@ -322,9 +322,9 @@ bool perhapsDecode(MeshPacket *p)
|
||||
|
||||
/*
|
||||
if (p->decoded.portnum == PortNum_TEXT_MESSAGE_APP) {
|
||||
DEBUG_MSG("\n\n** TEXT_MESSAGE_APP\n");
|
||||
LOG_DEBUG("\n\n** TEXT_MESSAGE_APP\n");
|
||||
} else if (p->decoded.portnum == PortNum_TEXT_MESSAGE_COMPRESSED_APP) {
|
||||
DEBUG_MSG("\n\n** PortNum_TEXT_MESSAGE_COMPRESSED_APP\n");
|
||||
LOG_DEBUG("\n\n** PortNum_TEXT_MESSAGE_COMPRESSED_APP\n");
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -339,7 +339,7 @@ bool perhapsDecode(MeshPacket *p)
|
||||
|
||||
decompressed_len = unishox2_decompress_simple(compressed_in, p->decoded.payload.size, decompressed_out);
|
||||
|
||||
// DEBUG_MSG("\n\n**\n\nDecompressed length - %d \n", decompressed_len);
|
||||
// LOG_DEBUG("\n\n**\n\nDecompressed length - %d \n", decompressed_len);
|
||||
|
||||
memcpy(p->decoded.payload.bytes, decompressed_out, decompressed_len);
|
||||
|
||||
@@ -353,7 +353,7 @@ bool perhapsDecode(MeshPacket *p)
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_MSG("No suitable channel found for decoding, hash was 0x%x!\n", p->channel);
|
||||
LOG_WARN("No suitable channel found for decoding, hash was 0x%x!\n", p->channel);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -379,20 +379,20 @@ Routing_Error perhapsEncode(MeshPacket *p)
|
||||
int compressed_len;
|
||||
compressed_len = unishox2_compress_simple(original_payload, p->decoded.payload.size, compressed_out);
|
||||
|
||||
DEBUG_MSG("Original length - %d \n", p->decoded.payload.size);
|
||||
DEBUG_MSG("Compressed length - %d \n", compressed_len);
|
||||
DEBUG_MSG("Original message - %s \n", p->decoded.payload.bytes);
|
||||
LOG_DEBUG("Original length - %d \n", p->decoded.payload.size);
|
||||
LOG_DEBUG("Compressed length - %d \n", compressed_len);
|
||||
LOG_DEBUG("Original message - %s \n", p->decoded.payload.bytes);
|
||||
|
||||
// If the compressed length is greater than or equal to the original size, don't use the compressed form
|
||||
if (compressed_len >= p->decoded.payload.size) {
|
||||
|
||||
DEBUG_MSG("Not using compressing message.\n");
|
||||
LOG_DEBUG("Not using compressing message.\n");
|
||||
// Set the uncompressed payload varient anyway. Shouldn't hurt?
|
||||
// p->decoded.which_payloadVariant = Data_payload_tag;
|
||||
|
||||
// Otherwise we use the compressor
|
||||
} else {
|
||||
DEBUG_MSG("Using compressed message.\n");
|
||||
LOG_DEBUG("Using compressed message.\n");
|
||||
// Copy the compressed data into the meshpacket
|
||||
|
||||
p->decoded.payload.size = compressed_len;
|
||||
@@ -464,9 +464,9 @@ void Router::perhapsHandleReceived(MeshPacket *p)
|
||||
bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from);
|
||||
|
||||
if (ignore)
|
||||
DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
|
||||
LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
|
||||
else if (ignore |= shouldFilterReceived(p)) {
|
||||
DEBUG_MSG("Incoming message was filtered 0x%x\n", p->from);
|
||||
LOG_DEBUG("Incoming message was filtered 0x%x\n", p->from);
|
||||
}
|
||||
|
||||
// Note: we avoid calling shouldFilterReceived if we are supposed to ignore certain nodes - because some overrides might
|
||||
|
||||
@@ -12,7 +12,7 @@ SX126xInterface<T>::SX126xInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq,
|
||||
SPIClass &spi)
|
||||
: RadioLibInterface(cs, irq, rst, busy, spi, &lora), lora(&module)
|
||||
{
|
||||
DEBUG_MSG("SX126xInterface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy);
|
||||
LOG_WARN("SX126xInterface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy);
|
||||
}
|
||||
|
||||
/// Initialise the Driver transport hardware and software.
|
||||
@@ -55,17 +55,17 @@ bool SX126xInterface<T>::init()
|
||||
|
||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
|
||||
// \todo Display actual typename of the adapter, not just `SX126x`
|
||||
DEBUG_MSG("SX126x init result %d\n", res);
|
||||
LOG_INFO("SX126x init result %d\n", res);
|
||||
|
||||
DEBUG_MSG("Frequency set to %f\n", getFreq());
|
||||
DEBUG_MSG("Bandwidth set to %f\n", bw);
|
||||
DEBUG_MSG("Power output set to %d\n", power);
|
||||
LOG_INFO("Frequency set to %f\n", getFreq());
|
||||
LOG_INFO("Bandwidth set to %f\n", bw);
|
||||
LOG_INFO("Power output set to %d\n", power);
|
||||
|
||||
// current limit was removed from module' ctor
|
||||
// override default value (60 mA)
|
||||
res = lora.setCurrentLimit(currentLimit);
|
||||
DEBUG_MSG("Current limit set to %f\n", currentLimit);
|
||||
DEBUG_MSG("Current limit set result %d\n", res);
|
||||
LOG_DEBUG("Current limit set to %f\n", currentLimit);
|
||||
LOG_DEBUG("Current limit set result %d\n", res);
|
||||
|
||||
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
||||
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
||||
@@ -170,7 +170,7 @@ void SX126xInterface<T>::setStandby()
|
||||
int err = lora.standby();
|
||||
|
||||
if (err != RADIOLIB_ERR_NONE)
|
||||
DEBUG_MSG("SX126x standby failed with error %d\n", err);
|
||||
LOG_DEBUG("SX126x standby failed with error %d\n", err);
|
||||
|
||||
assert(err == RADIOLIB_ERR_NONE);
|
||||
|
||||
@@ -192,7 +192,7 @@ void SX126xInterface<T>::setStandby()
|
||||
template<typename T>
|
||||
void SX126xInterface<T>::addReceiveMetadata(MeshPacket *mp)
|
||||
{
|
||||
// DEBUG_MSG("PacketStatus %x\n", lora.getPacketStatus());
|
||||
// LOG_DEBUG("PacketStatus %x\n", lora.getPacketStatus());
|
||||
mp->rx_snr = lora.getSNR();
|
||||
mp->rx_rssi = lround(lora.getRSSI());
|
||||
}
|
||||
@@ -275,7 +275,7 @@ bool SX126xInterface<T>::isActivelyReceiving()
|
||||
// this is not correct - often always true - need to add an extra conditional
|
||||
// size_t bytesPending = lora.getPacketLength();
|
||||
|
||||
// if (hasPreamble) DEBUG_MSG("rx hasPreamble\n");
|
||||
// if (hasPreamble) LOG_DEBUG("rx hasPreamble\n");
|
||||
return hasPreamble;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ bool SX126xInterface<T>::sleep()
|
||||
{
|
||||
// Not keeping config is busted - next time nrf52 board boots lora sending fails tcxo related? - see datasheet
|
||||
// \todo Display actual typename of the adapter, not just `SX126x`
|
||||
DEBUG_MSG("sx126x entering sleep mode (FIXME, don't keep config)\n");
|
||||
LOG_DEBUG("sx126x entering sleep mode (FIXME, don't keep config)\n");
|
||||
setStandby(); // Stop any pending operations
|
||||
|
||||
// turn off TCXO if it was powered
|
||||
|
||||
@@ -49,10 +49,10 @@ bool SX128xInterface<T>::init()
|
||||
|
||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
|
||||
// \todo Display actual typename of the adapter, not just `SX128x`
|
||||
DEBUG_MSG("SX128x init result %d\n", res);
|
||||
LOG_INFO("SX128x init result %d\n", res);
|
||||
|
||||
if((config.lora.region != Config_LoRaConfig_RegionCode_LORA_24) && (res == RADIOLIB_ERR_INVALID_FREQUENCY)) {
|
||||
DEBUG_MSG("Warning: Radio chip only supports 2.4GHz LoRa. Adjusting Region and rebooting.\n");
|
||||
LOG_WARN("Radio chip only supports 2.4GHz LoRa. Adjusting Region and rebooting.\n");
|
||||
config.lora.region = Config_LoRaConfig_RegionCode_LORA_24;
|
||||
nodeDB.saveToDisk(SEGMENT_CONFIG);
|
||||
delay(2000);
|
||||
@@ -61,13 +61,13 @@ bool SX128xInterface<T>::init()
|
||||
#elif defined(ARCH_NRF52)
|
||||
NVIC_SystemReset();
|
||||
#else
|
||||
DEBUG_MSG("FIXME implement reboot for this platform. Skipping for now.\n");
|
||||
LOG_ERROR("FIXME implement reboot for this platform. Skipping for now.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
DEBUG_MSG("Frequency set to %f\n", getFreq());
|
||||
DEBUG_MSG("Bandwidth set to %f\n", bw);
|
||||
DEBUG_MSG("Power output set to %d\n", power);
|
||||
LOG_INFO("Frequency set to %f\n", getFreq());
|
||||
LOG_INFO("Bandwidth set to %f\n", bw);
|
||||
LOG_INFO("Power output set to %d\n", power);
|
||||
|
||||
if (res == RADIOLIB_ERR_NONE)
|
||||
res = lora.setCRC(2);
|
||||
@@ -145,7 +145,7 @@ void SX128xInterface<T>::setStandby()
|
||||
int err = lora.standby();
|
||||
|
||||
if (err != RADIOLIB_ERR_NONE)
|
||||
DEBUG_MSG("SX128x standby failed with error %d\n", err);
|
||||
LOG_ERROR("SX128x standby failed with error %d\n", err);
|
||||
|
||||
assert(err == RADIOLIB_ERR_NONE);
|
||||
|
||||
@@ -167,7 +167,7 @@ void SX128xInterface<T>::setStandby()
|
||||
template<typename T>
|
||||
void SX128xInterface<T>::addReceiveMetadata(MeshPacket *mp)
|
||||
{
|
||||
// DEBUG_MSG("PacketStatus %x\n", lora.getPacketStatus());
|
||||
// LOG_DEBUG("PacketStatus %x\n", lora.getPacketStatus());
|
||||
mp->rx_snr = lora.getSNR();
|
||||
mp->rx_rssi = lround(lora.getRSSI());
|
||||
}
|
||||
@@ -248,7 +248,7 @@ bool SX128xInterface<T>::sleep()
|
||||
{
|
||||
// Not keeping config is busted - next time nrf52 board boots lora sending fails tcxo related? - see datasheet
|
||||
// \todo Display actual typename of the adapter, not just `SX128x`
|
||||
DEBUG_MSG("SX128x entering sleep mode (FIXME, don't keep config)\n");
|
||||
LOG_DEBUG("SX128x entering sleep mode (FIXME, don't keep config)\n");
|
||||
setStandby(); // Stop any pending operations
|
||||
|
||||
// turn off TCXO if it was powered
|
||||
|
||||
@@ -95,7 +95,7 @@ void StreamAPI::writeStream()
|
||||
void StreamAPI::emitTxBuffer(size_t len)
|
||||
{
|
||||
if (len != 0) {
|
||||
// DEBUG_MSG("emit tx %d\n", len);
|
||||
// LOG_DEBUG("emit tx %d\n", len);
|
||||
txBuf[0] = START1;
|
||||
txBuf[1] = START2;
|
||||
txBuf[2] = (len >> 8) & 0xff;
|
||||
@@ -114,7 +114,7 @@ void StreamAPI::emitRebooted()
|
||||
fromRadioScratch.which_payload_variant = FromRadio_rebooted_tag;
|
||||
fromRadioScratch.rebooted = true;
|
||||
|
||||
// DEBUG_MSG("Emitting reboot packet for serial shell\n");
|
||||
// LOG_DEBUG("Emitting reboot packet for serial shell\n");
|
||||
emitTxBuffer(pb_encode_to_bytes(txBuf + HEADER_LEN, FromRadio_size, &FromRadio_msg, &fromRadioScratch));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ static int32_t reconnectETH()
|
||||
Ethernet.maintain();
|
||||
if (!ethStartupComplete) {
|
||||
// Start web server
|
||||
DEBUG_MSG("... Starting network services\n");
|
||||
LOG_INFO("... Starting network services\n");
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
DEBUG_MSG("Starting NTP time client\n");
|
||||
LOG_INFO("Starting NTP time client\n");
|
||||
timeClient.begin();
|
||||
timeClient.setUpdateInterval(60 * 60); // Update once an hour
|
||||
#endif
|
||||
@@ -51,9 +51,9 @@ static int32_t reconnectETH()
|
||||
#ifndef DISABLE_NTP
|
||||
if (isEthernetAvailable() && (ntp_renew < millis())) {
|
||||
|
||||
DEBUG_MSG("Updating NTP time from %s\n", config.network.ntp_server);
|
||||
LOG_INFO("Updating NTP time from %s\n", config.network.ntp_server);
|
||||
if (timeClient.update()) {
|
||||
DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
||||
LOG_DEBUG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = timeClient.getEpochTime();
|
||||
@@ -64,7 +64,7 @@ static int32_t reconnectETH()
|
||||
ntp_renew = millis() + 43200 * 1000; // success, refresh every 12 hours
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("NTP Update failed\n");
|
||||
LOG_ERROR("NTP Update failed\n");
|
||||
ntp_renew = millis() + 300 * 1000; // failure, retry every 5 minutes
|
||||
}
|
||||
}
|
||||
@@ -96,32 +96,32 @@ bool initEthernet()
|
||||
getMacAddr(mac); // FIXME use the BLE MAC for now...
|
||||
|
||||
if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) {
|
||||
DEBUG_MSG("starting Ethernet DHCP\n");
|
||||
LOG_INFO("starting Ethernet DHCP\n");
|
||||
status = Ethernet.begin(mac);
|
||||
} else if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC) {
|
||||
DEBUG_MSG("starting Ethernet Static\n");
|
||||
LOG_INFO("starting Ethernet Static\n");
|
||||
Ethernet.begin(mac, config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.subnet);
|
||||
} else {
|
||||
DEBUG_MSG("Ethernet Disabled\n");
|
||||
LOG_INFO("Ethernet Disabled\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status == 0) {
|
||||
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||
DEBUG_MSG("Ethernet shield was not found.\n");
|
||||
LOG_ERROR("Ethernet shield was not found.\n");
|
||||
return false;
|
||||
} else if (Ethernet.linkStatus() == LinkOFF) {
|
||||
DEBUG_MSG("Ethernet cable is not connected.\n");
|
||||
LOG_ERROR("Ethernet cable is not connected.\n");
|
||||
return false;
|
||||
} else{
|
||||
DEBUG_MSG("Unknown Ethernet error.\n");
|
||||
LOG_ERROR("Unknown Ethernet error.\n");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
DEBUG_MSG("Local IP %u.%u.%u.%u\n",Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2], Ethernet.localIP()[3]);
|
||||
DEBUG_MSG("Subnet Mask %u.%u.%u.%u\n",Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2], Ethernet.subnetMask()[3]);
|
||||
DEBUG_MSG("Gateway IP %u.%u.%u.%u\n",Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2], Ethernet.gatewayIP()[3]);
|
||||
DEBUG_MSG("DNS Server IP %u.%u.%u.%u\n",Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1], Ethernet.dnsServerIP()[2], Ethernet.dnsServerIP()[3]);
|
||||
LOG_INFO("Local IP %u.%u.%u.%u\n",Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2], Ethernet.localIP()[3]);
|
||||
LOG_INFO("Subnet Mask %u.%u.%u.%u\n",Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2], Ethernet.subnetMask()[3]);
|
||||
LOG_INFO("Gateway IP %u.%u.%u.%u\n",Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2], Ethernet.gatewayIP()[3]);
|
||||
LOG_INFO("DNS Server IP %u.%u.%u.%u\n",Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1], Ethernet.dnsServerIP()[2], Ethernet.dnsServerIP()[3]);
|
||||
}
|
||||
|
||||
ethEvent = new Periodic("ethConnect", reconnectETH);
|
||||
@@ -129,7 +129,7 @@ bool initEthernet()
|
||||
return true;
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("Not using Ethernet\n");
|
||||
LOG_INFO("Not using Ethernet\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ void initApiServer(int port)
|
||||
// Start API server on port 4403
|
||||
if (!apiPort) {
|
||||
apiPort = new ethServerPort(port);
|
||||
DEBUG_MSG("API server listening on TCP port %d\n", port);
|
||||
LOG_INFO("API server listening on TCP port %d\n", port);
|
||||
apiPort->init();
|
||||
}
|
||||
}
|
||||
|
||||
ethServerAPI::ethServerAPI(EthernetClient &_client) : StreamAPI(&client), concurrency::OSThread("ethServerAPI"), client(_client)
|
||||
{
|
||||
DEBUG_MSG("Incoming ethernet connection\n");
|
||||
LOG_INFO("Incoming ethernet connection\n");
|
||||
}
|
||||
|
||||
ethServerAPI::~ethServerAPI()
|
||||
@@ -44,7 +44,7 @@ int32_t ethServerAPI::runOnce()
|
||||
if (client.connected()) {
|
||||
return StreamAPI::runOncePart();
|
||||
} else {
|
||||
DEBUG_MSG("Client dropped connection, suspending API service\n");
|
||||
LOG_INFO("Client dropped connection, suspending API service\n");
|
||||
enabled = false; // we no longer need to run
|
||||
return 0;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ int32_t ethServerPort::runOnce()
|
||||
if (client) {
|
||||
// Close any previous connection (see FIXME in header file)
|
||||
if (openAPI) {
|
||||
DEBUG_MSG("Force closing previous TCP connection\n");
|
||||
LOG_WARN("Force closing previous TCP connection\n");
|
||||
delete openAPI;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
|
||||
{
|
||||
|
||||
DEBUG_MSG("webAPI handleAPIv1FromRadio\n");
|
||||
LOG_DEBUG("webAPI handleAPIv1FromRadio\n");
|
||||
|
||||
/*
|
||||
For documentation, see:
|
||||
@@ -185,12 +185,12 @@ void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
|
||||
res->write(txBuf, len);
|
||||
}
|
||||
|
||||
DEBUG_MSG("webAPI handleAPIv1FromRadio, len %d\n", len);
|
||||
LOG_DEBUG("webAPI handleAPIv1FromRadio, len %d\n", len);
|
||||
}
|
||||
|
||||
void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
|
||||
{
|
||||
DEBUG_MSG("webAPI handleAPIv1ToRadio\n");
|
||||
LOG_DEBUG("webAPI handleAPIv1ToRadio\n");
|
||||
|
||||
/*
|
||||
For documentation, see:
|
||||
@@ -213,11 +213,11 @@ void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
|
||||
byte buffer[MAX_TO_FROM_RADIO_SIZE];
|
||||
size_t s = req->readBytes(buffer, MAX_TO_FROM_RADIO_SIZE);
|
||||
|
||||
DEBUG_MSG("Received %d bytes from PUT request\n", s);
|
||||
LOG_DEBUG("Received %d bytes from PUT request\n", s);
|
||||
webAPI.handleToRadio(buffer, s);
|
||||
|
||||
res->write(buffer, s);
|
||||
DEBUG_MSG("webAPI handleAPIv1ToRadio\n");
|
||||
LOG_DEBUG("webAPI handleAPIv1ToRadio\n");
|
||||
}
|
||||
|
||||
void htmlDeleteDir(const char *dirname)
|
||||
@@ -238,7 +238,7 @@ void htmlDeleteDir(const char *dirname)
|
||||
} else {
|
||||
String fileName = String(file.name());
|
||||
file.close();
|
||||
DEBUG_MSG(" %s\n", fileName.c_str());
|
||||
LOG_DEBUG(" %s\n", fileName.c_str());
|
||||
FSCom.remove(fileName);
|
||||
}
|
||||
file = root.openNextFile();
|
||||
@@ -335,7 +335,7 @@ void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
|
||||
if (params->getQueryParameter("delete", paramValDelete)) {
|
||||
std::string pathDelete = "/" + paramValDelete;
|
||||
if (FSCom.remove(pathDelete.c_str())) {
|
||||
Serial.println(pathDelete.c_str());
|
||||
LOG_INFO("%s\n", pathDelete.c_str());
|
||||
JSONObject jsonObjOuter;
|
||||
jsonObjOuter["status"] = new JSONValue("ok");
|
||||
JSONValue *value = new JSONValue(jsonObjOuter);
|
||||
@@ -343,7 +343,7 @@ void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
|
||||
delete value;
|
||||
return;
|
||||
} else {
|
||||
Serial.println(pathDelete.c_str());
|
||||
LOG_INFO("%s\n", pathDelete.c_str());
|
||||
JSONObject jsonObjOuter;
|
||||
jsonObjOuter["status"] = new JSONValue("Error");
|
||||
JSONValue *value = new JSONValue(jsonObjOuter);
|
||||
@@ -379,13 +379,13 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
||||
if (FSCom.exists(filename.c_str())) {
|
||||
file = FSCom.open(filename.c_str());
|
||||
if (!file.available()) {
|
||||
DEBUG_MSG("File not available - %s\n", filename.c_str());
|
||||
LOG_WARN("File not available - %s\n", filename.c_str());
|
||||
}
|
||||
} else if (FSCom.exists(filenameGzip.c_str())) {
|
||||
file = FSCom.open(filenameGzip.c_str());
|
||||
res->setHeader("Content-Encoding", "gzip");
|
||||
if (!file.available()) {
|
||||
DEBUG_MSG("File not available - %s\n", filenameGzip.c_str());
|
||||
LOG_WARN("File not available - %s\n", filenameGzip.c_str());
|
||||
}
|
||||
} else {
|
||||
has_set_content_type = true;
|
||||
@@ -393,7 +393,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
||||
file = FSCom.open(filenameGzip.c_str());
|
||||
res->setHeader("Content-Type", "text/html");
|
||||
if (!file.available()) {
|
||||
DEBUG_MSG("File not available - %s\n", filenameGzip.c_str());
|
||||
LOG_WARN("File not available - %s\n", filenameGzip.c_str());
|
||||
res->println("Web server is running.<br><br>The content you are looking for can't be found. Please see: <a "
|
||||
"href=https://meshtastic.org/docs/getting-started/faq#wifi--web-browser>FAQ</a>.<br><br><a "
|
||||
"href=/admin>admin</a>");
|
||||
@@ -437,7 +437,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
||||
return;
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("ERROR: This should not have happened...\n");
|
||||
LOG_ERROR("This should not have happened...\n");
|
||||
res->println("ERROR: This should not have happened...");
|
||||
}
|
||||
}
|
||||
@@ -445,7 +445,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
||||
void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
||||
{
|
||||
|
||||
DEBUG_MSG("Form Upload - Disabling keep-alive\n");
|
||||
LOG_DEBUG("Form Upload - Disabling keep-alive\n");
|
||||
res->setHeader("Connection", "close");
|
||||
|
||||
// First, we need to check the encoding of the form that we have received.
|
||||
@@ -453,7 +453,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
||||
// Then we select the body parser based on the encoding.
|
||||
// Actually we do this only for documentary purposes, we know the form is going
|
||||
// to be multipart/form-data.
|
||||
DEBUG_MSG("Form Upload - Creating body parser reference\n");
|
||||
LOG_DEBUG("Form Upload - Creating body parser reference\n");
|
||||
HTTPBodyParser *parser;
|
||||
std::string contentType = req->getHeader("Content-Type");
|
||||
|
||||
@@ -469,10 +469,10 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
||||
|
||||
// Now, we can decide based on the content type:
|
||||
if (contentType == "multipart/form-data") {
|
||||
DEBUG_MSG("Form Upload - multipart/form-data\n");
|
||||
LOG_DEBUG("Form Upload - multipart/form-data\n");
|
||||
parser = new HTTPMultipartBodyParser(req);
|
||||
} else {
|
||||
Serial.printf("Unknown POST Content-Type: %s\n", contentType.c_str());
|
||||
LOG_DEBUG("Unknown POST Content-Type: %s\n", contentType.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -499,19 +499,19 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
||||
std::string filename = parser->getFieldFilename();
|
||||
std::string mimeType = parser->getFieldMimeType();
|
||||
// We log all three values, so that you can observe the upload on the serial monitor:
|
||||
DEBUG_MSG("handleFormUpload: field name='%s', filename='%s', mimetype='%s'\n", name.c_str(), filename.c_str(),
|
||||
LOG_DEBUG("handleFormUpload: field name='%s', filename='%s', mimetype='%s'\n", name.c_str(), filename.c_str(),
|
||||
mimeType.c_str());
|
||||
|
||||
// Double check that it is what we expect
|
||||
if (name != "file") {
|
||||
DEBUG_MSG("Skipping unexpected field\n");
|
||||
LOG_DEBUG("Skipping unexpected field\n");
|
||||
res->println("<p>No file found.</p>");
|
||||
return;
|
||||
}
|
||||
|
||||
// Double check that it is what we expect
|
||||
if (filename == "") {
|
||||
DEBUG_MSG("Skipping unexpected field\n");
|
||||
LOG_DEBUG("Skipping unexpected field\n");
|
||||
res->println("<p>No file found.</p>");
|
||||
return;
|
||||
}
|
||||
@@ -532,7 +532,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
||||
|
||||
byte buf[512];
|
||||
size_t readLength = parser->read(buf, 512);
|
||||
// DEBUG_MSG("\n\nreadLength - %i\n", readLength);
|
||||
// LOG_DEBUG("\n\nreadLength - %i\n", readLength);
|
||||
|
||||
// Abort the transfer if there is less than 50k space left on the filesystem.
|
||||
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
|
||||
@@ -548,7 +548,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
||||
// if (readLength) {
|
||||
file.write(buf, readLength);
|
||||
fileLength += readLength;
|
||||
DEBUG_MSG("File Length %i\n", fileLength);
|
||||
LOG_DEBUG("File Length %i\n", fileLength);
|
||||
//}
|
||||
}
|
||||
// enableLoopWDT();
|
||||
@@ -671,7 +671,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
||||
*/
|
||||
void handleHotspot(HTTPRequest *req, HTTPResponse *res)
|
||||
{
|
||||
DEBUG_MSG("Hotspot Request\n");
|
||||
LOG_INFO("Hotspot Request\n");
|
||||
|
||||
/*
|
||||
If we don't do a redirect, be sure to return a "Success" message
|
||||
@@ -697,7 +697,7 @@ void handleDeleteFsContent(HTTPRequest *req, HTTPResponse *res)
|
||||
res->println("<h1>Meshtastic</h1>\n");
|
||||
res->println("Deleting Content in /static/*");
|
||||
|
||||
DEBUG_MSG("Deleting files from /static/* : \n");
|
||||
LOG_INFO("Deleting files from /static/* : \n");
|
||||
|
||||
htmlDeleteDir("/static");
|
||||
|
||||
@@ -771,7 +771,7 @@ void handleRestart(HTTPRequest *req, HTTPResponse *res)
|
||||
res->println("<h1>Meshtastic</h1>\n");
|
||||
res->println("Restarting");
|
||||
|
||||
DEBUG_MSG("***** Restarted on HTTP(s) Request *****\n");
|
||||
LOG_DEBUG("***** Restarted on HTTP(s) Request *****\n");
|
||||
webServerThread->requestRestart = (millis() / 1000) + 5;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,19 +68,19 @@ static void taskCreateCert(void *parameter)
|
||||
|
||||
#if 0
|
||||
// Delete the saved certs (used in debugging)
|
||||
DEBUG_MSG("Deleting any saved SSL keys ...\n");
|
||||
LOG_DEBUG("Deleting any saved SSL keys ...\n");
|
||||
// prefs.clear();
|
||||
prefs.remove("PK");
|
||||
prefs.remove("cert");
|
||||
#endif
|
||||
|
||||
DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n");
|
||||
LOG_INFO("Checking if we have a previously saved SSL Certificate.\n");
|
||||
|
||||
size_t pkLen = prefs.getBytesLength("PK");
|
||||
size_t certLen = prefs.getBytesLength("cert");
|
||||
|
||||
if (pkLen && certLen) {
|
||||
DEBUG_MSG("Existing SSL Certificate found!\n");
|
||||
LOG_INFO("Existing SSL Certificate found!\n");
|
||||
|
||||
uint8_t *pkBuffer = new uint8_t[pkLen];
|
||||
prefs.getBytes("PK", pkBuffer, pkLen);
|
||||
@@ -90,12 +90,12 @@ static void taskCreateCert(void *parameter)
|
||||
|
||||
cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen);
|
||||
|
||||
DEBUG_MSG("Retrieved Private Key: %d Bytes\n", cert->getPKLength());
|
||||
DEBUG_MSG("Retrieved Certificate: %d Bytes\n", cert->getCertLength());
|
||||
LOG_DEBUG("Retrieved Private Key: %d Bytes\n", cert->getPKLength());
|
||||
LOG_DEBUG("Retrieved Certificate: %d Bytes\n", cert->getCertLength());
|
||||
|
||||
} else {
|
||||
|
||||
DEBUG_MSG("Creating the certificate. This may take a while. Please wait...\n");
|
||||
LOG_INFO("Creating the certificate. This may take a while. Please wait...\n");
|
||||
yield();
|
||||
cert = new SSLCert();
|
||||
yield();
|
||||
@@ -104,14 +104,14 @@ static void taskCreateCert(void *parameter)
|
||||
yield();
|
||||
|
||||
if (createCertResult != 0) {
|
||||
DEBUG_MSG("Creating the certificate failed\n");
|
||||
LOG_ERROR("Creating the certificate failed\n");
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("Creating the certificate was successful\n");
|
||||
LOG_INFO("Creating the certificate was successful\n");
|
||||
|
||||
DEBUG_MSG("Created Private Key: %d Bytes\n", cert->getPKLength());
|
||||
LOG_DEBUG("Created Private Key: %d Bytes\n", cert->getPKLength());
|
||||
|
||||
DEBUG_MSG("Created Certificate: %d Bytes\n", cert->getCertLength());
|
||||
LOG_DEBUG("Created Certificate: %d Bytes\n", cert->getCertLength());
|
||||
|
||||
prefs.putBytes("PK", (uint8_t *)cert->getPKData(), cert->getPKLength());
|
||||
prefs.putBytes("cert", (uint8_t *)cert->getCertData(), cert->getCertLength());
|
||||
@@ -140,11 +140,11 @@ void createSSLCert()
|
||||
16, /* Priority of the task. */
|
||||
NULL); /* Task handle. */
|
||||
|
||||
DEBUG_MSG("Waiting for SSL Cert to be generated.\n");
|
||||
LOG_DEBUG("Waiting for SSL Cert to be generated.\n");
|
||||
while (!isCertReady) {
|
||||
if ((millis() / 500) % 2) {
|
||||
if (runLoop) {
|
||||
DEBUG_MSG(".");
|
||||
LOG_DEBUG(".");
|
||||
|
||||
yield();
|
||||
esp_task_wdt_reset();
|
||||
@@ -159,7 +159,7 @@ void createSSLCert()
|
||||
runLoop = true;
|
||||
}
|
||||
}
|
||||
DEBUG_MSG("SSL Cert Ready!\n");
|
||||
LOG_INFO("SSL Cert Ready!\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ int32_t WebServerThread::runOnce()
|
||||
|
||||
void initWebServer()
|
||||
{
|
||||
DEBUG_MSG("Initializing Web Server ...\n");
|
||||
LOG_DEBUG("Initializing Web Server ...\n");
|
||||
|
||||
// We can now use the new certificate to setup our server as usual.
|
||||
secureServer = new HTTPSServer(cert);
|
||||
@@ -198,15 +198,15 @@ void initWebServer()
|
||||
registerHandlers(insecureServer, secureServer);
|
||||
|
||||
if (secureServer) {
|
||||
DEBUG_MSG("Starting Secure Web Server...\n");
|
||||
LOG_INFO("Starting Secure Web Server...\n");
|
||||
secureServer->start();
|
||||
}
|
||||
DEBUG_MSG("Starting Insecure Web Server...\n");
|
||||
LOG_INFO("Starting Insecure Web Server...\n");
|
||||
insecureServer->start();
|
||||
if (insecureServer->isRunning()) {
|
||||
DEBUG_MSG("Web Servers Ready! :-) \n");
|
||||
LOG_INFO("Web Servers Ready! :-) \n");
|
||||
isWebServerReady = true;
|
||||
} else {
|
||||
DEBUG_MSG("Web Servers Failed! ;-( \n");
|
||||
LOG_ERROR("Web Servers Failed! ;-( \n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ static int32_t reconnectWiFi()
|
||||
// Make sure we clear old connection credentials
|
||||
WiFi.disconnect(false, true);
|
||||
|
||||
DEBUG_MSG("Reconnecting to WiFi access point %s\n",wifiName);
|
||||
LOG_INFO("Reconnecting to WiFi access point %s\n",wifiName);
|
||||
|
||||
WiFi.mode(WIFI_MODE_STA);
|
||||
WiFi.begin(wifiName, wifiPsw);
|
||||
@@ -64,9 +64,9 @@ static int32_t reconnectWiFi()
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
if (WiFi.isConnected() && (((millis() - lastrun_ntp) > 43200000) || (lastrun_ntp == 0))) { // every 12 hours
|
||||
DEBUG_MSG("Updating NTP time from %s\n",config.network.ntp_server);
|
||||
LOG_DEBUG("Updating NTP time from %s\n",config.network.ntp_server);
|
||||
if (timeClient.update()) {
|
||||
DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
||||
LOG_DEBUG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = timeClient.getEpochTime();
|
||||
@@ -76,7 +76,7 @@ static int32_t reconnectWiFi()
|
||||
lastrun_ntp = millis();
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("NTP Update failed\n");
|
||||
LOG_DEBUG("NTP Update failed\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -101,12 +101,12 @@ bool isWifiAvailable()
|
||||
// Disable WiFi
|
||||
void deinitWifi()
|
||||
{
|
||||
DEBUG_MSG("WiFi deinit\n");
|
||||
LOG_INFO("WiFi deinit\n");
|
||||
|
||||
if (isWifiAvailable()) {
|
||||
WiFi.disconnect(true);
|
||||
WiFi.mode(WIFI_MODE_NULL);
|
||||
DEBUG_MSG("WiFi Turned Off\n");
|
||||
LOG_INFO("WiFi Turned Off\n");
|
||||
// WiFi.printDiag(Serial);
|
||||
}
|
||||
}
|
||||
@@ -115,20 +115,20 @@ static void onNetworkConnected()
|
||||
{
|
||||
if (!APStartupComplete) {
|
||||
// Start web server
|
||||
DEBUG_MSG("Starting network services\n");
|
||||
LOG_INFO("Starting network services\n");
|
||||
|
||||
// start mdns
|
||||
if (!MDNS.begin("Meshtastic")) {
|
||||
DEBUG_MSG("Error setting up MDNS responder!\n");
|
||||
LOG_ERROR("Error setting up MDNS responder!\n");
|
||||
} else {
|
||||
DEBUG_MSG("mDNS responder started\n");
|
||||
DEBUG_MSG("mDNS Host: Meshtastic.local\n");
|
||||
LOG_INFO("mDNS responder started\n");
|
||||
LOG_INFO("mDNS Host: Meshtastic.local\n");
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
MDNS.addService("https", "tcp", 443);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
DEBUG_MSG("Starting NTP time client\n");
|
||||
LOG_INFO("Starting NTP time client\n");
|
||||
timeClient.begin();
|
||||
timeClient.setUpdateInterval(60 * 60); // Update once an hour
|
||||
#endif
|
||||
@@ -182,8 +182,7 @@ bool initWifi()
|
||||
|
||||
WiFi.onEvent(
|
||||
[](WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
Serial.print("WiFi lost connection. Reason: ");
|
||||
Serial.println(info.wifi_sta_disconnected.reason);
|
||||
LOG_WARN("WiFi lost connection. Reason: %s", info.wifi_sta_disconnected.reason);
|
||||
|
||||
/*
|
||||
If we are disconnected from the AP for some reason,
|
||||
@@ -196,12 +195,12 @@ bool initWifi()
|
||||
},
|
||||
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
|
||||
|
||||
DEBUG_MSG("JOINING WIFI soon: ssid=%s\n", wifiName);
|
||||
LOG_DEBUG("JOINING WIFI soon: ssid=%s\n", wifiName);
|
||||
wifiReconnect = new Periodic("WifiConnect", reconnectWiFi);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
DEBUG_MSG("Not using WIFI\n");
|
||||
LOG_INFO("Not using WIFI\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -209,137 +208,135 @@ bool initWifi()
|
||||
// Called by the Espressif SDK to
|
||||
static void WiFiEvent(WiFiEvent_t event)
|
||||
{
|
||||
DEBUG_MSG("WiFi-Event %d: ", event);
|
||||
LOG_DEBUG("WiFi-Event %d: ", event);
|
||||
|
||||
switch (event) {
|
||||
case ARDUINO_EVENT_WIFI_READY:
|
||||
DEBUG_MSG("WiFi interface ready\n");
|
||||
LOG_INFO("WiFi interface ready\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_SCAN_DONE:
|
||||
DEBUG_MSG("Completed scan for access points\n");
|
||||
LOG_INFO("Completed scan for access points\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_START:
|
||||
DEBUG_MSG("WiFi station started\n");
|
||||
LOG_INFO("WiFi station started\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_STOP:
|
||||
DEBUG_MSG("WiFi station stopped\n");
|
||||
LOG_INFO("WiFi station stopped\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
|
||||
DEBUG_MSG("Connected to access point\n");
|
||||
LOG_INFO("Connected to access point\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
DEBUG_MSG("Disconnected from WiFi access point\n");
|
||||
LOG_INFO("Disconnected from WiFi access point\n");
|
||||
WiFi.disconnect(false, true);
|
||||
needReconnect = true;
|
||||
wifiReconnect->setIntervalFromNow(1000);
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE:
|
||||
DEBUG_MSG("Authentication mode of access point has changed\n");
|
||||
LOG_INFO("Authentication mode of access point has changed\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
DEBUG_MSG("Obtained IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
LOG_INFO("Obtained IP address: ", WiFi.localIPv6());
|
||||
onNetworkConnected();
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
||||
DEBUG_MSG("Obtained IP6 address: ");
|
||||
Serial.println(WiFi.localIPv6());
|
||||
LOG_INFO("Obtained IP6 address: %s", WiFi.localIPv6());
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
|
||||
DEBUG_MSG("Lost IP address and IP address is reset to 0\n");
|
||||
LOG_INFO("Lost IP address and IP address is reset to 0\n");
|
||||
WiFi.disconnect(false, true);
|
||||
needReconnect = true;
|
||||
wifiReconnect->setIntervalFromNow(1000);
|
||||
break;
|
||||
case ARDUINO_EVENT_WPS_ER_SUCCESS:
|
||||
DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n");
|
||||
LOG_INFO("WiFi Protected Setup (WPS): succeeded in enrollee mode\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WPS_ER_FAILED:
|
||||
DEBUG_MSG("WiFi Protected Setup (WPS): failed in enrollee mode\n");
|
||||
LOG_INFO("WiFi Protected Setup (WPS): failed in enrollee mode\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WPS_ER_TIMEOUT:
|
||||
DEBUG_MSG("WiFi Protected Setup (WPS): timeout in enrollee mode\n");
|
||||
LOG_INFO("WiFi Protected Setup (WPS): timeout in enrollee mode\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WPS_ER_PIN:
|
||||
DEBUG_MSG("WiFi Protected Setup (WPS): pin code in enrollee mode\n");
|
||||
LOG_INFO("WiFi Protected Setup (WPS): pin code in enrollee mode\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WPS_ER_PBC_OVERLAP:
|
||||
DEBUG_MSG("WiFi Protected Setup (WPS): push button overlap in enrollee mode\n");
|
||||
LOG_INFO("WiFi Protected Setup (WPS): push button overlap in enrollee mode\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_AP_START:
|
||||
DEBUG_MSG("WiFi access point started\n");
|
||||
LOG_INFO("WiFi access point started\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_AP_STOP:
|
||||
DEBUG_MSG("WiFi access point stopped\n");
|
||||
LOG_INFO("WiFi access point stopped\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_AP_STACONNECTED:
|
||||
DEBUG_MSG("Client connected\n");
|
||||
LOG_INFO("Client connected\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED:
|
||||
DEBUG_MSG("Client disconnected\n");
|
||||
LOG_INFO("Client disconnected\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED:
|
||||
DEBUG_MSG("Assigned IP address to client\n");
|
||||
LOG_INFO("Assigned IP address to client\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED:
|
||||
DEBUG_MSG("Received probe request\n");
|
||||
LOG_INFO("Received probe request\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_AP_GOT_IP6:
|
||||
DEBUG_MSG("IPv6 is preferred\n");
|
||||
LOG_INFO("IPv6 is preferred\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_FTM_REPORT:
|
||||
DEBUG_MSG("Fast Transition Management report\n");
|
||||
LOG_INFO("Fast Transition Management report\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_START:
|
||||
DEBUG_MSG("Ethernet started\n");
|
||||
LOG_INFO("Ethernet started\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_STOP:
|
||||
DEBUG_MSG("Ethernet stopped\n");
|
||||
LOG_INFO("Ethernet stopped\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_CONNECTED:
|
||||
DEBUG_MSG("Ethernet connected\n");
|
||||
LOG_INFO("Ethernet connected\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
DEBUG_MSG("Ethernet disconnected\n");
|
||||
LOG_INFO("Ethernet disconnected\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
DEBUG_MSG("Obtained IP address (ARDUINO_EVENT_ETH_GOT_IP)\n");
|
||||
LOG_INFO("Obtained IP address (ARDUINO_EVENT_ETH_GOT_IP)\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP6:
|
||||
DEBUG_MSG("Obtained IP6 address (ARDUINO_EVENT_ETH_GOT_IP6)\n");
|
||||
LOG_INFO("Obtained IP6 address (ARDUINO_EVENT_ETH_GOT_IP6)\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_SC_SCAN_DONE:
|
||||
DEBUG_MSG("SmartConfig: Scan done\n");
|
||||
LOG_INFO("SmartConfig: Scan done\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_SC_FOUND_CHANNEL:
|
||||
DEBUG_MSG("SmartConfig: Found channel\n");
|
||||
LOG_INFO("SmartConfig: Found channel\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_SC_GOT_SSID_PSWD:
|
||||
DEBUG_MSG("SmartConfig: Got SSID and password\n");
|
||||
LOG_INFO("SmartConfig: Got SSID and password\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_SC_SEND_ACK_DONE:
|
||||
DEBUG_MSG("SmartConfig: Send ACK done\n");
|
||||
LOG_INFO("SmartConfig: Send ACK done\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_INIT:
|
||||
DEBUG_MSG("Provisioning: Init\n");
|
||||
LOG_INFO("Provisioning: Init\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_DEINIT:
|
||||
DEBUG_MSG("Provisioning: Stopped\n");
|
||||
LOG_INFO("Provisioning: Stopped\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_START:
|
||||
DEBUG_MSG("Provisioning: Started\n");
|
||||
LOG_INFO("Provisioning: Started\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_END:
|
||||
DEBUG_MSG("Provisioning: End\n");
|
||||
LOG_INFO("Provisioning: End\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_CRED_RECV:
|
||||
DEBUG_MSG("Provisioning: Credentials received\n");
|
||||
LOG_INFO("Provisioning: Credentials received\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_CRED_FAIL:
|
||||
DEBUG_MSG("Provisioning: Credentials failed\n");
|
||||
LOG_INFO("Provisioning: Credentials failed\n");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_CRED_SUCCESS:
|
||||
DEBUG_MSG("Provisioning: Credentials success\n");
|
||||
LOG_INFO("Provisioning: Credentials success\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -12,7 +12,7 @@ size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc
|
||||
{
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(destbuf, destbufsize);
|
||||
if (!pb_encode(&stream, fields, src_struct)) {
|
||||
DEBUG_MSG("Panic: can't encode protobuf reason='%s'\n", PB_GET_ERROR(&stream));
|
||||
LOG_ERROR("Panic: can't encode protobuf reason='%s'\n", PB_GET_ERROR(&stream));
|
||||
assert(0); // If this asser fails it probably means you made a field too large for the max limits specified in mesh.options
|
||||
} else {
|
||||
return stream.bytes_written;
|
||||
@@ -24,7 +24,7 @@ bool pb_decode_from_bytes(const uint8_t *srcbuf, size_t srcbufsize, const pb_msg
|
||||
{
|
||||
pb_istream_t stream = pb_istream_from_buffer(srcbuf, srcbufsize);
|
||||
if (!pb_decode(&stream, fields, dest_struct)) {
|
||||
DEBUG_MSG("Error: can't decode protobuf reason='%s', pb_msgdesc 0x%p\n", PB_GET_ERROR(&stream), fields);
|
||||
LOG_ERROR("Can't decode protobuf reason='%s', pb_msgdesc 0x%p\n", PB_GET_ERROR(&stream), fields);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -56,7 +56,7 @@ bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
|
||||
bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count)
|
||||
{
|
||||
File *file = (File *)stream->state;
|
||||
// DEBUG_MSG("writing %d bytes to protobuf file\n", count);
|
||||
// LOG_DEBUG("writing %d bytes to protobuf file\n", count);
|
||||
return file->write(buf, count) == count;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,14 +9,14 @@ void initApiServer(int port)
|
||||
// Start API server on port 4403
|
||||
if (!apiPort) {
|
||||
apiPort = new WiFiServerPort(port);
|
||||
DEBUG_MSG("API server listening on TCP port %d\n", port);
|
||||
LOG_INFO("API server listening on TCP port %d\n", port);
|
||||
apiPort->init();
|
||||
}
|
||||
}
|
||||
|
||||
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : StreamAPI(&client), concurrency::OSThread("WiFiServerAPI"), client(_client)
|
||||
{
|
||||
DEBUG_MSG("Incoming wifi connection\n");
|
||||
LOG_INFO("Incoming wifi connection\n");
|
||||
}
|
||||
|
||||
WiFiServerAPI::~WiFiServerAPI()
|
||||
@@ -44,7 +44,7 @@ int32_t WiFiServerAPI::runOnce()
|
||||
if (client.connected()) {
|
||||
return StreamAPI::runOncePart();
|
||||
} else {
|
||||
DEBUG_MSG("Client dropped connection, suspending API service\n");
|
||||
LOG_INFO("Client dropped connection, suspending API service\n");
|
||||
enabled = false; // we no longer need to run
|
||||
return 0;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ int32_t WiFiServerPort::runOnce()
|
||||
if (client) {
|
||||
// Close any previous connection (see FIXME in header file)
|
||||
if (openAPI) {
|
||||
DEBUG_MSG("Force closing previous TCP connection\n");
|
||||
LOG_INFO("Force closing previous TCP connection\n");
|
||||
delete openAPI;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user