Skip to content

Commit dcc42f6

Browse files
committed
Remove debug prints
1 parent 1034cc1 commit dcc42f6

File tree

7 files changed

+76
-153
lines changed

7 files changed

+76
-153
lines changed

ports/esp32s2/common-hal/socketpool/Socket.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
#include "shared-bindings/socketpool/Socket.h"
2828

29-
#include "esp_log.h"
30-
static const char *TAG = "socket";
31-
3229
void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_uint_t timeout_ms) {
3330
self->timeout_ms = timeout_ms;
3431
}
@@ -38,20 +35,17 @@ bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const c
3835
// NULL and should still work. This makes regular TCP connections more memory expensive but TLS
3936
// should become more and more common. Therefore, we optimize for the TLS case.
4037

41-
ESP_LOGI(TAG, "connecting to %s:%d %p", host, port, self->ssl_context);
4238
esp_tls_cfg_t* tls_config = NULL;
4339
if (self->ssl_context != NULL) {
4440
tls_config = &self->ssl_context->ssl_config;
4541
}
4642
int result = esp_tls_conn_new_sync(host, hostlen, port, tls_config, self->tcp);
47-
ESP_LOGI(TAG, "result %d", result);
4843
return result >= 0;
4944
}
5045

5146
mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len) {
5247
size_t sent = esp_tls_conn_write(self->tcp, buf, len);
5348

54-
ESP_LOGI(TAG, "sent %d bytes", sent);
5549
if (sent < 0) {
5650
// raise an error
5751
}
@@ -61,7 +55,6 @@ mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const
6155
mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len) {
6256
size_t received = esp_tls_conn_read(self->tcp, (void*) buf, len);
6357

64-
ESP_LOGI(TAG, "received %d bytes", received);
6558
if (received == 0) {
6659
// socket closed
6760
}

ports/esp32s2/common-hal/wifi/Radio.c

Lines changed: 73 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -38,99 +38,84 @@
3838
#include "esp-idf/components/esp_wifi/include/esp_wifi.h"
3939
#include "esp-idf/components/lwip/include/apps/ping/ping_sock.h"
4040

41-
#include "esp_log.h"
42-
static const char *TAG = "cp radio";
43-
4441
static void start_station(wifi_radio_obj_t *self) {
45-
if (self->sta_mode) {
46-
return;
47-
}
48-
wifi_mode_t next_mode;
49-
if (self->ap_mode) {
50-
next_mode = WIFI_MODE_APSTA;
51-
} else {
52-
next_mode = WIFI_MODE_STA;
53-
}
54-
esp_wifi_set_mode(next_mode);
55-
56-
esp_wifi_set_config(WIFI_MODE_STA, &self->sta_config);
42+
if (self->sta_mode) {
43+
return;
44+
}
45+
wifi_mode_t next_mode;
46+
if (self->ap_mode) {
47+
next_mode = WIFI_MODE_APSTA;
48+
} else {
49+
next_mode = WIFI_MODE_STA;
50+
}
51+
esp_wifi_set_mode(next_mode);
52+
53+
esp_wifi_set_config(WIFI_MODE_STA, &self->sta_config);
5754
}
5855

5956
bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self) {
60-
return self->started;
57+
return self->started;
6158
}
6259

6360
void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) {
64-
if (self->started && !enabled) {
65-
ESP_LOGI(TAG, "stop");
66-
if (self->current_scan != NULL) {
67-
common_hal_wifi_radio_stop_scanning_networks(self);
68-
}
69-
ESP_ERROR_CHECK(esp_wifi_stop());
70-
self->started = false;
71-
return;
72-
}
73-
if (!self->started && enabled) {
74-
ESP_LOGI(TAG, "start");
75-
ESP_ERROR_CHECK(esp_wifi_start());
76-
self->started = true;
77-
return;
78-
}
61+
if (self->started && !enabled) {
62+
if (self->current_scan != NULL) {
63+
common_hal_wifi_radio_stop_scanning_networks(self);
64+
}
65+
ESP_ERROR_CHECK(esp_wifi_stop());
66+
self->started = false;
67+
return;
68+
}
69+
if (!self->started && enabled) {
70+
ESP_ERROR_CHECK(esp_wifi_start());
71+
self->started = true;
72+
return;
73+
}
7974
}
8075

