File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
libraries/SocketWrapper/src Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -76,13 +76,20 @@ int arduino::MbedUDP::endPacket() {
7676
7777// Write a single byte into the packet
7878size_t arduino::MbedUDP::write (uint8_t byte) {
79- uint8_t buffer[1 ] = { byte };
80- return _socket.sendto (_host, buffer, 1 );
79+ return write (&byte, 1 );
8180}
8281
8382// Write size bytes from buffer into the packet
8483size_t arduino::MbedUDP::write (const uint8_t *buffer, size_t size) {
85- return _socket.sendto (_host, buffer, size);
84+ _socket.set_blocking (true );
85+ _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;
8693}
8794
8895int arduino::MbedUDP::parsePacket () {
You can’t perform that action at this time.
0 commit comments