1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-17 06:42:21 +03:00

write(), print(), and println() now return number of bytes written.

The type is long, and negative values indicate errors.  Needs more testing.
http://code.google.com/p/arduino/issues/detail?id=551
This commit is contained in:
David A. Mellis
2011-08-23 19:12:03 -04:00
parent b788ad593f
commit 8059abe581
24 changed files with 290 additions and 174 deletions

View File

@@ -102,21 +102,22 @@ int UDP::endPacket()
return sendUDP(_sock);
}
void UDP::write(uint8_t byte)
long UDP::write(uint8_t byte)
{
write(&byte, 1);
return write(&byte, 1);
}
void UDP::write(const char *str)
long UDP::write(const char *str)
{
size_t len = strlen(str);
write((const uint8_t *)str, len);
return write((const uint8_t *)str, len);
}
void UDP::write(const uint8_t *buffer, size_t size)
long UDP::write(const uint8_t *buffer, size_t size)
{
uint16_t bytes_written = bufferData(_sock, _offset, buffer, size);
_offset += bytes_written;
return bytes_written;
}
int UDP::parsePacket()