re-add namespacing in protobufs. Let's see what i missed. Portduino likely ...

Checking in generated on purpose.
This commit is contained in:
Thomas Göttgens
2023-01-21 18:22:19 +01:00
parent ab3446faed
commit 6fdb93cd16
157 changed files with 2770 additions and 2770 deletions

View File

@@ -115,7 +115,7 @@ void run_codec2(void *parameter)
}
}
AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule")
AudioModule::AudioModule() : SinglePortModule("AudioModule", meshtastic_PortNum_AUDIO_APP), concurrency::OSThread("AudioModule")
{
// moduleConfig.audio.codec2_enabled = true;
// moduleConfig.audio.i2s_ws = 13;
@@ -132,7 +132,7 @@ AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP),
tx_header.mode = (moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1;
codec2_set_lpc_post_filter(codec2, 1, 0, 0.8, 0.2);
encode_codec_size = (codec2_bits_per_frame(codec2) + 7) / 8;
encode_frame_num = (Constants_DATA_PAYLOAD_LEN - sizeof(tx_header)) / encode_codec_size;
encode_frame_num = (meshtastic_Constants_DATA_PAYLOAD_LEN - sizeof(tx_header)) / encode_codec_size;
encode_frame_size = encode_frame_num * encode_codec_size; // max 233 bytes + 4 header bytes
adc_buffer_size = codec2_samples_per_frame(codec2);
LOG_INFO(" using %d frames of %d bytes for a total payload length of %d bytes\n", encode_frame_num, encode_codec_size,
@@ -263,7 +263,7 @@ int32_t AudioModule::runOnce()
}
}
MeshPacket *AudioModule::allocReply()
meshtastic_MeshPacket *AudioModule::allocReply()
{
auto reply = allocDataPacket();
return reply;
@@ -279,12 +279,12 @@ bool AudioModule::shouldDraw()
void AudioModule::sendPayload(NodeNum dest, bool wantReplies)
{
MeshPacket *p = allocReply();
meshtastic_MeshPacket *p = allocReply();
p->to = dest;
p->decoded.want_response = wantReplies;
p->want_ack = false; // Audio is shoot&forget. No need to wait for ACKs.
p->priority = MeshPacket_Priority_MAX; // Audio is important, because realtime
p->priority = meshtastic_MeshPacket_Priority_MAX; // Audio is important, because realtime
p->decoded.payload.size = tx_encode_frame_index;
memcpy(p->decoded.payload.bytes, tx_encode_frame, p->decoded.payload.size);
@@ -292,7 +292,7 @@ void AudioModule::sendPayload(NodeNum dest, bool wantReplies)
service.sendToMesh(p);
}
ProcessMessage AudioModule::handleReceived(const MeshPacket &mp)
ProcessMessage AudioModule::handleReceived(const meshtastic_MeshPacket &mp)
{
if ((moduleConfig.audio.codec2_enabled) && (myRegion->audioPermitted)) {
auto &p = mp.decoded;

View File

@@ -28,13 +28,13 @@ struct c2_header {
#define I2S_PORT I2S_NUM_0
#define AUDIO_MODULE_RX_BUFFER 128
#define AUDIO_MODULE_MODE ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700
#define AUDIO_MODULE_MODE meshtastic_ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700
class AudioModule : public SinglePortModule, public Observable<const UIFrameEvent *>, private concurrency::OSThread
{
public:
unsigned char rx_encode_frame[Constants_DATA_PAYLOAD_LEN] = {};
unsigned char tx_encode_frame[Constants_DATA_PAYLOAD_LEN] = {};
unsigned char rx_encode_frame[meshtastic_Constants_DATA_PAYLOAD_LEN] = {};
unsigned char tx_encode_frame[meshtastic_Constants_DATA_PAYLOAD_LEN] = {};
c2_header tx_header = {};
int16_t speech[ADC_BUFFER_SIZE_MAX] = {};
int16_t output_buffer[ADC_BUFFER_SIZE_MAX] = {};
@@ -65,7 +65,7 @@ class AudioModule : public SinglePortModule, public Observable<const UIFrameEven
virtual int32_t runOnce() override;
virtual MeshPacket *allocReply() override;
virtual meshtastic_MeshPacket *allocReply() override;
virtual bool wantUIFrame() override { return this->shouldDraw(); }
virtual Observable<const UIFrameEvent *> *getUIFrameObservable() override { return this; }
@@ -79,7 +79,7 @@ class AudioModule : public SinglePortModule, public Observable<const UIFrameEven
* @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered
* for it
*/
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
};
extern AudioModule *audioModule;

View File

@@ -91,7 +91,7 @@ int32_t RangeTestModule::runOnce()
return disable();
}
MeshPacket *RangeTestModuleRadio::allocReply()
meshtastic_MeshPacket *RangeTestModuleRadio::allocReply()
{
auto reply = allocDataPacket(); // Allocate a packet for sending
@@ -101,7 +101,7 @@ MeshPacket *RangeTestModuleRadio::allocReply()
void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
{
MeshPacket *p = allocReply();
meshtastic_MeshPacket *p = allocReply();
p->to = dest;
p->decoded.want_response = wantReplies;
@@ -121,7 +121,7 @@ void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
}
ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
ProcessMessage RangeTestModuleRadio::handleReceived(const meshtastic_MeshPacket &mp)
{
#ifdef ARCH_ESP32
@@ -176,11 +176,11 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
}
bool RangeTestModuleRadio::appendFile(const MeshPacket &mp)
bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
{
auto &p = mp.decoded;
NodeInfo *n = nodeDB.getNode(getFrom(&mp));
meshtastic_NodeInfo *n = nodeDB.getNode(getFrom(&mp));
/*
LOG_DEBUG("-----------------------------------------\n");
LOG_DEBUG("p.payload.bytes \"%s\"\n", p.payload.bytes);

View File

@@ -28,7 +28,7 @@ class RangeTestModuleRadio : public SinglePortModule
uint32_t lastRxID = 0;
public:
RangeTestModuleRadio() : SinglePortModule("RangeTestModuleRadio", PortNum_TEXT_MESSAGE_APP)
RangeTestModuleRadio() : SinglePortModule("RangeTestModuleRadio", meshtastic_PortNum_TEXT_MESSAGE_APP)
{
loopbackOk = true; // Allow locally generated messages to loop back to the client
}
@@ -41,7 +41,7 @@ class RangeTestModuleRadio : public SinglePortModule
/**
* Append range test data to the file on the Filesystem
*/
bool appendFile(const MeshPacket &mp);
bool appendFile(const meshtastic_MeshPacket &mp);
/**
* Kevin's magical calculation of two points to meters.
@@ -49,14 +49,14 @@ class RangeTestModuleRadio : public SinglePortModule
float latLongToMeter(double lat_a, double lng_a, double lat_b, double lng_b);
protected:
virtual MeshPacket *allocReply() override;
virtual meshtastic_MeshPacket *allocReply() override;
/** Called to handle a particular incoming message
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for
it
*/
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
};
extern RangeTestModuleRadio *rangeTestModuleRadio;

View File

@@ -25,8 +25,8 @@ int32_t StoreForwardModule::runOnce()
storeForwardModule->sendPayload(this->busyTo, this->packetHistoryTXQueue_index);
if (this->packetHistoryTXQueue_index == packetHistoryTXQueue_size) {
// Tell the client we're done sending
StoreAndForward sf = StoreAndForward_init_zero;
sf.rr = StoreAndForward_RequestResponse_ROUTER_PING;
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
sf.rr = meshtastic_StoreAndForward_RequestResponse_ROUTER_PING;
storeForwardModule->sendMessage(this->busyTo, sf);
LOG_INFO("*** S&F - Done. (ROUTER_PING)\n");
this->packetHistoryTXQueue_index = 0;
@@ -40,9 +40,9 @@ int32_t StoreForwardModule::runOnce()
} else if ((millis() - lastHeartbeat > (heartbeatInterval * 1000)) && airTime->isTxAllowedChannelUtil(true)) {
lastHeartbeat = millis();
LOG_INFO("*** Sending heartbeat\n");
StoreAndForward sf = StoreAndForward_init_zero;
sf.rr = StoreAndForward_RequestResponse_ROUTER_HEARTBEAT;
sf.which_variant = StoreAndForward_heartbeat_tag;
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
sf.rr = meshtastic_StoreAndForward_RequestResponse_ROUTER_HEARTBEAT;
sf.which_variant = meshtastic_StoreAndForward_heartbeat_tag;
sf.variant.heartbeat.period = 300;
sf.variant.heartbeat.secondary = 0; // TODO we always have one primary router for now
storeForwardModule->sendMessage(NODENUM_BROADCAST, sf);
@@ -93,9 +93,9 @@ void StoreForwardModule::historySend(uint32_t msAgo, uint32_t to)
} else {
LOG_INFO("*** S&F - No history to send\n");
}
StoreAndForward sf = StoreAndForward_init_zero;
sf.rr = StoreAndForward_RequestResponse_ROUTER_HISTORY;
sf.which_variant = StoreAndForward_history_tag;
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
sf.rr = meshtastic_StoreAndForward_RequestResponse_ROUTER_HISTORY;
sf.which_variant = meshtastic_StoreAndForward_history_tag;
sf.variant.history.history_messages = queueSize;
sf.variant.history.window = msAgo;
storeForwardModule->sendMessage(to, sf);
@@ -130,7 +130,7 @@ uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to)
this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].channel = this->packetHistory[i].channel;
this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].payload_size = this->packetHistory[i].payload_size;
memcpy(this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].payload, this->packetHistory[i].payload,
Constants_DATA_PAYLOAD_LEN);
meshtastic_Constants_DATA_PAYLOAD_LEN);
this->packetHistoryTXQueue_size++;
LOG_DEBUG("*** PacketHistoryStruct time=%d\n", this->packetHistory[i].time);
@@ -141,7 +141,7 @@ uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to)
return this->packetHistoryTXQueue_size;
}
void StoreForwardModule::historyAdd(const MeshPacket &mp)
void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp)
{
const auto &p = mp.decoded;
@@ -150,13 +150,13 @@ void StoreForwardModule::historyAdd(const MeshPacket &mp)
this->packetHistory[this->packetHistoryCurrent].channel = mp.channel;
this->packetHistory[this->packetHistoryCurrent].from = mp.from;
this->packetHistory[this->packetHistoryCurrent].payload_size = p.payload.size;
memcpy(this->packetHistory[this->packetHistoryCurrent].payload, p.payload.bytes, Constants_DATA_PAYLOAD_LEN);
memcpy(this->packetHistory[this->packetHistoryCurrent].payload, p.payload.bytes, meshtastic_Constants_DATA_PAYLOAD_LEN);
this->packetHistoryCurrent++;
this->packetHistoryMax++;
}
MeshPacket *StoreForwardModule::allocReply()
meshtastic_MeshPacket *StoreForwardModule::allocReply()
{
auto reply = allocDataPacket(); // Allocate a packet for sending
return reply;
@@ -165,7 +165,7 @@ MeshPacket *StoreForwardModule::allocReply()
void StoreForwardModule::sendPayload(NodeNum dest, uint32_t packetHistory_index)
{
LOG_INFO("*** Sending S&F Payload\n");
MeshPacket *p = allocReply();
meshtastic_MeshPacket *p = allocReply();
p->to = dest;
p->from = this->packetHistoryTXQueue[packetHistory_index].from;
@@ -183,17 +183,17 @@ void StoreForwardModule::sendPayload(NodeNum dest, uint32_t packetHistory_index)
service.sendToMesh(p);
}
void StoreForwardModule::sendMessage(NodeNum dest, StoreAndForward &payload)
void StoreForwardModule::sendMessage(NodeNum dest, meshtastic_StoreAndForward &payload)
{
MeshPacket *p = allocDataProtobuf(payload);
meshtastic_MeshPacket *p = allocDataProtobuf(payload);
p->to = dest;
p->priority = MeshPacket_Priority_MIN;
p->priority = meshtastic_MeshPacket_Priority_MIN;
// FIXME - Determine if the delayed packet is broadcast or delayed. For now, assume
// everything is broadcast.
p->delayed = MeshPacket_Delayed_DELAYED_BROADCAST;
p->delayed = meshtastic_MeshPacket_Delayed_DELAYED_BROADCAST;
// Let's assume that if the router received the S&F request that the client is in range.
// TODO: Make this configurable.
@@ -203,20 +203,20 @@ void StoreForwardModule::sendMessage(NodeNum dest, StoreAndForward &payload)
service.sendToMesh(p);
}
void StoreForwardModule::sendMessage(NodeNum dest, StoreAndForward_RequestResponse rr)
void StoreForwardModule::sendMessage(NodeNum dest, meshtastic_StoreAndForward_RequestResponse rr)
{
// Craft an empty response, save some bytes in flash
StoreAndForward sf = StoreAndForward_init_zero;
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
sf.rr = rr;
storeForwardModule->sendMessage(dest, sf);
}
void StoreForwardModule::statsSend(uint32_t to)
{
StoreAndForward sf = StoreAndForward_init_zero;
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
sf.rr = StoreAndForward_RequestResponse_ROUTER_STATS;
sf.which_variant = StoreAndForward_stats_tag;
sf.rr = meshtastic_StoreAndForward_RequestResponse_ROUTER_STATS;
sf.which_variant = meshtastic_StoreAndForward_stats_tag;
sf.variant.stats.messages_total = this->packetHistoryMax;
sf.variant.stats.messages_saved = this->packetHistoryCurrent;
sf.variant.stats.messages_max = this->records;
@@ -231,29 +231,29 @@ void StoreForwardModule::statsSend(uint32_t to)
storeForwardModule->sendMessage(to, sf);
}
ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &mp)
{
#ifdef ARCH_ESP32
if (moduleConfig.store_forward.enabled) {
// The router node should not be sending messages as a client. Unless he is a ROUTER_CLIENT
if ((getFrom(&mp) != nodeDB.getNodeNum()) || (config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) {
if ((getFrom(&mp) != nodeDB.getNodeNum()) || (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT)) {
if ((mp.decoded.portnum == PortNum_TEXT_MESSAGE_APP) && is_server) {
if ((mp.decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP) && is_server) {
auto &p = mp.decoded;
if ((p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && (p.payload.bytes[2] == 0x00)) {
LOG_DEBUG("*** Legacy Request to send\n");
// Send the last 60 minutes of messages.
if (this->busy) {
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY);
storeForwardModule->sendMessage(getFrom(&mp), meshtastic_StoreAndForward_RequestResponse_ROUTER_BUSY);
LOG_INFO("*** S&F - Busy. Try again shortly.\n");
MeshPacket *pr = allocReply();
meshtastic_MeshPacket *pr = allocReply();
pr->to = getFrom(&mp);
pr->priority = MeshPacket_Priority_MIN;
pr->priority = meshtastic_MeshPacket_Priority_MIN;
pr->want_ack = false;
pr->decoded.want_response = false;
pr->decoded.portnum = PortNum_TEXT_MESSAGE_APP;
pr->decoded.portnum = meshtastic_PortNum_TEXT_MESSAGE_APP;
memcpy(pr->decoded.payload.bytes, "** S&F - Busy. Try again shortly.", 34);
pr->decoded.payload.size = 34;
service.sendToMesh(pr);
@@ -265,12 +265,12 @@ ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
LOG_INFO("*** S&F stored. Message history contains %u records now.\n", this->packetHistoryCurrent);
}
} else if (mp.decoded.portnum == PortNum_STORE_FORWARD_APP) {
} else if (mp.decoded.portnum == meshtastic_PortNum_STORE_FORWARD_APP) {
auto &p = mp.decoded;
StoreAndForward scratch;
StoreAndForward *decoded = NULL;
if (mp.which_payload_variant == MeshPacket_decoded_tag) {
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &StoreAndForward_msg, &scratch)) {
meshtastic_StoreAndForward scratch;
meshtastic_StoreAndForward *decoded = NULL;
if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_StoreAndForward_msg, &scratch)) {
decoded = &scratch;
} else {
LOG_ERROR("Error decoding protobuf module!\n");
@@ -288,7 +288,7 @@ ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
}
bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p)
bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_StoreAndForward *p)
{
if (!moduleConfig.store_forward.enabled) {
// If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume
@@ -298,8 +298,8 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
requests++;
switch (p->rr) {
case StoreAndForward_RequestResponse_CLIENT_ERROR:
case StoreAndForward_RequestResponse_CLIENT_ABORT:
case meshtastic_StoreAndForward_RequestResponse_CLIENT_ERROR:
case meshtastic_StoreAndForward_RequestResponse_CLIENT_ABORT:
if (is_server) {
// stop sending stuff, the client wants to abort or has another error
if ((this->busy) && (this->busyTo == getFrom(&mp))) {
@@ -310,16 +310,16 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
}
break;
case StoreAndForward_RequestResponse_CLIENT_HISTORY:
case meshtastic_StoreAndForward_RequestResponse_CLIENT_HISTORY:
if (is_server) {
requests_history++;
LOG_INFO("*** Client Request to send HISTORY\n");
// Send the last 60 minutes of messages.
if (this->busy) {
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY);
storeForwardModule->sendMessage(getFrom(&mp), meshtastic_StoreAndForward_RequestResponse_ROUTER_BUSY);
LOG_INFO("*** S&F - Busy. Try again shortly.\n");
} else {
if ((p->which_variant == StoreAndForward_history_tag) && (p->variant.history.window > 0)) {
if ((p->which_variant == meshtastic_StoreAndForward_history_tag) && (p->variant.history.window > 0)) {
storeForwardModule->historySend(p->variant.history.window * 60000, getFrom(&mp)); // window is in minutes
} else {
storeForwardModule->historySend(historyReturnWindow * 60000, getFrom(&mp)); // defaults to 4 hours
@@ -328,15 +328,15 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
}
break;
case StoreAndForward_RequestResponse_CLIENT_PING:
case meshtastic_StoreAndForward_RequestResponse_CLIENT_PING:
if (is_server) {
LOG_INFO("*** StoreAndForward_RequestResponse_CLIENT_PING\n");
// respond with a ROUTER PONG
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_PONG);
storeForwardModule->sendMessage(getFrom(&mp), meshtastic_StoreAndForward_RequestResponse_ROUTER_PONG);
}
break;
case StoreAndForward_RequestResponse_CLIENT_PONG:
case meshtastic_StoreAndForward_RequestResponse_CLIENT_PONG:
if (is_server) {
LOG_INFO("*** StoreAndForward_RequestResponse_CLIENT_PONG\n");
// The Client is alive, update NodeDB
@@ -344,11 +344,11 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
}
break;
case StoreAndForward_RequestResponse_CLIENT_STATS:
case meshtastic_StoreAndForward_RequestResponse_CLIENT_STATS:
if (is_server) {
LOG_INFO("*** Client Request to send STATS\n");
if (this->busy) {
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY);
storeForwardModule->sendMessage(getFrom(&mp), meshtastic_StoreAndForward_RequestResponse_ROUTER_BUSY);
LOG_INFO("*** S&F - Busy. Try again shortly.\n");
} else {
storeForwardModule->statsSend(getFrom(&mp));
@@ -356,22 +356,22 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
}
break;
case StoreAndForward_RequestResponse_ROUTER_ERROR:
case StoreAndForward_RequestResponse_ROUTER_BUSY:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_ERROR:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_BUSY:
if (is_client) {
LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_BUSY\n");
// retry in messages_saved * packetTimeMax ms
retry_delay =
millis() + packetHistoryCurrent * packetTimeMax * (StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1);
millis() + packetHistoryCurrent * packetTimeMax * (meshtastic_StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1);
}
break;
case StoreAndForward_RequestResponse_ROUTER_PONG:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_PONG:
// A router responded, this is equal to receiving a heartbeat
case StoreAndForward_RequestResponse_ROUTER_HEARTBEAT:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_HEARTBEAT:
if (is_client) {
// register heartbeat and interval
if (p->which_variant == StoreAndForward_heartbeat_tag) {
if (p->which_variant == meshtastic_StoreAndForward_heartbeat_tag) {
heartbeatInterval = p->variant.heartbeat.period;
}
lastHeartbeat = millis();
@@ -379,19 +379,19 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
}
break;
case StoreAndForward_RequestResponse_ROUTER_PING:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_PING:
if (is_client) {
LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_PING\n");
// respond with a CLIENT PONG
storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_CLIENT_PONG);
storeForwardModule->sendMessage(getFrom(&mp), meshtastic_StoreAndForward_RequestResponse_CLIENT_PONG);
}
break;
case StoreAndForward_RequestResponse_ROUTER_STATS:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_STATS:
if (is_client) {
LOG_DEBUG("*** Router Response STATS\n");
// These fields only have informational purpose on a client. Fill them to consume later.
if (p->which_variant == StoreAndForward_stats_tag) {
if (p->which_variant == meshtastic_StoreAndForward_stats_tag) {
this->packetHistoryMax = p->variant.stats.messages_total;
this->packetHistoryCurrent = p->variant.stats.messages_saved;
this->records = p->variant.stats.messages_max;
@@ -404,10 +404,10 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
}
break;
case StoreAndForward_RequestResponse_ROUTER_HISTORY:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_HISTORY:
if (is_client) {
// These fields only have informational purpose on a client. Fill them to consume later.
if (p->which_variant == StoreAndForward_history_tag) {
if (p->which_variant == meshtastic_StoreAndForward_history_tag) {
this->historyReturnWindow = p->variant.history.window / 60000;
LOG_INFO("*** Router Response HISTORY - Sending %d messages from last %d minutes\n",
p->variant.history.history_messages, this->historyReturnWindow);
@@ -422,7 +422,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
}
StoreForwardModule::StoreForwardModule()
: concurrency::OSThread("StoreForwardModule"), ProtobufModule("StoreForward", PortNum_STORE_FORWARD_APP, &StoreAndForward_msg)
: concurrency::OSThread("StoreForwardModule"), ProtobufModule("StoreForward", meshtastic_PortNum_STORE_FORWARD_APP, &meshtastic_StoreAndForward_msg)
{
#ifdef ARCH_ESP32
@@ -441,8 +441,8 @@ StoreForwardModule::StoreForwardModule()
if (moduleConfig.store_forward.enabled) {
// Router
if ((config.device.role == Config_DeviceConfig_Role_ROUTER) ||
(config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) {
if ((config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) ||
(config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT)) {
LOG_INFO("*** Initializing Store & Forward Module in Router mode\n");
if (ESP.getPsramSize() > 0) {
if (ESP.getFreePsram() >= 1024 * 1024) {
@@ -479,8 +479,8 @@ StoreForwardModule::StoreForwardModule()
// Client
}
if ((config.device.role == Config_DeviceConfig_Role_CLIENT) ||
(config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) {
if ((config.device.role == meshtastic_Config_DeviceConfig_Role_CLIENT) ||
(config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT)) {
is_client = true;
LOG_INFO("*** Initializing Store & Forward Module in Client mode\n");
}

View File

@@ -14,15 +14,15 @@ struct PacketHistoryStruct {
uint32_t from;
uint8_t channel;
bool ack;
uint8_t payload[Constants_DATA_PAYLOAD_LEN];
uint8_t payload[meshtastic_Constants_DATA_PAYLOAD_LEN];
pb_size_t payload_size;
};
class StoreForwardModule : private concurrency::OSThread, public ProtobufModule<StoreAndForward>
class StoreForwardModule : private concurrency::OSThread, public ProtobufModule<meshtastic_StoreAndForward>
{
bool busy = 0;
uint32_t busyTo = 0;
char routerMessage[Constants_DATA_PAYLOAD_LEN] = {0};
char routerMessage[meshtastic_Constants_DATA_PAYLOAD_LEN] = {0};
PacketHistoryStruct *packetHistory = 0;
uint32_t packetHistoryCurrent = 0;
@@ -47,7 +47,7 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule<
Update our local reference of when we last saw that node.
@return 0 if we have never seen that node before otherwise return the last time we saw the node.
*/
void historyAdd(const MeshPacket &mp);
void historyAdd(const meshtastic_MeshPacket &mp);
void statsSend(uint32_t to);
void historySend(uint32_t msAgo, uint32_t to);
@@ -57,18 +57,18 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule<
* Send our payload into the mesh
*/
void sendPayload(NodeNum dest = NODENUM_BROADCAST, uint32_t packetHistory_index = 0);
void sendMessage(NodeNum dest, StoreAndForward &payload);
void sendMessage(NodeNum dest, StoreAndForward_RequestResponse rr);
void sendMessage(NodeNum dest, meshtastic_StoreAndForward &payload);
void sendMessage(NodeNum dest, meshtastic_StoreAndForward_RequestResponse rr);
virtual MeshPacket *allocReply() override;
virtual meshtastic_MeshPacket *allocReply() override;
/*
-Override the wantPacket method.
*/
virtual bool wantPacket(const MeshPacket *p) override
virtual bool wantPacket(const meshtastic_MeshPacket *p) override
{
switch (p->decoded.portnum) {
case PortNum_TEXT_MESSAGE_APP:
case PortNum_STORE_FORWARD_APP:
case meshtastic_PortNum_TEXT_MESSAGE_APP:
case meshtastic_PortNum_STORE_FORWARD_APP:
return true;
default:
return false;
@@ -98,8 +98,8 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule<
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for
it
*/
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
virtual bool handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p);
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_StoreAndForward *p);
};
extern StoreForwardModule *storeForwardModule;