Commit 61d21d6c authored by 黄振令's avatar 黄振令

【修改内容】1. 根据topic过滤, get 不会把命令传到platform ;2.set 属性midware 做反馈给云端

【提交人】黄振令
parents 5a794539 ae347f12
...@@ -21,18 +21,8 @@ ...@@ -21,18 +21,8 @@
void mid_cb(void* data, int len){ void mid_cb(void* data, int len){
if (data != NULL){ if (data != NULL){
printf("app2mid_cb: %s RECEIVED \r\n", data); printf("app2mid_cb: %s RECEIVED \r\n", data);
char *out; char *out;cJSON *json, *topic, *payload;
cJSON *json;
cJSON *topic;
cJSON *payload;
int res; int res;
void* buf = malloc(len);
memcpy(buf, data, len);
res = dm_queue_msg_insert((void *)buf);
if (res != SUCCESS_RETURN) {
free(buf);
}
json=cJSON_Parse(data); json=cJSON_Parse(data);
if (!json) { if (!json) {
...@@ -43,24 +33,32 @@ void mid_cb(void* data, int len){ ...@@ -43,24 +33,32 @@ void mid_cb(void* data, int len){
topic = cJSON_GetObjectItem(json, "topic"); topic = cJSON_GetObjectItem(json, "topic");
payload = cJSON_GetObjectItem(json, "payload"); payload = cJSON_GetObjectItem(json, "payload");
printf("mid_cb topic: [%s] ,payload= %s \n",topic->valuestring,payload->valuestring ); printf("mid_cb topic: [%s] ,payload= %s \n",topic->valuestring,payload->valuestring );
if (strstr(topic->valuestring, "thing/service") != NULL && strstr(topic->valuestring, "service/property/get") == NULL){ if (strcmp(payload->valuestring, "addsub")==0){
//set to platform //kk_mid_subdev_add("a1OYuSallan","allanWno8yDdsjCX15iq","");
char mac[DEVICE_MAC_MAXLEN]; }else{
res =dm_mgr_search_mac_by_topic(topic->valuestring, mac); void* buf = malloc(len);
if (res == SUCCESS_RETURN) { memcpy(buf, data, len);
printf("mid_cb dm_mgr_search_mac_by_topic mac: %s \r\n", mac); int res = dm_queue_msg_insert((void *)buf);
if (res != SUCCESS_RETURN) {
cJSON * jsonplay=cJSON_Parse(payload->valuestring); free(buf);
cJSON_AddStringToObject(jsonplay, "mac", mac); //return FAIL_RETURN;
void* out = cJSON_Print(jsonplay);
kk_ipc_send(IPC_MID2PLAT, out, strlen(out));
free(out);
cJSON_Delete(jsonplay);
} }
}
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}
char mac[DEVICE_MAC_MAXLEN];
res =dm_mgr_search_mac_by_topic(topic->valuestring, mac);
if (res != SUCCESS_RETURN) {
return;
}
printf("dm_mgr_search_mac_by_topic mac: %s \r\n", mac);
cJSON * jsonplay=cJSON_Parse(payload->valuestring);
cJSON_AddStringToObject(jsonplay, "mac", mac);
void* out = cJSON_Print(jsonplay);
kk_ipc_send(IPC_MID2PLAT, out, strlen(out));
free(out);
cJSON_Delete(jsonplay);
cJSON_Delete(json); cJSON_Delete(json);
} }
...@@ -116,7 +114,7 @@ void kk_platMsg_handle(void* data){ ...@@ -116,7 +114,7 @@ void kk_platMsg_handle(void* data){
}else if (method != NULL && strcmp(method->valuestring, "thing.event.property.post")==0){ }else if (method != NULL && strcmp(method->valuestring, "thing.event.property.post")==0){
cJSON *mac; cJSON *mac;
mac = cJSON_GetObjectItem(json, "mac"); mac = cJSON_GetObjectItem(json, "mac");
kk_tsl_property_set_byMac(mac->valuestring, data, strlen(mac)+1, NULL);
//kk_tsl_service_property_set(topic->valuestring, data, strlen(data), NULL); //kk_tsl_service_property_set(topic->valuestring, data, strlen(data), NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment