diff --git a/firmware/esp32/main/main.cpp b/firmware/esp32/main/main.cpp index a12f469..d0a2489 100644 --- a/firmware/esp32/main/main.cpp +++ b/firmware/esp32/main/main.cpp @@ -28,7 +28,7 @@ static void watchdogTask(void *pvParameters) { ESP_ERROR_CHECK(esp_task_wdt_add(NULL)); for(;;) { - if (criticalErrorFlag) { + if(criticalErrorFlag) { ESP_LOGE(TAG, "Critical error flag raised. Rebooting."); esp_restart(); } diff --git a/firmware/esp32/main/mqtt.cpp b/firmware/esp32/main/mqtt.cpp index 8c92246..8f75cbd 100644 --- a/firmware/esp32/main/mqtt.cpp +++ b/firmware/esp32/main/mqtt.cpp @@ -22,9 +22,9 @@ static void mqtt_subscribe(void) { } static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data; + esp_mqtt_event_handle_t event =(esp_mqtt_event_handle_t)event_data; - switch (event->event_id) { + switch(event->event_id) { case MQTT_EVENT_CONNECTED: xEventGroupSetBits(connectivity_event_group, MQTT_CONNECTED_BIT); mqtt_subscribe(); @@ -41,7 +41,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_ ESP_LOGD(TAG, "Data received"); int len = event->data_len; - if (len > sizeof(global_rx_buffer) - 1) len = sizeof(global_rx_buffer) - 1; + if(len > sizeof(global_rx_buffer) - 1) len = sizeof(global_rx_buffer) - 1; memcpy(global_rx_buffer, event->data, len); global_rx_buffer[len] = '\0'; @@ -96,14 +96,12 @@ void mqttTask(void *pvParameters) { EventBits_t bits = xEventGroupGetBits(connectivity_event_group); - if ((bits & (WIFI_CONNECTED_BIT | MQTT_CONNECTED_BIT)) == (WIFI_CONNECTED_BIT | MQTT_CONNECTED_BIT)) { - + if((bits &(WIFI_CONNECTED_BIT | MQTT_CONNECTED_BIT)) ==(WIFI_CONNECTED_BIT | MQTT_CONNECTED_BIT)) { ESP_LOGV(TAG, "Connection established"); uint32_t task_notification = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(MQTT_TASK_TIMEOUT_MS)); - if (task_notification) {} //{twi_do(global_rx_buffer)} - + if(task_notification) {} //{twi_do(global_rx_buffer)} } else { ESP_LOGW(TAG, "Waiting for connection..."); vTaskDelay(pdMS_TO_TICKS(MQTT_TASK_TIMEOUT_MS/2)); diff --git a/firmware/esp32/main/wifi.cpp b/firmware/esp32/main/wifi.cpp index dfe46c0..88c903d 100644 --- a/firmware/esp32/main/wifi.cpp +++ b/firmware/esp32/main/wifi.cpp @@ -13,15 +13,15 @@ static const char* TAG = "WIFI"; static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { - if (event_base == WIFI_EVENT) { - switch (event_id) { + if(event_base == WIFI_EVENT) { + switch(event_id) { case WIFI_EVENT_STA_START: ESP_LOGV(TAG, "Process started, connecting..."); esp_wifi_connect(); break; case WIFI_EVENT_STA_DISCONNECTED: { - wifi_event_sta_disconnected_t* disconn = (wifi_event_sta_disconnected_t*) event_data; + wifi_event_sta_disconnected_t* disconn =(wifi_event_sta_disconnected_t*) event_data; ESP_LOGW(TAG, "Disconnected, reason: %d", disconn->reason); xEventGroupClearBits(connectivity_event_group, WIFI_CONNECTED_BIT | MQTT_CONNECTED_BIT); @@ -33,8 +33,8 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t e break; } } - else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { - ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; + else if(event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + ip_event_got_ip_t* event =(ip_event_got_ip_t*) event_data; ESP_LOGD(TAG, "Got IP: " IPSTR, IP2STR(&event->ip_info.ip)); xEventGroupSetBits(connectivity_event_group, WIFI_CONNECTED_BIT); @@ -44,7 +44,7 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t e static void wifi_init_sta(void) { esp_err_t nvs_err = nvs_flash_init(); - if (nvs_err == ESP_ERR_NVS_NO_FREE_PAGES || nvs_err == ESP_ERR_NVS_NEW_VERSION_FOUND) { + if(nvs_err == ESP_ERR_NVS_NO_FREE_PAGES || nvs_err == ESP_ERR_NVS_NEW_VERSION_FOUND) { ESP_ERROR_CHECK(nvs_flash_erase()); ESP_ERROR_CHECK(nvs_flash_init()); }