8176
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {
82-
uint8_t mac[6];
83-
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
84-
return mp_const_none;
77+
uint8_t mac[6];
78+
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
79+
return mp_const_none;
8580
}
8681

8782
mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) {
88-
if (self->current_scan != NULL) {
89-
mp_raise_RuntimeError(translate("Already scanning for wifi networks"));
90-
}
91-
// check enabled
92-
start_station(self);
93-
94-
ESP_LOGI(TAG, "start scan");
95-
wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t);
96-
self->current_scan = scan;
97-
scan->base.type = &wifi_scannednetworks_type;
98-
scan->start_channel = 1;
99-
scan->end_channel = 11;
100-
scan->radio_event_group = self->event_group_handle;
101-
wifi_scannednetworks_scan_next_channel(scan);
102-
return scan;
83+
if (self->current_scan != NULL) {
84+
mp_raise_RuntimeError(translate("Already scanning for wifi networks"));
85+
}
86+
// check enabled
87+
start_station(self);
88+
89+
wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t);
90+
self->current_scan = scan;
91+
scan->base.type = &wifi_scannednetworks_type;
92+
scan->start_channel = 1;
93+
scan->end_channel = 11;
94+
scan->radio_event_group = self->event_group_handle;
95+
wifi_scannednetworks_scan_next_channel(scan);
96+
return scan;
10397
}
10498

10599
void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self) {
106-
// Free the memory used to store the found aps.
107-
ESP_EARLY_LOGI(TAG, "stop scan");
108-
wifi_scannednetworks_deinit(self->current_scan);
109-
self->current_scan = NULL;
110-
ESP_EARLY_LOGI(TAG, "stop scan done");
100+
// Free the memory used to store the found aps.
101+
wifi_scannednetworks_deinit(self->current_scan);
102+
self->current_scan = NULL;
111103
}
112104

113105
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, uint8_t channel, mp_float_t timeout) {
114-
// check enabled
115-
wifi_config_t* config = &self->sta_config;
116-
memcpy(&config->sta.ssid, ssid, ssid_len);
117-
config->sta.ssid[ssid_len] = 0;
118-
if (password_len > 0) {
119-
memcpy(&config->sta.password, password, password_len);
120-
}
121-
config->sta.password[password_len] = 0;
122-
config->sta.channel = channel;
123-
ESP_EARLY_LOGI(TAG, "connecting to %s", config->sta.ssid);
124-
esp_err_t result = esp_wifi_set_config(ESP_IF_WIFI_STA, config);
125-
if (result != ESP_OK) {
126-
ESP_EARLY_LOGI(TAG, "config fail %d", result);
127-
}
128-
result = esp_wifi_connect();
129-
if (result != ESP_OK) {
130-
ESP_EARLY_LOGI(TAG, "connect fail %d", result);
131-
}
132-
133-
EventBits_t bits;
106+
// check enabled
107+
wifi_config_t* config = &self->sta_config;
108+
memcpy(&config->sta.ssid, ssid, ssid_len);
109+
config->sta.ssid[ssid_len] = 0;
110+
if (password_len > 0) {
111+
memcpy(&config->sta.password, password, password_len);
112+
}
113+
config->sta.password[password_len] = 0;
114+
config->sta.channel = channel;
115+
esp_wifi_set_config(ESP_IF_WIFI_STA, config);
116+
esp_wifi_connect();
117+
118+
EventBits_t bits;
134119
do {
135120
RUN_BACKGROUND_TASKS;
136121
bits = xEventGroupWaitBits(self->event_group_handle,
@@ -140,21 +125,18 @@ bool common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t
140125
0);
141126
} while ((bits & (WIFI_CONNECTED_BIT | WIFI_DISCONNECTED_BIT)) == 0 && !mp_hal_is_interrupted());
142127
if ((bits & WIFI_DISCONNECTED_BIT) != 0) {
143-
return false;
128+
return false;
144129
}
145-
return true;
130+
return true;
146131
}
147132

