Compare commits

...

3 Commits

Author SHA1 Message Date
Jonathan Bennett
845088e45b
Add 100 msecond delay in tft_task_handler when deviceScreen is null (#6695)
Some checks are pending
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (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 (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 (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
* Add 100 msecond delay in tft_task_handler when deviceScreen is null, to fix 100% usage bug

* move portduino tft task creation into tftSetup

* remove superfluous check

* update platform-native commit

---------

Co-authored-by: mverch67 <manuel.verch@gmx.de>
2025-04-30 06:17:24 -05:00
Ben Meadors
e0b1fdb5e8
Rate limit waypoints and alerts and increase to allow every 10 seconds instead of 5 (#6699)
* Rate limit waypoints and alerts and increase to allow every 10 seconds instead of 5.

* Update src/mesh/PhoneAPI.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Doot

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-30 06:08:10 -05:00
Jorropo
a7ef9e9c08
udp-multicast: remove the thread from the multicast thread API (#6685)
* udp-multicast: remove the thread from the multicast thread API

The whole API is parallel & asynchronous we don't need to start a thread ourself,
the implementation probably does when we call start listening already.

* Take copilot advice and call it a handler

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2025-04-30 05:52:42 -05:00
9 changed files with 30 additions and 33 deletions

View File

@ -2,7 +2,7 @@
[portduino_base] [portduino_base]
platform = platform =
# renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop # renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop
https://github.com/meshtastic/platform-native/archive/e19f77e034590669feaaf26214667b76d0821d06.zip https://github.com/meshtastic/platform-native/archive/622341c6de8a239704318b10c3dbb00c21a3eab3.zip
framework = arduino framework = arduino
build_src_filter = build_src_filter =

View File

@ -11,6 +11,7 @@
#ifdef ARCH_PORTDUINO #ifdef ARCH_PORTDUINO
#include "PortduinoGlue.h" #include "PortduinoGlue.h"
#include <thread>
#endif #endif
DeviceScreen *deviceScreen = nullptr; DeviceScreen *deviceScreen = nullptr;
@ -26,12 +27,10 @@ CallbackObserver<DeviceScreen, esp_sleep_wakeup_cause_t> endSleepObserver =
void tft_task_handler(void *param = nullptr) void tft_task_handler(void *param = nullptr)
{ {
while (true) { while (true) {
if (deviceScreen) { spiLock->lock();
spiLock->lock(); deviceScreen->task_handler();
deviceScreen->task_handler(); spiLock->unlock();
spiLock->unlock(); deviceScreen->sleep();
deviceScreen->sleep();
}
} }
} }
@ -116,11 +115,15 @@ void tftSetup(void)
} }
#endif #endif
if (deviceScreen) {
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
tftSleepObserver.observe(&notifyLightSleep); tftSleepObserver.observe(&notifyLightSleep);
endSleepObserver.observe(&notifyLightSleepEnd); endSleepObserver.observe(&notifyLightSleepEnd);
xTaskCreatePinnedToCore(tft_task_handler, "tft", 10240, NULL, 1, NULL, 0); xTaskCreatePinnedToCore(tft_task_handler, "tft", 10240, NULL, 1, NULL, 0);
#elif defined(ARCH_PORTDUINO)
std::thread *tft_task = new std::thread([] { tft_task_handler(); });
#endif #endif
}
} }
#endif #endif

View File

@ -124,8 +124,8 @@ extern void tftSetup(void);
#endif #endif
#ifdef HAS_UDP_MULTICAST #ifdef HAS_UDP_MULTICAST
#include "mesh/udp/UdpMulticastThread.h" #include "mesh/udp/UdpMulticastHandler.h"
UdpMulticastThread *udpThread = nullptr; UdpMulticastHandler *udpHandler = nullptr;
#endif #endif
#if defined(TCXO_OPTIONAL) #if defined(TCXO_OPTIONAL)
@ -918,12 +918,12 @@ void setup()
#ifdef HAS_UDP_MULTICAST #ifdef HAS_UDP_MULTICAST
LOG_DEBUG("Start multicast thread"); LOG_DEBUG("Start multicast thread");
udpThread = new UdpMulticastThread(); udpHandler = new UdpMulticastHandler();
#ifdef ARCH_PORTDUINO #ifdef ARCH_PORTDUINO
// FIXME: portduino does not ever call onNetworkConnected so call it here because I don't know what happen if I call // FIXME: portduino does not ever call onNetworkConnected so call it here because I don't know what happen if I call
// onNetworkConnected there // onNetworkConnected there
if (config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) { if (config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) {
udpThread->start(); udpHandler->start();
} }
#endif #endif
#endif #endif

View File

@ -51,8 +51,8 @@ extern AudioThread *audioThread;
#endif #endif
#ifdef HAS_UDP_MULTICAST #ifdef HAS_UDP_MULTICAST
#include "mesh/udp/UdpMulticastThread.h" #include "mesh/udp/UdpMulticastHandler.h"
extern UdpMulticastThread *udpThread; extern UdpMulticastHandler *udpHandler;
#endif #endif
// Global Screen singleton. // Global Screen singleton.

View File

@ -6,6 +6,7 @@
#define ONE_MINUTE_MS 60 * 1000 #define ONE_MINUTE_MS 60 * 1000
#define THIRTY_SECONDS_MS 30 * 1000 #define THIRTY_SECONDS_MS 30 * 1000
#define FIVE_SECONDS_MS 5 * 1000 #define FIVE_SECONDS_MS 5 * 1000
#define TEN_SECONDS_MS 10 * 1000
#define min_default_telemetry_interval_secs 30 * 60 #define min_default_telemetry_interval_secs 30 * 60
#define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60) #define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60)

View File

@ -649,8 +649,10 @@ bool PhoneAPI::handleToRadioPacket(meshtastic_MeshPacket &p)
meshtastic_QueueStatus qs = router->getQueueStatus(); meshtastic_QueueStatus qs = router->getQueueStatus();
service->sendQueueStatusToPhone(qs, 0, p.id); service->sendQueueStatusToPhone(qs, 0, p.id);
return false; return false;
} else if (p.decoded.portnum == meshtastic_PortNum_POSITION_APP && lastPortNumToRadio[p.decoded.portnum] && } else if (IS_ONE_OF(meshtastic_PortNum_POSITION_APP, meshtastic_PortNum_WAYPOINT_APP, meshtastic_PortNum_ALERT_APP) &&
Throttle::isWithinTimespanMs(lastPortNumToRadio[p.decoded.portnum], FIVE_SECONDS_MS)) { lastPortNumToRadio[p.decoded.portnum] &&
Throttle::isWithinTimespanMs(lastPortNumToRadio[p.decoded.portnum], TEN_SECONDS_MS)) {
// TODO: [Issue #6700] Make this rate limit throttling scale up / down with the preset
LOG_WARN("Rate limit portnum %d", p.decoded.portnum); LOG_WARN("Rate limit portnum %d", p.decoded.portnum);
meshtastic_QueueStatus qs = router->getQueueStatus(); meshtastic_QueueStatus qs = router->getQueueStatus();
service->sendQueueStatusToPhone(qs, 0, p.id); service->sendQueueStatusToPhone(qs, 0, p.id);

View File

@ -293,8 +293,8 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
} }
#if HAS_UDP_MULTICAST #if HAS_UDP_MULTICAST
if (udpThread && config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) { if (udpHandler && config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) {
udpThread->onSend(const_cast<meshtastic_MeshPacket *>(p)); udpHandler->onSend(const_cast<meshtastic_MeshPacket *>(p));
} }
#endif #endif

