Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
Diff: SocketInterface.cpp
- Revision:
- 40:4b4306f3d829
- Parent:
- 29:b6af04b77a56
--- a/SocketInterface.cpp Mon Feb 23 20:30:18 2015 -0800 +++ b/SocketInterface.cpp Mon Feb 23 22:21:50 2015 -0800 @@ -248,6 +248,38 @@ return result; } + +/*************************************************************************************************/ +WiconnectResult SocketInterface::httpAcceptWebSocket(WiconnectSocket &socket, uint32_t timeoutMs) +{ + TimeoutTimer timer; + + do + { + uint8_t handle; + uint16_t local, remote; + uint32_t ipAddress; + WiconnectResult result; + + if(WICONNECT_SUCCEEDED(result, pollForClient(SOCKET_TYPE_WS, &handle, &local, &remote, &ipAddress))) + { + char ipBuffer[17]; + if(WICONNECT_FAILED(result, socket.init(handle, SOCKET_TYPE_WS, Wiconnect::ipToStr(ipAddress, ipBuffer), remote, local))) + { + return result; + } + websocketConnectedList |= (1 << handle); + return WICONNECT_SUCCESS; + } + else if(!(result == WICONNECT_PROCESSING || result == WICONNECT_NOT_FOUND)) + { + return result; + } + + } while(timeoutMs == WICONNECT_WAIT_FOREVER || !timer.timedOut(timeoutMs)); + + return WICONNECT_TIMEOUT; +} /*************************************************************************************************/ WiconnectResult SocketInterface::closeAllSockets()