app: verify if ESP is connected
This commit is contained in:
parent
78bc3b97f3
commit
bbc981fecb
@ -1051,7 +1051,11 @@ void main(void)
|
||||
puts_debug("setup ESP8266 Art-Net: ");
|
||||
sleep_ms(1000); // wit for ESP to boot
|
||||
radio_esp8266_setup(); // connect to WiFi network
|
||||
if (!radio_esp8266_connected()) { // check if we are connected
|
||||
radio_esp8266_reset();
|
||||
}
|
||||
radio_esp8266_listen(true, 6454); // open UDP Art-Net
|
||||
bool net_connected = true; // remember we are connected
|
||||
puts_debug("OK");
|
||||
|
||||
// setup terminal
|
||||
@ -1100,6 +1104,16 @@ void main(void)
|
||||
if (second_flag) { // one second passed
|
||||
second_flag = false; // clear flag
|
||||
led_toggle(); // toggle LED to indicate if main function is stuck
|
||||
if (net_connected) {
|
||||
net_connected = false; // reset flag
|
||||
} else {
|
||||
if (!radio_esp8266_connected()) { // check if we are connected
|
||||
puts("not connected: resetting network");
|
||||
radio_esp8266_reset(); // restart and try to reconnect
|
||||
radio_esp8266_listen(true, 6454); // open UDP Art-Net
|
||||
}
|
||||
net_connected = true; // remember we are connected
|
||||
}
|
||||
}
|
||||
if (0 == gpio_get(GPIO_PORT(DRV8825_FAULT_PIN), GPIO_PIN(DRV8825_FAULT_PIN))) { // DRV8825 stepper motor error reports error
|
||||
gpio_set(GPIO_PORT(DRV8825_ENABLE_PIN), GPIO_PIN(DRV8825_ENABLE_PIN)); // disable motor
|
||||
@ -1125,6 +1139,7 @@ void main(void)
|
||||
action = true; // redo main loop
|
||||
}
|
||||
if (radio_esp8266_received_len) {
|
||||
net_connected = true; // we are connected since we received data
|
||||
if (radio_esp8266_received_len >= 18 && 0 == memcmp((char*)radio_esp8266_received, "Art-Net", 7)) {
|
||||
const uint16_t dmx_universe = radio_esp8266_received[14] + (radio_esp8266_received[15] << 8);
|
||||
const uint16_t dmx_length = radio_esp8266_received[17] + (radio_esp8266_received[16] << 8);
|
||||
|
Loading…
Reference in New Issue
Block a user