|
|
@@ -599,18 +599,18 @@ static int send_stat(mqtt_handle_t *h, int type)
|
|
|
|
|
|
case MQTT_PUB_STAT_POWER_ALL:
|
|
|
{
|
|
|
- cJSON* root=cJSON_CreateObject();
|
|
|
- if(root) {
|
|
|
- int cnt=1;
|
|
|
- pwrall_info_t *pall=websocket_get_pwrall();
|
|
|
+ int cnt=1;
|
|
|
+ pwrall_info_t *pall=websocket_get_pwrall();
|
|
|
|
|
|
- if(pall->ph3) {
|
|
|
- cnt = 3;
|
|
|
- }
|
|
|
+ if(pall->ph3) {
|
|
|
+ cnt = 3;
|
|
|
+ }
|
|
|
|
|
|
- for(i=0; i<cnt; i++) {
|
|
|
- _OverAllPwrAckInfo *info=&pall->ch[i];
|
|
|
+ for(i=0; i<cnt; i++) {
|
|
|
+ _OverAllPwrAckInfo *info=&pall->ch[i];
|
|
|
|
|
|
+ cJSON* root=cJSON_CreateObject();
|
|
|
+ if(root) {
|
|
|
sprintf(buf, "L%d", i+1);
|
|
|
cJSON_AddStringToObject(root,"phase", buf);
|
|
|
cJSON_AddStringToObject(root,"voltage", get_float_str(info->voltage));
|
|
|
@@ -632,8 +632,9 @@ static int send_stat(mqtt_handle_t *h, int type)
|
|
|
content = cJSON_Print(root);
|
|
|
my_pub(h, type, topic, content);
|
|
|
cJSON_free(content);
|
|
|
+
|
|
|
+ cJSON_Delete(root);
|
|
|
}
|
|
|
- cJSON_Delete(root);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -985,12 +986,15 @@ static int my_recv(char *topic, char *data)
|
|
|
int i,r,cmd;
|
|
|
|
|
|
#ifdef USE_MQTT
|
|
|
- char temp[512];
|
|
|
+ char *p,temp[512];
|
|
|
uint32_t flag=0;
|
|
|
mqtt_handle_t *h=&mqHandle;
|
|
|
|
|
|
for(i=0; i<MQTT_SUB_MAX; i++) {
|
|
|
snprintf(temp, sizeof(temp), topic_sub[i], h->prod_id);
|
|
|
+ p = strrchr(temp, '+');
|
|
|
+ if(p) p[0] = 0;
|
|
|
+
|
|
|
if(strstr(topic, temp)) {
|
|
|
switch(i) {
|
|
|
case MQTT_SUB_CMD_POWER_ALL:
|