MQTT with CC3000 Wi-Fi interface
Dependencies: ADT7410 MQTToveCC3000 MbedJSONValue NVIC_set_all_priorities cc3000_hostdriver_mbedsocket2 mbed
Fork of cc3000_simple_socket_demo by
Revision 8:be68e827aa53, committed 2013-10-09
- Comitter:
- Kojto
- Date:
- Wed Oct 09 21:40:48 2013 +0200
- Parent:
- 7:afaa17c11965
- Child:
- 9:48842d8a1285
- Commit message:
- Smart config correction
- options now are 0,1,2 and 9
- prints user settings for an access point
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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)
