Skip to content

Commit

Permalink
fixes #552 - UDP.begin/write now return expected values.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mcgowan committed Aug 20, 2015
1 parent f6550ca commit 2978a3f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- `TCPClient::stop()` does not work on first connection [#536](https://github.com/spark/firmware/issues/536)
- `TCPClient::connect()` does not close an existing socket. [#538](https://github.com/spark/firmware/issues/538)
- TX/RX PWM randomly inverted [#545](https://github.com/spark/firmware/issues/545)
- UDP.begin/write return values [#552](https://github.com/spark/firmware/issues/552)

## v0.4.3

Expand Down
10 changes: 10 additions & 0 deletions hal/inc/socket_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ sock_result_t socket_receivefrom(sock_handle_t sd, void* buffer, socklen_t len,

sock_result_t socket_send(sock_handle_t sd, const void* buffer, socklen_t len);

/**
*
* @param sd The socket handle to send
* @param buffer
* @param len
* @param flags
* @param addr
* @param addr_size
* @return Return the number of bytes sent or a negative value on error.
*/
sock_result_t socket_sendto(sock_handle_t sd, const void* buffer, socklen_t len, uint32_t flags, sockaddr_t* addr, socklen_t addr_size);

sock_result_t socket_close(sock_handle_t sd);
Expand Down
4 changes: 3 additions & 1 deletion hal/src/photon/socket_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,11 @@ sock_result_t socket_sendto(sock_handle_t sd, const void* buffer, socklen_t len,
/* Set the end of the data portion */
wiced_packet_set_data_end(packet, (uint8_t*) data + size);
result = wiced_udp_send(udp(socket), &ip_addr, port, packet);
len = size;
}
}
return as_sock_result(result);
// return negative value on error, or length if successful.
return result ? -result : len;
}

sock_result_t socket_receivefrom(sock_handle_t sd, void* buffer, socklen_t bufLen, uint32_t flags, sockaddr_t* addr, socklen_t* addrsize)
Expand Down

0 comments on commit 2978a3f

Please sign in to comment.