Remove deprecated MyNodeInfo fields (#2552)

* Skadoosh

* Removing deprecated fields

* Remove remaining deprecations

* Macro

* Macro
This commit is contained in:
Ben Meadors 2023-06-08 08:07:32 -05:00 committed by GitHub
parent 44a54278b3
commit 81f80546b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 177 additions and 79 deletions

@ -1 +1 @@
Subproject commit f746cd8add18d4573ba2e06f3ea31408afb3e877 Subproject commit 5f3daac5fabdfe2a0561395fed0ba11a38ba3e7e

View File

@ -157,7 +157,7 @@ class ButtonThread : public concurrency::OSThread
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW); digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
#endif #endif
screen->print("Sent ad-hoc ping\n"); screen->print("Sent ad-hoc ping\n");
service.refreshMyNodeInfo(); service.refreshLocalNodeInfo();
service.sendNetworkPing(NODENUM_BROADCAST, true); service.sendNetworkPing(NODENUM_BROADCAST, true);
} }

View File

@ -6,20 +6,22 @@ AirTime *airTime = NULL;
// Don't read out of this directly. Use the helper functions. // Don't read out of this directly. Use the helper functions.
uint32_t air_period_tx[PERIODS_TO_LOG];
uint32_t air_period_rx[PERIODS_TO_LOG];
void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms)
{ {
if (reportType == TX_LOG) { if (reportType == TX_LOG) {
LOG_DEBUG("AirTime - Packet transmitted : %ums\n", airtime_ms); LOG_DEBUG("AirTime - Packet transmitted : %ums\n", airtime_ms);
this->airtimes.periodTX[0] = this->airtimes.periodTX[0] + airtime_ms; this->airtimes.periodTX[0] = this->airtimes.periodTX[0] + airtime_ms;
myNodeInfo.air_period_tx[0] = myNodeInfo.air_period_tx[0] + airtime_ms; air_period_tx[0] = air_period_tx[0] + airtime_ms;
this->utilizationTX[this->getPeriodUtilHour()] = this->utilizationTX[this->getPeriodUtilHour()] + airtime_ms; this->utilizationTX[this->getPeriodUtilHour()] = this->utilizationTX[this->getPeriodUtilHour()] + airtime_ms;
} else if (reportType == RX_LOG) { } else if (reportType == RX_LOG) {
LOG_DEBUG("AirTime - Packet received : %ums\n", airtime_ms); LOG_DEBUG("AirTime - Packet received : %ums\n", airtime_ms);
this->airtimes.periodRX[0] = this->airtimes.periodRX[0] + airtime_ms; this->airtimes.periodRX[0] = this->airtimes.periodRX[0] + airtime_ms;
myNodeInfo.air_period_rx[0] = myNodeInfo.air_period_rx[0] + airtime_ms; air_period_rx[0] = air_period_rx[0] + airtime_ms;
} else if (reportType == RX_ALL_LOG) { } else if (reportType == RX_ALL_LOG) {
LOG_DEBUG("AirTime - Packet received (noise?) : %ums\n", airtime_ms); LOG_DEBUG("AirTime - Packet received (noise?) : %ums\n", airtime_ms);
this->airtimes.periodRX_ALL[0] = this->airtimes.periodRX_ALL[0] + airtime_ms; this->airtimes.periodRX_ALL[0] = this->airtimes.periodRX_ALL[0] + airtime_ms;
@ -55,16 +57,16 @@ void AirTime::airtimeRotatePeriod()
this->airtimes.periodRX[i + 1] = this->airtimes.periodRX[i]; this->airtimes.periodRX[i + 1] = this->airtimes.periodRX[i];
this->airtimes.periodRX_ALL[i + 1] = this->airtimes.periodRX_ALL[i]; this->airtimes.periodRX_ALL[i + 1] = this->airtimes.periodRX_ALL[i];
myNodeInfo.air_period_tx[i + 1] = this->airtimes.periodTX[i]; air_period_tx[i + 1] = this->airtimes.periodTX[i];
myNodeInfo.air_period_rx[i + 1] = this->airtimes.periodRX[i]; air_period_rx[i + 1] = this->airtimes.periodRX[i];
} }
this->airtimes.periodTX[0] = 0; this->airtimes.periodTX[0] = 0;
this->airtimes.periodRX[0] = 0; this->airtimes.periodRX[0] = 0;
this->airtimes.periodRX_ALL[0] = 0; this->airtimes.periodRX_ALL[0] = 0;
myNodeInfo.air_period_tx[0] = 0; air_period_tx[0] = 0;
myNodeInfo.air_period_rx[0] = 0; air_period_rx[0] = 0;
this->airtimes.lastPeriodIndex = this->currentPeriodIndex(); this->airtimes.lastPeriodIndex = this->currentPeriodIndex();
} }
@ -179,18 +181,17 @@ int32_t AirTime::runOnce()
} }
// Init airtime windows to all 0 // Init airtime windows to all 0
for (int i = 0; i < myNodeInfo.air_period_rx_count; i++) { for (int i = 0; i < PERIODS_TO_LOG; i++) {
this->airtimes.periodTX[i] = 0; this->airtimes.periodTX[i] = 0;
this->airtimes.periodRX[i] = 0; this->airtimes.periodRX[i] = 0;
this->airtimes.periodRX_ALL[i] = 0; this->airtimes.periodRX_ALL[i] = 0;
// myNodeInfo.air_period_tx[i] = 0; // air_period_tx[i] = 0;
// myNodeInfo.air_period_rx[i] = 0; // air_period_rx[i] = 0;
} }
firstTime = false; firstTime = false;
lastUtilPeriod = utilPeriod; lastUtilPeriod = utilPeriod;
} else { } else {
this->airtimeRotatePeriod(); this->airtimeRotatePeriod();
@ -206,12 +207,6 @@ int32_t AirTime::runOnce()
this->utilizationTX[utilPeriodTX] = 0; this->utilizationTX[utilPeriodTX] = 0;
} }
// Update channel_utilization every second.
myNodeInfo.channel_utilization = airTime->channelUtilizationPercent();
// Update channel_utilization every second.
myNodeInfo.air_util_tx = airTime->utilizationTXPercent();
} }
/* /*
LOG_DEBUG("utilPeriodTX %d TX Airtime %3.2f%\n", utilPeriodTX, airTime->utilizationTXPercent()); LOG_DEBUG("utilPeriodTX %d TX Airtime %3.2f%\n", utilPeriodTX, airTime->utilizationTXPercent());
@ -223,4 +218,4 @@ int32_t AirTime::runOnce()
LOG_DEBUG("\n"); LOG_DEBUG("\n");
*/ */
return (1000 * 1); return (1000 * 1);
} }

