Skip to content

Commit 243e6a5

Browse files
authored
Merge pull request #11460 from dmaziec1/esp8266_new_trace_debug_logs
ESP8266 Unified Mbed trace prints.
2 parents 171fe5a + 66bf8bc commit 243e6a5

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

components/wifi/esp8266-driver/ESP8266/ESP8266.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ bool ESP8266::at_available()
116116
if (ready) {
117117
break;
118118
}
119-
tr_debug("waiting AT response");
119+
tr_debug("at_available(): Waiting AT response.");
120120
}
121121
_smutex.unlock();
122122

@@ -227,7 +227,7 @@ bool ESP8266::start_uart_hw_flow_ctrl(void)
227227
_smutex.unlock();
228228

229229
if (!done) {
230-
tr_debug("Enable UART HW flow control: FAIL");
230+
tr_debug("start_uart_hw_flow_ctrl(): Enable UART HW flow control: FAIL.");
231231
}
232232
#else
233233
if (_serial_rts != NC || _serial_cts != NC) {
@@ -268,7 +268,7 @@ bool ESP8266::reset(void)
268268
set_timeout(ESP8266_RECV_TIMEOUT);
269269
for (int i = 0; i < 2; i++) {
270270
if (!_parser.send("AT+RST") || !_parser.recv("OK\n")) {
271-
tr_debug("reset(): AT+RST failed or no response");
271+
tr_debug("reset(): AT+RST failed or no response.");
272272
continue;
273273
}
274274

@@ -285,7 +285,7 @@ bool ESP8266::reset(void)
285285
}
286286
}
287287

288-
tr_debug("reset(): done: %s", done ? "OK" : "FAIL");
288+
tr_debug("reset(): Done: %s.", done ? "OK" : "FAIL");
289289

290290
_clear_socket_packets(ESP8266_ALL_SOCKET_IDS);
291291
set_timeout();
@@ -484,7 +484,7 @@ int ESP8266::scan(WiFiAccessPoint *res, unsigned limit, scan_mode mode, unsigned
484484
}
485485

486486
if (!(ret_parse_send && _parser.recv("OK\n"))) {
487-
tr_warning("scan(): AP info parsing aborted");
487+
tr_warning("scan(): AP info parsing aborted.");
488488
// Lets be happy about partial success and not return NSAPI_ERROR_DEVICE_ERROR
489489
if (!_scan_r.cnt) {
490490
_scan_r.cnt = NSAPI_ERROR_DEVICE_ERROR;
@@ -547,7 +547,7 @@ nsapi_error_t ESP8266::open_udp(int id, const char *addr, int port, int local_po
547547

548548
_smutex.unlock();
549549

550-
tr_debug("UDP socket %d opened: %s", id, (_sock_i[id].open ? "true" : "false"));
550+
tr_debug("open_udp(): UDP socket %d opened: %s.", id, (_sock_i[id].open ? "true" : "false"));
551551

552552
return done ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
553553
}
@@ -598,7 +598,7 @@ nsapi_error_t ESP8266::open_tcp(int id, const char *addr, int port, int keepaliv
598598

599599
_smutex.unlock();
600600

601-
tr_debug("TCP socket %d opened: %s", id, (_sock_i[id].open ? "true" : "false"));
601+
tr_debug("open_tcp: TCP socket %d opened: %s . ", id, (_sock_i[id].open ? "true" : "false"));
602602

603603
return done ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
604604
}
@@ -621,7 +621,7 @@ nsapi_error_t ESP8266::send(int id, const void *data, uint32_t amount)
621621
amount = 2048;
622622
// Datagram must stay intact
623623
} else if (amount > 2048 && _sock_i[id].proto == NSAPI_UDP) {
624-
tr_debug("UDP datagram maximum size is 2048");
624+
tr_debug("send(): UDP datagram maximum size is 2048 .");
625625
return NSAPI_ERROR_PARAMETER;
626626
}
627627

@@ -630,12 +630,12 @@ nsapi_error_t ESP8266::send(int id, const void *data, uint32_t amount)
630630
_busy = false;
631631
_error = false;
632632
if (!_parser.send("AT+CIPSEND=%d,%" PRIu32, id, amount)) {
633-
tr_debug("ESP8266::send(): AT+CIPSEND failed");
633+
tr_debug("send(): AT+CIPSEND failed.");
634634
goto END;
635635
}
636636

637637
if (!_parser.recv(">")) {
638-
tr_debug("ESP8266::send(): didn't get \">\"");
638+
tr_debug("send(): Didn't get \">\"");
639639
ret = NSAPI_ERROR_WOULD_BLOCK;
640640
goto END;
641641
}
@@ -650,22 +650,22 @@ nsapi_error_t ESP8266::send(int id, const void *data, uint32_t amount)
650650
// error hierarchy, from low to high
651651
if (_busy) {
652652
ret = NSAPI_ERROR_WOULD_BLOCK;
653-
tr_debug("ESP8266::send(): modem busy");
653+
tr_debug("send(): Modem busy. ");
654654
}
655655

656656
if (ret == NSAPI_ERROR_DEVICE_ERROR) {
657657
ret = NSAPI_ERROR_WOULD_BLOCK;
658-
tr_debug("ESP8266::send(): send failed");
658+
tr_debug("send(): Send failed.");
659659
}
660660

661661
if (_error) {
662662
ret = NSAPI_ERROR_CONNECTION_LOST;
663-
tr_debug("ESP8266::send(): connection disrupted");
663+
tr_debug("send(): Connection disrupted.");
664664
}
665665

666666
if (!_sock_i[id].open && ret != NSAPI_ERROR_OK) {
667667
ret = NSAPI_ERROR_CONNECTION_LOST;
668-
tr_debug("ESP8266::send(): socket closed abruptly");
668+
tr_debug("send(): Socket closed abruptly.");
669669
}
670670

671671
set_timeout();
@@ -708,7 +708,7 @@ void ESP8266::_oob_packet_hdlr()
708708

709709
struct packet *packet = (struct packet *)malloc(pdu_len);
710710
if (!packet) {
711-
tr_debug("out of memory, unable to allocate memory for packet");
711+
tr_debug("_oob_packet_hdlr(): Out of memory, unable to allocate memory for packet.");
712712
return;
713713
}
714714
_heap_usage += pdu_len;
@@ -798,10 +798,10 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t
798798
BUSY:
799799
_process_oob(ESP8266_RECV_TIMEOUT, true);
800800
if (_busy) {
801-
tr_debug("_recv_tcp_passive(): modem busy");
801+
tr_debug("_recv_tcp_passive(): Modem busy.");
802802
ret = NSAPI_ERROR_WOULD_BLOCK;
803803
} else {
804-
tr_error("_recv_tcp_passive(): unknown state");
804+
tr_error("_recv_tcp_passive(): Unknown state.");
805805
ret = NSAPI_ERROR_DEVICE_ERROR;
806806
}
807807
_smutex.unlock();
@@ -1024,7 +1024,7 @@ bool ESP8266::_recv_ap(nsapi_wifi_ap_t *ap)
10241024

10251025
if (ret < 0) {
10261026
_parser.abort();
1027-
tr_warning("_recv_ap(): AP info missing");
1027+
tr_warning("_recv_ap(): AP info missing.");
10281028
}
10291029

10301030
ap->security = sec < 5 ? (nsapi_security_t)sec : NSAPI_SECURITY_UNKNOWN;
@@ -1054,19 +1054,19 @@ void ESP8266::_oob_ready()
10541054
_conn_status = NSAPI_STATUS_ERROR_UNSUPPORTED;
10551055
_conn_stat_cb();
10561056

1057-
tr_debug("_oob_reset(): reset detected");
1057+
tr_debug("_oob_reset(): Reset detected.");
10581058
}
10591059

