Hi I am working with esp32 platformio and arduino framework…
I am having issues with the PubSubClient lib.
It was working under this platform platform = espressif32@3.5.0…
But then when I do the migration to platform = espressif32 @ ^5 I had to do this trick in order to compile…
but now when it comes to publish it crashes…
Any ideas?
Thanks a lot
Please post the full project.
Hi @maxgerhardt … thanks for your suggestion… what do you mean for the full project ?
i have investigated and i found where it crashes…
boolean PubSubClient::write(uint8_t header, uint8_t *buf, uint16_t length)
{
uint16_t rc;
uint8_t hlen = buildHeader(header, buf, length);
#ifdef MQTT_MAX_TRANSFER_SIZE
uint8_t *writeBuf = buf + (MQTT_MAX_HEADER_SIZE - hlen);
uint16_t bytesRemaining = length + hlen; // Match the length type
uint8_t bytesToWrite;
boolean result = true;
while ((bytesRemaining > 0) && result)
{
bytesToWrite = (bytesRemaining > MQTT_MAX_TRANSFER_SIZE) ? MQTT_MAX_TRANSFER_SIZE : bytesRemaining;
rc = _client->write(writeBuf, bytesToWrite);
result = (rc == bytesToWrite);
bytesRemaining -= rc;
writeBuf += rc;
}
return result;
#else
Serial.println("arrivo");
Serial.println(hlen);
Serial.println(length);
rc = _client->write(buf + (MQTT_MAX_HEADER_SIZE - hlen), length + hlen);
lastOutActivity = millis();
return (rc == hlen + length);
#endif
}
With 3.5.0 it is able to execute
rc = _client->write(buf + (MQTT_MAX_HEADER_SIZE - hlen), length + hlen);
with 5.0
it is crashing
Any ideas?
Thanks