ACKme
/
wiconnect-test-console
Test serial console demonstrating various API functions of WiConnect library.
Diff: tests/blocking/network/JoinNetworkTest.cpp
- Revision:
- 0:836c9a6383e0
- Child:
- 1:5137ec8f4c45
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/blocking/network/JoinNetworkTest.cpp Mon Aug 11 11:31:32 2014 +0000 @@ -0,0 +1,62 @@ +/* + * 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 "tests/Tests.h" +#include "Wiconnect.h" + + + +static void joinCompleteCallback(WiconnectResult result, void *arg1, void *arg2); + + +/*************************************************************************************************/ +WiconnectResult networkJoinCommand(int argc, char **argv) +{ + WiconnectResult result; + Wiconnect *wiconnect = Wiconnect::getInstance(); + + const char *ssid = (argc > 0) ? argv[0] : NULL; + const char *password = (argc > 1) ? argv[1] : NULL; + + if(!WICONNECT_FAILED(result, wiconnect->join(ssid, password, Callback(joinCompleteCallback)))) + { + LOG_INFO("Joining network"); + } + + return result; +} + +/*************************************************************************************************/ +WiconnectResult networkLeaveCommand(int argc, char **argv) +{ + WiconnectResult result; + Wiconnect *wiconnect = Wiconnect::getInstance(); + + if(!WICONNECT_FAILED(result, wiconnect->leave())) + { + LOG_INFO("Successfully disconnected from network"); + } + return result; +} + +/*************************************************************************************************/ +static void joinCompleteCallback(WiconnectResult result, void *arg1, void *arg2) +{ + if(result == WICONNECT_SUCCESS) + { + LOG_INFO("Successfully joined network"); + } + else + { + LOG_WICONNECT_ERROR(result, "Errors occurred while joining network"); + } +} +