Fork of KL46Z Wifi version. Moved to KL25Z as umbrella stand now requires 2 SPIs, thus requires 46z.
Dependencies: WIZnet_Library_ASE mbed nanoservice_client_1_12
Fork of Trenton_Doormat_FRDM-KL25Z_ETH by
Diff: main.cpp
- Revision:
- 8:be68e827aa53
- Parent:
- 7:afaa17c11965
- Child:
- 10:09a1dd3fbd3d
diff -r afaa17c11965 -r be68e827aa53 main.cpp --- a/main.cpp Tue Oct 08 15:04:55 2013 +0000 +++ b/main.cpp Wed Oct 09 21:40:48 2013 +0200 @@ -19,6 +19,9 @@ #include "TCPSocketConnection.h" #include "TCPSocketServer.h" +#define STRINGIFY(x) #x +#define TO_STRING(x) STRINGIFY(x) + using namespace mbed_cc3000; tUserFS user_info; @@ -104,7 +107,7 @@ printf("FTC finished. \r\n"); } -/** +/** * \brief Start smart config * \param none * \return none @@ -113,7 +116,7 @@ wifi.start_smart_config(smartconfigkey); } -/** +/** * \brief Simple socket demo * \param none * \return int @@ -126,15 +129,18 @@ printf("cc3000 simple socket demo. \r\n"); print_cc3000_info(); + printf("User's AP setup: SSID: %s, Password: %s, Security: %s \r\n", TO_STRING(SSID), TO_STRING(AP_KEY), TO_STRING(AP_SECURITY)); + printf("\n<0> Normal run. SmartConfig will \r\n start if no valid connection exists. \r\n"); - printf("<1> Connect using fixed SSID : %s \r\n", SSID); - printf("<2> SmartConfig. \r\n"); + printf("<1> Connect using fixed SSID without AP_KEY: %s \r\n", SSID); + printf("<2> Connect using fixed SSID with AP_KEY: %s \r\n", SSID); + printf("<9> SmartConfig. \r\n"); signed char c = getchar(); switch (c) { case '0': - if(!user_info.FTC) + if (!user_info.FTC) { do_FTC(); wifi._wlan.stop(); @@ -142,17 +148,29 @@ break; case '1': printf("Attempting SSID Connection. \r\n"); + + wifi._wlan.ioctl_set_connection_policy(0, 0, 0); + wait(1); + wifi.stop(); + wait(1); + wifi.start(0); + connect_to_ssid(SSID); + break; + case '2': + printf("Attempting SSID Connection. \r\n"); + + wifi._wlan.ioctl_set_connection_policy(0, 0, 0); + wait(1); + wifi.stop(); + wait(1); + wifi.start(0); #ifndef CC3000_TINY_DRIVER - #ifdef AP_KEY - connect_to_ssid(SSID, AP_KEY, AP_SECURITY); /* TODO rewrite to const vraiables - NOT MACROS */ - #else - connect_to_ssid(SSID); - #endif + connect_to_ssid(SSID, AP_KEY, AP_SECURITY); #else connect_to_ssid(SSID); #endif break; - case '2': + case '9': printf("Starting Smart Config configuration. \r\n"); start_smart_config(); while (wifi.is_dhcp_configured() == false)