View File

@ -9,4 +9,4 @@
/// Record an error that should be reported via analytics /// Record an error that should be reported via analytics
void recordCriticalError(meshtastic_CriticalErrorCode code = meshtastic_CriticalErrorCode_UNSPECIFIED, uint32_t address = 0, void recordCriticalError(meshtastic_CriticalErrorCode code = meshtastic_CriticalErrorCode_UNSPECIFIED, uint32_t address = 0,
const char *filename = NULL); const char *filename = NULL);

View File

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "GPS.h" #include "GPS.h"
#include "MeshService.h" #include "MeshService.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "error.h"
#include "gps/GeoCoord.h" #include "gps/GeoCoord.h"
#include "gps/RTC.h" #include "gps/RTC.h"
#include "graphics/images.h" #include "graphics/images.h"
@ -352,7 +353,7 @@ static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *sta
display->setFont(FONT_MEDIUM); display->setFont(FONT_MEDIUM);
char tempBuf[24]; char tempBuf[24];
snprintf(tempBuf, sizeof(tempBuf), "Critical fault #%d", myNodeInfo.error_code); snprintf(tempBuf, sizeof(tempBuf), "Critical fault #%d", error_code);
display->drawString(0 + x, 0 + y, tempBuf); display->drawString(0 + x, 0 + y, tempBuf);
display->setTextAlignment(TEXT_ALIGN_LEFT); display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(FONT_SMALL); display->setFont(FONT_SMALL);
@ -1258,7 +1259,7 @@ void Screen::setFrames()
LOG_DEBUG("Added modules. numframes: %d\n", numframes); LOG_DEBUG("Added modules. numframes: %d\n", numframes);
// If we have a critical fault, show it first // If we have a critical fault, show it first
if (myNodeInfo.error_code) if (error_code)
normalFrames[numframes++] = drawCriticalFaultFrame; normalFrames[numframes++] = drawCriticalFaultFrame;
// If we have a text message - show it next, unless it's a phone message and we aren't using any special modules // If we have a text message - show it next, unless it's a phone message and we aren't using any special modules