View File

@ -13,12 +13,11 @@
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#define UDP_MULTICAST_DEFAUL_PORT 4403 // Default port for UDP multicast is same as TCP api server #define UDP_MULTICAST_DEFAUL_PORT 4403 // Default port for UDP multicast is same as TCP api server
#define UDP_MULTICAST_THREAD_INTERVAL_MS 15000
class UdpMulticastThread : public concurrency::OSThread class UdpMulticastHandler final
{ {
public: public:
UdpMulticastThread() : OSThread("UdpMulticast") { udpIpAddress = IPAddress(224, 0, 0, 69); } UdpMulticastHandler() { udpIpAddress = IPAddress(224, 0, 0, 69); }
void start() void start()
{ {
@ -71,14 +70,6 @@ class UdpMulticastThread : public concurrency::OSThread
return true; return true;
} }
protected:
int32_t runOnce() override
{
canSleep = true;
// TODO: Implement nodeinfo broadcast
return UDP_MULTICAST_THREAD_INTERVAL_MS;
}
private: private:
IPAddress udpIpAddress; IPAddress udpIpAddress;
AsyncUDP udp; AsyncUDP udp;

View File

@ -133,8 +133,8 @@ static void onNetworkConnected()
} }
#if HAS_UDP_MULTICAST #if HAS_UDP_MULTICAST
if (udpThread && config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) { if (udpHandler && config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) {
udpThread->start(); udpHandler->start();
} }
#endif #endif
} }