mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-10 07:02:11 +00:00
Account for size of Envelope when allocating buffer. (#4819)
* Account for size of Envelope when allocating buffer. INFO | 09:29:20 568 [mqtt] Subscribing to msh/2/e/LongFast/+ INFO | 09:29:20 568 [mqtt] Subscribing to msh/2/json/LongFast/+ INFO | 09:29:20 568 [mqtt] Subscribing to msh/2/e/PKI/+ DEBUG | 09:29:20 568 [mqtt] Publishing enqueued MQTT message ERROR | 09:29:20 568 [mqtt] Panic: can't encode protobuf reason='bytes size exceeded' assert failed: size_t pb_encode_to_bytes(uint8_t*, size_t, const pb_msgdesc_t*, const void*) mesh-pb-constants.cpp:18 (0) * save some mem
This commit is contained in:
parent
baf9cf5a59
commit
118809fbfc
@ -32,6 +32,9 @@ static MemoryDynamic<meshtastic_ServiceEnvelope> staticMqttPool;
|
|||||||
|
|
||||||
Allocator<meshtastic_ServiceEnvelope> &mqttPool = staticMqttPool;
|
Allocator<meshtastic_ServiceEnvelope> &mqttPool = staticMqttPool;
|
||||||
|
|
||||||
|
// FIXME - this size calculation is super sloppy, but it will go away once we dynamically alloc meshpackets
|
||||||
|
static uint8_t bytes[meshtastic_MqttClientProxyMessage_size + 30]; // 12 for channel name and 16 for nodeid
|
||||||
|
|
||||||
void MQTT::mqttCallback(char *topic, byte *payload, unsigned int length)
|
void MQTT::mqttCallback(char *topic, byte *payload, unsigned int length)
|
||||||
{
|
{
|
||||||
mqtt->onReceive(topic, payload, length);
|
mqtt->onReceive(topic, payload, length);
|
||||||
@ -482,9 +485,7 @@ void MQTT::publishQueuedMessages()
|
|||||||
{
|
{
|
||||||
if (!mqttQueue.isEmpty()) {
|
if (!mqttQueue.isEmpty()) {
|
||||||
LOG_DEBUG("Publishing enqueued MQTT message\n");
|
LOG_DEBUG("Publishing enqueued MQTT message\n");
|
||||||
// FIXME - this size calculation is super sloppy, but it will go away once we dynamically alloc meshpackets
|
|
||||||
meshtastic_ServiceEnvelope *env = mqttQueue.dequeuePtr(0);
|
meshtastic_ServiceEnvelope *env = mqttQueue.dequeuePtr(0);
|
||||||
static uint8_t bytes[meshtastic_MqttClientProxyMessage_size];
|
|
||||||
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, env);
|
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, env);
|
||||||
std::string topic;
|
std::string topic;
|
||||||
if (env->packet->pki_encrypted) {
|
if (env->packet->pki_encrypted) {
|
||||||
@ -570,8 +571,6 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket &
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (moduleConfig.mqtt.proxy_to_client_enabled || this->isConnectedDirectly()) {
|
if (moduleConfig.mqtt.proxy_to_client_enabled || this->isConnectedDirectly()) {
|
||||||
// FIXME - this size calculation is super sloppy, but it will go away once we dynamically alloc meshpackets
|
|
||||||
static uint8_t bytes[meshtastic_MqttClientProxyMessage_size];
|
|
||||||
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, env);
|
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, env);
|
||||||
std::string topic = cryptTopic + channelId + "/" + owner.id;
|
std::string topic = cryptTopic + channelId + "/" + owner.id;
|
||||||
LOG_DEBUG("MQTT Publish %s, %u bytes\n", topic.c_str(), numBytes);
|
LOG_DEBUG("MQTT Publish %s, %u bytes\n", topic.c_str(), numBytes);
|
||||||
@ -666,8 +665,6 @@ void MQTT::perhapsReportToMap()
|
|||||||
&meshtastic_MapReport_msg, &mapReport);
|
&meshtastic_MapReport_msg, &mapReport);
|
||||||
se->packet = mp;
|
se->packet = mp;
|
||||||
|
|
||||||
// FIXME - this size calculation is super sloppy, but it will go away once we dynamically alloc meshpackets
|
|
||||||
static uint8_t bytes[meshtastic_MqttClientProxyMessage_size];
|
|
||||||
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, se);
|
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, se);
|
||||||
|
|
||||||
LOG_INFO("MQTT Publish map report to %s\n", mapTopic.c_str());
|
LOG_INFO("MQTT Publish map report to %s\n", mapTopic.c_str());
|
||||||
|
Loading…
Reference in New Issue
Block a user