works better now
This commit is contained in:
@ -272,7 +272,8 @@ boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length) {
|
||||
uint8_t digit;
|
||||
uint8_t pos = 0;
|
||||
uint8_t rc;
|
||||
uint8_t len = length;
|
||||
uint16_t len = length;
|
||||
|
||||
do {
|
||||
digit = len % 128;
|
||||
len = len / 128;
|
||||
@ -294,12 +295,12 @@ boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length) {
|
||||
|
||||
const size_t SEND_AT_ONCE = 64;
|
||||
size_t remains = length + 1 + llen;
|
||||
// Serial.print("write len: "); Serial.println(remains);
|
||||
//Serial.print("write len: "); Serial.println(remains);
|
||||
const uint8_t *writebuf = buf + (4 - llen);
|
||||
bool result = true;
|
||||
while ((remains > 0) && result) {
|
||||
size_t actuallySendChars = (remains > SEND_AT_ONCE) ? SEND_AT_ONCE : remains;
|
||||
// Serial.print("tbs: "); Serial.println(actuallySendChars);
|
||||
//Serial.print("tbs: "); Serial.println(actuallySendChars);
|
||||
size_t sentChars = _client->write(writebuf, actuallySendChars);
|
||||
result = sentChars == actuallySendChars;
|
||||
remains -= sentChars;
|
||||
@ -309,6 +310,7 @@ boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length) {
|
||||
|
||||
lastOutActivity = millis();
|
||||
// return (rc == 1+llen+length);
|
||||
//Serial.print("res: "); Serial.println(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user