1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +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

@ -42,13 +42,15 @@ bool IPAddress::operator==(const uint8_t* addr)
return memcmp(addr, _address, sizeof(_address)) == 0;
}
void IPAddress::printTo(Print& p) const
long IPAddress::printTo(Print& p) const
{
long n = 0, t;
for (int i =0; i < 3; i++)
{
p.print(_address[i], DEC);
p.print('.');
if ((t = p.print(_address[i], DEC)) > 0) n += t;
if ((t = p.print('.')) > 0) n+= t;
}
p.print(_address[3], DEC);
if ((t = p.print(_address[3], DEC)) > 0) n += t;
return n;
}