/******************************************************************************* * Function Name : Start_Smart_Config. * Description : The function triggers a smart configuration process on CC3000. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Start_Smart_Config(void) { WLAN_SMART_CONFIG_FINISHED = 0; WLAN_SMART_CONFIG_STOP = 0; WLAN_SERIAL_CONFIG_DONE = 0; WLAN_CONNECTED = 0; WLAN_DHCP = 0; WLAN_CAN_SHUTDOWN = 0; SPARK_SOCKET_CONNECTED = 0; SPARK_HANDSHAKE_COMPLETED = 0; SPARK_FLASH_UPDATE = 0; SPARK_LED_FADE = 0; LED_SetRGBColor(RGB_COLOR_BLUE); LED_On(LED_RGB); /* Reset all the previous configuration */ wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE); NVMEM_Spark_File_Data[WLAN_POLICY_FILE_OFFSET] = 0; nvmem_write(NVMEM_SPARK_FILE_ID, 1, WLAN_POLICY_FILE_OFFSET, &NVMEM_Spark_File_Data[WLAN_POLICY_FILE_OFFSET]); /* Wait until CC3000 is disconnected */ while (WLAN_CONNECTED == 1) { //Delay 100ms Delay(100); hci_unsolicited_event_handler(); } /* Create new entry for AES encryption key */ nvmem_create_entry(NVMEM_AES128_KEY_FILEID,16); /* Write AES key to NVMEM */ aes_write_key((unsigned char *)(&smartconfigkey[0])); wlan_smart_config_set_prefix((char*)aucCC3000_prefix); /* Start the SmartConfig start process */ wlan_smart_config_start(1); WiFiCredentialsReader wifi_creds_reader(wifi_add_profile_callback); /* Wait for SmartConfig/SerialConfig to finish */ while (!(WLAN_SMART_CONFIG_FINISHED | WLAN_SERIAL_CONFIG_DONE)) { if(WLAN_DELETE_PROFILES && wlan_ioctl_del_profile(255) == 0) { int toggle = 25; while(toggle--) { LED_Toggle(LED_RGB); Delay(50); } NVMEM_Spark_File_Data[WLAN_PROFILE_FILE_OFFSET] = 0; nvmem_write(NVMEM_SPARK_FILE_ID, 1, WLAN_PROFILE_FILE_OFFSET, &NVMEM_Spark_File_Data[WLAN_PROFILE_FILE_OFFSET]); WLAN_DELETE_PROFILES = 0; } else { LED_Toggle(LED_RGB); Delay(250); wifi_creds_reader.read(); } } LED_On(LED_RGB); /* read count of wlan profiles stored */ nvmem_read(NVMEM_SPARK_FILE_ID, 1, WLAN_PROFILE_FILE_OFFSET, &NVMEM_Spark_File_Data[WLAN_PROFILE_FILE_OFFSET]); // if(NVMEM_Spark_File_Data[WLAN_PROFILE_FILE_OFFSET] >= 7) // { // if(wlan_ioctl_del_profile(255) == 0) // NVMEM_Spark_File_Data[WLAN_PROFILE_FILE_OFFSET] = 0; // } if(WLAN_SMART_CONFIG_FINISHED) { /* Decrypt configuration information and add profile */ wlan_profile_index = wlan_smart_config_process(); } if(wlan_profile_index != -1) { NVMEM_Spark_File_Data[WLAN_PROFILE_FILE_OFFSET] = wlan_profile_index + 1; } /* write count of wlan profiles stored */ nvmem_write(NVMEM_SPARK_FILE_ID, 1, WLAN_PROFILE_FILE_OFFSET, &NVMEM_Spark_File_Data[WLAN_PROFILE_FILE_OFFSET]); /* Configure to connect automatically to the AP retrieved in the Smart config process */ wlan_ioctl_set_connection_policy(DISABLE, DISABLE, ENABLE); NVMEM_Spark_File_Data[WLAN_POLICY_FILE_OFFSET] = 1; nvmem_write(NVMEM_SPARK_FILE_ID, 1, WLAN_POLICY_FILE_OFFSET, &NVMEM_Spark_File_Data[WLAN_POLICY_FILE_OFFSET]); /* Reset the CC3000 */ wlan_stop(); Delay(100); wlan_start(0); SPARK_WLAN_STARTED = 1; /* Mask out all non-required events */ wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE | HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_ASYNC_PING_REPORT); LED_SetRGBColor(RGB_COLOR_GREEN); LED_On(LED_RGB); Set_NetApp_Timeout(); WLAN_SMART_CONFIG_START = 0; }
void StartSmartConfig(void) { ulSmartConfigFinished = 0; ulCC3000Connected = 0; ulCC3000DHCP = 0; OkToDoShutDown=0; // Reset all the previous configuration wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE); wlan_ioctl_del_profile(255); //Wait until CC3000 is disconnected while (ulCC3000Connected == 1) { SysCtlDelay(100); hci_unsolicited_event_handler(); } // Start blinking LED1 during Smart Configuration process turnLedOn(1); wlan_smart_config_set_prefix((char*)aucCC3000_prefix); turnLedOff(1); // Start the SmartConfig start process wlan_smart_config_start(1); turnLedOn(1); // Wait for Smart config to finish while (ulSmartConfigFinished == 0) { turnLedOff(1); SysCtlDelay(16500000); turnLedOn(1); SysCtlDelay(16500000); } turnLedOn(1); // create new entry for AES encryption key nvmem_create_entry(NVMEM_AES128_KEY_FILEID,16); // write AES key to NVMEM aes_write_key((unsigned char *)(&smartconfigkey[0])); // Decrypt configuration information and add profile wlan_smart_config_process(); // Configure to connect automatically to the AP retrieved in the // Smart config process wlan_ioctl_set_connection_policy(DISABLE, DISABLE, ENABLE); // reset the CC3000 wlan_stop(); DispatcherUartSendPacket((unsigned char*)pucUARTCommandSmartConfigDoneString, sizeof(pucUARTCommandSmartConfigDoneString)); SysCtlDelay(100000); wlan_start(0); // Mask out all non-required events wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT| HCI_EVNT_WLAN_ASYNC_PING_REPORT); }
void StartSmartConfig(void) { // Reset all the previous configuration // wlan_ioctl_set_connection_policy(0, 0, 0); wlan_ioctl_del_profile(255); //Wait until CC3000 is dissconected while (ulCC3000Connected == 1) { __delay_cycles(100); } // Start blinking LED6 during Smart Configuration process turnLedOn(LED6); wlan_smart_config_set_prefix(aucCC3000_prefix); //wlan_first_time_config_set_prefix(aucCC3000_prefix); turnLedOff(LED6); // Start the SmartConfig start process wlan_smart_config_start(1); turnLedOn(LED6); // // Wait for Smart config finished // while (ulSmartConfigFinished == 0) { __delay_cycles(6000000); turnLedOn(LED6); __delay_cycles(6000000); turnLedOff(LED6); } turnLedOff(LED6); // create new entry for AES encryption key nvmem_create_entry(NVMEM_AES128_KEY_FILEID,16); // write AES key to NVMEM aes_write_key((unsigned char *)(&smartconfigkey[0])); // Decrypt configuration information and add profile wlan_smart_config_process(); // // Configure to connect automatically to the AP retrieved in the // Smart config process // wlan_ioctl_set_connection_policy(0, 0, 1); // // reset the CC3000 // wlan_stop(); __delay_cycles(600000); wlan_start(0); ConnectUsingSmartConfig = 1; ulSmartConfigFinished = 0; // // Mask out all non-required events // wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT); }