10601060
void ESP8266::_oob_busy()
10611061
{
10621062
char status;
10631063
if (_parser.scanf("%c...\n", &status)) {
10641064
if (status == 's') {
1065-
tr_debug("busy s...");
1065+
tr_debug("_oob_busy(): Busy s...");
10661066
} else if (status == 'p') {
1067-
tr_debug("busy p...");
1067+
tr_debug("_oob_busy(): Busy p...");
10681068
} else {
1069-
tr_error("unrecognized busy state '%c...'", status);
1069+
tr_error("_oob_busy(): unrecognized busy state '%c...'", status);
10701070
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_EBADMSG), \
10711071
"ESP8266::_oob_busy() unrecognized busy state\n");
10721072
}
@@ -1144,35 +1144,35 @@ void ESP8266::_oob_socket0_closed()
11441144
{
11451145
static const int id = 0;
11461146
_sock_i[id].open = false;
1147-
tr_debug("socket %d closed", id);
1147+
tr_debug("_oob_socket0_closed(): Socket %d closed.", id);
11481148
}
11491149

11501150
void ESP8266::_oob_socket1_closed()
11511151
{
11521152
static const int id = 1;
11531153
_sock_i[id].open = false;
1154-
tr_debug("socket %d closed", id);
1154+
tr_debug("_oob_socket1_closed(): Socket %d closed.", id);
11551155
}
11561156

11571157
void ESP8266::_oob_socket2_closed()
11581158
{
11591159
static const int id = 2;
11601160
_sock_i[id].open = false;
1161-
tr_debug("socket %d closed", id);
1161+
tr_debug("_oob_socket2_closed(): Socket %d closed.", id);
11621162
}
11631163

11641164
void ESP8266::_oob_socket3_closed()
11651165
{
11661166
static const int id = 3;
11671167
_sock_i[id].open = false;
1168-
tr_debug("socket %d closed", id);
1168+
tr_debug("_oob_socket3_closed(): %d closed.", id);
11691169
}
11701170

11711171
void ESP8266::_oob_socket4_closed()
11721172
{
11731173
static const int id = 4;
11741174
_sock_i[id].open = false;
1175-
tr_debug("socket %d closed", id);
1175+
tr_debug("_oob_socket0_closed(): Socket %d closed.", id);
11761176
}
11771177