View File

@ -667,12 +667,10 @@ void setup()
else { else {
router->addInterface(rIf); router->addInterface(rIf);
// Calculate and save the bit rate to myNodeInfo // Log bit rate to debug output
// TODO: This needs to be added what ever method changes the channel from the phone. LOG_DEBUG("LoRA bitrate = %f bytes / sec\n", (float(meshtastic_Constants_DATA_PAYLOAD_LEN) /
myNodeInfo.bitrate = (float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) *
(float(meshtastic_Constants_DATA_PAYLOAD_LEN) / (float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) * 1000);
1000;
LOG_DEBUG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
} }
// This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values // This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values
@ -693,7 +691,7 @@ bool runASAP;
extern meshtastic_DeviceMetadata getDeviceMetadata() extern meshtastic_DeviceMetadata getDeviceMetadata()
{ {
meshtastic_DeviceMetadata deviceMetadata; meshtastic_DeviceMetadata deviceMetadata;
strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); strncpy(deviceMetadata.firmware_version, optstr(APP_VERSION), sizeof(deviceMetadata.firmware_version));
deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; deviceMetadata.device_state_version = DEVICESTATE_CUR_VER;
deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN;
deviceMetadata.hasBluetooth = HAS_BLUETOOTH; deviceMetadata.hasBluetooth = HAS_BLUETOOTH;

View File

@ -266,7 +266,7 @@ void MeshService::sendToPhone(meshtastic_MeshPacket *p)
fromNum++; fromNum++;
} }
meshtastic_NodeInfo *MeshService::refreshMyNodeInfo() meshtastic_NodeInfo *MeshService::refreshLocalNodeInfo()
{ {
meshtastic_NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); meshtastic_NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
assert(node); assert(node);
@ -293,7 +293,7 @@ meshtastic_NodeInfo *MeshService::refreshMyNodeInfo()
int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus) int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
{ {
// Update our local node info with our position (even if we don't decide to update anyone else) // Update our local node info with our position (even if we don't decide to update anyone else)
meshtastic_NodeInfo *node = refreshMyNodeInfo(); meshtastic_NodeInfo *node = refreshLocalNodeInfo();
meshtastic_Position pos = meshtastic_Position_init_default; meshtastic_Position pos = meshtastic_Position_init_default;
if (newStatus->getHasLock()) { if (newStatus->getHasLock()) {
@ -312,7 +312,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
} }
// Finally add a fresh timestamp and battery level reading // Finally add a fresh timestamp and battery level reading
// I KNOW this is redundant with refreshMyNodeInfo() above, but these are // I KNOW this is redundant with refreshLocalNodeInfo() above, but these are
// inexpensive nonblocking calls and can be refactored in due course // inexpensive nonblocking calls and can be refactored in due course
pos.time = getValidTime(RTCQualityGPS); pos.time = getValidTime(RTCQualityGPS);

View File

@ -98,7 +98,7 @@ class MeshService
bool cancelSending(PacketId id); bool cancelSending(PacketId id);
/// Pull the latest power and time info into my nodeinfo /// Pull the latest power and time info into my nodeinfo
meshtastic_NodeInfo *refreshMyNodeInfo(); meshtastic_NodeInfo *refreshLocalNodeInfo();
/// Send a packet to the phone /// Send a packet to the phone
void sendToPhone(meshtastic_MeshPacket *p); void sendToPhone(meshtastic_MeshPacket *p);

View File

@ -56,6 +56,10 @@ extern void getMacAddr(uint8_t *dmac);
*/ */
meshtastic_User &owner = devicestate.owner; meshtastic_User &owner = devicestate.owner;
meshtastic_CriticalErrorCode error_code =
meshtastic_CriticalErrorCode_NONE; // For the error code, only show values from this boot (discard value from flash)
uint32_t error_address = 0;
static uint8_t ourMacAddr[6]; static uint8_t ourMacAddr[6];
NodeDB::NodeDB() : nodes(devicestate.node_db), numNodes(&devicestate.node_db_count) {} NodeDB::NodeDB() : nodes(devicestate.node_db), numNodes(&devicestate.node_db_count) {}
@ -275,9 +279,6 @@ void NodeDB::installDefaultDeviceState()
devicestate.version = DEVICESTATE_CUR_VER; devicestate.version = DEVICESTATE_CUR_VER;
devicestate.receive_queue_count = 0; // Not yet implemented FIXME devicestate.receive_queue_count = 0; // Not yet implemented FIXME
// default to no GPS, until one has been found by probing
myNodeInfo.has_gps = false;
myNodeInfo.message_timeout_msec = FLOOD_EXPIRE_TIME;
generatePacketId(); // FIXME - ugly way to init current_packet_id; generatePacketId(); // FIXME - ugly way to init current_packet_id;
// Init our blank owner info to reasonable defaults // Init our blank owner info to reasonable defaults
@ -302,12 +303,6 @@ void NodeDB::init()
int saveWhat = 0; int saveWhat = 0;
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
myNodeInfo.error_code =
meshtastic_CriticalErrorCode_NONE; // For the error code, only show values from this boot (discard value from flash)
myNodeInfo.error_address = 0;
// likewise - we always want the app requirements to come from the running appload // likewise - we always want the app requirements to come from the running appload
myNodeInfo.min_app_version = 20300; // format is Mmmss (where M is 1+the numeric major number. i.e. 20120 means 1.1.20 myNodeInfo.min_app_version = 20300; // format is Mmmss (where M is 1+the numeric major number. i.e. 20120 means 1.1.20
@ -323,19 +318,12 @@ void NodeDB::init()
info->user = owner; info->user = owner;
info->has_user = true; info->has_user = true;
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
Preferences preferences; Preferences preferences;
preferences.begin("meshtastic", false); preferences.begin("meshtastic", false);
myNodeInfo.reboot_count = preferences.getUInt("rebootCounter", 0); myNodeInfo.reboot_count = preferences.getUInt("rebootCounter", 0);
preferences.end(); preferences.end();
LOG_DEBUG("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.
*/
myNodeInfo.has_wifi = true;
#endif #endif
resetRadioConfig(); // If bogus settings got saved, then fix them resetRadioConfig(); // If bogus settings got saved, then fix them
@ -816,13 +804,12 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co
} }
// Record error to DB // Record error to DB
myNodeInfo.error_code = code; error_code = code;
myNodeInfo.error_address = address; error_address = address;
myNodeInfo.error_count++;
// Currently portuino is mostly used for simulation. Make sue the user notices something really bad happend // Currently portuino is mostly used for simulation. Make sue the user notices something really bad happend
#ifdef ARCH_PORTDUINO #ifdef ARCH_PORTDUINO
LOG_ERROR("A critical failure occurred, portduino is exiting..."); LOG_ERROR("A critical failure occurred, portduino is exiting...");
exit(2); exit(2);
#endif #endif
} }

