Skip to content

Commit 6e9dffa

Browse files
Tiny optimization (suggested by Rotzbua)
1 parent c6bfda6 commit 6e9dffa

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Ethernet.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ class EthernetClass {
130130
static uint8_t socketPeek(uint8_t s);
131131
// sets up a UDP datagram, the data for which will be provided by one
132132
// or more calls to bufferData and then finally sent with sendUDP.
133-
// return 1 if the datagram was successfully set up, or 0 if there was an error
134-
static int socketStartUDP(uint8_t s, uint8_t* addr, uint16_t port);
133+
// return true if the datagram was successfully set up, or false if there was an error
134+
static bool socketStartUDP(uint8_t s, uint8_t* addr, uint16_t port);
135135
// copy up to len bytes of data from buf into a UDP datagram to be
136136
// sent later by sendUDP. Allows datagrams to be built up from a series of bufferData calls.
137137
// return Number of bytes successfully buffered
138138
static uint16_t socketBufferData(uint8_t s, uint16_t offset, const uint8_t* buf, uint16_t len);
139139
// Send a UDP datagram built up from a sequence of startUDP followed by one or more
140140
// calls to bufferData.
141-
// return 1 if the datagram was successfully sent, or 0 if there was an error
142-
static int socketSendUDP(uint8_t s);
141+
// return true if the datagram was successfully sent, or false if there was an error
142+
static bool socketSendUDP(uint8_t s);
143143
// Initialize the "random" source port number
144144
static void socketPortRand(uint16_t n);
145145
};

src/socket.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,20 +496,20 @@ uint16_t EthernetClass::socketBufferData(uint8_t s, uint16_t offset, const uint8
496496
return ret;
497497
}
498498

499-
int EthernetClass::socketStartUDP(uint8_t s, uint8_t* addr, uint16_t port)
499+
bool EthernetClass::socketStartUDP(uint8_t s, uint8_t* addr, uint16_t port)
500500
{
501501
if ( ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) ||
502502
((port == 0x00)) ) {
503-
return 0;
503+
return false;
504504
}
505505
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
506506
W5100.writeSnDIPR(s, addr);
507507
W5100.writeSnDPORT(s, port);
508508
SPI.endTransaction();
509-
return 1;
509+
return true;
510510
}
511511

512-
int EthernetClass::socketSendUDP(uint8_t s)
512+
bool EthernetClass::socketSendUDP(uint8_t s)
513513
{
514514
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
515515
W5100.execCmdSn(s, Sock_SEND);
@@ -521,7 +521,7 @@ int EthernetClass::socketSendUDP(uint8_t s)
521521
W5100.writeSnIR(s, (SnIR::SEND_OK|SnIR::TIMEOUT));
522522
SPI.endTransaction();
523523
//Serial.printf("sendUDP timeout\n");
524-
return 0;
524+
return false;
525525
}
526526
SPI.endTransaction();
527527
yield();
@@ -534,6 +534,6 @@ int EthernetClass::socketSendUDP(uint8_t s)
534534

535535
//Serial.printf("sendUDP ok\n");
536536
/* Sent ok */
537-
return 1;
537+
return true;
538538
}
539539

0 commit comments

Comments
 (0)