Initial PhoneAPI rate-limiting of messages on certain ports (#4756)

This commit is contained in:
Ben Meadors
2024-09-18 10:13:07 -05:00
committed by GitHub
parent 35e1c401e2
commit 777bcf691a
3 changed files with 37 additions and 1 deletions

View File

@@ -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
*