Code cleanup

Tue, 08 Oct 2019 16:51:30 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 08 Oct 2019 16:51:30 +0200
changeset 3
cd760fd45271
parent 2
c0184362d48c
child 4
2a57c466bf45

Code cleanup

main/config.c file | annotate | diff | comparison | revisions
main/task_ds18b20.c file | annotate | diff | comparison | revisions
main/task_mqtt.c file | annotate | diff | comparison | revisions
--- a/main/config.c	Tue Oct 08 15:47:34 2019 +0200
+++ b/main/config.c	Tue Oct 08 16:51:30 2019 +0200
@@ -79,7 +79,7 @@
 void read_units() {
     uint8_t     *dst;
     uint8_t     mac_addr[8] = {0};
-    FILE        *f = fopen("/spiffs/etc/units.conft", "r");
+    FILE        *f = fopen("/spiffs/etc/units.conf", "r");
 
     if (f == NULL) {
         // No units yet, create them.
--- a/main/task_ds18b20.c	Tue Oct 08 15:47:34 2019 +0200
+++ b/main/task_ds18b20.c	Tue Oct 08 16:51:30 2019 +0200
@@ -14,13 +14,11 @@
 
 
 #define GPIO_DS18B20_BUS	(CONFIG_ONE_WIRE_BUS)
-#define MAX_DEVICES		(8)
 #define DS18B20_RESOLUTION	(DS18B20_RESOLUTION_12_BIT)
-#define SAMPLE_PERIOD		(2000)   // milliseconds
 
 
 static const char		*TAG = "task_ds18b20";
-static const char		*dsErrors[] = { "Ok", "No sensor", "Too many sensors", "CRC error", "Read error" };
+static const char		*dsErrors[] = { "Ok", "CRC error", "Read error" };
 
 SemaphoreHandle_t		xSemaphoreDS18B20 = NULL;	///< Semaphire DS18B20 task
 EventGroupHandle_t		xEventGroupDS18B20;		///< Events DS18B20 task
@@ -126,10 +124,8 @@
 	    	    } else {
 		    	if (errors == DS18B20_ERROR_CRC)
 		    	    ds18b20_state->sensor[0].error = DS18B20_ERR_CRC;
-		    	if (errors == DS18B20_ERROR_OWB)
-		    	    ds18b20_state->sensor[0].error = DS18B20_ERR_READ;
-		    	if (errors == DS18B20_ERROR_DEVICE)
-		    	    ds18b20_state->sensor[0].error = DS18B20_ERR_READ;
+			else
+		    	    ds18b20_state->sensor[0].error = DS18B20_ERR_READ; // All other errors
 		    	ds18b20_state->valid = false;
 		    	ds18b20_state->sensor[0].temperature = 0.0;
 	    	    }
--- a/main/task_mqtt.c	Tue Oct 08 15:47:34 2019 +0200
+++ b/main/task_mqtt.c	Tue Oct 08 16:51:30 2019 +0200
@@ -221,21 +221,6 @@
         case MQTT_EVENT_CONNECTED:
             ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
 	    xEventGroupSetBits(xEventGroupMQTT, TASK_MQTT_CONNECTED);
-
-//	    topic = topic_base((char *)"NCMD");
-//            topic = xstrcat(topic, (char *)"/#");
-//	    ESP_LOGI(TAG, "Subscribe %s", topic);
-//            msg_id = esp_mqtt_client_subscribe(client, topic, 0);
-//            ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
-//	    free(topic);
-
-//	    topic = topic_base((char *)"DCMD");
-//            topic = xstrcat(topic, (char *)"/#");
-//	    ESP_LOGI(TAG, "Subscribe %s", topic);
-//            msg_id = esp_mqtt_client_subscribe(client, topic, 1);
-//            ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
-//	    free(topic);
-//	    topic = NULL;
             break;
 
         case MQTT_EVENT_DISCONNECTED:
@@ -266,7 +251,7 @@
             break;
 
 	case MQTT_EVENT_BEFORE_CONNECT:
-	    ESP_LOGI(TAG, "MQTT_EVENT_BEFORE_CONNECT");
+	    //ESP_LOGI(TAG, "MQTT_EVENT_BEFORE_CONNECT");
 	    // Configure connection can be here.
 	    break;
 
@@ -280,7 +265,7 @@
 
 
 static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) {
-    ESP_LOGI(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id);
+//    ESP_LOGI(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id);
     mqtt_event_handler_cb(event_data);
 }
 

mercurial