void ESP8266WiFiClass::printDiag(Print& p) { const char* modes[] = {"NULL", "STA", "AP", "STA+AP"}; p.print("Mode: "); p.println(modes[wifi_get_opmode()]); const char* phymodes[] = {"", "B", "G", "N"}; p.print("PHY mode: "); p.println(phymodes[(int) wifi_get_phy_mode()]); p.print("Channel: "); p.println(wifi_get_channel()); p.print("AP id: "); p.println(wifi_station_get_current_ap_id()); p.print("Status: "); p.println(wifi_station_get_connect_status()); p.print("Auto connect: "); p.println(wifi_station_get_auto_connect()); static struct station_config conf; wifi_station_get_config(&conf); const char* ssid = reinterpret_cast<const char*>(conf.ssid); p.print("SSID ("); p.print(strlen(ssid)); p.print("): "); p.println(ssid); const char* passphrase = reinterpret_cast<const char*>(conf.password); p.print("Passphrase ("); p.print(strlen(passphrase)); p.print("): "); p.println(passphrase); p.print("BSSID set: "); p.println(conf.bssid_set); }
/****************************************************************************** * FunctionName : user_esp_platform_ap_change * Description : add the user interface for changing to next ap ID. * Parameters : * Returns : none *******************************************************************************/ LOCAL void ICACHE_FLASH_ATTR user_esp_platform_ap_change(void) { uint8 current_id; uint8 i = 0; ESP_DBG("user_esp_platform_ap_is_changing\n"); current_id = wifi_station_get_current_ap_id(); ESP_DBG("current ap id =%d\n", current_id); if (current_id == AP_CACHE_NUMBER - 1) { i = 0; } else { i = current_id + 1; } while (wifi_station_ap_change(i) != true) { i++; if (i == AP_CACHE_NUMBER - 1) { i = 0; } } }
void ICACHE_FLASH_ATTR APCache_Connect() { //INFO("------------------\r\n"); //INFO("APCache_Connect\r\n"); ap_cache_if=true; struct station_config config[5]; uint8 ap_cnt = wifi_station_get_ap_info(config); INFO("AP CACHE NUM : %d \r\n",ap_cnt); uint8 ap_cur; if(ap_cnt>0){ INFO("AP CACHE FIND, TRY CONNECTING WIFI \r\n"); ap_cur = wifi_station_get_current_ap_id(); ap_cache_record_num = ap_cur; while (1) { ap_cur = ((ap_cur==AP_CACHE_NUMBER-1)?0:ap_cur+1); if(ap_cache_record_num == ap_cur){ INFO("AC CACHE CONNECT FAIL...\r\n"); break; } INFO("ap_cur: %d \r\n",ap_cur); INFO("DEBUG:SSID: %s\r\n",config[ap_cur].ssid); INFO("DEBUG:PASSWORD: %s \r\n",config[ap_cur].password); if(wifi_station_ap_change(ap_cur) == true){ INFO("----------------\r\n"); INFO("CURRENT AP NUM: %d \r\n",ap_cur); INFO("AP CACHE CONNECT: \r\n"); INFO("SSID: %s\r\n",config[ap_cur].ssid); INFO("PASSWORD: %s \r\n",config[ap_cur].password); INFO("----------------\r\n"); wifi_station_disconnect(); WIFI_Connect(config[ap_cur].ssid,config[ap_cur].password,NULL); INFO("CONNECT...\r\n"); INFO("----------------\r\n"); break; } } if(ap_cache_record_num == ap_cur){ APCache_TimeoutCb(); } }else{ _LINE_DESP(); INFO("FIND NO AP CACHE,ENABLE ESPTOUCH NEXT\r\n"); _LINE_DESP(); os_timer_disarm(&ap_cache_t); ap_cache_if = false; #if ESP_TOUCH_SUPPORT INFO("ESP_TOUCH FLG: %d \r\n",esptouch_getAckFlag()); if(false == esptouch_getAckFlag()){ esptouch_FlowStart(); return; } #endif #if ESP_MESH_SUPPORT //else{ INFO("ALREADY DID ESP-TOUCH,RESTART MESH IN 5 S\r\n"); mesh_StopReconnCheck(); mesh_SetSoftap(); os_timer_disarm(&mesh_scan_t); os_timer_setfn(&mesh_scan_t,user_MeshStart,NULL); os_timer_arm(&mesh_scan_t,5000,0); //user_MeshStart(); //} #endif } }