update cli and change esp_log to printf

This commit is contained in:
Laila van Reenen 2024-06-27 18:09:52 +02:00
parent fd6e6fa48e
commit 668a62c90e
Signed by: LailaTheElf
GPG Key ID: 1F4E6EE3E6DDF769
6 changed files with 137 additions and 124 deletions

11
rcrf-wifi.code-workspace Normal file
View File

@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
},
{
"path": "rx_esp32"
}
],
"settings": {}
}

@ -1 +1 @@
Subproject commit 09ae51070be1be5ebf6717649460510dd744cf65 Subproject commit f08c8e5788cb24b7321697560987ecca9322e050

View File

@ -13,4 +13,7 @@ static uint8_t BoatId = 1;
static const char *TAG = "rcrf-rx_esp32"; static const char *TAG = "rcrf-rx_esp32";
// cli config
#define HISTORY
#endif #endif

View File

@ -2,7 +2,6 @@
#include <stdint.h> #include <stdint.h>
#include "nvs_flash.h" #include "nvs_flash.h"
#include "esp_log.h"
#include "esp_wifi.h" #include "esp_wifi.h"
#include "esp_event.h" #include "esp_event.h"
#include "esp_task_wdt.h" #include "esp_task_wdt.h"
@ -24,9 +23,9 @@ bool rxBuffer_overflow = false;
* CLI char out function. used to print back to a CLI, but the lib * CLI char out function. used to print back to a CLI, but the lib
* is only used for reciving command and not having a full cli * is only used for reciving command and not having a full cli
*/ */
int charOut(const char* line) int charOut(const char* c)
{ {
printf(line); printf(c);
return 0; return 0;
} }
@ -60,7 +59,6 @@ void app_main() {
// // wait so I have time to open the serial monitor // // wait so I have time to open the serial monitor
// for (unsigned long i=1; i < 1000000; i++) // for (unsigned long i=1; i < 1000000; i++)
// { // {
// if (i % 100 == 0) // if (i % 100 == 0)
// { // {
// printf(","); // printf(",");
@ -83,11 +81,11 @@ void app_main() {
* happened. */ * happened. */
if (bits & WIFI_CONNECTED_BIT) if (bits & WIFI_CONNECTED_BIT)
{ {
printf("INFO: connected to ap SSID:%s password:%s\n", WIFI_SSID, WIFI_PASS); printf("INFO: connected to ap SSID '%s'\n", WIFI_SSID);
} }
else if (bits & WIFI_FAIL_BIT) else if (bits & WIFI_FAIL_BIT)
{ {
printf("ERROR: Failed to connect to SSID:%s, password:%s\n", WIFI_SSID, WIFI_PASS); printf("ERROR: Failed to connect to SSID '%s',\n", WIFI_SSID);
} }
else else
{ {
@ -95,39 +93,42 @@ void app_main() {
return; return;
} }
// while(true) // // setup UDP server
{ // int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
printf(":3"); // if (sock < 0)
} // {
// printf("FAITAL: failed to create UDP socket\n");
// return;
// }
running = true; // running = true;
cmdList = getCMDList(); // cmdList = getCMDList();
// init cli
CLI_init((CLI_charOutFn)&charOut, cmdList);
while (running) // // init cli
{ // CLI_init((CLI_charOutFn)&charOut, cmdList);
int packetSize = UDP.parsePacket();
while (packetSize) {
char c;
int len = UDP.read(&c, 1);
if (len == 1)
{
CLI_charIn(c);
packetSize--;
}
else
{
printf("UDP read error");
break;
}
}
}
CLI_deinit(); // while (running)
CMDList_deinit(cmdList); // {
// int packetSize = UDP.parsePacket();
// while (packetSize) {
// char c;
// int len = UDP.read(&c, 1);
// if (len == 1)
// {
// CLI_charIn(c);
// packetSize--;
// }
// else
// {
// printf("UDP read error");
// break;
// }
// }
// }
// CLI_deinit();
// CMDList_deinit(cmdList);
return; return;
} }

View File

@ -4,7 +4,6 @@
#include <stdint.h> #include <stdint.h>
#include "nvs_flash.h" #include "nvs_flash.h"
#include "esp_log.h"
#include "esp_wifi.h" #include "esp_wifi.h"
#include "esp_event.h" #include "esp_event.h"
@ -25,30 +24,30 @@ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_
switch (event_id) switch (event_id)
{ {
case WIFI_EVENT_WIFI_READY: case WIFI_EVENT_WIFI_READY:
ESP_LOGI(TAG, "WiFi ready"); printf("INFO: WiFi ready\n");
break; break;
case WIFI_EVENT_SCAN_DONE: case WIFI_EVENT_SCAN_DONE:
ESP_LOGI(TAG, "Finished scanning AP"); printf("INFO: Finished scanning AP\n");
break; break;
case WIFI_EVENT_STA_START: case WIFI_EVENT_STA_START:
ESP_LOGI(TAG, "Station start"); printf("INFO: Station start\n");
esp_wifi_connect(); esp_wifi_connect();
break; break;
case WIFI_EVENT_STA_STOP: case WIFI_EVENT_STA_STOP:
ESP_LOGI(TAG, "Station stop"); printf("INFO: Station stop\n");
break; break;
case WIFI_EVENT_STA_CONNECTED: case WIFI_EVENT_STA_CONNECTED:
ESP_LOGI(TAG, "Station connected to AP"); printf("INFO: Station connected to AP\n");
break; break;
case WIFI_EVENT_STA_DISCONNECTED: case WIFI_EVENT_STA_DISCONNECTED:
ESP_LOGI(TAG, "Station disconnected from AP"); printf("INFO: Station disconnected from AP\n");
if (s_retry_num < MAX_RETRY_ATTEMPTS) if (s_retry_num < MAX_RETRY_ATTEMPTS)
{ {
s_retry_num++; s_retry_num++;
ESP_LOGI(TAG, "retry num %d", s_retry_num); printf("INFO: retry num %d", s_retry_num);
for (unsigned long i=0; i < 10000000; i++) for (unsigned long i=0; i < 10000000; i++)
{ {
// printf("."); // printf(".\n");
} }
esp_wifi_connect(); esp_wifi_connect();
} }
@ -59,119 +58,119 @@ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_
break; break;
break; break;
case WIFI_EVENT_STA_AUTHMODE_CHANGE: case WIFI_EVENT_STA_AUTHMODE_CHANGE:
ESP_LOGI(TAG, "the auth mode of AP connected by device's station changed"); printf("INFO: the auth mode of AP connected by device's station changed\n");
break; break;
case WIFI_EVENT_STA_WPS_ER_SUCCESS: case WIFI_EVENT_STA_WPS_ER_SUCCESS:
ESP_LOGI(TAG, "Station wps succeeds in enrollee mode"); printf("INFO: Station wps succeeds in enrollee mode\n");
break; break;
case WIFI_EVENT_STA_WPS_ER_FAILED: case WIFI_EVENT_STA_WPS_ER_FAILED:
ESP_LOGI(TAG, "Station wps fails in enrollee mode"); printf("INFO: Station wps fails in enrollee mode\n");
break; break;
case WIFI_EVENT_STA_WPS_ER_TIMEOUT: case WIFI_EVENT_STA_WPS_ER_TIMEOUT:
ESP_LOGI(TAG, "Station wps timeout in enrollee mode"); printf("INFO: Station wps timeout in enrollee mode\n");
break; break;
case WIFI_EVENT_STA_WPS_ER_PIN: case WIFI_EVENT_STA_WPS_ER_PIN:
ESP_LOGI(TAG, "Station wps pin code in enrollee mode"); printf("INFO: Station wps pin code in enrollee mode\n");
break; break;
case WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP: case WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP:
ESP_LOGI(TAG, "Station wps overlap in enrollee mode"); printf("INFO: Station wps overlap in enrollee mode\n");
break; break;
case WIFI_EVENT_AP_START: case WIFI_EVENT_AP_START:
ESP_LOGI(TAG, "Soft-AP start"); printf("INFO: Soft-AP start\n");
break; break;
case WIFI_EVENT_AP_STOP: case WIFI_EVENT_AP_STOP:
ESP_LOGI(TAG, "Soft-AP stop"); printf("INFO: Soft-AP stop\n");
break; break;
case WIFI_EVENT_AP_STACONNECTED: case WIFI_EVENT_AP_STACONNECTED:
ESP_LOGI(TAG, "a station connected to Soft-AP"); printf("INFO: a station connected to Soft-AP\n");
break; break;
case WIFI_EVENT_AP_STADISCONNECTED: case WIFI_EVENT_AP_STADISCONNECTED:
ESP_LOGI(TAG, "a station disconnected from Soft-AP"); printf("INFO: a station disconnected from Soft-AP\n");
break; break;
case WIFI_EVENT_AP_PROBEREQRECVED: case WIFI_EVENT_AP_PROBEREQRECVED:
ESP_LOGI(TAG, "Receive probe request packet in soft-AP interface"); printf("INFO: Receive probe request packet in soft-AP interface\n");
break; break;
case WIFI_EVENT_FTM_REPORT: case WIFI_EVENT_FTM_REPORT:
ESP_LOGI(TAG, "Receive report of FTM procedure"); printf("INFO: Receive report of FTM procedure\n");
break; break;
case WIFI_EVENT_STA_BSS_RSSI_LOW: case WIFI_EVENT_STA_BSS_RSSI_LOW:
ESP_LOGI(TAG, "AP's RSSI crossed configured threshold"); printf("INFO: AP's RSSI crossed configured threshold\n");
break; break;
case WIFI_EVENT_ACTION_TX_STATUS: case WIFI_EVENT_ACTION_TX_STATUS:
ESP_LOGI(TAG, "Status indication of Action Tx operation"); printf("INFO: Status indication of Action Tx operation\n");
break; break;
case WIFI_EVENT_ROC_DONE: case WIFI_EVENT_ROC_DONE:
ESP_LOGI(TAG, "Remain-on-Channel operation complete"); printf("INFO: Remain-on-Channel operation complete\n");
break; break;
case WIFI_EVENT_STA_BEACON_TIMEOUT: case WIFI_EVENT_STA_BEACON_TIMEOUT:
ESP_LOGI(TAG, "Station beacon timeout"); printf("INFO: Station beacon timeout\n");
break; break;
case WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START: case WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START:
ESP_LOGI(TAG, "Connectionless module wake interval start"); printf("INFO: Connectionless module wake interval start\n");
break; break;
case WIFI_EVENT_AP_WPS_RG_SUCCESS: case WIFI_EVENT_AP_WPS_RG_SUCCESS:
ESP_LOGI(TAG, "Soft-AP wps succeeds in registrar mode"); printf("INFO: Soft-AP wps succeeds in registrar mode\n");
break; break;
case WIFI_EVENT_AP_WPS_RG_FAILED: case WIFI_EVENT_AP_WPS_RG_FAILED:
ESP_LOGI(TAG, "Soft-AP wps fails in registrar mode"); printf("INFO: Soft-AP wps fails in registrar mode\n");
break; break;
case WIFI_EVENT_AP_WPS_RG_TIMEOUT: case WIFI_EVENT_AP_WPS_RG_TIMEOUT:
ESP_LOGI(TAG, "Soft-AP wps timeout in registrar mode"); printf("INFO: Soft-AP wps timeout in registrar mode\n");
break; break;
case WIFI_EVENT_AP_WPS_RG_PIN: case WIFI_EVENT_AP_WPS_RG_PIN:
ESP_LOGI(TAG, "Soft-AP wps pin code in registrar mode"); printf("INFO: Soft-AP wps pin code in registrar mode\n");
break; break;
case WIFI_EVENT_AP_WPS_RG_PBC_OVERLAP: case WIFI_EVENT_AP_WPS_RG_PBC_OVERLAP:
ESP_LOGI(TAG, "Soft-AP wps overlap in registrar mode"); printf("INFO: Soft-AP wps overlap in registrar mode\n");
break; break;
case WIFI_EVENT_ITWT_SETUP: case WIFI_EVENT_ITWT_SETUP:
ESP_LOGI(TAG, "iTWT setup"); printf("INFO: iTWT setup\n");
break; break;
case WIFI_EVENT_ITWT_TEARDOWN: case WIFI_EVENT_ITWT_TEARDOWN:
ESP_LOGI(TAG, "iTWT teardown"); printf("INFO: iTWT teardown\n");
break; break;
case WIFI_EVENT_ITWT_PROBE: case WIFI_EVENT_ITWT_PROBE:
ESP_LOGI(TAG, "iTWT probe"); printf("INFO: iTWT probe\n");
break; break;
case WIFI_EVENT_ITWT_SUSPEND: case WIFI_EVENT_ITWT_SUSPEND:
ESP_LOGI(TAG, "iTWT suspend"); printf("INFO: iTWT suspend\n");
break; break;
case WIFI_EVENT_NAN_STARTED: case WIFI_EVENT_NAN_STARTED:
ESP_LOGI(TAG, "NAN Discovery has started"); printf("INFO: NAN Discovery has started\n");
break; break;
case WIFI_EVENT_NAN_STOPPED: case WIFI_EVENT_NAN_STOPPED:
ESP_LOGI(TAG, "NAN Discovery has stopped"); printf("INFO: NAN Discovery has stopped\n");
break; break;
case WIFI_EVENT_NAN_SVC_MATCH: case WIFI_EVENT_NAN_SVC_MATCH:
ESP_LOGI(TAG, "NAN Service Discovery match found"); printf("INFO: NAN Service Discovery match found\n");
break; break;
case WIFI_EVENT_NAN_REPLIED: case WIFI_EVENT_NAN_REPLIED:
ESP_LOGI(TAG, "Replied to a NAN peer with Service Discovery match"); printf("INFO: Replied to a NAN peer with Service Discovery match\n");
break; break;
case WIFI_EVENT_NAN_RECEIVE: case WIFI_EVENT_NAN_RECEIVE:
ESP_LOGI(TAG, "Received a Follow-up message"); printf("INFO: Received a Follow-up message\n");
break; break;
case WIFI_EVENT_NDP_INDICATION: case WIFI_EVENT_NDP_INDICATION:
ESP_LOGI(TAG, "Received NDP Request from a NAN Peer"); printf("INFO: Received NDP Request from a NAN Peer\n");
break; break;
case WIFI_EVENT_NDP_CONFIRM: case WIFI_EVENT_NDP_CONFIRM:
ESP_LOGI(TAG, "NDP Confirm Indication"); printf("INFO: NDP Confirm Indication\n");
break; break;
case WIFI_EVENT_NDP_TERMINATED: case WIFI_EVENT_NDP_TERMINATED:
ESP_LOGI(TAG, "NAN Datapath terminated indication"); printf("INFO: NAN Datapath terminated indication\n");
break; break;
case WIFI_EVENT_HOME_CHANNEL_CHANGE: case WIFI_EVENT_HOME_CHANNEL_CHANGE:
ESP_LOGI(TAG, "WiFi home channel changedoesn't occur when scanning"); printf("INFO: WiFi home channel changedoesn't occur when scanning\n");
break; break;
case WIFI_EVENT_MAX: case WIFI_EVENT_MAX:
ESP_LOGI(TAG, "Invalid WiFi event ID"); printf("INFO: Invalid WiFi event ID\n");
break; break;
} }
} }
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
{ {
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); printf("INFO: got ip: " IPSTR "\n", IP2STR(&event->ip_info.ip));
s_retry_num = 0; s_retry_num = 0;
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
} }
@ -199,7 +198,7 @@ void wifiInit()
ESP_ERROR_CHECK(esp_event_handler_instance_register( ESP_ERROR_CHECK(esp_event_handler_instance_register(
IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL, &instance_got_ip)); IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL, &instance_got_ip));
ESP_LOGI(TAG, "wifi_init_sta finished."); printf("INFO: wifi_init_sta finished.\n");
} }
void wifi_connect() void wifi_connect()

