Experiment: C++17 support (#9874)
* Add C++17 support * Add C++17 runtime probes and update build configurations for STM32 and Portduino * Remove unflags * Update C++ standard flags across the platforms * Convert a couple of instances to structured bindings * NRF52 platform.txt to add C++17 support * Still need the unflags apparently * Remove C++17 runtime probe tests from test_main.cpp * Reconfigured doesnt need a nodiscard * Remove nodiscard attribute from init() method in RadioInterface * Remove mbedtls/error.h from build flags Removed include directive for mbedtls/error.h from build flags. * Fix IRAM overflow * Fix IRAM overflow * Add build flag to exclude MQTT from rak11200 * Update C++ standard from gnu17 to gnu++17
This commit is contained in:
@@ -23,7 +23,7 @@ ErrorCode NextHopRouter::send(meshtastic_MeshPacket *p)
|
||||
p->relay_node = nodeDB->getLastByteOfNodeNum(getNodeNum()); // First set the relayer to us
|
||||
wasSeenRecently(p); // FIXME, move this to a sniffSent method
|
||||
|
||||
p->next_hop = getNextHop(p->to, p->relay_node); // set the next hop
|
||||
p->next_hop = getNextHop(p->to, p->relay_node).value_or(NO_NEXT_HOP_PREFERENCE); // set the next hop
|
||||
LOG_DEBUG("Setting next hop for packet with dest %x to %x", p->to, p->next_hop);
|
||||
|
||||
// If it's from us, ReliableRouter already handles retransmissions if want_ack is set. If a next hop is set and hop limit is
|
||||
@@ -170,10 +170,10 @@ bool NextHopRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
|
||||
* Get the next hop for a destination, given the relay node
|
||||
* @return the node number of the next hop, 0 if no preference (fallback to FloodingRouter)
|
||||
*/
|
||||
uint8_t NextHopRouter::getNextHop(NodeNum to, uint8_t relay_node)
|
||||
std::optional<uint8_t> NextHopRouter::getNextHop(NodeNum to, uint8_t relay_node)
|
||||
{
|
||||
if (isBroadcast(to))
|
||||
return NO_NEXT_HOP_PREFERENCE;
|
||||
return std::nullopt;
|
||||
|
||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(to);
|
||||
if (node && node->next_hop) {
|
||||
@@ -184,7 +184,7 @@ uint8_t NextHopRouter::getNextHop(NodeNum to, uint8_t relay_node)
|
||||
} else
|
||||
LOG_WARN("Next hop for 0x%x is 0x%x, same as relayer; set no pref", to, node->next_hop);
|
||||
}
|
||||
return NO_NEXT_HOP_PREFERENCE;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
PendingPacket *NextHopRouter::findPendingPacket(GlobalPacketId key)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "FloodingRouter.h"
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
|
||||
/**
|
||||
@@ -146,7 +147,7 @@ class NextHopRouter : public FloodingRouter
|
||||
* Get the next hop for a destination, given the relay node
|
||||
* @return the node number of the next hop, 0 if no preference (fallback to FloodingRouter)
|
||||
*/
|
||||
uint8_t getNextHop(NodeNum to, uint8_t relay_node);
|
||||
std::optional<uint8_t> getNextHop(NodeNum to, uint8_t relay_node);
|
||||
|
||||
/** Check if we should be rebroadcasting this packet if so, do so.
|
||||
* @return true if we did rebroadcast */
|
||||
|
||||
+12
-12
@@ -156,7 +156,7 @@ class RadioInterface
|
||||
virtual ErrorCode send(meshtastic_MeshPacket *p) = 0;
|
||||
|
||||
/** Return TX queue status */
|
||||
virtual meshtastic_QueueStatus getQueueStatus()
|
||||
[[nodiscard]] virtual meshtastic_QueueStatus getQueueStatus()
|
||||
{
|
||||
meshtastic_QueueStatus qs;
|
||||
qs.res = qs.mesh_packet_id = qs.free = qs.maxlen = 0;
|
||||
@@ -182,22 +182,22 @@ class RadioInterface
|
||||
virtual bool reconfigure();
|
||||
|
||||
/** The delay to use for retransmitting dropped packets */
|
||||
uint32_t getRetransmissionMsec(const meshtastic_MeshPacket *p);
|
||||
[[nodiscard]] uint32_t getRetransmissionMsec(const meshtastic_MeshPacket *p);
|
||||
|
||||
/** The delay to use when we want to send something */
|
||||
uint32_t getTxDelayMsec();
|
||||
[[nodiscard]] uint32_t getTxDelayMsec();
|
||||
|
||||
/** The CW to use when calculating SNR_based delays */
|
||||
uint8_t getCWsize(float snr);
|
||||
[[nodiscard]] uint8_t getCWsize(float snr);
|
||||
|
||||
/** The worst-case SNR_based packet delay */
|
||||
uint32_t getTxDelayMsecWeightedWorst(float snr);
|
||||
[[nodiscard]] uint32_t getTxDelayMsecWeightedWorst(float snr);
|
||||
|
||||
/** Returns true if we should rebroadcast early like a ROUTER */
|
||||
bool shouldRebroadcastEarlyLikeRouter(meshtastic_MeshPacket *p);
|
||||
[[nodiscard]] bool shouldRebroadcastEarlyLikeRouter(meshtastic_MeshPacket *p);
|
||||
|
||||
/** The delay to use when we want to flood a message. Use a weighted scale based on SNR */
|
||||
uint32_t getTxDelayMsecWeighted(meshtastic_MeshPacket *p);
|
||||
[[nodiscard]] uint32_t getTxDelayMsecWeighted(meshtastic_MeshPacket *p);
|
||||
|
||||
/** If the packet is not already in the late rebroadcast window, move it there */
|
||||
virtual void clampToLateRebroadcastWindow(NodeNum from, PacketId id) { return; }
|
||||
@@ -215,18 +215,18 @@ class RadioInterface
|
||||
*
|
||||
* @return num msecs for the packet
|
||||
*/
|
||||
uint32_t getPacketTime(const meshtastic_MeshPacket *p, bool received = false);
|
||||
virtual uint32_t getPacketTime(uint32_t totalPacketLen, bool received = false) = 0;
|
||||
[[nodiscard]] uint32_t getPacketTime(const meshtastic_MeshPacket *p, bool received = false);
|
||||
[[nodiscard]] virtual uint32_t getPacketTime(uint32_t totalPacketLen, bool received = false) = 0;
|
||||
|
||||
/**
|
||||
* Get the channel we saved.
|
||||
*/
|
||||
uint32_t getChannelNum();
|
||||
[[nodiscard]] uint32_t getChannelNum();
|
||||
|
||||
/**
|
||||
* Get the frequency we saved.
|
||||
*/
|
||||
virtual float getFreq();
|
||||
[[nodiscard]] virtual float getFreq();
|
||||
|
||||
/// Some boards (1st gen Pinetab Lora module) have broken IRQ wires, so we need to poll via i2c registers
|
||||
virtual bool isIRQPending() { return false; }
|
||||
@@ -246,7 +246,7 @@ class RadioInterface
|
||||
*
|
||||
* Used as the first step of
|
||||
*/
|
||||
size_t beginSending(meshtastic_MeshPacket *p);
|
||||
[[nodiscard]] size_t beginSending(meshtastic_MeshPacket *p);
|
||||
|
||||
/**
|
||||
* Some regulatory regions limit xmit power.
|
||||
|
||||
+3
-3
@@ -58,14 +58,14 @@ class Router : protected concurrency::OSThread, protected PacketHistory
|
||||
/** Allocate and return a meshpacket which defaults as send to broadcast from the current node.
|
||||
* The returned packet is guaranteed to have a unique packet ID already assigned
|
||||
*/
|
||||
meshtastic_MeshPacket *allocForSending();
|
||||
[[nodiscard]] meshtastic_MeshPacket *allocForSending();
|
||||
|
||||
/** Return Underlying interface's TX queue status */
|
||||
meshtastic_QueueStatus getQueueStatus();
|
||||
[[nodiscard]] meshtastic_QueueStatus getQueueStatus();
|
||||
|
||||
/**
|
||||
* @return our local nodenum */
|
||||
NodeNum getNodeNum();
|
||||
[[nodiscard]] NodeNum getNodeNum();
|
||||
|
||||
/** Wake up the router thread ASAP, because we just queued a message for it.
|
||||
* FIXME, this is kinda a hack because we don't have a nice way yet to say 'wake us because we are 'blocked on this queue'
|
||||
|
||||
@@ -141,12 +141,12 @@ bool TransmitHistory::saveToDisk()
|
||||
file.write((uint8_t *)&header, sizeof(header));
|
||||
|
||||
uint8_t written = 0;
|
||||
for (auto &pair : history) {
|
||||
for (const auto &[key, epochSeconds] : history) {
|
||||
if (written >= MAX_ENTRIES)
|
||||
break;
|
||||
Entry entry{};
|
||||
entry.key = pair.first;
|
||||
entry.epochSeconds = pair.second;
|
||||
entry.key = key;
|
||||
entry.epochSeconds = epochSeconds;
|
||||
file.write((uint8_t *)&entry, sizeof(entry));
|
||||
written++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user