mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 10:42:49 +00:00
Initial PhoneAPI rate-limiting of messages on certain ports (#4756)
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
#include "Observer.h"
|
||||
#include "mesh-pb-constants.h"
|
||||
#include "meshtastic/portnums.pb.h"
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// Make sure that we never let our packets grow too large for one BLE packet
|
||||
@@ -48,6 +50,9 @@ class PhoneAPI
|
||||
|
||||
uint8_t config_state = 0;
|
||||
|
||||
// Hashmap of timestamps for last time we received a packet on the API per portnum
|
||||
std::unordered_map<meshtastic_PortNum, uint32_t> lastPortNumToRadio;
|
||||
|
||||
/**
|
||||
* Each packet sent to the phone has an incrementing count
|
||||
*/
|
||||
@@ -99,6 +104,11 @@ class PhoneAPI
|
||||
*/
|
||||
virtual bool handleToRadio(const uint8_t *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Send a (client)notification to the phone
|
||||
*/
|
||||
virtual void sendNotification(meshtastic_LogRecord_Level level, uint32_t replyId, const char *message);
|
||||
|
||||
/**
|
||||
* Get the next packet we want to send to the phone
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user