ACKme
/
wiconnect-test-console
Test serial console demonstrating various API functions of WiConnect library.
Revision 22:26420b641605, committed 2014-10-23
- Comitter:
- dan_ackme
- Date:
- Thu Oct 23 15:17:15 2014 -0700
- Parent:
- 20:86c7b49bee61
- Child:
- 23:6b0434d3819e
- Commit message:
- Join command fixes and added 'update' command
Changed in this revision
--- a/target_config.h Tue Aug 26 23:57:16 2014 +0000 +++ b/target_config.h Thu Oct 23 15:17:15 2014 -0700 @@ -1,30 +1,30 @@ -/** - * ACKme WiConnect Host Library is licensed under the BSD licence: - * - * Copyright (c)2014 ACKme Networks. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. +/** + * ACKme WiConnect Host Library is licensed under the BSD licence: + * + * Copyright (c)2014 ACKme Networks. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. */ #pragma once @@ -73,7 +73,7 @@ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Nucleo F401RE Target Configuration -#ifdef TARGET_NUCLEO_F401RE +#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) #define WICONNECT_TX_PIN PA_9 #define WICONNECT_RX_PIN PA_10
--- a/tests/blocking/network/JoinNetworkTest.cpp Tue Aug 26 23:57:16 2014 +0000 +++ b/tests/blocking/network/JoinNetworkTest.cpp Thu Oct 23 15:17:15 2014 -0700 @@ -43,8 +43,13 @@ 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)))) + + // if we're changing the ssid, then we need to leave the current network we're connected to first + if(ssid != NULL && WICONNECT_FAILED(result, wiconnect->leave())) + { + LOG_WICONNECT_ERROR(result, "Failed to disconnect from the network first"); + } + else if(!WICONNECT_FAILED(result, wiconnect->join(ssid, password, Callback(joinCompleteCallback)))) { LOG_INFO("Joining network"); } @@ -73,7 +78,8 @@ LOG_INFO("Successfully joined network"); } else - { - LOG_WICONNECT_ERROR(result, "Errors occurred while joining network"); + { + NetworkJoinResult joinResult = (NetworkJoinResult)(uint32_t)arg1; + LOG_WICONNECT_ERROR(result, "Errors occurred while joining network. Join result: %s", Wiconnect::networkJoinResultToStr(joinResult)); } }
--- a/tests/blocking/wiconnect/WiconnectTests.cpp Tue Aug 26 23:57:16 2014 +0000 +++ b/tests/blocking/wiconnect/WiconnectTests.cpp Thu Oct 23 15:17:15 2014 -0700 @@ -123,6 +123,37 @@ } return result; } + +/*************************************************************************************************/ +WiconnectResult wiconnectUpdateFirmwareCommand(int argc, char **argv) +{ + WiconnectResult result; + bool forceUpdate = false; + const char *version = NULL; + Wiconnect *wiconnect = Wiconnect::getInstance(); + + if(argc > 0) + { + if(strcmp(argv[0], "-f") == 0) + { + forceUpdate = true; + } + else + { + version = argv[0]; + } + } + + if(!WICONNECT_FAILED(result, wiconnect->updateFirmware(forceUpdate, version))) + { + wiconnect->getVersion(); + LOG_INFO("Success!"); + LOG_INFO("Firmware version: %s", wiconnect->getResponseBuffer()); + } + + return result; +} + /*************************************************************************************************/ WiconnectResult wiconnectDebugEnableCommand(int argc, char **argv)
--- a/tests/blocking/wiconnect/WiconnectTests.h Tue Aug 26 23:57:16 2014 +0000 +++ b/tests/blocking/wiconnect/WiconnectTests.h Thu Oct 23 15:17:15 2014 -0700 @@ -31,15 +31,21 @@ #define WICONNECT_TEST_CMD_LIST \ ADD_HEADER("WiConnect commands:"), \ - ADD_CMD(":", wiconnectSendRawBlocking, "Send a blocking raw wiconnect command to module", \ - "Usage: : <wiconnet command> [command options]\n" \ - "Example:\n> : get network.status"), \ - ADD_CMD("#", wiconnectSendRawNonBlocking, "Send a non-blocking raw wiconnect command to module", \ - "Usage: # <wiconnet command> [command options]\n" \ - "Example:\n> # get network.status"), \ - ADD_CMD("ver", wiconnectGetVersion, "Get WiConnect version string", \ - "Usage: ver"), \ - ADD_CMD("debug", wiconnectDebugEnable, "Enabled/disable wiconnect library debug messages", \ + ADD_CMD(":", wiconnectSendRawBlocking, "Send a blocking raw wiconnect command to module", \ + "Usage: : <wiconnet command> [command options]\n" \ + "Example:\n> : get network.status"), \ + ADD_CMD("#", wiconnectSendRawNonBlocking, "Send a non-blocking raw wiconnect command to module", \ + "Usage: # <wiconnet command> [command options]\n" \ + "Example:\n> # get network.status"), \ + ADD_CMD("ver", wiconnectGetVersion, "Get WiConnect version string", \ + "Usage: ver"), \ + ADD_CMD("update", wiconnectUpdateFirmware, "Update the Wi-Fi module's internal firmware", \ + "Usage: update [-f] [<version>]\n" \ + "Examples:\n" \ + "> update // update to latest firmware (if necessary)\n" \ + "> update -f // force update all files to latest verison\n" \ + "> update 2.0.0.11 // update to specific version"), \ + ADD_CMD("debug", wiconnectDebugEnable, "Enabled/disable wiconnect library debug messages", \ "Usage: debug <on/off>") @@ -47,5 +53,6 @@ WiconnectResult wiconnectSendRawBlockingCommand(int argc, char **argv); WiconnectResult wiconnectSendRawNonBlockingCommand(int argc, char **argv); -WiconnectResult wiconnectGetVersionCommand(int argc, char **argv); +WiconnectResult wiconnectGetVersionCommand(int argc, char **argv); +WiconnectResult wiconnectUpdateFirmwareCommand(int argc, char **argv); WiconnectResult wiconnectDebugEnableCommand(int argc, char **argv);
--- a/util/log/log.cpp Tue Aug 26 23:57:16 2014 +0000 +++ b/util/log/log.cpp Thu Oct 23 15:17:15 2014 -0700 @@ -86,10 +86,12 @@ /*************************************************************************************************/ void logWiconnectError(WiconnectResult result, const char *msg, ...) { - va_list args; - consoleSerial.write("[ERROR] "); - va_start(args, msg); - consoleSerial.printf("%s, (%d) %s\r\n", msg, result, Wiconnect::getWiconnectResultStr(result)); - va_end(args); + va_list args; + + consoleSerial.printf("[ERROR] (%d) %s. ", result, Wiconnect::getWiconnectResultStr(result)); + va_start(args, msg); + consoleSerial.vprintf(msg, args); + va_end(args); + consoleSerial.write("\r\n"); }