From 18bf2ac699f176d46d4c86ea50a52bde90c7b664 Mon Sep 17 00:00:00 2001 From: Alexander Bobkov Date: Tue, 4 Mar 2025 20:18:56 -0500 Subject: [PATCH] wifi scan --- ESP32-Console/main/cmd_scan_wifi.h | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ESP32-Console/main/cmd_scan_wifi.h b/ESP32-Console/main/cmd_scan_wifi.h index 1234540cd..ce781c2c3 100644 --- a/ESP32-Console/main/cmd_scan_wifi.h +++ b/ESP32-Console/main/cmd_scan_wifi.h @@ -10,4 +10,51 @@ static struct { static int exec_scan_wifi_cmd(int argc, char **argv); static void register_scan_wifi_cmd(void); +static int exec_scan_wifi_cmd(int argc, char **argv) { + + printf("Scanning Wi-Fi ...\n"); + + int nerrors = arg_parse(argc, argv, (void**) &scan_wifi_args); + if (nerrors != 0) { + arg_print_errors(stderr, gpio_get_args.end, argv[0]); + s = 1; + } + else { + // Gets GPIO level + if (gpio_get_args.gpio->count > 0) { + pin = gpio_get_args.gpio->ival[0]; + printf("\nGPIO: %d \n", pin); + //ESP_LOGI("gpio-get", "GPIO # %i", gpio_get_args.gpio->ival[0]); + //gpio_dump_io_configuration(stdout, 1ULL << gpio_get_args.gpio->ival[0]); + printf("GPIO #%d level is %d\n", gpio_get_args.gpio->ival[0], gpio_get_level(gpio_get_args.gpio->ival[0])); + ESP_LOGW("gpio-get", "%d ", gpio_get_level(GPIO_NUM_8)); + //printf("GPIO level was changed."); + s = 0; + } + // Dump GPIO configuration information. + if (gpio_get_args.dump->count > 0) { + printf("Printing GPIO dump ...\n"); + printf("GPDIO: %d \n", gpio_get_args.dump->ival[0]); + gpio_dump_io_configuration(stdout, 1ULL << gpio_get_args.dump->ival[0]); + s = 0; + } + } + return s; +} + +static void register_scan_wifi_cmd (void) { + + gpio_get_args.gpio = arg_int0("p", "pin", "", "Specifies GPIO to be used."); + gpio_get_args.dump = arg_int0("d", "dump", "", "Outputs the GPIO dump."); + gpio_get_args.end = arg_end(5); + const esp_console_cmd_t gpio_get_cmd = { + .command = "gpio-get", + .help = "Displays information about GPIOs", + .hint = NULL, + .func = &exec_gpio_get_cmd, + .argtable = &gpio_get_args + }; + ESP_ERROR_CHECK(esp_console_cmd_register(&gpio_get_cmd)); +} + #endif \ No newline at end of file