summaryrefslogtreecommitdiff
path: root/ports/esp32s2/common-hal/wifi/__init__.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/esp32s2/common-hal/wifi/__init__.c')
-rw-r--r--ports/esp32s2/common-hal/wifi/__init__.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c
index a3927b7c3..3ec4ebc24 100644
--- a/ports/esp32s2/common-hal/wifi/__init__.c
+++ b/ports/esp32s2/common-hal/wifi/__init__.c
@@ -39,11 +39,11 @@ wifi_radio_obj_t common_hal_wifi_radio_obj;
#include "components/log/include/esp_log.h"
-static const char* TAG = "wifi";
+static const char *TAG = "wifi";
-static void event_handler(void* arg, esp_event_base_t event_base,
- int32_t event_id, void* event_data) {
- wifi_radio_obj_t* radio = arg;
+static void event_handler(void *arg, esp_event_base_t event_base,
+ int32_t event_id, void *event_data) {
+ wifi_radio_obj_t *radio = arg;
if (event_base == WIFI_EVENT) {
switch (event_id) {
case WIFI_EVENT_SCAN_DONE:
@@ -61,13 +61,13 @@ static void event_handler(void* arg, esp_event_base_t event_base,
break;
case WIFI_EVENT_STA_DISCONNECTED: {
ESP_LOGW(TAG, "disconnected");
- wifi_event_sta_disconnected_t* d = (wifi_event_sta_disconnected_t*) event_data;
+ wifi_event_sta_disconnected_t *d = (wifi_event_sta_disconnected_t *)event_data;
uint8_t reason = d->reason;
ESP_LOGW(TAG, "reason %d 0x%02x", reason, reason);
if (radio->retries_left > 0 &&
- reason != WIFI_REASON_AUTH_FAIL &&
- reason != WIFI_REASON_NO_AP_FOUND &&
- reason != WIFI_REASON_ASSOC_LEAVE) {
+ reason != WIFI_REASON_AUTH_FAIL &&
+ reason != WIFI_REASON_NO_AP_FOUND &&
+ reason != WIFI_REASON_ASSOC_LEAVE) {
radio->retries_left--;
ESP_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
esp_wifi_connect();
@@ -107,7 +107,7 @@ void common_hal_wifi_init(void) {
}
wifi_ever_inited = true;
- wifi_radio_obj_t* self = &common_hal_wifi_radio_obj;
+ wifi_radio_obj_t *self = &common_hal_wifi_radio_obj;
self->netif = esp_netif_create_default_wifi_sta();
self->started = false;
@@ -120,15 +120,15 @@ void common_hal_wifi_init(void) {
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_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));
+ 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);
@@ -144,26 +144,26 @@ void wifi_reset(void) {
if (!wifi_inited) {
return;
}
- wifi_radio_obj_t* radio = &common_hal_wifi_radio_obj;
+ 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_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));
+ IP_EVENT_STA_GOT_IP,
+ radio->handler_instance_got_ip));
ESP_ERROR_CHECK(esp_wifi_deinit());
esp_netif_destroy(radio->netif);
radio->netif = NULL;
}
-void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t* esp_ip_address) {
+void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t *esp_ip_address) {
if (!MP_OBJ_IS_TYPE(ip_address, &ipaddress_ipv4address_type)) {
mp_raise_ValueError(translate("Only IPv4 addresses supported"));
}
mp_obj_t packed = common_hal_ipaddress_ipv4address_get_packed(ip_address);
size_t len;
- const char* bytes = mp_obj_str_get_data(packed, &len);
+ const char *bytes = mp_obj_str_get_data(packed, &len);
IP_ADDR4(esp_ip_address, bytes[0], bytes[1], bytes[2], bytes[3]);
}