knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

PubSubClient: Add failure test into readByte() #987

Closed ajlennon closed 1 year ago

ajlennon commented 1 year ago

_client->read() returns a signed int which can fail if the underlying stream is implemented as such.

e.g. TinyGsmTCP::read() is implemented to return a -1 on failure

int read() override { uint8_t c; if (read(&c, 1) == 1) { return c; } return -1; }

Signed-off-by: Alex J Lennon ajlennon@dynamicdevices.co.uk