148133
mp_obj_t common_hal_wifi_radio_get_ipv4_address(wifi_radio_obj_t *self) {
149-
if (!esp_netif_is_netif_up(self->netif)) {
150-
return mp_const_none;
151-
}
152-
esp_netif_ip_info_t ip_info;
153-
esp_err_t result = esp_netif_get_ip_info(self->netif, &ip_info);
154-
if (result != ESP_OK) {
155-
ESP_EARLY_LOGI(TAG, "get ip fail %d", result);
156-
}
157-
return common_hal_ipaddress_new_ipv4address(ip_info.ip.addr);
134+
if (!esp_netif_is_netif_up(self->netif)) {
135+
return mp_const_none;
136+
}
137+
esp_netif_ip_info_t ip_info;
138+
esp_netif_get_ip_info(self->netif, &ip_info);
139+
return common_hal_ipaddress_new_ipv4address(ip_info.ip.addr);
158140
}
159141

160142
mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address, mp_float_t timeout) {
@@ -171,15 +153,15 @@ mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address,
171153
uint32_t received = 0;
172154
uint32_t total_time_ms = 0;
173155
while (received == 0 && total_time_ms < timeout_ms) {
174-
RUN_BACKGROUND_TASKS;
175-
esp_ping_get_profile(ping, ESP_PING_PROF_DURATION, &total_time_ms, sizeof(total_time_ms));
176-
esp_ping_get_profile(ping, ESP_PING_PROF_REPLY, &received, sizeof(received));
156+
RUN_BACKGROUND_TASKS;
157+
esp_ping_get_profile(ping, ESP_PING_PROF_DURATION, &total_time_ms, sizeof(total_time_ms));
158+
esp_ping_get_profile(ping, ESP_PING_PROF_REPLY, &received, sizeof(received));
177159
}
178-
uint32_t elapsed_time = 0xffffffff;
160+
uint32_t elapsed_time = 0xffffffff;
179161
if (received > 0) {
180-
esp_ping_get_profile(ping, ESP_PING_PROF_TIMEGAP, &elapsed_time, sizeof(elapsed_time));
162+
esp_ping_get_profile(ping, ESP_PING_PROF_TIMEGAP, &elapsed_time, sizeof(elapsed_time));
181163
}
182164
esp_ping_delete_session(ping);
183165

184-
return elapsed_time;
166+
return elapsed_time;
185167
}

ports/esp32s2/common-hal/wifi/ScannedNetworks.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@
3939

4040
#include "esp-idf/components/esp_wifi/include/esp_wifi.h"
4141

