ACKme
/
wiconnect-test-console
Test serial console demonstrating various API functions of WiConnect library.
tests/blocking/network/WebSetupNetworkTest.cpp
- Committer:
- dan_ackme
- Date:
- 2014-08-11
- Revision:
- 0:836c9a6383e0
- Child:
- 1:5137ec8f4c45
File content as of revision 0:836c9a6383e0:
/* * 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 webSetupCompleteCallback(WiconnectResult result, void *arg1, void *arg2); /*************************************************************************************************/ WiconnectResult networkSetupWebCommand(int argc, char **argv) { WiconnectResult result = WICONNECT_BAD_ARG; Wiconnect *wiconnect = Wiconnect::getInstance(); if(strcmp(argv[0], "status") == 0) { bool isRunning; if(!WICONNECT_FAILED(result, wiconnect->isWebSetupRunning(&isRunning))) { LOG_INFO("Web setup is %s", isRunning ? "running" : "stopped"); } } else if(strcmp(argv[0], "start") == 0) { const char *ssid = (argc > 1) ? argv[1] : NULL; const char *password = (argc > 2) ? argv[2] : NULL; if(!WICONNECT_FAILED(result, wiconnect->startWebSetup(ssid, password, Callback(webSetupCompleteCallback)))) { LOG_INFO("Web setup started"); } } else if(strcmp(argv[0], "stop") == 0) { if(!WICONNECT_FAILED(result, wiconnect->stopWebSetup())) { LOG_INFO("Web setup stopped"); } } return result; } /*************************************************************************************************/ static void webSetupCompleteCallback(WiconnectResult result, void *arg1, void *arg2) { if(result == WICONNECT_SUCCESS) { LOG_INFO("Web setup successfully completed"); } else { LOG_WICONNECT_ERROR(result, "Web setup finished with errors"); } }