diff --git a/rx_esp32/src/CMakeLists.txt b/rx_esp32/src/CMakeLists.txt index 00ecd11..d6973b8 100644 --- a/rx_esp32/src/CMakeLists.txt +++ b/rx_esp32/src/CMakeLists.txt @@ -10,6 +10,7 @@ idf_component_register( ./led.c ./commands.c ./servos.c + ./logger.c INCLUDE_DIRS "./" PRIV_REQUIRES # project components diff --git a/rx_esp32/src/commands.c b/rx_esp32/src/commands.c index 0a4018d..6ef7445 100644 --- a/rx_esp32/src/commands.c +++ b/rx_esp32/src/commands.c @@ -8,6 +8,7 @@ #include #include "commands.h" +#include "logger.h" #include "utils.h" #include "led.h" #include "servos.h" @@ -144,13 +145,26 @@ int cmd_history(char* line, void* cli) return 0; } +int cmd_showlog(char* line, void* cli) +{ + logger_printFullLog(cli); + return 0; +} + +int cmd_clearlog(char* line, void* cli) +{ + logger_clearBuffer(); + return 0; +} const CMD_t Commands[] = { { "history", &cmd_history }, { "d", &cmd_contrl }, { "shutdown", &cmd_shutdown }, { "status", &cmd_status }, - { "led", &setLed } + { "led", &setLed }, + { "log", &cmd_showlog }, + { "logclear", &cmd_clearlog } }; CMDList_t* getCMDList() diff --git a/rx_esp32/src/logger.c b/rx_esp32/src/logger.c new file mode 100644 index 0000000..2648e15 --- /dev/null +++ b/rx_esp32/src/logger.c @@ -0,0 +1,51 @@ +#include +#include +#include + +#include "logger.h" + +#ifndef LOGGER_BUFFER_SIZE +#define LOGGER_BUFFER_SIZE 65536 +#endif + +char Logger_buff[LOGGER_BUFFER_SIZE]; +uint16_t Logger_buff_wp = 0; + +void logger_printf(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + int len = vsnprintf(&Logger_buff[Logger_buff_wp], LOGGER_BUFFER_SIZE-Logger_buff_wp, fmt, args); + va_end(args); + + puts(&Logger_buff[Logger_buff_wp]); + Logger_buff_wp += len + 1; +} + +void logger_printFullLog(CLI_t* cli) +{ + uint16_t line = 0; + char str[20]; + snprintf(str, 20, "%03u: ", line); + CLI_stringOut(cli, str); + line++; + for (uint16_t i = 0; i < Logger_buff_wp-1; i++) + { + if (Logger_buff[i] != '\0') + { + CLI_charOut_save(cli, Logger_buff[i]); + } + else + { + snprintf(str, 20, "\n%03u: ", line); + CLI_stringOut(cli, str); + line++; + } + } + printf("\n"); +} + +void logger_clearBuffer() +{ + Logger_buff_wp = 0; +} diff --git a/rx_esp32/src/logger.h b/rx_esp32/src/logger.h new file mode 100644 index 0000000..db3b89d --- /dev/null +++ b/rx_esp32/src/logger.h @@ -0,0 +1,26 @@ +#ifndef LOGGER_H +#define LOGGER_H + +#include + +typedef enum { + LOG_DEBUG, + LOG_INFO, + LOG_WARN, + LOG_ERROR, + LOG_CRITICAL +} logger_level_t; + +#define CONSTANT_INT_TO_STR(str) #str + +#define LOG_D(fmt, args...) logger_printf("DEBUG %30s:%3u " fmt, __FILE__, __LINE__, ## args) +#define LOG_I(fmt, args...) logger_printf("INFO %30s:%3u " fmt, __FILE__, __LINE__, ## args) +#define LOG_W(fmt, args...) logger_printf("WARN %30s:%3u " fmt, __FILE__, __LINE__, ## args) +#define LOG_E(fmt, args...) logger_printf("ERROR %30s:%3u " fmt, __FILE__, __LINE__, ## args) +#define LOG_C(fmt, args...) logger_printf("\n\n\n!!!!!!!!!! CRITICAL ERROR !!!!!!!!!!!!!!\n\n\tfile: %s:%3u\n\tmsg: " fmt "\n\n", __FILE__, __LINE__, ## args) + +void logger_printf( const char *fmt, ...); +void logger_printFullLog(CLI_t* cli); +void logger_clearBuffer(); + +#endif diff --git a/rx_esp32/src/main.c b/rx_esp32/src/main.c index 3047095..f0739e8 100644 --- a/rx_esp32/src/main.c +++ b/rx_esp32/src/main.c @@ -15,6 +15,7 @@ #include "wifi.h" #include "led.h" #include "servos.h" +#include "logger.h" bool volatile running = true; CMDList_t* cmdList; @@ -73,15 +74,17 @@ void app_main() { if (bits & WIFI_CONNECTED_BIT) { led_setRGB(0, 20, 0); - printf("INFO: main: connected to ap SSID '%s'\n", WIFI_SSID); + LOG_I("main: connected to ap SSID '%s'", WIFI_SSID); } else if (bits & WIFI_FAIL_BIT) { led_setRGB(2, 0, 0); + LOG_E("main: Failed to connect to SSID '%s',", WIFI_SSID); } else { led_setRGB(2, 0, 0); + LOG_C("main: UNEXPECTED EVENT"); return; } diff --git a/rx_esp32/src/servos.c b/rx_esp32/src/servos.c index c6bb520..bc3225e 100644 --- a/rx_esp32/src/servos.c +++ b/rx_esp32/src/servos.c @@ -1,9 +1,10 @@ -#include "driver/ledc.h" +#include #include #include "config.h" #include "servos.h" +#include "logger.h" #define SERVO_LEDC_TIMER LEDC_TIMER_0 #define SERVO_LEDC_MODE LEDC_LOW_SPEED_MODE @@ -57,7 +58,7 @@ void servo_init(void) .hpoint = 0 }; ledc_channel_config(&ledc_channel); - printf("DEBUG: inited servo channel %d (ledc: %u, gpio: %d)\n", i, Server_chs[i].channel, Server_chs[i].gpio); + LOG_D("servo_init: inited servo channel %d (ledc: %u, gpio: %d)", i, Server_chs[i].channel, Server_chs[i].gpio); } } void servo_deinit(void) diff --git a/rx_esp32/src/utils.c b/rx_esp32/src/utils.c index ff43318..1f404c6 100644 --- a/rx_esp32/src/utils.c +++ b/rx_esp32/src/utils.c @@ -4,9 +4,11 @@ #include #include -#include "esp_system.h" -#include "esp_chip_info.h" -#include "esp_flash.h" +#include +#include +#include + +#include "logger.h" char* getNextArg(char* args, const char separator) { @@ -87,7 +89,7 @@ void printChipInfo() esp_chip_info_t chip_info; uint32_t flash_size; esp_chip_info(&chip_info); - printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", + LOG_D("This is %s chip with %d CPU core(s), %s%s%s%s", CONFIG_IDF_TARGET, chip_info.cores, (chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "", @@ -98,15 +100,17 @@ void printChipInfo() unsigned major_rev = chip_info.revision / 100; unsigned minor_rev = chip_info.revision % 100; - printf("silicon revision v%d.%d, ", major_rev, minor_rev); - if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) { - printf("Get flash size failed"); + LOG_D("silicon revision v%d.%d", major_rev, minor_rev); + if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) + { + LOG_W("Get flash size failed"); return; - } + } - printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024), + LOG_D("%" PRIu32 "MB %s flash", + flash_size / (uint32_t)(1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external" ); - printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size()); + LOG_D("Minimum free heap size: %" PRIu32 " bytes", esp_get_minimum_free_heap_size()); } diff --git a/rx_esp32/src/wifi.c b/rx_esp32/src/wifi.c index 935797c..cf1145f 100644 --- a/rx_esp32/src/wifi.c +++ b/rx_esp32/src/wifi.c @@ -3,11 +3,12 @@ #include #include -#include "nvs_flash.h" -#include "esp_wifi.h" -#include "esp_event.h" +#include +#include +#include #include "config.h" +#include "logger.h" #define MAX_RETRY_ATTEMPTS 20 // static int s_ap_creds_num = 0; @@ -24,31 +25,27 @@ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_ switch (event_id) { case WIFI_EVENT_WIFI_READY: - printf("INFO: wifi: WiFi ready\n"); + LOG_I("wifi: WiFi ready"); break; case WIFI_EVENT_SCAN_DONE: - printf("INFO: wifi: Finished scanning AP\n"); + LOG_I("wifi: Finished scanning AP"); break; case WIFI_EVENT_STA_START: - printf("INFO: wifi: Station start\n"); + LOG_I("wifi: Station start"); esp_wifi_connect(); break; case WIFI_EVENT_STA_STOP: - printf("INFO: wifi: Station stop\n"); + LOG_I("wifi: Station stop"); break; case WIFI_EVENT_STA_CONNECTED: - printf("INFO: wifi: Station connected to AP\n"); + LOG_I("wifi: Station connected to AP"); break; case WIFI_EVENT_STA_DISCONNECTED: - printf("WARN: wifi: Station disconnected from AP\n"); + LOG_W("wifi: Station disconnected from AP"); if (s_retry_num < MAX_RETRY_ATTEMPTS) { s_retry_num++; - printf("INFO: wifi: retry num %d\n", s_retry_num); - for (unsigned long i=0; i < 10000000; i++) - { - // printf(".\n"); - } + LOG_I("wifi: retry num %d", s_retry_num); esp_wifi_connect(); } else @@ -58,119 +55,119 @@ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_ break; break; case WIFI_EVENT_STA_AUTHMODE_CHANGE: - printf("INFO: wifi: the auth mode of AP connected by device's station changed\n"); + LOG_I("wifi: the auth mode of AP connected by device's station changed"); break; case WIFI_EVENT_STA_WPS_ER_SUCCESS: - printf("INFO: wifi: Station wps succeeds in enrollee mode\n"); + LOG_I("wifi: Station wps succeeds in enrollee mode"); break; case WIFI_EVENT_STA_WPS_ER_FAILED: - printf("ERROR: wifi: Station wps fails in enrollee mode\n"); + LOG_E("wifi: Station wps fails in enrollee mode"); break; case WIFI_EVENT_STA_WPS_ER_TIMEOUT: - printf("ERROR: wifi: Station wps timeout in enrollee mode\n"); + LOG_E("wifi: Station wps timeout in enrollee mode"); break; case WIFI_EVENT_STA_WPS_ER_PIN: - printf("INFO: wifi: Station wps pin code in enrollee mode\n"); + LOG_I("wifi: Station wps pin code in enrollee mode"); break; case WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP: - printf("INFO: wifi: Station wps overlap in enrollee mode\n"); + LOG_I("wifi: Station wps overlap in enrollee mode"); break; case WIFI_EVENT_AP_START: - printf("INFO: wifi: Soft-AP start\n"); + LOG_I("wifi: Soft-AP start"); break; case WIFI_EVENT_AP_STOP: - printf("INFO: wifi: Soft-AP stop\n"); + LOG_I("wifi: Soft-AP stop"); break; case WIFI_EVENT_AP_STACONNECTED: - printf("INFO: wifi: a station connected to Soft-AP\n"); + LOG_I("wifi: a station connected to Soft-AP"); break; case WIFI_EVENT_AP_STADISCONNECTED: - printf("WARN: wifi: a station disconnected from Soft-AP\n"); + LOG_W("wifi: a station disconnected from Soft-AP"); break; case WIFI_EVENT_AP_PROBEREQRECVED: - printf("INFO: wifi: Receive probe request packet in soft-AP interface\n"); + LOG_I("wifi: Receive probe request packet in soft-AP interface"); break; case WIFI_EVENT_FTM_REPORT: - printf("INFO: wifi: Receive report of FTM procedure\n"); + LOG_I("wifi: Receive report of FTM procedure"); break; case WIFI_EVENT_STA_BSS_RSSI_LOW: - printf("INFO: wifi: AP's RSSI crossed configured threshold\n"); + LOG_I("wifi: AP's RSSI crossed configured threshold"); break; case WIFI_EVENT_ACTION_TX_STATUS: - printf("INFO: wifi: Status indication of Action Tx operation\n"); + LOG_I("wifi: Status indication of Action Tx operation"); break; case WIFI_EVENT_ROC_DONE: - printf("INFO: wifi: Remain-on-Channel operation complete\n"); + LOG_I("wifi: Remain-on-Channel operation complete"); break; case WIFI_EVENT_STA_BEACON_TIMEOUT: - printf("ERROR: wifi: Station beacon timeout\n"); + LOG_E("wifi: Station beacon timeout"); break; case WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START: - printf("INFO: wifi: Connectionless module wake interval start\n"); + LOG_I("wifi: Connectionless module wake interval start"); break; case WIFI_EVENT_AP_WPS_RG_SUCCESS: - printf("INFO: wifi: Soft-AP wps succeeds in registrar mode\n"); + LOG_I("wifi: Soft-AP wps succeeds in registrar mode"); break; case WIFI_EVENT_AP_WPS_RG_FAILED: - printf("ERROR: wifi: Soft-AP wps fails in registrar mode\n"); + LOG_E("wifi: Soft-AP wps fails in registrar mode"); break; case WIFI_EVENT_AP_WPS_RG_TIMEOUT: - printf("ERROR: wifi: Soft-AP wps timeout in registrar mode\n"); + LOG_E("wifi: Soft-AP wps timeout in registrar mode"); break; case WIFI_EVENT_AP_WPS_RG_PIN: - printf("INFO: wifi: Soft-AP wps pin code in registrar mode\n"); + LOG_I("wifi: Soft-AP wps pin code in registrar mode"); break; case WIFI_EVENT_AP_WPS_RG_PBC_OVERLAP: - printf("INFO: wifi: Soft-AP wps overlap in registrar mode\n"); + LOG_I("wifi: Soft-AP wps overlap in registrar mode"); break; case WIFI_EVENT_ITWT_SETUP: - printf("INFO: wifi: iTWT setup\n"); + LOG_I("wifi: iTWT setup"); break; case WIFI_EVENT_ITWT_TEARDOWN: - printf("INFO: wifi: iTWT teardown\n"); + LOG_I("wifi: iTWT teardown"); break; case WIFI_EVENT_ITWT_PROBE: - printf("INFO: wifi: iTWT probe\n"); + LOG_I("wifi: iTWT probe"); break; case WIFI_EVENT_ITWT_SUSPEND: - printf("INFO: wifi: iTWT suspend\n"); + LOG_I("wifi: iTWT suspend"); break; case WIFI_EVENT_NAN_STARTED: - printf("INFO: wifi: NAN Discovery has started\n"); + LOG_I("wifi: NAN Discovery has started"); break; case WIFI_EVENT_NAN_STOPPED: - printf("INFO: wifi: NAN Discovery has stopped\n"); + LOG_I("wifi: NAN Discovery has stopped"); break; case WIFI_EVENT_NAN_SVC_MATCH: - printf("INFO: wifi: NAN Service Discovery match found\n"); + LOG_I("wifi: NAN Service Discovery match found"); break; case WIFI_EVENT_NAN_REPLIED: - printf("INFO: wifi: Replied to a NAN peer with Service Discovery match\n"); + LOG_I("wifi: Replied to a NAN peer with Service Discovery match"); break; case WIFI_EVENT_NAN_RECEIVE: - printf("INFO: wifi: Received a Follow-up message\n"); + LOG_I("wifi: Received a Follow-up message"); break; case WIFI_EVENT_NDP_INDICATION: - printf("INFO: wifi: Received NDP Request from a NAN Peer\n"); + LOG_I("wifi: Received NDP Request from a NAN Peer"); break; case WIFI_EVENT_NDP_CONFIRM: - printf("INFO: wifi: NDP Confirm Indication\n"); + LOG_I("wifi: NDP Confirm Indication"); break; case WIFI_EVENT_NDP_TERMINATED: - printf("INFO: wifi: NAN Datapath terminated indication\n"); + LOG_I("wifi: NAN Datapath terminated indication"); break; case WIFI_EVENT_HOME_CHANNEL_CHANGE: - printf("INFO: wifi: WiFi home channel change,doesn't occur when scanning\n"); + LOG_I("wifi: WiFi home channel change,doesn't occur when scanning"); break; case WIFI_EVENT_MAX: - printf("INFO: wifi: Invalid WiFi event ID\n"); + LOG_I("wifi: Invalid WiFi event ID"); break; } } 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; - printf("INFO: wifi: got ip: " IPSTR "\n", IP2STR(&event->ip_info.ip)); + LOG_I("wifi: got ip: " IPSTR "", IP2STR(&event->ip_info.ip)); s_retry_num = 0; xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); } @@ -198,7 +195,7 @@ void wifiInit() ESP_ERROR_CHECK(esp_event_handler_instance_register( IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL, &instance_got_ip)); - printf("INFO: wifi: wifi_init_sta finished.\n"); + LOG_I("wifi: wifi_init_sta finished."); } void wifi_connect() diff --git a/rx_esp32/src/wifi_scan.c b/rx_esp32/src/wifi_scan.c index ee45bcb..b61bc45 100644 --- a/rx_esp32/src/wifi_scan.c +++ b/rx_esp32/src/wifi_scan.c @@ -8,6 +8,8 @@ #include "nvs_flash.h" #include "regex.h" +#include "logger.h" + #define SCAN_LIST_SIZE 30 #ifdef CONFIG_EXAMPLE_USE_SCAN_CHANNEL_BITMAP @@ -22,37 +24,37 @@ static void print_auth_mode(int authmode) { switch (authmode) { case WIFI_AUTH_OPEN: - printf("INFO: \tAuthmode: WIFI_AUTH_OPEN\n"); + LOG_I("\tAuthmode: WIFI_AUTH_OPEN"); break; case WIFI_AUTH_OWE: - printf("INFO: \tAuthmode: WIFI_AUTH_OWE\n"); + LOG_I("\tAuthmode: WIFI_AUTH_OWE"); break; case WIFI_AUTH_WEP: - printf("INFO: \tAuthmode: WIFI_AUTH_WEP\n"); + LOG_I("\tAuthmode: WIFI_AUTH_WEP"); break; case WIFI_AUTH_WPA_PSK: - printf("INFO: \tAuthmode: WIFI_AUTH_WPA_PSK\n"); + LOG_I("\tAuthmode: WIFI_AUTH_WPA_PSK"); break; case WIFI_AUTH_WPA2_PSK: - printf("INFO: \tAuthmode: WIFI_AUTH_WPA2_PSK\n"); + LOG_I("\tAuthmode: WIFI_AUTH_WPA2_PSK"); break; case WIFI_AUTH_WPA_WPA2_PSK: - printf("INFO: \tAuthmode: WIFI_AUTH_WPA_WPA2_PSK\n"); + LOG_I("\tAuthmode: WIFI_AUTH_WPA_WPA2_PSK"); break; case WIFI_AUTH_ENTERPRISE: - printf("INFO: \tAuthmode: WIFI_AUTH_ENTERPRISE\n"); + LOG_I("\tAuthmode: WIFI_AUTH_ENTERPRISE"); break; case WIFI_AUTH_WPA3_PSK: - printf("INFO: \tAuthmode: WIFI_AUTH_WPA3_PSK\n"); + LOG_I("\tAuthmode: WIFI_AUTH_WPA3_PSK"); break; case WIFI_AUTH_WPA2_WPA3_PSK: - printf("INFO: \tAuthmode: WIFI_AUTH_WPA2_WPA3_PSK\n"); + LOG_I("\tAuthmode: WIFI_AUTH_WPA2_WPA3_PSK"); break; case WIFI_AUTH_WPA3_ENT_192: - printf("INFO: \tAuthmode: WIFI_AUTH_WPA3_ENT_192\n"); + LOG_I("\tAuthmode: WIFI_AUTH_WPA3_ENT_192"); break; default: - printf("INFO: \tAuthmode: WIFI_AUTH_UNKNOWN\n"); + LOG_I("\tAuthmode: WIFI_AUTH_UNKNOWN"); break; } } @@ -61,70 +63,70 @@ static void print_cipher_type(int pairwise_cipher, int group_cipher) { switch (pairwise_cipher) { case WIFI_CIPHER_TYPE_NONE: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_NONE\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_NONE"); break; case WIFI_CIPHER_TYPE_WEP40: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_WEP40\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_WEP40"); break; case WIFI_CIPHER_TYPE_WEP104: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_WEP104\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_WEP104"); break; case WIFI_CIPHER_TYPE_TKIP: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP"); break; case WIFI_CIPHER_TYPE_CCMP: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_CCMP\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_CCMP"); break; case WIFI_CIPHER_TYPE_TKIP_CCMP: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP"); break; case WIFI_CIPHER_TYPE_AES_CMAC128: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_AES_CMAC128\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_AES_CMAC128"); break; case WIFI_CIPHER_TYPE_SMS4: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_SMS4\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_SMS4"); break; case WIFI_CIPHER_TYPE_GCMP: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP"); break; case WIFI_CIPHER_TYPE_GCMP256: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP256\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_GCMP256"); break; default: - printf("INFO: \tPairwise Cipher: WIFI_CIPHER_TYPE_UNKNOWN\n"); + LOG_I("\tPairwise Cipher: WIFI_CIPHER_TYPE_UNKNOWN"); break; } switch (group_cipher) { case WIFI_CIPHER_TYPE_NONE: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_NONE\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_NONE"); break; case WIFI_CIPHER_TYPE_WEP40: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_WEP40\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_WEP40"); break; case WIFI_CIPHER_TYPE_WEP104: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_WEP104\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_WEP104"); break; case WIFI_CIPHER_TYPE_TKIP: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_TKIP\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_TKIP"); break; case WIFI_CIPHER_TYPE_CCMP: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_CCMP\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_CCMP"); break; case WIFI_CIPHER_TYPE_TKIP_CCMP: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_TKIP_CCMP"); break; case WIFI_CIPHER_TYPE_SMS4: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_SMS4\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_SMS4"); break; case WIFI_CIPHER_TYPE_GCMP: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_GCMP\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_GCMP"); break; case WIFI_CIPHER_TYPE_GCMP256: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_GCMP256\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_GCMP256"); break; default: - printf("INFO: \tGroup Cipher: WIFI_CIPHER_TYPE_UNKNOWN\n"); + LOG_I("\tGroup Cipher: WIFI_CIPHER_TYPE_UNKNOWN"); break; } } @@ -153,7 +155,7 @@ void wifi_scan() #ifdef USE_CHANNEL_BTIMAP wifi_scan_config_t *scan_config = (wifi_scan_config_t *)calloc(1,sizeof(wifi_scan_config_t)); if (!scan_config) { - printf("ERROR: Memory Allocation for scan config failed!\n"); + LOG_I("Memory Allocation for scan config failed!"); return; } array_2_channel_bitmap(channel_list, CHANNEL_LIST_SIZE, scan_config); @@ -163,16 +165,16 @@ void wifi_scan() esp_wifi_scan_start(NULL, true); #endif /*USE_CHANNEL_BTIMAP*/ - printf("INFO: Max AP number ap_info can hold = %u\n", number); + LOG_I("Max AP number ap_info can hold = %u", number); ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count)); ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info)); - printf("INFO: Total APs scanned = %u, actual AP number ap_info holds = %u\n", ap_count, number); + LOG_I("Total APs scanned = %u, actual AP number ap_info holds = %u", ap_count, number); for (int i = 0; i < number; i++) { - printf("INFO: %s \tRSSI: %d", ap_info[i].ssid, ap_info[i].rssi); + LOG_I("%s \tRSSI: %d", ap_info[i].ssid, ap_info[i].rssi); print_auth_mode(ap_info[i].authmode); // if (ap_info[i].authmode != WIFI_AUTH_WEP) { // print_cipher_type(ap_info[i].pairwise_cipher, ap_info[i].group_cipher); // } - printf("INFO: \tChannel: %d\n", ap_info[i].primary); + LOG_I("\tChannel: %d", ap_info[i].primary); } }