mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-14 14:31:24 +00:00
Merge pull request #7969 from meshtastic/master
Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (rp2350) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / version (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32s3 (push) Blocked by required conditions
CI / build-esp32c3 (push) Blocked by required conditions
CI / build-esp32c6 (push) Blocked by required conditions
CI / build-nrf52840 (push) Blocked by required conditions
CI / build-rp2040 (push) Blocked by required conditions
CI / build-rp2350 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (rp2350) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (rp2350) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (rp2350) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / version (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32s3 (push) Blocked by required conditions
CI / build-esp32c3 (push) Blocked by required conditions
CI / build-esp32c6 (push) Blocked by required conditions
CI / build-nrf52840 (push) Blocked by required conditions
CI / build-rp2040 (push) Blocked by required conditions
CI / build-rp2350 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (rp2350) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (rp2350) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
Backmerge
This commit is contained in:
commit
e6bfc4a97a
@ -6,6 +6,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "PointerQueue.h"
|
#include "PointerQueue.h"
|
||||||
|
#include "configuration.h" // For LOG_WARN, LOG_DEBUG, LOG_HEAP
|
||||||
|
|
||||||
template <class T> class Allocator
|
template <class T> class Allocator
|
||||||
{
|
{
|
||||||
@ -14,13 +15,14 @@ template <class T> class Allocator
|
|||||||
Allocator() : deleter([this](T *p) { this->release(p); }) {}
|
Allocator() : deleter([this](T *p) { this->release(p); }) {}
|
||||||
virtual ~Allocator() {}
|
virtual ~Allocator() {}
|
||||||
|
|
||||||
/// Return a queable object which has been prefilled with zeros. Panic if no buffer is available
|
/// Return a queable object which has been prefilled with zeros. Return nullptr if no buffer is available
|
||||||
/// Note: this method is safe to call from regular OR ISR code
|
/// Note: this method is safe to call from regular OR ISR code
|
||||||
T *allocZeroed()
|
T *allocZeroed()
|
||||||
{
|
{
|
||||||
T *p = allocZeroed(0);
|
T *p = allocZeroed(0);
|
||||||
|
if (!p) {
|
||||||
assert(p); // FIXME panic instead
|
LOG_WARN("Failed to allocate zeroed memory");
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,9 +41,11 @@ template <class T> class Allocator
|
|||||||
T *allocCopy(const T &src, TickType_t maxWait = portMAX_DELAY)
|
T *allocCopy(const T &src, TickType_t maxWait = portMAX_DELAY)
|
||||||
{
|
{
|
||||||
T *p = alloc(maxWait);
|
T *p = alloc(maxWait);
|
||||||
assert(p);
|
if (!p) {
|
||||||
|
LOG_WARN("Failed to allocate memory for copy");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (p)
|
|
||||||
*p = src;
|
*p = src;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -83,7 +87,9 @@ template <class T> class MemoryDynamic : public Allocator<T>
|
|||||||
/// Return a buffer for use by others
|
/// Return a buffer for use by others
|
||||||
virtual void release(T *p) override
|
virtual void release(T *p) override
|
||||||
{
|
{
|
||||||
assert(p);
|
if (p == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
LOG_HEAP("Freeing 0x%x", p);
|
LOG_HEAP("Freeing 0x%x", p);
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
@ -98,3 +104,59 @@ template <class T> class MemoryDynamic : public Allocator<T>
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A static memory pool that uses a fixed buffer instead of heap allocation
|
||||||
|
*/
|
||||||
|
template <class T, int MaxSize> class MemoryPool : public Allocator<T>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
T pool[MaxSize];
|
||||||
|
bool used[MaxSize];
|
||||||
|
|
||||||
|
public:
|
||||||
|
MemoryPool()
|
||||||
|
{
|
||||||
|
// Initialize the used array to false (all slots free)
|
||||||
|
for (int i = 0; i < MaxSize; i++) {
|
||||||
|
used[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return a buffer for use by others
|
||||||
|
virtual void release(T *p) override
|
||||||
|
{
|
||||||
|
if (!p) {
|
||||||
|
LOG_DEBUG("Failed to release memory, pointer is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the index of this pointer in our pool
|
||||||
|
int index = p - pool;
|
||||||
|
if (index >= 0 && index < MaxSize) {
|
||||||
|
assert(used[index]); // Should be marked as used
|
||||||
|
used[index] = false;
|
||||||
|
LOG_HEAP("Released static pool item %d at 0x%x", index, p);
|
||||||
|
} else {
|
||||||
|
LOG_WARN("Pointer 0x%x not from our pool!", p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Alloc some storage from our static pool
|
||||||
|
virtual T *alloc(TickType_t maxWait) override
|
||||||
|
{
|
||||||
|
// Find first free slot
|
||||||
|
for (int i = 0; i < MaxSize; i++) {
|
||||||
|
if (!used[i]) {
|
||||||
|
used[i] = true;
|
||||||
|
LOG_HEAP("Allocated static pool item %d at 0x%x", i, &pool[i]);
|
||||||
|
return &pool[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No free slots available - return nullptr instead of asserting
|
||||||
|
LOG_WARN("No free slots available in static memory pool!");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -100,7 +100,6 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
|
|||||||
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
|
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
|
||||||
auto ourNodeNum = nodeDB->getNodeNum();
|
auto ourNodeNum = nodeDB->getNodeNum();
|
||||||
bool toUs = isBroadcast(mp.to) || isToUs(&mp);
|
bool toUs = isBroadcast(mp.to) || isToUs(&mp);
|
||||||
bool fromUs = mp.from == ourNodeNum;
|
|
||||||
|
|
||||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||||
auto &pi = **i;
|
auto &pi = **i;
|
||||||
|
@ -662,7 +662,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
|||||||
|
|
||||||
// call modules here
|
// call modules here
|
||||||
// If this could be a spoofed packet, don't let the modules see it.
|
// If this could be a spoofed packet, don't let the modules see it.
|
||||||
if (!skipHandle && p->from != nodeDB->getNodeNum()) {
|
if (!skipHandle) {
|
||||||
MeshModule::callModules(*p, src);
|
MeshModule::callModules(*p, src);
|
||||||
|
|
||||||
#if !MESHTASTIC_EXCLUDE_MQTT
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
@ -676,8 +676,6 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
|||||||
!isFromUs(p) && mqtt)
|
!isFromUs(p) && mqtt)
|
||||||
mqtt->onSend(*p_encrypted, *p, p->channel);
|
mqtt->onSend(*p_encrypted, *p, p->channel);
|
||||||
#endif
|
#endif
|
||||||
} else if (p->from == nodeDB->getNodeNum() && !skipHandle) {
|
|
||||||
MeshModule::callModules(*p, src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packetPool.release(p_encrypted); // Release the encrypted packet
|
packetPool.release(p_encrypted); // Release the encrypted packet
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
/// max number of ClientNotification packets which can be waiting for delivery to phone
|
/// max number of ClientNotification packets which can be waiting for delivery to phone
|
||||||
#ifndef MAX_RX_NOTIFICATION_TOPHONE
|
#ifndef MAX_RX_NOTIFICATION_TOPHONE
|
||||||
#define MAX_RX_NOTIFICATION_TOPHONE 4
|
#define MAX_RX_NOTIFICATION_TOPHONE 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Verify baseline assumption of node size. If it increases, we need to reevaluate
|
/// Verify baseline assumption of node size. If it increases, we need to reevaluate
|
||||||
|
@ -12,12 +12,12 @@ NodeInfoModule *nodeInfoModule;
|
|||||||
|
|
||||||
bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_User *pptr)
|
bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_User *pptr)
|
||||||
{
|
{
|
||||||
auto p = *pptr;
|
|
||||||
|
|
||||||
if (mp.from == nodeDB->getNodeNum()) {
|
if (mp.from == nodeDB->getNodeNum()) {
|
||||||
LOG_WARN("Ignoring packet supposed to be from our own node: %08x", mp.from);
|
LOG_WARN("Ignoring packet supposed to be from our own node: %08x", mp.from);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto p = *pptr;
|
||||||
if (p.is_licensed != owner.is_licensed) {
|
if (p.is_licensed != owner.is_licensed) {
|
||||||
LOG_WARN("Invalid nodeInfo detected, is_licensed mismatch!");
|
LOG_WARN("Invalid nodeInfo detected, is_licensed mismatch!");
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user