84 |
84 |
85 |
85 |
86 |
86 |
87 void publisher(char *topic, char *payload) |
87 void publisher(char *topic, char *payload) |
88 { |
88 { |
89 // publish the data |
89 /* |
|
90 * First count, then sent the data. |
|
91 */ |
|
92 if (xSemaphoreTake(xSemaphorePcounter, 10) == pdTRUE) { |
|
93 count_pub++; |
|
94 printf(" up %d\n", count_pub); |
|
95 xSemaphoreGive(xSemaphorePcounter); |
|
96 } else { |
|
97 ESP_LOGE(TAG, "Missed lock 1"); |
|
98 } |
|
99 |
90 if (payload) |
100 if (payload) |
91 esp_mqtt_client_publish(client, topic, payload, strlen(payload), 1, 0); |
101 esp_mqtt_client_publish(client, topic, payload, strlen(payload), 1, 0); |
92 else |
102 else |
93 esp_mqtt_client_publish(client, topic, NULL, 0, 1, 0); |
103 esp_mqtt_client_publish(client, topic, NULL, 0, 1, 0); |
94 if (xSemaphoreTake(xSemaphorePcounter, 10) == pdTRUE) { |
|
95 count_pub++; |
|
96 printf(" up %d\n", count_pub); |
|
97 xSemaphoreGive(xSemaphorePcounter); |
|
98 } else { |
|
99 ESP_LOGE(TAG, "Missed lock 1"); |
|
100 } |
|
101 } |
104 } |
102 |
105 |
103 |
106 |
104 |
107 |
105 char *unit_data(int i) |
108 char *unit_data(int i) |