Scanning WIP. Need to sort out supervisor memory
This commit is contained in:
parent
c5b8401a15
commit
1a6f4e0fe0
@ -248,7 +248,7 @@ menuconfig: $(BUILD)/esp-idf/config
|
|||||||
$(HEADER_BUILD)/qstr.i.last: | $(BUILD)/esp-idf/config/sdkconfig.h
|
$(HEADER_BUILD)/qstr.i.last: | $(BUILD)/esp-idf/config/sdkconfig.h
|
||||||
|
|
||||||
# Order here matters
|
# Order here matters
|
||||||
ESP_IDF_COMPONENTS_LINK = freertos log esp_system esp32s2 bootloader_support pthread esp_timer vfs spi_flash app_update esp_common esp32s2 heap newlib driver xtensa soc esp_ringbuf esp_wifi esp_event wpa_supplicant mbedtls efuse nvs_flash
|
ESP_IDF_COMPONENTS_LINK = freertos log esp_system esp32s2 bootloader_support pthread esp_timer vfs spi_flash app_update esp_common esp32s2 heap newlib driver xtensa soc esp_ringbuf esp_wifi esp_event wpa_supplicant mbedtls efuse nvs_flash esp_netif lwip
|
||||||
|
|
||||||
ESP_IDF_COMPONENTS_INCLUDE = driver freertos log soc
|
ESP_IDF_COMPONENTS_INCLUDE = driver freertos log soc
|
||||||
|
|
||||||
@ -278,8 +278,10 @@ esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
|
|||||||
esp-idf/bootloader_support/libbootloader_support.a \
|
esp-idf/bootloader_support/libbootloader_support.a \
|
||||||
esp-idf/esp32s2/ld/esp32s2.project.ld \
|
esp-idf/esp32s2/ld/esp32s2.project.ld \
|
||||||
esp-idf/esp_event/libesp_event.a \
|
esp-idf/esp_event/libesp_event.a \
|
||||||
|
esp-idf/esp_netif/libesp_netif.a \
|
||||||
esp-idf/esp_system/libesp_system.a \
|
esp-idf/esp_system/libesp_system.a \
|
||||||
esp-idf/esp_wifi/libesp_wifi.a \
|
esp-idf/esp_wifi/libesp_wifi.a \
|
||||||
|
esp-idf/lwip/liblwip.a \
|
||||||
esp-idf/nvs_flash/libnvs_flash.a \
|
esp-idf/nvs_flash/libnvs_flash.a \
|
||||||
esp-idf/wpa_supplicant/libwpa_supplicant.a \
|
esp-idf/wpa_supplicant/libwpa_supplicant.a \
|
||||||
esp-idf/mbedtls/libmbedtls.a \
|
esp-idf/mbedtls/libmbedtls.a \
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
|
||||||
|
#include "esp-idf/components/esp_wifi/include/esp_wifi_types.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
// Stores no state currently.
|
wifi_ap_record_t record;
|
||||||
} wifi_network_obj_t;
|
} wifi_network_obj_t;
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_NETWORK_H
|
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_NETWORK_H
|
||||||
|
@ -26,28 +26,62 @@
|
|||||||
|
|
||||||
#include "shared-bindings/wifi/Radio.h"
|
#include "shared-bindings/wifi/Radio.h"
|
||||||
|
|
||||||
|
#include "py/runtime.h"
|
||||||
|
#include "shared-bindings/wifi/ScannedNetworks.h"
|
||||||
|
|
||||||
|
#include "esp-idf/components/esp_wifi/include/esp_wifi.h"
|
||||||
|
|
||||||
bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self) {
|
bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self) {
|
||||||
return true;
|
return self->started;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) {
|
void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) {
|
||||||
|
if (self->started && !enabled) {
|
||||||
|
esp_wifi_stop();
|
||||||
|
self->started = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!self->started && enabled) {
|
||||||
|
esp_wifi_start();
|
||||||
|
self->started = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {
|
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {
|
||||||
|
uint8_t mac[6];
|
||||||
|
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) {
|
mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) {
|
||||||
return mp_const_none;
|
if (self->current_scan != NULL) {
|
||||||
|
mp_raise_RuntimeError(translate("Already scanning for wifi networks"));
|
||||||
|
}
|
||||||
|
// check enabled
|
||||||
|
|
||||||
|
wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t);
|
||||||
|
self->current_scan = scan;
|
||||||
|
scan->base.type = &wifi_scannednetworks_type;
|
||||||
|
scan->start_channel = 1;
|
||||||
|
scan->end_channel = 11;
|
||||||
|
scan->radio_event_group = self->event_group_handle;
|
||||||
|
wifi_scannednetworks_scan_next_channel(scan);
|
||||||
|
return scan;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self) {
|
void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self) {
|
||||||
|
// Free the memory used to store the found aps.
|
||||||
|
wifi_scannednetworks_deinit(self->current_scan);
|
||||||
|
self->current_scan = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, mp_float_t timeout) {
|
bool common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, mp_float_t timeout) {
|
||||||
return false;
|
// check enabled
|
||||||
|
wifi_config_t config;
|
||||||
|
esp_err_t result = esp_wifi_set_config(ESP_IF_WIFI_STA, &config);
|
||||||
|
result = esp_wifi_connect();
|
||||||
|
return result == ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t common_hal_wifi_radio_get_ip_address(wifi_radio_obj_t *self) {
|
mp_obj_t common_hal_wifi_radio_get_ip_address(wifi_radio_obj_t *self) {
|
||||||
|
@ -29,9 +29,21 @@
|
|||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
|
||||||
|
#include "esp-idf/components/esp_event/include/esp_event.h"
|
||||||
|
|
||||||
|
#include "shared-bindings/wifi/ScannedNetworks.h"
|
||||||
|
|
||||||
|
// Event bits for the Radio event group.
|
||||||
|
#define WIFI_SCAN_DONE_BIT BIT0
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
// Stores no state currently.
|
esp_event_handler_instance_t handler_instance_all_wifi;
|
||||||
|
esp_event_handler_instance_t handler_instance_got_ip;
|
||||||
|
wifi_scannednetworks_obj_t *current_scan;
|
||||||
|
StaticEventGroup_t event_group;
|
||||||
|
EventGroupHandle_t event_group_handle;
|
||||||
|
bool started;
|
||||||
} wifi_radio_obj_t;
|
} wifi_radio_obj_t;
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_RADIO_H
|
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_RADIO_H
|
||||||
|
159
ports/esp32s2/common-hal/wifi/ScannedNetworks.c
Normal file
159
ports/esp32s2/common-hal/wifi/ScannedNetworks.c
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
||||||
|
* Copyright (c) 2018 Artur Pacholec
|
||||||
|
* Copyright (c) 2017 Glenn Ruben Bakke
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "lib/utils/interrupt_char.h"
|
||||||
|
#include "py/objstr.h"
|
||||||
|
#include "py/runtime.h"
|
||||||
|
#include "shared-bindings/wifi/__init__.h"
|
||||||
|
#include "shared-bindings/wifi/Network.h"
|
||||||
|
#include "shared-bindings/wifi/Radio.h"
|
||||||
|
#include "shared-bindings/wifi/ScannedNetworks.h"
|
||||||
|
|
||||||
|
#include "esp-idf/components/esp_wifi/include/esp_wifi.h"
|
||||||
|
|
||||||
|
static void wifi_scannednetworks_done(wifi_scannednetworks_obj_t *self) {
|
||||||
|
self->done = true;
|
||||||
|
free(self->results);
|
||||||
|
self->results = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool wifi_scannednetworks_wait_for_scan(wifi_scannednetworks_obj_t *self) {
|
||||||
|
EventBits_t bits = xEventGroupWaitBits(self->radio_event_group,
|
||||||
|
WIFI_SCAN_DONE_BIT,
|
||||||
|
pdTRUE,
|
||||||
|
pdTRUE,
|
||||||
|
0);
|
||||||
|
while ((bits & WIFI_SCAN_DONE_BIT) == 0 && !mp_hal_is_interrupted()) {
|
||||||
|
RUN_BACKGROUND_TASKS;
|
||||||
|
bits = xEventGroupWaitBits(self->radio_event_group,
|
||||||
|
WIFI_SCAN_DONE_BIT,
|
||||||
|
pdTRUE,
|
||||||
|
pdTRUE,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
return !mp_hal_is_interrupted();
|
||||||
|
}
|
||||||
|
|
||||||
|
mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) {
|
||||||
|
if (self->done) {
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
// If we are scanning, wait and then load them.
|
||||||
|
if (self->scanning) {
|
||||||
|
// We may have to scan more than one channel to get a result.
|
||||||
|
while (!self->done) {
|
||||||
|
if (!wifi_scannednetworks_wait_for_scan(self)) {
|
||||||
|
wifi_scannednetworks_done(self);
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_wifi_scan_get_ap_num(&self->total_results);
|
||||||
|
if (self->total_results > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// If total_results is zero then we need to start a scan and wait again.
|
||||||
|
wifi_scannednetworks_scan_next_channel(self);
|
||||||
|
}
|
||||||
|
// We not have found any more results so we're done.
|
||||||
|
if (self->done) {
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
// If we need more space than we have, realloc.
|
||||||
|
if (self->total_results > self->max_results) {
|
||||||
|
wifi_ap_record_t* results = m_renew_maybe(wifi_ap_record_t,
|
||||||
|
self->results,
|
||||||
|
self->max_results,
|
||||||
|
self->total_results,
|
||||||
|
true /* allow move */);
|
||||||
|
if (results != NULL) {
|
||||||
|
self->results = results;
|
||||||
|
self->max_results = self->total_results;
|
||||||
|
} else {
|
||||||
|
if (self->max_results == 0) {
|
||||||
|
// No room for any results should error.
|
||||||
|
mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate wifi scan memory"));
|
||||||
|
}
|
||||||
|
// Unable to allocate more results, so load what we can.
|
||||||
|
self->total_results = self->max_results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
esp_wifi_scan_get_ap_records(&self->total_results, self->results);
|
||||||
|
self->scanning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wifi_network_obj_t *entry = m_new_obj(wifi_network_obj_t);
|
||||||
|
entry->base.type = &wifi_network_type;
|
||||||
|
memcpy(&entry->record, &self->results[self->current_result], sizeof(wifi_ap_record_t));
|
||||||
|
self->current_result++;
|
||||||
|
|
||||||
|
// If we're returning our last network then start the next channel scan or
|
||||||
|
// be done.
|
||||||
|
if (self->current_result >= self->total_results) {
|
||||||
|
wifi_scannednetworks_scan_next_channel(self);
|
||||||
|
self->total_results = 0;
|
||||||
|
self->current_result = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MP_OBJ_FROM_PTR(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't do a linear scan so that we look at a variety of spectrum up front.
|
||||||
|
static uint8_t scan_pattern[] = {6, 1, 11, 3, 9, 13, 2, 4, 8, 12, 5, 7, 10, 14};
|
||||||
|
|
||||||
|
void wifi_scannednetworks_scan_next_channel(wifi_scannednetworks_obj_t *self) {
|
||||||
|
wifi_scan_config_t config;
|
||||||
|
uint8_t next_channel = sizeof(scan_pattern);
|
||||||
|
while (self->current_channel_index < sizeof(scan_pattern)) {
|
||||||
|
next_channel = scan_pattern[self->current_channel_index];
|
||||||
|
self->current_channel_index++;
|
||||||
|
if (self->start_channel <= next_channel && next_channel <= self->end_channel) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (next_channel == sizeof(scan_pattern) ||
|
||||||
|
esp_wifi_scan_start(&config, false) != ESP_OK) {
|
||||||
|
wifi_scannednetworks_done(self);
|
||||||
|
} else {
|
||||||
|
self->scanning = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wifi_scannednetworks_deinit(wifi_scannednetworks_obj_t* self) {
|
||||||
|
// if a scan is active, make sure and clean up the idf's buffer of results.
|
||||||
|
if (self->scanning) {
|
||||||
|
esp_wifi_scan_stop();
|
||||||
|
if (wifi_scannednetworks_wait_for_scan(self)) {
|
||||||
|
uint16_t number = 0;
|
||||||
|
esp_wifi_scan_get_ap_records(&number, NULL);
|
||||||
|
self->scanning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wifi_scannednetworks_done(self);
|
||||||
|
}
|
62
ports/esp32s2/common-hal/wifi/ScannedNetworks.h
Normal file
62
ports/esp32s2/common-hal/wifi/ScannedNetworks.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
||||||
|
* Copyright (c) 2018 Artur Pacholec
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_SCANNEDNETWORKS_H
|
||||||
|
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_SCANNEDNETWORKS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "py/obj.h"
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "freertos/event_groups.h"
|
||||||
|
|
||||||
|
#include "esp-idf/components/esp_wifi/include/esp_wifi_types.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
mp_obj_base_t base;
|
||||||
|
uint8_t current_channel_index;
|
||||||
|
EventGroupHandle_t radio_event_group;
|
||||||
|
|
||||||
|
// Results from the last channel scan
|
||||||
|
wifi_ap_record_t* results;
|
||||||
|
uint16_t current_result;
|
||||||
|
uint16_t total_results;
|
||||||
|
uint16_t max_results;
|
||||||
|
|
||||||
|
// Limits on what channels to scan.
|
||||||
|
uint8_t start_channel;
|
||||||
|
uint8_t end_channel; // Inclusive
|
||||||
|
|
||||||
|
bool done;
|
||||||
|
bool scanning;
|
||||||
|
} wifi_scannednetworks_obj_t;
|
||||||
|
|
||||||
|
void wifi_scannednetworks_scan_next_channel(wifi_scannednetworks_obj_t *self);
|
||||||
|
void wifi_scannednetworks_deinit(wifi_scannednetworks_obj_t *self);
|
||||||
|
|
||||||
|
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_SCANNEDNETWORKS_H
|
@ -28,22 +28,88 @@
|
|||||||
|
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
|
#include "esp_log.h"
|
||||||
|
static const char *TAG = "cp wifi";
|
||||||
|
|
||||||
#include "esp-idf/components/esp_wifi/include/esp_wifi.h"
|
#include "esp-idf/components/esp_wifi/include/esp_wifi.h"
|
||||||
|
|
||||||
wifi_radio_obj_t common_hal_wifi_radio_obj;
|
wifi_radio_obj_t common_hal_wifi_radio_obj;
|
||||||
|
|
||||||
void common_hal_wifi_init(void) {
|
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||||
common_hal_wifi_radio_obj.base.type = &wifi_radio_type;
|
int32_t event_id, void* event_data) {
|
||||||
wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
|
ESP_LOGI(TAG, "event");
|
||||||
|
wifi_radio_obj_t* radio = arg;
|
||||||
|
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_SCAN_DONE) {
|
||||||
|
xEventGroupSetBits(radio->event_group_handle, WIFI_SCAN_DONE_BIT);
|
||||||
|
}
|
||||||
|
// esp_wifi_connect();
|
||||||
|
// if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||||
|
// esp_wifi_connect();
|
||||||
|
// } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||||
|
// if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) {
|
||||||
|
// esp_wifi_connect();
|
||||||
|
// s_retry_num++;
|
||||||
|
// ESP_LOGI(TAG, "retry to connect to the AP");
|
||||||
|
// } else {
|
||||||
|
// xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||||
|
// }
|
||||||
|
// ESP_LOGI(TAG,"connect to the AP fail");
|
||||||
|
// } 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;
|
||||||
|
// ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||||
|
// s_retry_num = 0;
|
||||||
|
// xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool wifi_inited;
|
||||||
|
|
||||||
|
void common_hal_wifi_init(void) {
|
||||||
|
ESP_LOGI(TAG, "init");
|
||||||
|
wifi_inited = true;
|
||||||
|
common_hal_wifi_radio_obj.base.type = &wifi_radio_type;
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_netif_init());
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||||
|
esp_netif_create_default_wifi_sta();
|
||||||
|
|
||||||
|
wifi_radio_obj_t* self = &common_hal_wifi_radio_obj;
|
||||||
|
self->event_group_handle = xEventGroupCreateStatic(&self->event_group);
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||||
|
ESP_EVENT_ANY_ID,
|
||||||
|
&event_handler,
|
||||||
|
self,
|
||||||
|
self->handler_instance_all_wifi));
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||||
|
IP_EVENT_STA_GOT_IP,
|
||||||
|
&event_handler,
|
||||||
|
self,
|
||||||
|
self->handler_instance_got_ip));
|
||||||
|
|
||||||
|
|
||||||
|
wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
esp_err_t result = esp_wifi_init(&config);
|
esp_err_t result = esp_wifi_init(&config);
|
||||||
if (result == ESP_ERR_NO_MEM) {
|
if (result == ESP_ERR_NO_MEM) {
|
||||||
mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate Wifi memory"));
|
mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate Wifi memory"));
|
||||||
} else if (result != ESP_OK) {
|
} else if (result != ESP_OK) {
|
||||||
// handle this
|
// handle this
|
||||||
}
|
}
|
||||||
|
common_hal_wifi_radio_set_enabled(self, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_reset(void) {
|
void wifi_reset(void) {
|
||||||
|
ESP_LOGI(TAG, "reset");
|
||||||
|
if (!wifi_inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wifi_radio_obj_t* radio = &common_hal_wifi_radio_obj;
|
||||||
|
common_hal_wifi_radio_set_enabled(radio, false);
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT,
|
||||||
|
ESP_EVENT_ANY_ID,
|
||||||
|
radio->handler_instance_all_wifi));
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT,
|
||||||
|
IP_EVENT_STA_GOT_IP,
|
||||||
|
radio->handler_instance_got_ip));
|
||||||
esp_wifi_deinit();
|
esp_wifi_deinit();
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,6 @@
|
|||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
|
||||||
|
void wifi_reset(void);
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI___INIT___H
|
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI___INIT___H
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f5aff20b378f7c4002605a4158a41630c21f343d
|
Subproject commit e15ce11ebca15a1f6eca22779e89f761b1fc2142
|
@ -3,8 +3,8 @@
|
|||||||
# bootloader.bin 0x1000
|
# bootloader.bin 0x1000
|
||||||
# partition table 0x8000, 0xC00
|
# partition table 0x8000, 0xC00
|
||||||
otadata, data, ota, 0xd000, 0x2000,
|
otadata, data, ota, 0xd000, 0x2000,
|
||||||
ota_0, 0, ota_0, 0x10000, 512K,
|
ota_0, 0, ota_0, 0x10000, 0x100000,
|
||||||
ota_1, 0, ota_1, 0x90000, 512K,
|
ota_1, 0, ota_1, 0x110000, 0x100000,
|
||||||
phy_init, data, phy, 0x110000, 0x1000,
|
phy_init, data, phy, 0x210000, 0x1000,
|
||||||
nvs, data, nvs, 0x111000, 0x6000,
|
nvs, data, nvs, 0x211000, 0x6000,
|
||||||
user_fs, data, fat, 0x200000, 2M,
|
user_fs, data, fat, 0x217000, 0x1e9000,
|
||||||
|
|
@ -122,8 +122,8 @@ CONFIG_PARTITION_TABLE_MD5=y
|
|||||||
#
|
#
|
||||||
# Compiler options
|
# Compiler options
|
||||||
#
|
#
|
||||||
CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y
|
# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
|
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set
|
||||||
@ -331,10 +331,17 @@ CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
|
|||||||
CONFIG_ESP32_WIFI_TX_BA_WIN=6
|
CONFIG_ESP32_WIFI_TX_BA_WIN=6
|
||||||
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
|
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
|
||||||
CONFIG_ESP32_WIFI_RX_BA_WIN=6
|
CONFIG_ESP32_WIFI_RX_BA_WIN=6
|
||||||
CONFIG_ESP32_WIFI_NVS_ENABLED=y
|
# CONFIG_ESP32_WIFI_NVS_ENABLED is not set
|
||||||
CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752
|
CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752
|
||||||
CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32
|
CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32
|
||||||
# CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE is not set
|
CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE=y
|
||||||
|
CONFIG_ESP32_WIFI_DEBUG_LOG_DEBUG=y
|
||||||
|
# CONFIG_ESP32_WIFI_DEBUG_LOG_VERBOSE is not set
|
||||||
|
# CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_ALL is not set
|
||||||
|
CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_WIFI=y
|
||||||
|
# CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_COEX is not set
|
||||||
|
# CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_MESH is not set
|
||||||
|
# CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE is not set
|
||||||
CONFIG_ESP32_WIFI_IRAM_OPT=y
|
CONFIG_ESP32_WIFI_IRAM_OPT=y
|
||||||
CONFIG_ESP32_WIFI_RX_IRAM_OPT=y
|
CONFIG_ESP32_WIFI_RX_IRAM_OPT=y
|
||||||
# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set
|
# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set
|
||||||
@ -387,7 +394,6 @@ CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
|
|||||||
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
||||||
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
|
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
|
||||||
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
||||||
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
|
|
||||||
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
|
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
|
||||||
# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
|
# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
|
||||||
CONFIG_FREERTOS_DEBUG_OCDAWARE=y
|
CONFIG_FREERTOS_DEBUG_OCDAWARE=y
|
||||||
@ -576,8 +582,8 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y
|
|||||||
|
|
||||||
CONFIG_MBEDTLS_SSL_RENEGOTIATION=y
|
CONFIG_MBEDTLS_SSL_RENEGOTIATION=y
|
||||||
# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set
|
# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set
|
||||||
CONFIG_MBEDTLS_SSL_PROTO_TLS1=y
|
# CONFIG_MBEDTLS_SSL_PROTO_TLS1 is not set
|
||||||
CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y
|
# CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 is not set
|
||||||
CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y
|
CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y
|
||||||
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
|
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
|
||||||
CONFIG_MBEDTLS_SSL_ALPN=y
|
CONFIG_MBEDTLS_SSL_ALPN=y
|
||||||
@ -708,7 +714,7 @@ CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128
|
|||||||
CONFIG_WPA_MBEDTLS_CRYPTO=y
|
CONFIG_WPA_MBEDTLS_CRYPTO=y
|
||||||
# CONFIG_WPA_DEBUG_PRINT is not set
|
# CONFIG_WPA_DEBUG_PRINT is not set
|
||||||
# CONFIG_WPA_TESTING_OPTIONS is not set
|
# CONFIG_WPA_TESTING_OPTIONS is not set
|
||||||
# CONFIG_WPA_TLS_V12 is not set
|
CONFIG_WPA_TLS_V12=y
|
||||||
# CONFIG_WPA_WPS_WARS is not set
|
# CONFIG_WPA_WPS_WARS is not set
|
||||||
# end of Supplicant
|
# end of Supplicant
|
||||||
# end of Component config
|
# end of Component config
|
||||||
@ -743,8 +749,8 @@ CONFIG_MONITOR_BAUD_115200B=y
|
|||||||
# CONFIG_MONITOR_BAUD_OTHER is not set
|
# CONFIG_MONITOR_BAUD_OTHER is not set
|
||||||
CONFIG_MONITOR_BAUD_OTHER_VAL=115200
|
CONFIG_MONITOR_BAUD_OTHER_VAL=115200
|
||||||
CONFIG_MONITOR_BAUD=115200
|
CONFIG_MONITOR_BAUD=115200
|
||||||
CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y
|
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
|
CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
|
||||||
# CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED is not set
|
# CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED is not set
|
||||||
CONFIG_OPTIMIZATION_ASSERTIONS_SILENT=y
|
CONFIG_OPTIMIZATION_ASSERTIONS_SILENT=y
|
||||||
# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set
|
# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set
|
||||||
|
@ -39,15 +39,25 @@
|
|||||||
#include "common-hal/busio/SPI.h"
|
#include "common-hal/busio/SPI.h"
|
||||||
#include "common-hal/busio/UART.h"
|
#include "common-hal/busio/UART.h"
|
||||||
#include "common-hal/pulseio/PWMOut.h"
|
#include "common-hal/pulseio/PWMOut.h"
|
||||||
|
#include "common-hal/wifi/__init__.h"
|
||||||
#include "supervisor/memory.h"
|
#include "supervisor/memory.h"
|
||||||
#include "supervisor/shared/tick.h"
|
#include "supervisor/shared/tick.h"
|
||||||
|
|
||||||
|
#include "esp-idf/components/heap/include/esp_heap_caps.h"
|
||||||
|
|
||||||
|
#include "esp_log.h"
|
||||||
|
static const char *TAG = "cp port";
|
||||||
|
|
||||||
|
#define HEAP_SIZE (96 * 1024)
|
||||||
|
|
||||||
STATIC esp_timer_handle_t _tick_timer;
|
STATIC esp_timer_handle_t _tick_timer;
|
||||||
|
|
||||||
void tick_timer_cb(void* arg) {
|
void tick_timer_cb(void* arg) {
|
||||||
supervisor_tick();
|
supervisor_tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t* heap;
|
||||||
|
|
||||||
safe_mode_t port_init(void) {
|
safe_mode_t port_init(void) {
|
||||||
esp_timer_create_args_t args;
|
esp_timer_create_args_t args;
|
||||||
args.callback = &tick_timer_cb;
|
args.callback = &tick_timer_cb;
|
||||||
@ -55,6 +65,12 @@ safe_mode_t port_init(void) {
|
|||||||
args.dispatch_method = ESP_TIMER_TASK;
|
args.dispatch_method = ESP_TIMER_TASK;
|
||||||
args.name = "CircuitPython Tick";
|
args.name = "CircuitPython Tick";
|
||||||
esp_timer_create(&args, &_tick_timer);
|
esp_timer_create(&args, &_tick_timer);
|
||||||
|
|
||||||
|
heap = malloc(HEAP_SIZE);
|
||||||
|
if (heap == NULL) {
|
||||||
|
heap_caps_print_heap_info(MALLOC_CAP_8BIT);
|
||||||
|
ESP_LOGE(TAG, "failed to allocate heap");
|
||||||
|
}
|
||||||
never_reset_module_internal_pins();
|
never_reset_module_internal_pins();
|
||||||
return NO_SAFE_MODE;
|
return NO_SAFE_MODE;
|
||||||
}
|
}
|
||||||
@ -73,6 +89,9 @@ void reset_port(void) {
|
|||||||
spi_reset();
|
spi_reset();
|
||||||
uart_reset();
|
uart_reset();
|
||||||
#endif
|
#endif
|
||||||
|
#if CIRCUITPY_WIFI
|
||||||
|
wifi_reset();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_to_bootloader(void) {
|
void reset_to_bootloader(void) {
|
||||||
@ -81,14 +100,14 @@ void reset_to_bootloader(void) {
|
|||||||
void reset_cpu(void) {
|
void reset_cpu(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t heap[64 / sizeof(uint32_t) * 1024];
|
|
||||||
|
|
||||||
uint32_t *port_heap_get_bottom(void) {
|
uint32_t *port_heap_get_bottom(void) {
|
||||||
|
|
||||||
|
ESP_EARLY_LOGI(TAG, "heap %x", heap);
|
||||||
return heap;
|
return heap;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *port_heap_get_top(void) {
|
uint32_t *port_heap_get_top(void) {
|
||||||
return heap + sizeof(heap) / sizeof(heap[0]);
|
return heap + (HEAP_SIZE / sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *port_stack_get_limit(void) {
|
uint32_t *port_stack_get_limit(void) {
|
||||||
@ -110,6 +129,13 @@ supervisor_allocation* port_fixed_stack(void) {
|
|||||||
return &_fixed_stack;
|
return &_fixed_stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supervisor_allocation _fixed_heap;
|
||||||
|
supervisor_allocation* port_fixed_heap(void) {
|
||||||
|
_fixed_heap.ptr = port_heap_get_bottom();
|
||||||
|
_fixed_heap.length = (port_heap_get_top() - port_heap_get_bottom()) * sizeof(uint32_t);
|
||||||
|
return &_fixed_heap;
|
||||||
|
}
|
||||||
|
|
||||||
// Place the word to save just after our BSS section that gets blanked.
|
// Place the word to save just after our BSS section that gets blanked.
|
||||||
void port_set_saved_word(uint32_t value) {
|
void port_set_saved_word(uint32_t value) {
|
||||||
}
|
}
|
||||||
|
@ -338,6 +338,7 @@ SRC_COMMON_HAL_ALL = \
|
|||||||
watchdog/__init__.c \
|
watchdog/__init__.c \
|
||||||
wifi/Network.c \
|
wifi/Network.c \
|
||||||
wifi/Radio.c \
|
wifi/Radio.c \
|
||||||
|
wifi/ScannedNetworks.c \
|
||||||
wifi/__init__.c \
|
wifi/__init__.c \
|
||||||
|
|
||||||
SRC_COMMON_HAL = $(filter $(SRC_PATTERNS), $(SRC_COMMON_HAL_ALL))
|
SRC_COMMON_HAL = $(filter $(SRC_PATTERNS), $(SRC_COMMON_HAL_ALL))
|
||||||
|
@ -78,8 +78,8 @@ const mp_obj_property_t wifi_radio_mac_address_obj = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//| def start_scanning_networks(self) -> Iterable[Network]:
|
//| def start_scanning_networks(self, *, start_channel=1, stop_channel=11) -> Iterable[Network]:
|
||||||
//| """"""
|
//| """Scans for available wifi networks over the given channel range. Make sure the channels are allowed in your country."""
|
||||||
//| ...
|
//| ...
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t wifi_radio_start_scanning_networks(mp_obj_t self_in) {
|
STATIC mp_obj_t wifi_radio_start_scanning_networks(mp_obj_t self_in) {
|
||||||
|
68
shared-bindings/wifi/ScannedNetworks.c
Normal file
68
shared-bindings/wifi/ScannedNetworks.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
||||||
|
* Copyright (c) 2018 Artur Pacholec
|
||||||
|
* Copyright (c) 2017 Glenn Ruben Bakke
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "py/objproperty.h"
|
||||||
|
#include "py/runtime.h"
|
||||||
|
#include "shared-bindings/wifi/ScannedNetworks.h"
|
||||||
|
|
||||||
|
//| class ScannedNetworks:
|
||||||
|
//| """Iterates over wifi `Network`s found while scanning. This object is always created
|
||||||
|
//| by a `wifi.Radio`: it has no user-visible constructor."""
|
||||||
|
//|
|
||||||
|
STATIC mp_obj_t scannednetworks_iternext(mp_obj_t self_in) {
|
||||||
|
mp_check_self(MP_OBJ_IS_TYPE(self_in, &wifi_scannednetworks_type));
|
||||||
|
wifi_scannednetworks_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
|
mp_obj_t network = common_hal_wifi_scannednetworks_next(self);
|
||||||
|
if (network != mp_const_none) {
|
||||||
|
return network;
|
||||||
|
}
|
||||||
|
return MP_OBJ_STOP_ITERATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
//| def __init__(self) -> None:
|
||||||
|
//| """Cannot be instantiated directly. Use `wifi.Radio.start_scanning_networks`."""
|
||||||
|
//| ...
|
||||||
|
//|
|
||||||
|
//| def __iter__(self) -> Iterator[Network]:
|
||||||
|
//| """Returns itself since it is the iterator."""
|
||||||
|
//| ...
|
||||||
|
//|
|
||||||
|
//| def __next__(self) -> Network:
|
||||||
|
//| """Returns the next `wifi.Network`.
|
||||||
|
//| Raises `StopIteration` if scanning is finished and no other results are available."""
|
||||||
|
//| ...
|
||||||
|
//|
|
||||||
|
|
||||||
|
const mp_obj_type_t wifi_scannednetworks_type = {
|
||||||
|
{ &mp_type_type },
|
||||||
|
.name = MP_QSTR_ScannedNetworks,
|
||||||
|
.getiter = mp_identity_getiter,
|
||||||
|
.iternext = scannednetworks_iternext,
|
||||||
|
};
|
39
shared-bindings/wifi/ScannedNetworks.h
Normal file
39
shared-bindings/wifi/ScannedNetworks.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
||||||
|
* Copyright (c) 2018 Artur Pacholec
|
||||||
|
* Copyright (c) 2017 Glenn Ruben Bakke
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_SCANNEDNETWORKS_H
|
||||||
|
#define MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_SCANNEDNETWORKS_H
|
||||||
|
|
||||||
|
#include "py/obj.h"
|
||||||
|
#include "common-hal/wifi/ScannedNetworks.h"
|
||||||
|
|
||||||
|
extern const mp_obj_type_t wifi_scannednetworks_type;
|
||||||
|
|
||||||
|
mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self);
|
||||||
|
|
||||||
|
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_SCANNEDNETWORKS_H
|
@ -69,6 +69,8 @@ uint32_t *port_heap_get_bottom(void);
|
|||||||
// Get heap top address
|
// Get heap top address
|
||||||
uint32_t *port_heap_get_top(void);
|
uint32_t *port_heap_get_top(void);
|
||||||
|
|
||||||
|
supervisor_allocation* port_fixed_heap(void);
|
||||||
|
|
||||||
// Save and retrieve a word from memory that is preserved over reset. Used for safe mode.
|
// Save and retrieve a word from memory that is preserved over reset. Used for safe mode.
|
||||||
void port_set_saved_word(uint32_t);
|
void port_set_saved_word(uint32_t);
|
||||||
uint32_t port_get_saved_word(void);
|
uint32_t port_get_saved_word(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user