We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 123694b commit bc92047Copy full SHA for bc92047
libraries/SocketWrapper/src/MbedUdp.cpp
@@ -76,13 +76,20 @@ int arduino::MbedUDP::endPacket() {
76
77
// Write a single byte into the packet
78
size_t arduino::MbedUDP::write(uint8_t byte) {
79
- uint8_t buffer[1] = { byte };
80
- return _socket.sendto(_host, buffer, 1);
+ return write(&byte, 1);
81
}
82
83
// Write size bytes from buffer into the packet
84
size_t arduino::MbedUDP::write(const uint8_t *buffer, size_t size) {
85
- return _socket.sendto(_host, buffer, size);
+ _socket.set_blocking(true);
+ _socket.set_timeout(1000);
86
+ nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size);
87
+ _socket.set_blocking(false);
88
+ _socket.set_timeout(0);
89
+ if (ret < 0) {
90
+ return 0;
91
+ }
92
+ return size;
93
94
95
int arduino::MbedUDP::parsePacket() {
0 commit comments