View File

@ -4,7 +4,6 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h" #include "freertos/event_groups.h"
#include "esp_wifi.h" #include "esp_wifi.h"
#include "esp_log.h"
#include "esp_event.h" #include "esp_event.h"
#include "nvs_flash.h" #include "nvs_flash.h"
#include "regex.h" #include "regex.h"
@ -25,37 +24,37 @@ static void print_auth_mode(int authmode)
{ {
switch (authmode) { switch (authmode) {
case WIFI_AUTH_OPEN: case WIFI_AUTH_OPEN:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_OPEN"); printf("INFO: \tAuthmode: WIFI_AUTH_OPEN\n");
break; break;
case WIFI_AUTH_OWE: case WIFI_AUTH_OWE:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_OWE"); printf("INFO: \tAuthmode: WIFI_AUTH_OWE\n");
break; break;
case WIFI_AUTH_WEP: case WIFI_AUTH_WEP:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_WEP"); printf("INFO: \tAuthmode: WIFI_AUTH_WEP\n");
break; break;
case WIFI_AUTH_WPA_PSK: case WIFI_AUTH_WPA_PSK:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_WPA_PSK"); printf("INFO: \tAuthmode: WIFI_AUTH_WPA_PSK\n");
break; break;
case WIFI_AUTH_WPA2_PSK: case WIFI_AUTH_WPA2_PSK:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_WPA2_PSK"); printf("INFO: \tAuthmode: WIFI_AUTH_WPA2_PSK\n");
break; break;
case WIFI_AUTH_WPA_WPA2_PSK: case WIFI_AUTH_WPA_WPA2_PSK:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_WPA_WPA2_PSK"); printf("INFO: \tAuthmode: WIFI_AUTH_WPA_WPA2_PSK\n");
break; break;
case WIFI_AUTH_ENTERPRISE: case WIFI_AUTH_ENTERPRISE:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_ENTERPRISE"); printf("INFO: \tAuthmode: WIFI_AUTH_ENTERPRISE\n");
break; break;
case WIFI_AUTH_WPA3_PSK: case WIFI_AUTH_WPA3_PSK:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_WPA3_PSK"); printf("INFO: \tAuthmode: WIFI_AUTH_WPA3_PSK\n");
break; break;
case WIFI_AUTH_WPA2_WPA3_PSK: case WIFI_AUTH_WPA2_WPA3_PSK:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_WPA2_WPA3_PSK"); printf("INFO: \tAuthmode: WIFI_AUTH_WPA2_WPA3_PSK\n");
break; break;
case WIFI_AUTH_WPA3_ENT_192: case WIFI_AUTH_WPA3_ENT_192:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_WPA3_ENT_192"); printf("INFO: \tAuthmode: WIFI_AUTH_WPA3_ENT_192\n");
break; break;
default: default:
ESP_LOGI(TAG_SCAN, "\tAuthmode: WIFI_AUTH_UNKNOWN"); printf("INFO: \tAuthmode: WIFI_AUTH_UNKNOWN\n");
break; break;
} }
} }
@ -64,70 +63,70 @@ static void print_cipher_type(int pairwise_cipher, int group_cipher)
{ {
switch (pairwise_cipher) { switch (pairwise_cipher) {
case WIFI_CIPHER_TYPE_NONE: case WIFI_CIPHER_TYPE_NONE:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_NONE"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_NONE\n");
break; break;
case WIFI_CIPHER_TYPE_WEP40: case WIFI_CIPHER_TYPE_WEP40:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_WEP40"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_WEP40\n");
break; break;
case WIFI_CIPHER_TYPE_WEP104: case WIFI_CIPHER_TYPE_WEP104:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_WEP104"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_WEP104\n");
break; break;
case WIFI_CIPHER_TYPE_TKIP: case WIFI_CIPHER_TYPE_TKIP:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP\n");
break; break;
case WIFI_CIPHER_TYPE_CCMP: case WIFI_CIPHER_TYPE_CCMP:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_CCMP"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_CCMP\n");
break; break;
case WIFI_CIPHER_TYPE_TKIP_CCMP: case WIFI_CIPHER_TYPE_TKIP_CCMP:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP\n");
break; break;
case WIFI_CIPHER_TYPE_AES_CMAC128: case WIFI_CIPHER_TYPE_AES_CMAC128:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_AES_CMAC128"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_AES_CMAC128\n");
break; break;
case WIFI_CIPHER_TYPE_SMS4: case WIFI_CIPHER_TYPE_SMS4:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_SMS4"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_SMS4\n");
break; break;
case WIFI_CIPHER_TYPE_GCMP: case WIFI_CIPHER_TYPE_GCMP:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP\n");
break; break;
case WIFI_CIPHER_TYPE_GCMP256: case WIFI_CIPHER_TYPE_GCMP256:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP256"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP256\n");
break; break;
default: default:
ESP_LOGI(TAG_SCAN, "\tPairwise Cipher: WIFI_CIPHER_TYPE_UNKNOWN"); printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_UNKNOWN\n");
break; break;
} }
switch (group_cipher) { switch (group_cipher) {
case WIFI_CIPHER_TYPE_NONE: case WIFI_CIPHER_TYPE_NONE:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_NONE"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_NONE\n");
break; break;
case WIFI_CIPHER_TYPE_WEP40: case WIFI_CIPHER_TYPE_WEP40:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_WEP40"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_WEP40\n");
break; break;
case WIFI_CIPHER_TYPE_WEP104: case WIFI_CIPHER_TYPE_WEP104:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_WEP104"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_WEP104\n");
break; break;
case WIFI_CIPHER_TYPE_TKIP: case WIFI_CIPHER_TYPE_TKIP:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_TKIP"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_TKIP\n");
break; break;
case WIFI_CIPHER_TYPE_CCMP: case WIFI_CIPHER_TYPE_CCMP:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_CCMP"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_CCMP\n");
break; break;
case WIFI_CIPHER_TYPE_TKIP_CCMP: case WIFI_CIPHER_TYPE_TKIP_CCMP:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP\n");
break; break;
case WIFI_CIPHER_TYPE_SMS4: case WIFI_CIPHER_TYPE_SMS4:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_SMS4"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_SMS4\n");
break; break;
case WIFI_CIPHER_TYPE_GCMP: case WIFI_CIPHER_TYPE_GCMP:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_GCMP"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_GCMP\n");
break; break;
case WIFI_CIPHER_TYPE_GCMP256: case WIFI_CIPHER_TYPE_GCMP256:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_GCMP256"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_GCMP256\n");
break; break;
default: default:
ESP_LOGI(TAG_SCAN, "\tGroup Cipher: WIFI_CIPHER_TYPE_UNKNOWN"); printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_UNKNOWN\n");
break; break;
} }
} }
@ -156,7 +155,7 @@ void wifi_scan()
#ifdef USE_CHANNEL_BTIMAP #ifdef USE_CHANNEL_BTIMAP
wifi_scan_config_t *scan_config = (wifi_scan_config_t *)calloc(1,sizeof(wifi_scan_config_t)); wifi_scan_config_t *scan_config = (wifi_scan_config_t *)calloc(1,sizeof(wifi_scan_config_t));
if (!scan_config) { if (!scan_config) {
ESP_LOGE(TAG_SCAN, "Memory Allocation for scan config failed!"); printf("ERROR: Memory Allocation for scan config failed!\n");
return; return;
} }
array_2_channel_bitmap(channel_list, CHANNEL_LIST_SIZE, scan_config); array_2_channel_bitmap(channel_list, CHANNEL_LIST_SIZE, scan_config);
@ -166,16 +165,16 @@ void wifi_scan()
esp_wifi_scan_start(NULL, true); esp_wifi_scan_start(NULL, true);
#endif /*USE_CHANNEL_BTIMAP*/ #endif /*USE_CHANNEL_BTIMAP*/
ESP_LOGI(TAG_SCAN, "Max AP number ap_info can hold = %u", number); printf("INFO: Max AP number ap_info can hold = %u\n", number);
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count)); ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info)); ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info));
ESP_LOGI(TAG_SCAN, "Total APs scanned = %u, actual AP number ap_info holds = %u", ap_count, number); printf("INFO: Total APs scanned = %u, actual AP number ap_info holds = %u\n", ap_count, number);
for (int i = 0; i < number; i++) { for (int i = 0; i < number; i++) {
ESP_LOGI(TAG_SCAN, "%s \tRSSI: %d", ap_info[i].ssid, ap_info[i].rssi); printf("INFO: %s \tRSSI: %d", ap_info[i].ssid, ap_info[i].rssi);
print_auth_mode(ap_info[i].authmode); print_auth_mode(ap_info[i].authmode);
if (ap_info[i].authmode != WIFI_AUTH_WEP) { // if (ap_info[i].authmode != WIFI_AUTH_WEP) {
print_cipher_type(ap_info[i].pairwise_cipher, ap_info[i].group_cipher); // print_cipher_type(ap_info[i].pairwise_cipher, ap_info[i].group_cipher);
} // }
ESP_LOGI(TAG_SCAN, "\tChannel: %d", ap_info[i].primary); printf("INFO: \tChannel: %d\n", ap_info[i].primary);
} }
} }