Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed NVIC_set_all_priorities cc3000_hostdriver_mbedsocket
Revision 1:1ef047ffeef4, committed 2013-09-15
- Comitter:
- Kojto
- Date:
- Sun Sep 15 14:41:26 2013 +0000
- Parent:
- 0:26d9788555b6
- Child:
- 2:07b4869bc572
- Commit message:
- Smart config addition, removed non-used macros from the main header file
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| main.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Sep 14 05:13:00 2013 +0000
+++ b/main.cpp Sun Sep 15 14:41:26 2013 +0000
@@ -28,6 +28,13 @@
Serial pc(USBTX, USBRX);
cc3000 wigo(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), PORTA_IRQn);
+tUserFS user_info;
+
+#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
+ const uint8_t smartconfigkey[] = {0x73,0x6d,0x61,0x72,0x74,0x63,0x6f,0x6e,0x66,0x69,0x67,0x41,0x45,0x53,0x31,0x36};
+#else
+ const uint8_t smartconfigkey = 0;
+#endif
/** Print cc3000 information
* \param none
@@ -35,7 +42,6 @@
*/
void print_cc3000_info() {
uint8_t myMAC[8];
- tUserFS user_info;
printf("MAC address + cc3000 info\n");
wigo.get_user_file_info((uint8_t *)&user_info, sizeof(user_info));
@@ -78,7 +84,7 @@
// Wi-Go set current to 500mA since we're turning on the Wi-Fi
SET_PWR_EN1;
SET_PWR_EN2;
-
+
NVIC_SetAllPriority(3);
NVIC_SetPriority(SPI0_IRQn, 0x0); // Wi-Fi SPI interrupt must be higher priority than SysTick
NVIC_SetPriority(PORTA_IRQn, 0x1);
@@ -87,7 +93,24 @@
CLEAN_PORT_INTERRUPT;
}
-/** Main function
+/** First time configuration
+ * \param none
+ * \return none
+ */
+void do_FTC(void) {
+ printf("Running First Time Configuration\n");
+ wigo.start_smart_config(smartconfigkey);
+ while (wigo.is_dhcp_configured() == false) {
+ wait_ms(500);
+ printf("Waiting for dhcp to be set.\n");
+ }
+ user_info.FTC = 1;
+ wigo.set_user_file_info((uint8_t *)&user_info, sizeof(user_info));
+ wigo._wlan.stop();
+ printf("FTC finished.\n");
+}
+
+/** Ping a site
* \param none
* \return int
*/
@@ -100,16 +123,29 @@
print_cc3000_info();
printf("Attempting SSID Connection\n");
+#if (USE_SMART_CONFIG == 1)
+ if (user_info.FTC == 1) {
+ wigo._wlan.ioctl_set_connection_policy(0, 1, 1);
+ } else {
+ printf("Smart config is not set, starting configuration\n");
+ do_FTC();
+ printf("Smart config is set. Please restart your board.\n");
+ while(1);
+ }
+#else
+ wigo._wlan.ioctl_set_connection_policy(0, 0, 0);
+
+
#ifndef CC3000_TINY_DRIVER
- #ifdef AP_KEY
- connect_to_ssid((uint8_t *)SSID,(uint8_t *)AP_KEY,AP_SECURITY);
- #else
- connect_to_ssid((uint8_t *)SSID);
- #endif
+#ifdef AP_KEY
+ connect_to_ssid((uint8_t *)SSID,(uint8_t *)AP_KEY,AP_SECURITY);
#else
- connect_to_ssid((uint8_t *)SSID);
+ connect_to_ssid((uint8_t *)SSID);
#endif
-
+#else
+ connect_to_ssid((uint8_t *)SSID);
+#endif
+#endif
printf("DHCP request\n");
while (wigo.is_dhcp_configured() == false) {
wait_ms(500);
--- a/main.h Sat Sep 14 05:13:00 2013 +0000 +++ b/main.h Sun Sep 15 14:41:26 2013 +0000 @@ -16,43 +16,20 @@ #ifndef MAIN_H #define MAIN_H -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#define SMART_CONFIG_SET 0x55 -#define TCPIP_PORT 15000 - -#define USE_DHCP 1 -#define USE_STATIC_IP 2 - +/* use this defines in AP_SECURITY */ #define NONE 0 #define WEP 1 #define WPA 2 #define WPA2 3 -// Modify the following settings as necessary for your Wi-Fi Network setup: -#define IP_ALLOC_METHOD USE_DHCP // for DHCP assigned IP address -//#define IP_ALLOC_METHOD USE_STATIC_IP // for static IP address +// use smart config +#define USE_SMART_CONFIG 0 -// Default SSID Settings -#define AP_KEY "87654321" + // Default SSID Settings +#define AP_KEY "test" #define AP_SECURITY WPA2 // WPA2 must be enabled for use with iPhone or Android phone hotspot! #define SSID "test" -//#define AP_SECURITY NONE // no security but will connect quicker! -#define STATIC_IP_OCT1 192 -#define STATIC_IP_OCT2 168 -#define STATIC_IP_OCT3 0 -#define STATIC_IP_OCT4 103 - -#define STATIC_GW_OCT4 1 // Static Gateway address = STATIC_IP_OCT1.STATIC_IP_OCT2.STATIC_IP_OCT3.STATIC_GW_OCT4 - -#define REQ_BUFFER_SIZE 400 - +/* Board specific */ #define WIGO_BOARD 1 #if (WIGO_BOARD == 1)