Skip to content

Commit e44a3ca

Browse files
committed
Fix Emoncms publication for serial interface
Preliminary, quite hacky solution. But I wanted to get it to work again until we have the improved generic ThingSet handler.
1 parent 3b25a24 commit e44a3ca

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

main/emoncms.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@ void emoncms_post_task(void *arg)
107107
while (1) {
108108
esp_err_t err;
109109

110+
// attempt to get serial publication message
111+
char *pub_msg = ts_serial_pubmsg(100);
112+
110113
// wait until we receive an update
111114
while (update_bms_received == false &&
112-
update_mppt_received == false/* &&
113-
pub_serial_received == false*/)
115+
update_mppt_received == false &&
116+
pub_msg == NULL)
114117
{
115-
vTaskDelay(100 / portTICK_PERIOD_MS);
118+
// try again as long as a message from
119+
pub_msg = ts_serial_pubmsg(100);
116120
}
117121

118122
//esp_netif_ip_info_t ip_info;
@@ -150,15 +154,15 @@ void emoncms_post_task(void *arg)
150154
gpio_set_level(CONFIG_GPIO_LED, 1);
151155

152156
vTaskDelay(100 / portTICK_PERIOD_MS);
153-
/*
154-
if (pub_serial_received) {
157+
158+
if (pub_msg != NULL && strlen(pub_msg) > 2) {
155159
gpio_set_level(CONFIG_GPIO_LED, 0);
156-
send_emoncms(res, CONFIG_EMONCMS_NODE_SERIAL, get_serial_json_data());
157-
pub_serial_received = false;
160+
send_emoncms(res, CONFIG_EMONCMS_NODE_SERIAL, pub_msg + 2);
161+
ts_serial_pubmsg_clear();
158162
vTaskDelay(100 / portTICK_PERIOD_MS);
159163
}
160164
gpio_set_level(CONFIG_GPIO_LED, 1);
161-
*/
165+
162166
// sending interval almost 10s
163167
vTaskDelay(8000 / portTICK_PERIOD_MS);
164168

0 commit comments

Comments
 (0)