From 6ebdb31e07c18d1191e2a8d91f643ca157baac2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Thu, 11 Aug 2022 14:06:22 +0200 Subject: [PATCH] esp8266: add reset function --- lib/radio_esp8266.c | 14 +++++++++++++- lib/radio_esp8266.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/radio_esp8266.c b/lib/radio_esp8266.c index f2c82da..eafe843 100644 --- a/lib/radio_esp8266.c +++ b/lib/radio_esp8266.c @@ -122,7 +122,19 @@ void radio_esp8266_setup(void) while (!radio_esp8266_activity || !radio_esp8266_success) { // wait for response __WFI(); // sleep until something happened } - radio_esp8266_transmit((uint8_t*)"AT+RST\r\n", 8); // reset module + radio_esp8266_transmit_at("E0"); // disable echoing + while (!radio_esp8266_activity || !radio_esp8266_success) { // wait for response + __WFI(); // sleep until something happened + } +} + +void radio_esp8266_reset(void) +{ + radio_esp8266_transmit_at("+RST"); // reset module + while (!radio_esp8266_activity || !radio_esp8266_success) { // wait for response + __WFI(); // sleep until something happened + } + radio_esp8266_transmit_at("E0"); // disable echoing while (!radio_esp8266_activity || !radio_esp8266_success) { // wait for response __WFI(); // sleep until something happened } diff --git a/lib/radio_esp8266.h b/lib/radio_esp8266.h index 93516f8..ab822b6 100644 --- a/lib/radio_esp8266.h +++ b/lib/radio_esp8266.h @@ -20,6 +20,8 @@ extern uint16_t radio_esp8266_received_len; * @note this is blocking to ensure we are connected to the WiFi network */ void radio_esp8266_setup(void); +/** reset ESP */ +void radio_esp8266_reset(void); /** establish TCP connection * @param[in] host host to connect to * @param[in] port TCP port to connect to