11781178
void ESP8266::_oob_connection_status()
@@ -1191,16 +1191,16 @@ void ESP8266::_oob_connection_status()
11911191
} else if (strcmp(status, "CONNECTED\n") == 0) {
11921192
_conn_status = NSAPI_STATUS_CONNECTING;
11931193
} else {
1194-
tr_error("invalid AT cmd \'%s\'", status);
1194+
tr_error("_oob_connection_status(): Invalid AT cmd \'%s\' .", status);
11951195
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_EBADMSG), \
11961196
"ESP8266::_oob_connection_status: invalid AT cmd\n");
11971197
}
11981198
} else {
1199-
tr_error("_oob_connection_status(): network status timeout, disconnecting");
1199+
tr_error("_oob_connection_status(): Network status timeout, disconnecting.");
12001200
if (!disconnect()) {
1201-
tr_warning("_oob_connection_status(): driver initiated disconnect failed");
1201+
tr_warning("_oob_connection_status(): Driver initiated disconnect failed.");
12021202
} else {
1203-
tr_debug("_oob_connection_status(): disconnected");
1203+
tr_debug("_oob_connection_status(): Disconnected.");
12041204
}
12051205
_conn_status = NSAPI_STATUS_ERROR_UNSUPPORTED;
12061206
}

components/wifi/esp8266-driver/ESP8266Interface.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void ESP8266Interface::ResetPin::rst_assert()
153153
{
154154
if (_rst_pin.is_connected()) {
155155
_rst_pin = 0;
156-
tr_debug("HW reset asserted");
156+
tr_debug("rst_assert(): HW reset asserted.");
157157
}
158158
}
159159

@@ -162,7 +162,7 @@ void ESP8266Interface::ResetPin::rst_deassert()
162162
if (_rst_pin.is_connected()) {
163163
// Notice that Pin7 CH_EN cannot be left floating if used as reset
164164
_rst_pin = 1;
165-
tr_debug("HW reset deasserted");
165+
tr_debug("rst_deassert(): HW reset deasserted.");
166166
}
167167
}
168168

@@ -179,7 +179,7 @@ void ESP8266Interface::PowerPin::power_on()
179179
{
180180
if (_pwr_pin.is_connected()) {
181181
_pwr_pin = MBED_CONF_ESP8266_POWER_ON_POLARITY;
182-
tr_debug("HW power-on");
182+
tr_debug("power_on(): HW power-on.");
183183
ThisThread::sleep_for(MBED_CONF_ESP8266_POWER_ON_TIME_MS);
184184
}
185185
}
@@ -188,7 +188,7 @@ void ESP8266Interface::PowerPin::power_off()
188188
{
189189
if (_pwr_pin.is_connected()) {
190190
_pwr_pin = !MBED_CONF_ESP8266_POWER_ON_POLARITY;
191-
tr_debug("HW power-off");
191+
tr_debug("power_off(): HW power-off.");
192192
ThisThread::sleep_for(MBED_CONF_ESP8266_POWER_OFF_TIME_MS);
193193
}
194194
}
@@ -237,7 +237,7 @@ void ESP8266Interface::_connect_async()
237237
}
238238
_cmutex.lock();
239239
if (!_connect_event_id) {
240-
tr_debug("_connect_async(): cancelled");
240+
tr_debug("_connect_async(): Cancelled.");
241241
_cmutex.unlock();
242242
return;
243243
}
@@ -750,7 +750,7 @@ int ESP8266Interface::socket_send(void *handle, const void *data, unsigned size)
750750
if (status == NSAPI_ERROR_WOULD_BLOCK
751751
&& socket->proto == NSAPI_TCP
752752
&& core_util_atomic_cas_u8(&_cbs[socket->id].deferred, &expect_false, true)) {
753-
tr_debug("Postponing SIGIO from the device");
753+
tr_debug("socket_send(...): Postponing SIGIO from the device.");
754754
if (!_global_event_queue->call_in(50, callback(this, &ESP8266Interface::event_deferred))) {
755755
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
756756
"socket_send(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
@@ -983,7 +983,7 @@ void ESP8266Interface::refresh_conn_state_cb()
983983
return;
984984
}
985985

986-
tr_debug("refresh_conn_state_cb(): changed to %d", _conn_stat);
986+
tr_debug("refresh_conn_state_cb(): Changed to %d.", _conn_stat);
987987

988988
if (_conn_stat_cb) {
989989
// _conn_stat_cb will be called in _connect_async or disconnect_assync to avoid race condition
@@ -1036,7 +1036,7 @@ nsapi_error_t ESP8266Interface::set_country_code(bool track_ap, const char *coun
10361036
for (int i = 0; i < len; i++) {
10371037
// Validation done by firmware
10381038
if (!country_code[i]) {
1039-
tr_warning("invalid country code");
1039+
tr_warning("set_country_code(): Invalid country code.");
10401040
return NSAPI_ERROR_PARAMETER;
10411041
}
10421042
}

0 commit comments

Comments
 (0)