42-
#include "esp_log.h"
43-
static const char *TAG = "cp scannednetworks";
44-
4542
static void wifi_scannednetworks_done(wifi_scannednetworks_obj_t *self) {
4643
self->done = true;
47-
ESP_EARLY_LOGI(TAG, "free %x", self->results);
4844
if (self->results != NULL) {
4945
// Check to see if the heap is still active. If not, it'll be freed automatically.
5046
if (gc_alloc_possible()) {
@@ -94,7 +90,6 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self)
9490
}
9591
// We not have found any more results so we're done.
9692
if (self->done) {
97-
ESP_LOGI(TAG, "return done");
9893
return mp_const_none;
9994
}
10095
// If we need more space than we have, realloc.
@@ -104,7 +99,6 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self)
10499
self->max_results,
105100
self->total_results,
106101
true /* allow move */);
107-
ESP_EARLY_LOGI(TAG, "alloc %x", results);
108102
if (results != NULL) {
109103
self->results = results;
110104
self->max_results = self->total_results;
@@ -152,12 +146,10 @@ void wifi_scannednetworks_scan_next_channel(wifi_scannednetworks_obj_t *self) {
152146
wifi_scan_config_t config = { 0 };
153147
config.channel = next_channel;
154148
if (next_channel == sizeof(scan_pattern)) {
155-
ESP_LOGI(TAG, "scan done");
156149
wifi_scannednetworks_done(self);
157150
} else {
158151
esp_err_t result = esp_wifi_scan_start(&config, false);
159152
if (result != ESP_OK) {
160-
ESP_LOGI(TAG, "start failed 0x%x", result);
161153
wifi_scannednetworks_done(self);
162154
} else {
163155
self->scanning = true;

ports/esp32s2/common-hal/wifi/__init__.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131

3232
#include "py/runtime.h"
3333

34-
#include "esp_log.h"
35-
static const char *TAG = "cp wifi";
36-
3734
#include "esp-idf/components/esp_wifi/include/esp_wifi.h"
3835

3936
#include "esp-idf/components/heap/include/esp_heap_caps.h"
@@ -42,31 +39,20 @@ wifi_radio_obj_t common_hal_wifi_radio_obj;
4239

4340
static void event_handler(void* arg, esp_event_base_t event_base,
4441
int32_t event_id, void* event_data) {
45-
ESP_LOGI(TAG, "event %x", event_id);
4642
wifi_radio_obj_t* radio = arg;
4743
if (event_base == WIFI_EVENT) {
4844
if (event_id == WIFI_EVENT_SCAN_DONE) {
49-
ESP_LOGI(TAG, "scan done");
5045
xEventGroupSetBits(radio->event_group_handle, WIFI_SCAN_DONE_BIT);
5146
} else if (event_id == WIFI_EVENT_STA_START) {
52-
ESP_LOGI(TAG, "station start");
53-
5447
} else if (event_id == WIFI_EVENT_STA_STOP) {
55-
ESP_LOGI(TAG, "station stop");
56-
5748
} else if (event_id == WIFI_EVENT_STA_CONNECTED) {
58-
ESP_LOGI(TAG, "connected to ap");
5949
} else if (event_id == WIFI_EVENT_STA_DISCONNECTED) {
60-
ESP_LOGI(TAG, "disconnected");
61-
wifi_event_sta_disconnected_t* d = (wifi_event_sta_disconnected_t*) event_data;
62-
ESP_LOGI(TAG, "reason %d", d->reason);
50+
// wifi_event_sta_disconnected_t* d = (wifi_event_sta_disconnected_t*) event_data;
6351
if (event_id != WIFI_REASON_ASSOC_LEAVE) {
6452
// reconnect
6553
}
6654
xEventGroupSetBits(radio->event_group_handle, WIFI_DISCONNECTED_BIT);
6755
} else if (event_id == WIFI_EVENT_STA_AUTHMODE_CHANGE) {
68-
ESP_LOGI(TAG, "auth change");
69-
7056
}
7157
}
7258

@@ -84,27 +70,19 @@ static void event_handler(void* arg, esp_event_base_t event_base,
8470
// ESP_LOGI(TAG,"connect to the AP fail");
8571
// } else
8672
if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
87-
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
88-
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
89-
// s_retry_num = 0;
9073
xEventGroupSetBits(radio->event_group_handle, WIFI_CONNECTED_BIT);
9174
}
9275
}
9376

9477
static bool wifi_inited;
9578

9679
void common_hal_wifi_init(void) {
97-
ESP_EARLY_LOGI(TAG, "init");
98-
heap_caps_print_heap_info(MALLOC_CAP_8BIT);
9980
wifi_inited = true;
10081
common_hal_wifi_radio_obj.base.type = &wifi_radio_type;
10182

10283
ESP_ERROR_CHECK(esp_netif_init());
103-
104-
ESP_EARLY_LOGI(TAG, "create event loop");
10584
ESP_ERROR_CHECK(esp_event_loop_create_default());
10685

107-
ESP_EARLY_LOGI(TAG, "create wifi sta");
10886
wifi_radio_obj_t* self = &common_hal_wifi_radio_obj;
10987
self->netif = esp_netif_create_default_wifi_sta();
11088

@@ -120,21 +98,17 @@ void common_hal_wifi_init(void) {
12098
self,
12199
&self->handler_instance_got_ip));
122100

123-
124-
ESP_EARLY_LOGI(TAG, "wifi init");
125101
wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
126102
esp_err_t result = esp_wifi_init(&config);
127103
if (result == ESP_ERR_NO_MEM) {
128104
mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate Wifi memory"));
129105
} else if (result != ESP_OK) {
130106
// handle this
131107
}
132-
ESP_EARLY_LOGI(TAG, "enable radio");
133108
common_hal_wifi_radio_set_enabled(self, true);
134109
}
135110

136111
void wifi_reset(void) {
137-
ESP_LOGI(TAG, "reset");
138112
if (!wifi_inited) {
139113
return;
140114
}

0 commit comments

Comments
 (0)