View File

@ -7,6 +7,7 @@
#include "MeshTypes.h" #include "MeshTypes.h"
#include "NodeStatus.h" #include "NodeStatus.h"
#include "mesh-pb-constants.h" #include "mesh-pb-constants.h"
#include "mesh/generated/meshtastic/mesh.pb.h" // For CriticalErrorCode
/* /*
DeviceState versions used to be defined in the .proto file but really only this function cares. So changed to a DeviceState versions used to be defined in the .proto file but really only this function cares. So changed to a
@ -224,6 +225,13 @@ static inline bool hasValidPosition(const meshtastic_NodeInfo *n)
*/ */
extern uint32_t radioGeneration; extern uint32_t radioGeneration;
extern meshtastic_CriticalErrorCode error_code;
/*
* A numeric error address (nonzero if available)
*/
extern uint32_t error_address;
#define Module_Config_size \ #define Module_Config_size \
(ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \
ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \

View File

@ -143,12 +143,11 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
LOG_INFO("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 // 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. // app not to send locations on our behalf.
myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_my_info_tag; fromRadioScratch.which_payload_variant = meshtastic_FromRadio_my_info_tag;
fromRadioScratch.my_info = myNodeInfo; fromRadioScratch.my_info = myNodeInfo;
state = STATE_SEND_NODEINFO; state = STATE_SEND_NODEINFO;
service.refreshMyNodeInfo(); // Update my NodeInfo because the client will be asking for it soon. service.refreshLocalNodeInfo(); // Update my NodeInfo because the client will be asking for it soon.
break; break;
case STATE_SEND_NODEINFO: { case STATE_SEND_NODEINFO: {

View File

@ -9,6 +9,12 @@
PB_BIND(meshtastic_DeviceState, meshtastic_DeviceState, 4) PB_BIND(meshtastic_DeviceState, meshtastic_DeviceState, 4)
PB_BIND(meshtastic_NodeInfoLite, meshtastic_NodeInfoLite, AUTO)
PB_BIND(meshtastic_PositionLite, meshtastic_PositionLite, AUTO)
PB_BIND(meshtastic_ChannelFile, meshtastic_ChannelFile, 2) PB_BIND(meshtastic_ChannelFile, meshtastic_ChannelFile, 2)

File diff suppressed because one or more lines are too long

View File

@ -579,12 +579,15 @@ typedef struct _meshtastic_MyNodeInfo {
/* Tells the phone what our node number is, default starting value is /* Tells the phone what our node number is, default starting value is
lowbyte of macaddr, but it will be fixed if that is already in use */ lowbyte of macaddr, but it will be fixed if that is already in use */
uint32_t my_node_num; uint32_t my_node_num;
/* Note: This flag merely means we detected a hardware GPS in our node. /* Deprecated in 2.1.x (Source from device_metadata)
Note: This flag merely means we detected a hardware GPS in our node.
Not the same as UserPreferences.location_sharing */ Not the same as UserPreferences.location_sharing */
bool has_gps; bool has_gps;
/* The maximum number of 'software' channels that can be set on this node. */ /* Deprecated in 2.1.x
The maximum number of 'software' channels that can be set on this node. */
uint32_t max_channels; uint32_t max_channels;
/* 0.0.5 etc... */ /* Deprecated in 2.1.x (Source from device_metadata)
0.0.5 etc... */
char firmware_version[18]; char firmware_version[18];
/* An error message we'd like to report back to the mothership through analytics. /* An error message we'd like to report back to the mothership through analytics.
It indicates a serious bug occurred on the device, the device coped with it, It indicates a serious bug occurred on the device, the device coped with it,
@ -601,9 +604,11 @@ typedef struct _meshtastic_MyNodeInfo {
/* The total number of reboots this node has ever encountered /* The total number of reboots this node has ever encountered
(well - since the last time we discarded preferences) */ (well - since the last time we discarded preferences) */
uint32_t reboot_count; uint32_t reboot_count;
/* Calculated bitrate of the current channel (in Bytes Per Second) */ /* Deprecated in 2.1.x
Calculated bitrate of the current channel (in Bytes Per Second) */
float bitrate; float bitrate;
/* How long before we consider a message abandoned and we can clear our /* Deprecated in 2.1.x
How long before we consider a message abandoned and we can clear our
caches of any messages in flight Normally quite large to handle the worst case caches of any messages in flight Normally quite large to handle the worst case
message delivery time, 5 minutes. message delivery time, 5 minutes.
Formerly called FLOOD_EXPIRE_TIME in the device code */ Formerly called FLOOD_EXPIRE_TIME in the device code */
@ -611,17 +616,22 @@ typedef struct _meshtastic_MyNodeInfo {
/* The minimum app version that can talk to this device. /* The minimum app version that can talk to this device.
Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */ Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */
uint32_t min_app_version; uint32_t min_app_version;
/* 24 time windows of 1hr each with the airtime transmitted out of the device per hour. */ /* Deprecated in 2.1.x (Only used on device to keep track of utilization)
24 time windows of 1hr each with the airtime transmitted out of the device per hour. */
pb_size_t air_period_tx_count; pb_size_t air_period_tx_count;
uint32_t air_period_tx[8]; uint32_t air_period_tx[8];
/* 24 time windows of 1hr each with the airtime of valid packets for your mesh. */ /* Deprecated in 2.1.x (Only used on device to keep track of utilization)
24 time windows of 1hr each with the airtime of valid packets for your mesh. */
pb_size_t air_period_rx_count; pb_size_t air_period_rx_count;
uint32_t air_period_rx[8]; uint32_t air_period_rx[8];
/* Is the device wifi capable? */ /* Deprecated in 2.1.x (Source from DeviceMetadata instead)
Is the device wifi capable? */
bool has_wifi; bool has_wifi;
/* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */ /* Deprecated in 2.1.x (Source from DeviceMetrics telemetry payloads)
Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */
float channel_utilization; float channel_utilization;
/* Percent of airtime for transmission used within the last hour. */ /* Deprecated in 2.1.x (Source from DeviceMetrics telemetry payloads)
Percent of airtime for transmission used within the last hour. */
float air_util_tx; float air_util_tx;
} meshtastic_MyNodeInfo; } meshtastic_MyNodeInfo;

View File

@ -56,7 +56,7 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
meshtastic_MeshPacket *PositionModule::allocReply() meshtastic_MeshPacket *PositionModule::allocReply()
{ {
meshtastic_NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position meshtastic_NodeInfo *node = service.refreshLocalNodeInfo(); // should guarantee there is now a position
assert(node->has_position); assert(node->has_position);
node->position.seq_number++; node->position.seq_number++;
@ -171,7 +171,7 @@ int32_t PositionModule::runOnce()
} else if (config.position.position_broadcast_smart_enabled) { } else if (config.position.position_broadcast_smart_enabled) {
// Only send packets if the channel is less than 25% utilized or we're a tracker. // Only send packets if the channel is less than 25% utilized or we're a tracker.
if (airTime->isTxAllowedChannelUtil(config.device.role != meshtastic_Config_DeviceConfig_Role_TRACKER)) { if (airTime->isTxAllowedChannelUtil(config.device.role != meshtastic_Config_DeviceConfig_Role_TRACKER)) {
meshtastic_NodeInfo *node2 = service.refreshMyNodeInfo(); // should guarantee there is now a position meshtastic_NodeInfo *node2 = service.refreshLocalNodeInfo(); // should guarantee there is now a position
if (hasValidPosition(node2)) { if (hasValidPosition(node2)) {
// The minimum distance to travel before we are able to send a new position packet. // The minimum distance to travel before we are able to send a new position packet.

View File

@ -50,14 +50,14 @@ bool DeviceTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
t.time = getTime(); t.time = getTime();
t.which_variant = meshtastic_Telemetry_device_metrics_tag; t.which_variant = meshtastic_Telemetry_device_metrics_tag;
t.variant.device_metrics.air_util_tx = myNodeInfo.air_util_tx; t.variant.device_metrics.air_util_tx = airTime->utilizationTXPercent();
if (powerStatus->getIsCharging()) { if (powerStatus->getIsCharging()) {
t.variant.device_metrics.battery_level = MAGIC_USB_BATTERY_LEVEL; t.variant.device_metrics.battery_level = MAGIC_USB_BATTERY_LEVEL;
} else { } else {
t.variant.device_metrics.battery_level = powerStatus->getBatteryChargePercent(); t.variant.device_metrics.battery_level = powerStatus->getBatteryChargePercent();
} }
t.variant.device_metrics.channel_utilization = myNodeInfo.channel_utilization; t.variant.device_metrics.channel_utilization = airTime->channelUtilizationPercent();
t.variant.device_metrics.voltage = powerStatus->getBatteryVoltageMv() / 1000.0; t.variant.device_metrics.voltage = powerStatus->getBatteryVoltageMv() / 1000.0;
LOG_INFO("(Sending): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n", LOG_INFO("(Sending): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n",
@ -78,4 +78,4 @@ bool DeviceTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
service.sendToMesh(p, RX_SRC_LOCAL, true); service.sendToMesh(p, RX_SRC_LOCAL, true);
} }
return true; return true;
} }

View File

@ -36,8 +36,6 @@ int32_t StoreForwardModule::runOnce()
this->packetHistoryTXQueue_index++; this->packetHistoryTXQueue_index++;
} }
} }
LOG_DEBUG("*** SF bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
} else if ((millis() - lastHeartbeat > (heartbeatInterval * 1000)) && airTime->isTxAllowedChannelUtil(true)) { } else if ((millis() - lastHeartbeat > (heartbeatInterval * 1000)) && airTime->isTxAllowedChannelUtil(true)) {
lastHeartbeat = millis(); lastHeartbeat = millis();
LOG_INFO("*** Sending heartbeat\n"); LOG_INFO("*** Sending heartbeat\n");
@ -266,7 +264,6 @@ ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &m
storeForwardModule->historyAdd(mp); storeForwardModule->historyAdd(mp);
LOG_INFO("*** S&F stored. Message history contains %u records now.\n", this->packetHistoryCurrent); LOG_INFO("*** S&F stored. Message history contains %u records now.\n", this->packetHistoryCurrent);
} }
} else if (mp.decoded.portnum == meshtastic_PortNum_STORE_FORWARD_APP) { } else if (mp.decoded.portnum == meshtastic_PortNum_STORE_FORWARD_APP) {
auto &p = mp.decoded; auto &p = mp.decoded;
meshtastic_StoreAndForward scratch; meshtastic_StoreAndForward scratch;