first commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "wifi_scan.c"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,17 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: '>=4.1.0'
|
||||
# # Put list of dependencies here
|
||||
# # For components maintained by Espressif:
|
||||
# component: "~1.0.0"
|
||||
# # For 3rd party components:
|
||||
# username/component: ">=1.0.0,<2.0.0"
|
||||
# username2/component2:
|
||||
# version: "~1.0.0"
|
||||
# # For transient dependencies `public` flag can be set.
|
||||
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||
# # All dependencies of `main` are public by default.
|
||||
# public: true
|
||||
espressif/esp_wifi_remote: ^0.14.2
|
||||
@@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_remote.h"
|
||||
|
||||
|
||||
#define TAG "app_main"
|
||||
#define SCAN_LIST_SIZE 20
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
esp_wifi_set_mode(WIFI_MODE_STA);
|
||||
esp_wifi_start();
|
||||
|
||||
uint16_t number = SCAN_LIST_SIZE;
|
||||
wifi_ap_record_t ap_info[SCAN_LIST_SIZE];
|
||||
uint16_t ap_count = 0;
|
||||
memset(ap_info, 0, sizeof(ap_info));
|
||||
|
||||
esp_wifi_scan_start(NULL, true);
|
||||
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
|
||||
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info));
|
||||
|
||||
ESP_LOGI(TAG,"-------------------------------------------------------");
|
||||
ESP_LOGI(TAG,"|\tSSID\t\t\t\t RSSI\t\t|");
|
||||
|
||||
for (int i = 0; (i < SCAN_LIST_SIZE) && (i < ap_count); i++) {
|
||||
ESP_LOGI(TAG,"|\t%-*s %d\t\t|",33,ap_info[i].ssid, ap_info[i].rssi);
|
||||
}
|
||||
ESP_LOGI(TAG,"-------------------------------------------------------");
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user