diff options
| author | Daniel Campora <daniel@wipy.io> | 2015-06-29 09:55:28 +0200 |
|---|---|---|
| committer | Daniel Campora <daniel@wipy.io> | 2015-06-29 11:01:11 +0200 |
| commit | 5ebf39784aafd2ea6186b3b7058b741f6266bf67 (patch) | |
| tree | e27d7ec9ef88d462df0991a8da71837c8b35104f /cc3200/mods/modwlan.c | |
| parent | 9780e552748842d6f76f7a1a7f390287552844f1 (diff) | |
cc3200: Correct socket settimeout time format.
Diffstat (limited to 'cc3200/mods/modwlan.c')
| -rw-r--r-- | cc3200/mods/modwlan.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/cc3200/mods/modwlan.c b/cc3200/mods/modwlan.c index 664bbf054..7c6732855 100644 --- a/cc3200/mods/modwlan.c +++ b/cc3200/mods/modwlan.c @@ -1279,21 +1279,24 @@ int wlan_socket_setsockopt(mod_network_socket_obj_t *socket, mp_uint_t level, mp return 0; } -int wlan_socket_settimeout(mod_network_socket_obj_t *s, mp_uint_t timeout_ms, int *_errno) { +int wlan_socket_settimeout(mod_network_socket_obj_t *s, mp_uint_t timeout_s, int *_errno) { int ret; - if (timeout_ms == 0 || timeout_ms == -1) { - int optval; - if (timeout_ms == 0) { + if (timeout_s == 0 || timeout_s == -1) { + SlSockNonblocking_t option; + if (timeout_s == 0) { // set non-blocking mode - optval = 1; + option.NonblockingEnabled = 1; } else { // set blocking mode - optval = 0; + option.NonblockingEnabled = 0; } - ret = sl_SetSockOpt(s->sd, SOL_SOCKET, SO_NONBLOCKING, &optval, sizeof(optval)); + ret = sl_SetSockOpt(s->sd, SOL_SOCKET, SO_NONBLOCKING, &option, sizeof(option)); } else { // set timeout - ret = sl_SetSockOpt(s->sd, SOL_SOCKET, SO_RCVTIMEO, &timeout_ms, sizeof(timeout_ms)); + struct SlTimeval_t timeVal; + timeVal.tv_sec = timeout_s; // seconds + timeVal.tv_usec = 0; // microseconds. 10000 microseconds resolution + ret = sl_SetSockOpt(s->sd, SOL_SOCKET, SO_RCVTIMEO, &timeVal, sizeof(timeVal)); } if (ret != 0) { |
