mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 10:42:49 +00:00
Make SPI frequency and TOPHONE queue size configurable on Native (#4369)
* Make SPI frequency configurable on Native * Make the tophone queue size configurable for Portduino * The modified SPISettings must be configured in setup(), after config.yaml is processed * make MeshService a pointer, so we can configure MAX_RX_TOPHONE at run time * Got a little over excited with refactoring * Silence a warning
This commit is contained in:
@@ -170,7 +170,7 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
|
||||
if (isDecoded && mp.decoded.want_response && toUs) {
|
||||
if (currentReply) {
|
||||
printPacket("Sending response", currentReply);
|
||||
service.sendToMesh(currentReply);
|
||||
service->sendToMesh(currentReply);
|
||||
currentReply = NULL;
|
||||
} else if (mp.from != ourNodeNum && !ignoreRequest) {
|
||||
// Note: if the message started with the local node or a module asked to ignore the request, we don't want to send a
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
#include "nimble/NimbleBluetooth.h"
|
||||
#endif
|
||||
|
||||
#if ARCH_PORTDUINO
|
||||
#include "PortduinoGlue.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
receivedPacketQueue - this is a queue of messages we've received from the mesh, which we are keeping to deliver to the phone.
|
||||
It is implemented with a FreeRTos queue (wrapped with a little RTQueue class) of pointers to MeshPacket protobufs (which were
|
||||
@@ -53,7 +57,7 @@ nodenum (filtering against whatever it knows about the nodedb) and rebroadcast t
|
||||
FIXME in the initial proof of concept we just skip the entire want/deny flow and just hand pick node numbers at first.
|
||||
*/
|
||||
|
||||
MeshService service;
|
||||
MeshService *service;
|
||||
|
||||
static MemoryDynamic<meshtastic_MqttClientProxyMessage> staticMqttClientProxyMessagePool;
|
||||
|
||||
|
||||
@@ -150,4 +150,4 @@ class MeshService
|
||||
friend class RoutingModule;
|
||||
};
|
||||
|
||||
extern MeshService service;
|
||||
extern MeshService *service;
|
||||
@@ -41,7 +41,7 @@ void PhoneAPI::handleStartConfig()
|
||||
// Must be before setting state (because state is how we know !connected)
|
||||
if (!isConnected()) {
|
||||
onConnectionChanged(true);
|
||||
observe(&service.fromNumChanged);
|
||||
observe(&service->fromNumChanged);
|
||||
#ifdef FSCom
|
||||
observe(&xModem.packetReady);
|
||||
#endif
|
||||
@@ -63,7 +63,7 @@ void PhoneAPI::close()
|
||||
if (state != STATE_SEND_NOTHING) {
|
||||
state = STATE_SEND_NOTHING;
|
||||
|
||||
unobserve(&service.fromNumChanged);
|
||||
unobserve(&service->fromNumChanged);
|
||||
#ifdef FSCom
|
||||
unobserve(&xModem.packetReady);
|
||||
#endif
|
||||
@@ -186,7 +186,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
fromRadioScratch.my_info = myNodeInfo;
|
||||
state = STATE_SEND_OWN_NODEINFO;
|
||||
|
||||
service.refreshLocalMeshNode(); // Update my NodeInfo because the client will be asking for it soon.
|
||||
service->refreshLocalMeshNode(); // Update my NodeInfo because the client will be asking for it soon.
|
||||
break;
|
||||
|
||||
case STATE_SEND_OWN_NODEINFO: {
|
||||
@@ -443,7 +443,7 @@ void PhoneAPI::handleDisconnect()
|
||||
void PhoneAPI::releasePhonePacket()
|
||||
{
|
||||
if (packetForPhone) {
|
||||
service.releaseToPool(packetForPhone); // we just copied the bytes, so don't need this buffer anymore
|
||||
service->releaseToPool(packetForPhone); // we just copied the bytes, so don't need this buffer anymore
|
||||
packetForPhone = NULL;
|
||||
}
|
||||
}
|
||||
@@ -451,7 +451,7 @@ void PhoneAPI::releasePhonePacket()
|
||||
void PhoneAPI::releaseQueueStatusPhonePacket()
|
||||
{
|
||||
if (queueStatusPacketForPhone) {
|
||||
service.releaseQueueStatusToPool(queueStatusPacketForPhone);
|
||||
service->releaseQueueStatusToPool(queueStatusPacketForPhone);
|
||||
queueStatusPacketForPhone = NULL;
|
||||
}
|
||||
}
|
||||
@@ -459,7 +459,7 @@ void PhoneAPI::releaseQueueStatusPhonePacket()
|
||||
void PhoneAPI::releaseMqttClientProxyPhonePacket()
|
||||
{
|
||||
if (mqttClientProxyMessageForPhone) {
|
||||
service.releaseMqttClientProxyMessageToPool(mqttClientProxyMessageForPhone);
|
||||
service->releaseMqttClientProxyMessageToPool(mqttClientProxyMessageForPhone);
|
||||
mqttClientProxyMessageForPhone = NULL;
|
||||
}
|
||||
}
|
||||
@@ -495,9 +495,9 @@ bool PhoneAPI::available()
|
||||
return true; // Always say we have something, because we might need to advance our state machine
|
||||
case STATE_SEND_PACKETS: {
|
||||
if (!queueStatusPacketForPhone)
|
||||
queueStatusPacketForPhone = service.getQueueStatusForPhone();
|
||||
queueStatusPacketForPhone = service->getQueueStatusForPhone();
|
||||
if (!mqttClientProxyMessageForPhone)
|
||||
mqttClientProxyMessageForPhone = service.getMqttClientProxyMessageForPhone();
|
||||
mqttClientProxyMessageForPhone = service->getMqttClientProxyMessageForPhone();
|
||||
bool hasPacket = !!queueStatusPacketForPhone || !!mqttClientProxyMessageForPhone;
|
||||
if (hasPacket)
|
||||
return true;
|
||||
@@ -520,7 +520,7 @@ bool PhoneAPI::available()
|
||||
#endif
|
||||
|
||||
if (!packetForPhone)
|
||||
packetForPhone = service.getForPhone();
|
||||
packetForPhone = service->getForPhone();
|
||||
hasPacket = !!packetForPhone;
|
||||
// LOG_DEBUG("available hasPacket=%d\n", hasPacket);
|
||||
return hasPacket;
|
||||
@@ -538,7 +538,7 @@ bool PhoneAPI::available()
|
||||
bool PhoneAPI::handleToRadioPacket(meshtastic_MeshPacket &p)
|
||||
{
|
||||
printPacket("PACKET FROM PHONE", &p);
|
||||
service.handleToRadio(p);
|
||||
service->handleToRadio(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
||||
/**
|
||||
* Return a mesh packet which has been preinited with a particular protobuf data payload and port number.
|
||||
* You can then send this packet (after customizing any of the payload fields you might need) with
|
||||
* service.sendToMesh()
|
||||
* service->sendToMesh()
|
||||
*/
|
||||
meshtastic_MeshPacket *allocDataProtobuf(const T &payload)
|
||||
{
|
||||
|
||||
@@ -334,7 +334,7 @@ bool RadioInterface::init()
|
||||
{
|
||||
LOG_INFO("Starting meshradio init...\n");
|
||||
|
||||
configChangedObserver.observe(&service.configChanged);
|
||||
configChangedObserver.observe(&service->configChanged);
|
||||
preflightSleepObserver.observe(&preflightSleep);
|
||||
notifyDeepSleepObserver.observe(¬ifyDeepSleep);
|
||||
|
||||
@@ -585,4 +585,4 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
|
||||
|
||||
sendingPacket = p;
|
||||
return p->encrypted.size + sizeof(PacketHeader);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class SinglePortModule : public MeshModule
|
||||
/**
|
||||
* Return a mesh packet which has been preinited as a data packet with a particular port number.
|
||||
* You can then send this packet (after customizing any of the payload fields you might need) with
|
||||
* service.sendToMesh()
|
||||
* service->sendToMesh()
|
||||
*/
|
||||
meshtastic_MeshPacket *allocDataPacket()
|
||||
{
|
||||
@@ -36,4 +36,4 @@ class SinglePortModule : public MeshModule
|
||||
|
||||
return p;
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -14,7 +14,9 @@
|
||||
/// max number of packets which can be waiting for delivery to android - note, this value comes from mesh.options protobuf
|
||||
// FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in
|
||||
// RAM #define MAX_RX_TOPHONE (member_size(DeviceState, receive_queue) / member_size(DeviceState, receive_queue[0]))
|
||||
#ifndef MAX_RX_TOPHONE
|
||||
#define MAX_RX_TOPHONE 32
|
||||
#endif
|
||||
|
||||
/// max number of nodes allowed in the mesh
|
||||
#ifndef MAX_NUM_NODES
|
||||
|
||||
Reference in New Issue
Block a user