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

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

【提交人】黄振令
parents 5a794539 ae347f12
......@@ -21,19 +21,9 @@
void mid_cb(void* data, int len){
if (data != NULL){
printf("app2mid_cb: %s RECEIVED \r\n", data);
char *out;
cJSON *json;
cJSON *topic;
cJSON *payload;
char *out;cJSON *json, *topic, *payload;
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);
if (!json) {
printf("Error before: [%s]\n","cJSON_Parse");
......@@ -43,12 +33,25 @@ void mid_cb(void* data, int len){
topic = cJSON_GetObjectItem(json, "topic");
payload = cJSON_GetObjectItem(json, "payload");
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){
//set to platform
if (strcmp(payload->valuestring, "addsub")==0){
//kk_mid_subdev_add("a1OYuSallan","allanWno8yDdsjCX15iq","");
}else{
void* buf = malloc(len);
memcpy(buf, data, len);
int res = dm_queue_msg_insert((void *)buf);
if (res != SUCCESS_RETURN) {
free(buf);
//return FAIL_RETURN;
}
//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) {
printf("mid_cb dm_mgr_search_mac_by_topic mac: %s \r\n", 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);
......@@ -56,11 +59,6 @@ void mid_cb(void* data, int len){
kk_ipc_send(IPC_MID2PLAT, out, strlen(out));
free(out);
cJSON_Delete(jsonplay);
}
}
cJSON_Delete(json);
}
......@@ -116,7 +114,7 @@ void kk_platMsg_handle(void* data){
}else if (method != NULL && strcmp(method->valuestring, "thing.event.property.post")==0){
cJSON *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);
......
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