mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Fix unwanted WiZMote restart
This commit is contained in:
parent
cc14f721f9
commit
f383c877c6
@ -44,7 +44,7 @@ protected:
|
||||
* @brief Communication subsistem initialization
|
||||
* @param peerType Role that peer plays into the system, node or gateway.
|
||||
*/
|
||||
virtual void initComms () = 0;
|
||||
virtual bool initComms () = 0;
|
||||
|
||||
|
||||
public:
|
||||
|
@ -46,8 +46,8 @@ bool QuickEspNow::begin (uint8_t channel, uint32_t wifi_interface, bool synchron
|
||||
DEBUG_INFO (QESPNOW_TAG, ARDUHAL_LOG_COLOR (ARDUHAL_LOG_COLOR_RED) "Starting ESP-NOW in in channel %u interface %s", channel, wifi_if == WIFI_IF_STA ? "STA" : "AP");
|
||||
|
||||
this->channel = channel;
|
||||
initComms ();
|
||||
return true;
|
||||
|
||||
return initComms ();
|
||||
}
|
||||
|
||||
void QuickEspNow::stop () {
|
||||
@ -303,11 +303,12 @@ bool QuickEspNow::addPeer (const uint8_t* peer_addr) {
|
||||
return error == ESP_OK;
|
||||
}
|
||||
|
||||
void QuickEspNow::initComms () {
|
||||
bool QuickEspNow::initComms () {
|
||||
if (esp_now_init ()) {
|
||||
DEBUG_ERROR (QESPNOW_TAG, "Failed to init ESP-NOW");
|
||||
ESP.restart ();
|
||||
delay (1);
|
||||
// ESP.restart ();
|
||||
// delay (1);
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_now_register_recv_cb (rx_cb);
|
||||
@ -328,6 +329,8 @@ void QuickEspNow::initComms () {
|
||||
dataTPTimer = xTimerCreate ("espnow_tp_timer", pdMS_TO_TICKS (MEAS_TP_EVERY_MS), pdTRUE, NULL, tp_timer_cb);
|
||||
xTimerStart (dataTPTimer, 0);
|
||||
#endif // MEAS_TPUT
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QuickEspNow::espnowTxTask_cb (void* param) {
|
||||
|
@ -150,7 +150,7 @@ protected:
|
||||
//uint8_t channel;
|
||||
bool followWiFiChannel = false;
|
||||
|
||||
void initComms ();
|
||||
bool initComms ();
|
||||
bool addPeer (const uint8_t* peer_addr);
|
||||
static void espnowTxTask_cb (void* param);
|
||||
int32_t sendEspNowMessage (comms_tx_queue_item_t* message);
|
||||
|
@ -74,9 +74,8 @@ bool QuickEspNow::begin (uint8_t channel, uint32_t wifi_interface, bool synchron
|
||||
DEBUG_INFO (QESPNOW_TAG, "Starting ESP-NOW in in channel %u interface %s", channel, wifi_if == WIFI_IF_STA ? "STA" : "AP");
|
||||
|
||||
this->channel = channel;
|
||||
initComms ();
|
||||
// addPeer (ESPNOW_BROADCAST_ADDRESS); // Not needed ?
|
||||
return true;
|
||||
|
||||
return initComms ();
|
||||
}
|
||||
|
||||
void QuickEspNow::stop () {
|
||||
@ -261,11 +260,12 @@ void QuickEspNow::enableTransmit (bool enable) {
|
||||
}
|
||||
}
|
||||
|
||||
void QuickEspNow::initComms () {
|
||||
bool QuickEspNow::initComms () {
|
||||
if (esp_now_init ()) {
|
||||
DEBUG_ERROR (QESPNOW_TAG, "Failed to init ESP-NOW");
|
||||
ESP.restart ();
|
||||
delay (1);
|
||||
// ESP.restart ();
|
||||
// delay (1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (wifi_if == WIFI_IF_STA) {
|
||||
@ -288,6 +288,7 @@ void QuickEspNow::initComms () {
|
||||
os_timer_arm (&dataTPTimer, MEAS_TP_EVERY_MS, true);
|
||||
#endif // MEAS_TPUT
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QuickEspNow::espnowTxTask_cb (void* param) {
|
||||
|
@ -127,7 +127,7 @@ protected:
|
||||
//uint8_t channel;
|
||||
bool followWiFiChannel = false;
|
||||
|
||||
void initComms ();
|
||||
bool initComms ();
|
||||
static void espnowTxTask_cb (void* param);
|
||||
static void espnowRxTask_cb (void* param);
|
||||
int32_t sendEspNowMessage (comms_tx_queue_item_t* message);
|
||||
|
@ -156,9 +156,10 @@ void EspNowInit(void) {
|
||||
#ifdef ESP32
|
||||
// quickEspNow.setWiFiBandwidth (WIFI_IF_STA, WIFI_BW_HT20); // Only needed for ESP32 in case you need coexistence with ESP8266 in the same network
|
||||
#endif //ESP32
|
||||
quickEspNow.begin();
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("NOW: ESP-NOW started"));
|
||||
WizMote.active = true;
|
||||
if (quickEspNow.begin()) {
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("NOW: ESP-NOW started"));
|
||||
WizMote.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user