mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-14 22:47:18 +00:00
Portduino dynamic alloc
This commit is contained in:
parent
9211b1bb4b
commit
78dfb05eeb
@ -5,6 +5,7 @@
|
|||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "detect/LoRaRadioType.h"
|
#include "detect/LoRaRadioType.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -27,13 +28,24 @@
|
|||||||
|
|
||||||
// I think this is right, one packet for each of the three fifos + one packet being currently assembled for TX or RX
|
// I think this is right, one packet for each of the three fifos + one packet being currently assembled for TX or RX
|
||||||
// And every TX packet might have a retransmission packet or an ack alive at any moment
|
// And every TX packet might have a retransmission packet or an ack alive at any moment
|
||||||
|
|
||||||
|
#ifdef ARCH_PORTDUINO
|
||||||
|
// Portduino (native) targets can use dynamic memory pools with runtime-configurable sizes
|
||||||
#define MAX_PACKETS \
|
#define MAX_PACKETS \
|
||||||
(MAX_RX_TOPHONE + MAX_RX_FROMRADIO + 2 * MAX_TX_QUEUE + \
|
(MAX_RX_TOPHONE + MAX_RX_FROMRADIO + 2 * MAX_TX_QUEUE + \
|
||||||
2) // max number of packets which can be in flight (either queued from reception or queued for sending)
|
2) // max number of packets which can be in flight (either queued from reception or queued for sending)
|
||||||
|
|
||||||
static MemoryPool<meshtastic_MeshPacket, MAX_PACKETS> staticPool;
|
static MemoryDynamic<meshtastic_MeshPacket> dynamicPool(MAX_PACKETS);
|
||||||
|
Allocator<meshtastic_MeshPacket> &packetPool = dynamicPool;
|
||||||
|
#else
|
||||||
|
// Embedded targets use static memory pools with compile-time constants
|
||||||
|
#define MAX_PACKETS_STATIC \
|
||||||
|
(MAX_RX_TOPHONE + MAX_RX_FROMRADIO + 2 * MAX_TX_QUEUE + \
|
||||||
|
2) // max number of packets which can be in flight (either queued from reception or queued for sending)
|
||||||
|
|
||||||
|
static MemoryPool<meshtastic_MeshPacket, MAX_PACKETS_STATIC> staticPool;
|
||||||
Allocator<meshtastic_MeshPacket> &packetPool = staticPool;
|
Allocator<meshtastic_MeshPacket> &packetPool = staticPool;
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint8_t bytes[MAX_LORA_PAYLOAD_LEN + 1] __attribute__((__aligned__));
|
static uint8_t bytes[MAX_LORA_PAYLOAD_LEN + 1] __attribute__((__aligned__));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user