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: internal/wiconnect/WiconnectCommand.cpp
- Revision:
- 0:ea85c4bb5e1f
- Child:
- 1:6ec9998427ad
diff -r 000000000000 -r ea85c4bb5e1f internal/wiconnect/WiconnectCommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/internal/wiconnect/WiconnectCommand.cpp Mon Aug 11 09:58:24 2014 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright 2014, ACKme Networks + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of ACKme Networks. + */ + + +#include "CommandCommon.h" +#include "StringUtil.h" + + + +/*************************************************************************************************/ +void Wiconnect::setCommandDefaultTimeout(int timeoutMs) +{ + defaultTimeoutMs = timeoutMs; +} + +/*************************************************************************************************/ +int Wiconnect::getCommandDefaultTimeout() +{ + return defaultTimeoutMs; +} + +/*************************************************************************************************/ +char* Wiconnect::getResponseBuffer() +{ + return internalBuffer; +} + +/*************************************************************************************************/ +uint16_t Wiconnect::getLastCommandResponseLength() +{ + CommandHeader *header = (CommandHeader*)commandHeaderBuffer; + return header->response_len; +} + +/*************************************************************************************************/ +const char* Wiconnect::getLastCommandResponseCodeStr() +{ + if(!initialized) + { + return NULL; + } + static const char* const response_error_strings[] ={ + "Null", + "Success", + "Failed", + "Parse error", + "Unknown command", + "Too few arguments", + "Too many arguments", + "Unknown command option", + "Bad command arguments" + }; + CommandHeader *header = (CommandHeader*)commandHeaderBuffer; + + return response_error_strings[header->response_code]; +} + + +/*************************************************************************************************/ +WiconnectResult Wiconnect::responseToUint32(uint32_t *uint32Ptr) +{ + CHECK_INITIALIZED(); + return StringUtil::strToUint32(internalBuffer, uint32Ptr) ? WICONNECT_SUCCESS : WICONNECT_RESPONSE_PARSE_ERROR; +} + + +/*************************************************************************************************/ +WiconnectResult Wiconnect::responseToInt32(int32_t *int32Ptr) +{ + CHECK_INITIALIZED(); + return StringUtil::strToInt32(internalBuffer, int32Ptr) ? WICONNECT_SUCCESS : WICONNECT_RESPONSE_PARSE_ERROR; +} + + +