From 3c60df15651698239a4e3426c62ba37be558d6ae Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 13 Jan 2021 20:22:59 -0800 Subject: [PATCH 1/8] Partial work on the SerialPlugin --- src/plugins/Plugins.cpp | 2 + src/plugins/SerialPlugin.cpp | 133 +++++++++++++++++++++++++++++++++++ src/plugins/SerialPlugin.h | 54 ++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 src/plugins/SerialPlugin.cpp create mode 100644 src/plugins/SerialPlugin.h diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index 7a43c45ff..eee8280c5 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -1,6 +1,7 @@ #include "plugins/NodeInfoPlugin.h" #include "plugins/PositionPlugin.h" #include "plugins/ReplyPlugin.h" +#include "plugins/SerialPlugin.h" #include "plugins/RemoteHardwarePlugin.h" #include "plugins/TextMessagePlugin.h" @@ -17,4 +18,5 @@ void setupPlugins() { new RemoteHardwarePlugin(); new ReplyPlugin(); + new SerialPlugin(); // Maintained by MC Hamster (Jm Casler) jm@casler.org } \ No newline at end of file diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp new file mode 100644 index 000000000..f317e822e --- /dev/null +++ b/src/plugins/SerialPlugin.cpp @@ -0,0 +1,133 @@ +#include "SerialPlugin.h" +#include "MeshService.h" +#include "NodeDB.h" +#include "RTC.h" +#include "Router.h" +#include "configuration.h" +#include + +#include + +/* + Designed for lora32 v1.0 + Manufacture Info: http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1133&FId=t3:50003:3 + Pin Mapping: http://ae01.alicdn.com/kf/HTB1fLBcxkSWBuNjSszdq6zeSpXaJ.jpg +*/ + +#define RXD2 16 +#define TXD2 17 +#define SERIALPLUGIN_RX_BUFFER 128 +#define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN +#define SERIALPLUGIN_TIMEOUT 250 +#define SERIALPLUGIN_BAUD 38400 +#define SERIALPLUGIN_ENABLED 0 +#define SERIALPLUGIN_ECHO 1 + +SerialPlugin *serialPlugin; +SerialPluginRadio *serialPluginRadio; + +SerialPlugin::SerialPlugin() : concurrency::OSThread("SerialPlugin") {} + +char serialStringChar[Constants_DATA_PAYLOAD_LEN]; + +int32_t SerialPlugin::runOnce() +{ + +#if SERIALPLUGIN_ENABLED == 0 + + if (firstTime) { + + // Interface with the serial peripheral from in here. + DEBUG_MSG("Initilizing serial peripheral interface\n"); + + Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2); + Serial2.setTimeout(SERIALPLUGIN_TIMEOUT); // Number of MS to wait to set the timeout for the string. + Serial2.setRxBufferSize(SERIALPLUGIN_RX_BUFFER); + + serialPluginRadio = new SerialPluginRadio(); + + DEBUG_MSG("Initilizing serial peripheral interface - Done\n"); + + firstTime = 0; + + } else { + // Interface with the serial peripheral from in here. + String serialString; + + while (Serial2.available()) { + serialString = Serial2.readString(); + serialString.toCharArray(serialStringChar, Constants_DATA_PAYLOAD_LEN); + + serialPluginRadio->sendPayload(); + + DEBUG_MSG("Received: %s\n", serialStringChar); + } + } + + return (10); +#else + DEBUG_MSG("Serial Plugin Disabled\n"); + + return (INT32_MAX); +#endif +} + +MeshPacket *SerialPluginRadio::allocReply() +{ + + auto reply = allocDataPacket(); // Allocate a packet for sending + + return reply; +} + +void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) +{ + MeshPacket *p = allocReply(); + p->to = dest; + p->decoded.want_response = wantReplies; + + p->decoded.data.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply + memcpy(p->decoded.data.payload.bytes, serialStringChar, p->decoded.data.payload.size); + + service.sendToMesh(p); +} + +bool SerialPluginRadio::handleReceived(const MeshPacket &mp) +{ + auto &p = mp.decoded.data; + DEBUG_MSG("* * * * * * * * * * Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), + mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); + + /* + * If SERIALPLUGIN_ECHO is true, then echo the packets that are sent out back to the TX + * of the serial interface. + */ + if (mp.from == nodeDB.getNodeNum()) { + + if (SERIALPLUGIN_ECHO) { + + // For some reason, we get the packet back twice when we send out of the radio. + // TODO: need to find out why. + if (lastRxID != mp.id) { + lastRxID = mp.id; + DEBUG_MSG("* * Message came this device\n"); + Serial2.println("* * Message came this device"); + } + } + + } else { + DEBUG_MSG("* * Message came from the mesh\n"); + Serial2.println("* * Message came from the mesh"); + } + + // We only store/display messages destined for us. + // Keep a copy of the most recent text message. + // devicestate.rx_text_message = mp; + // devicestate.has_rx_text_message = true; + + // Serial2.print(p.payload.bytes); + + // TODO: If packet came from this device, don't echo locally. + + return true; // Let others look at this message also if they want +} diff --git a/src/plugins/SerialPlugin.h b/src/plugins/SerialPlugin.h new file mode 100644 index 000000000..814fbd15e --- /dev/null +++ b/src/plugins/SerialPlugin.h @@ -0,0 +1,54 @@ +#pragma once + +#include "SinglePortPlugin.h" +#include "concurrency/OSThread.h" +#include "configuration.h" +#include +#include + +class SerialPlugin : private concurrency::OSThread +{ + bool firstTime = 1; + + public: + SerialPlugin(); + + protected: + virtual int32_t runOnce(); +}; + +extern SerialPlugin *serialPlugin; + +/* + * Radio interface for SerialPlugin + * + */ +class SerialPluginRadio : public SinglePortPlugin +{ + uint32_t lastRxID; + + public: + /* + TODO: Switch this to PortNum_SERIAL_APP once the change is able to be merged back here + from the main code. + */ + + SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {} + // SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_PRIVATE_APP) {} + + /** + * Send our payload into the mesh + */ + void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + + protected: + virtual MeshPacket *allocReply(); + + /** Called to handle a particular incoming message + + @return true if you've guaranteed you've handled this message and no other handlers should be considered for it + */ + virtual bool handleReceived(const MeshPacket &mp); +}; + +extern SerialPluginRadio *serialPluginRadio; \ No newline at end of file From eee7e1de570c8239806941494e2bff0698e38d7e Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 13 Jan 2021 22:39:11 -0800 Subject: [PATCH 2/8] Update to serial plugin --- src/plugins/SerialPlugin.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index f317e822e..00d6070d4 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -46,7 +46,7 @@ int32_t SerialPlugin::runOnce() serialPluginRadio = new SerialPluginRadio(); - DEBUG_MSG("Initilizing serial peripheral interface - Done\n"); + //DEBUG_MSG("Initilizing serial peripheral interface - Done\n"); firstTime = 0; @@ -95,8 +95,8 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) bool SerialPluginRadio::handleReceived(const MeshPacket &mp) { auto &p = mp.decoded.data; - DEBUG_MSG("* * * * * * * * * * Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), - mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); + //DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), + // mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); /* * If SERIALPLUGIN_ECHO is true, then echo the packets that are sent out back to the TX @@ -110,24 +110,17 @@ bool SerialPluginRadio::handleReceived(const MeshPacket &mp) // TODO: need to find out why. if (lastRxID != mp.id) { lastRxID = mp.id; - DEBUG_MSG("* * Message came this device\n"); - Serial2.println("* * Message came this device"); + //DEBUG_MSG("* * Message came this device\n"); + //Serial2.println("* * Message came this device"); + Serial2.printf("%s", p.payload.bytes); } } } else { - DEBUG_MSG("* * Message came from the mesh\n"); - Serial2.println("* * Message came from the mesh"); + //DEBUG_MSG("* * Message came from the mesh\n"); + //Serial2.println("* * Message came from the mesh"); + Serial2.printf("%s", p.payload.bytes); } - // We only store/display messages destined for us. - // Keep a copy of the most recent text message. - // devicestate.rx_text_message = mp; - // devicestate.has_rx_text_message = true; - - // Serial2.print(p.payload.bytes); - - // TODO: If packet came from this device, don't echo locally. - return true; // Let others look at this message also if they want } From c54e87f9a26ffa664387c0759e91e78d2b393f7e Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 13 Jan 2021 22:50:02 -0800 Subject: [PATCH 3/8] Update SerialPlugin.cpp Added documentation. --- src/plugins/SerialPlugin.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index 00d6070d4..710a9f204 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -12,16 +12,36 @@ Designed for lora32 v1.0 Manufacture Info: http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1133&FId=t3:50003:3 Pin Mapping: http://ae01.alicdn.com/kf/HTB1fLBcxkSWBuNjSszdq6zeSpXaJ.jpg + + + This will probably and most likely work on other boards too. + + Need help with this plugin? Post your question on the Meshtastic Discourse: + https://meshtastic.discourse.group + + Basic Usage: + + 1) Enable the plugin by setting SERIALPLUGIN_ENABLED to 1. + 2) Set the pins (RXD2 / TXD2) for your preferred RX and TX GPIO pins + 3) Set SERIALPLUGIN_TIMEOUT to the amount of time to wait before we consider + your packet as "done". + 4) (Optional) In SerialPlugin.h set the port to PortNum_TEXT_MESSAGE_APP if you want to + send messages to/from the general text message channel. + 5) Connect to your device over the serial interface at 38400 8N1. + 6) Send a packet up to 240 bytes in length. This will get relayed over the mesh network. + 7) (Optional) Set SERIALPLUGIN_ECHO to 1 and any message you send out will be echoed back + to your device. + */ #define RXD2 16 #define TXD2 17 #define SERIALPLUGIN_RX_BUFFER 128 #define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN -#define SERIALPLUGIN_TIMEOUT 250 +#define SERIALPLUGIN_TIMEOUT 100 #define SERIALPLUGIN_BAUD 38400 #define SERIALPLUGIN_ENABLED 0 -#define SERIALPLUGIN_ECHO 1 +#define SERIALPLUGIN_ECHO 0 SerialPlugin *serialPlugin; SerialPluginRadio *serialPluginRadio; @@ -33,7 +53,7 @@ char serialStringChar[Constants_DATA_PAYLOAD_LEN]; int32_t SerialPlugin::runOnce() { -#if SERIALPLUGIN_ENABLED == 0 +#if SERIALPLUGIN_ENABLED == 1 if (firstTime) { @@ -46,12 +66,9 @@ int32_t SerialPlugin::runOnce() serialPluginRadio = new SerialPluginRadio(); - //DEBUG_MSG("Initilizing serial peripheral interface - Done\n"); - firstTime = 0; } else { - // Interface with the serial peripheral from in here. String serialString; while (Serial2.available()) { From 89b32dd7eeed252223d1dc15da5fedd948fae8c4 Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 13 Jan 2021 22:51:36 -0800 Subject: [PATCH 4/8] Fix comments in serial plugin --- src/plugins/SerialPlugin.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index 710a9f204..43f40bbde 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -22,7 +22,7 @@ Basic Usage: 1) Enable the plugin by setting SERIALPLUGIN_ENABLED to 1. - 2) Set the pins (RXD2 / TXD2) for your preferred RX and TX GPIO pins + 2) Set the pins (RXD2 / TXD2) for your preferred RX and TX GPIO pins. 3) Set SERIALPLUGIN_TIMEOUT to the amount of time to wait before we consider your packet as "done". 4) (Optional) In SerialPlugin.h set the port to PortNum_TEXT_MESSAGE_APP if you want to @@ -112,30 +112,30 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) bool SerialPluginRadio::handleReceived(const MeshPacket &mp) { auto &p = mp.decoded.data; - //DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), + // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), // mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); - /* - * If SERIALPLUGIN_ECHO is true, then echo the packets that are sent out back to the TX - * of the serial interface. - */ if (mp.from == nodeDB.getNodeNum()) { + /* + * If SERIALPLUGIN_ECHO is true, then echo the packets that are sent out back to the TX + * of the serial interface. + */ if (SERIALPLUGIN_ECHO) { // For some reason, we get the packet back twice when we send out of the radio. // TODO: need to find out why. if (lastRxID != mp.id) { lastRxID = mp.id; - //DEBUG_MSG("* * Message came this device\n"); - //Serial2.println("* * Message came this device"); + // DEBUG_MSG("* * Message came this device\n"); + // Serial2.println("* * Message came this device"); Serial2.printf("%s", p.payload.bytes); } } } else { - //DEBUG_MSG("* * Message came from the mesh\n"); - //Serial2.println("* * Message came from the mesh"); + // DEBUG_MSG("* * Message came from the mesh\n"); + // Serial2.println("* * Message came from the mesh"); Serial2.printf("%s", p.payload.bytes); } From b1181deb58f3168dbbf7f732dfba58ced24f09bd Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 13 Jan 2021 23:02:13 -0800 Subject: [PATCH 5/8] serialplugin - Added my todo list --- src/plugins/SerialPlugin.cpp | 9 +++++++-- src/plugins/SerialPlugin.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index 43f40bbde..daf0c8c2c 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -13,8 +13,8 @@ Manufacture Info: http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1133&FId=t3:50003:3 Pin Mapping: http://ae01.alicdn.com/kf/HTB1fLBcxkSWBuNjSszdq6zeSpXaJ.jpg - - This will probably and most likely work on other boards too. + This will probably and most likely work on other esp32 devices, given possible change the RX/TX + selection. Need help with this plugin? Post your question on the Meshtastic Discourse: https://meshtastic.discourse.group @@ -32,6 +32,11 @@ 7) (Optional) Set SERIALPLUGIN_ECHO to 1 and any message you send out will be echoed back to your device. + TODO: + * Once protobufs regenerated with the new port, update SerialPlugin.h + * Implement an interface to enable / disable ack + * Ensure this works on a tbeam + */ #define RXD2 16 diff --git a/src/plugins/SerialPlugin.h b/src/plugins/SerialPlugin.h index 814fbd15e..c6d79f3eb 100644 --- a/src/plugins/SerialPlugin.h +++ b/src/plugins/SerialPlugin.h @@ -34,7 +34,7 @@ class SerialPluginRadio : public SinglePortPlugin */ SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {} - // SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_PRIVATE_APP) {} + // SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {} /** * Send our payload into the mesh From f68a31ab28f004d64340561d1fc204025c6ffe84 Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 13 Jan 2021 23:21:55 -0800 Subject: [PATCH 6/8] serialplugin - ability to configure ACK --- src/plugins/SerialPlugin.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index daf0c8c2c..a0f071ef0 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -32,10 +32,16 @@ 7) (Optional) Set SERIALPLUGIN_ECHO to 1 and any message you send out will be echoed back to your device. - TODO: + TODO (in this order): * Once protobufs regenerated with the new port, update SerialPlugin.h - * Implement an interface to enable / disable ack * Ensure this works on a tbeam + * Define a verbose RX mode to report on mesh and packet infomration. + - This won't happen any time soon. + + KNOWN PROBLEMS + * Until the plugin is initilized by the startup sequence, the TX pin is in a floating + state. Device connected to that pin may see this as "noise". + */ @@ -43,10 +49,11 @@ #define TXD2 17 #define SERIALPLUGIN_RX_BUFFER 128 #define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN -#define SERIALPLUGIN_TIMEOUT 100 +#define SERIALPLUGIN_TIMEOUT 250 #define SERIALPLUGIN_BAUD 38400 -#define SERIALPLUGIN_ENABLED 0 +#define SERIALPLUGIN_ENABLED 1 #define SERIALPLUGIN_ECHO 0 +#define SERIALPLUGIN_ACK 0 SerialPlugin *serialPlugin; SerialPluginRadio *serialPluginRadio; @@ -108,6 +115,8 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) p->to = dest; p->decoded.want_response = wantReplies; + p->want_ack = SERIALPLUGIN_ACK; + p->decoded.data.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply memcpy(p->decoded.data.payload.bytes, serialStringChar, p->decoded.data.payload.size); From e39506824d547da2c6204473b517d316346faa9f Mon Sep 17 00:00:00 2001 From: Jm Date: Thu, 14 Jan 2021 18:08:23 -0800 Subject: [PATCH 7/8] Added more comments --- src/plugins/SerialPlugin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index a0f071ef0..cc355c066 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -9,7 +9,11 @@ #include /* - Designed for lora32 v1.0 + SerialPlugin + An overly simplistic interface to send messages over the mesh network by sending strings + over a serial port. + + Originally designed for lora32 v1.0 Manufacture Info: http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1133&FId=t3:50003:3 Pin Mapping: http://ae01.alicdn.com/kf/HTB1fLBcxkSWBuNjSszdq6zeSpXaJ.jpg From 507cd1dd20e9b587ae3dd6e34a78f805344bdff0 Mon Sep 17 00:00:00 2001 From: Jm Date: Thu, 14 Jan 2021 18:40:18 -0800 Subject: [PATCH 8/8] #639 - Move from counting seconds to milliseconds --- src/airtime.cpp | 26 ++++++++++---------------- src/airtime.h | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 66f4a0a57..8d1800d52 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -5,10 +5,6 @@ AirTime *airTime; -// A reminder that there are 3600 seconds in an hour so I don't have -// to keep googling it. -// This can be changed to a smaller number to speed up testing. -// uint32_t secondsPerPeriod = 3600; uint32_t lastMillis = 0; uint32_t secSinceBoot = 0; @@ -17,25 +13,23 @@ uint32_t secSinceBoot = 0; // Don't read out of this directly. Use the helper functions. struct airtimeStruct { - uint16_t periodTX[periodsToLog]; // AirTime transmitted - uint16_t periodRX[periodsToLog]; // AirTime received and repeated (Only valid mesh packets) - uint16_t periodRX_ALL[periodsToLog]; // AirTime received regardless of valid mesh packet. Could include noise. + uint32_t periodTX[periodsToLog]; // AirTime transmitted + uint32_t periodRX[periodsToLog]; // AirTime received and repeated (Only valid mesh packets) + uint32_t periodRX_ALL[periodsToLog]; // AirTime received regardless of valid mesh packet. Could include noise. uint8_t lastPeriodIndex; } airtimes; void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) { - // DEBUG_MSG("Packet - logAirtime()\n"); - if (reportType == TX_LOG) { - DEBUG_MSG("AirTime - Packet transmitted : %us %ums\n", (uint32_t)round((float)airtime_ms / (float)1000), airtime_ms); - airtimes.periodTX[0] = airtimes.periodTX[0] + round(airtime_ms / 1000); + DEBUG_MSG("AirTime - Packet transmitted : %ums\n", airtime_ms); + airtimes.periodTX[0] = airtimes.periodTX[0] + airtime_ms; } else if (reportType == RX_LOG) { - DEBUG_MSG("AirTime - Packet received : %us %ums\n", (uint32_t)round((float)airtime_ms / (float)1000), airtime_ms); - airtimes.periodRX[0] = airtimes.periodRX[0] + round(airtime_ms / 1000); + DEBUG_MSG("AirTime - Packet received : %ums\n", airtime_ms); + airtimes.periodRX[0] = airtimes.periodRX[0] + airtime_ms; } else if (reportType == RX_ALL_LOG) { - DEBUG_MSG("AirTime - Packet received (noise?) : %us %ums\n", (uint32_t)round((float)airtime_ms / (float)1000), airtime_ms); - airtimes.periodRX_ALL[0] = airtimes.periodRX_ALL[0] + round(airtime_ms / 1000); + DEBUG_MSG("AirTime - Packet received (noise?) : %ums\n", airtime_ms); + airtimes.periodRX_ALL[0] = airtimes.periodRX_ALL[0] + airtime_ms; } else { DEBUG_MSG("AirTime - Unknown report time. This should never happen!!\n"); } @@ -65,7 +59,7 @@ void airtimeRotatePeriod() } } -uint16_t *airtimeReport(reportTypes reportType) +uint32_t *airtimeReport(reportTypes reportType) { if (reportType == TX_LOG) { diff --git a/src/airtime.h b/src/airtime.h index 439670010..d78db86a4 100644 --- a/src/airtime.h +++ b/src/airtime.h @@ -34,7 +34,7 @@ uint8_t getPeriodsToLog(); uint32_t getSecondsSinceBoot(); -uint16_t *airtimeReport(reportTypes reportType); +uint32_t *airtimeReport(reportTypes reportType); uint32_t getSecondsPerPeriod();