Commit dbaa62f2 authored by 黄振令's avatar 黄振令

【修改内容】kcloud—>ccu的消息做过滤,给主机或给网关

【提交人】huang.zhenling
parent c4dbdba7
...@@ -46,6 +46,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY; ...@@ -46,6 +46,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_LOGIN_TOPIC_REPLY "/thing/combine/login_reply" #define KK_LOGIN_TOPIC_REPLY "/thing/combine/login_reply"
#define KK_ONLINE_TOPIC_REPLY "/thing/status/online_reply" #define KK_ONLINE_TOPIC_REPLY "/thing/status/online_reply"
#define KK_THING_SERVICE_PROPERTY_SET "/thing/service/property/set" #define KK_THING_SERVICE_PROPERTY_SET "/thing/service/property/set"
#define KK_THING_SERVICE_PROPERTY_GET "/thing/service/property/get"
#define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade" #define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade"
#define KK_THING_CLOUDSTATE_MSG "/thing/ccu/cloudstate_reply" #define KK_THING_CLOUDSTATE_MSG "/thing/ccu/cloudstate_reply"
#define KK_THING_TOPO_ADD_MSG "/thing/topo/add" #define KK_THING_TOPO_ADD_MSG "/thing/topo/add"
......
...@@ -27,8 +27,8 @@ char * g_filerToPlatTable[] = ...@@ -27,8 +27,8 @@ char * g_filerToPlatTable[] =
{KK_REGISTER_TOPIC_REPLY}, {KK_REGISTER_TOPIC_REPLY},
{KK_ADD_TOPIC_REPLY}, {KK_ADD_TOPIC_REPLY},
{KK_LOGIN_TOPIC_REPLY}, {KK_LOGIN_TOPIC_REPLY},
{KK_THING_OTA_DEVICE_UPGRADE}, {KK_THING_SERVICE_PROPERTY_GET},
{KK_THING_CLOUDSTATE_MSG}, {KK_THING_CLOUDSTATE_MSG},
}; };
static int _kk_filter_to_plat(const char* msgtype) static int _kk_filter_to_plat(const char* msgtype)
...@@ -61,38 +61,42 @@ void kk_sendData2gw(void* data, int len, char* chalMark){ ...@@ -61,38 +61,42 @@ void kk_sendData2gw(void* data, int len, char* chalMark){
void mid_cb(void* data, int len){ void mid_cb(void* data, int len){
if (data != NULL){ if (data != NULL){
char *out;
cJSON *json; cJSON *json;
cJSON *info_root,*info,*type; cJSON *info_root,*type;
cJSON*payload;
cJSON*deviceCode; cJSON*deviceCode;
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);
//return FAIL_RETURN;
}
json=cJSON_Parse(data); json=cJSON_Parse(data);
if (!json) { if (!json) {
printf("Error before: [%s]\n","cJSON_Parse"); ERROR_PRINT("Error before: [%s]\n","cJSON_Parse");
} }
else else
{ {
info_root = cJSON_GetObjectItem(json, MSG_INFO_STR); info_root = cJSON_GetObjectItem(json, MSG_INFO_STR);
if (info_root == NULL){
ERROR_PRINT(" params [%s] can't find \n",MSG_INFO_STR);
cJSON_Delete(json);
return;
}
deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR); deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR);
type = cJSON_GetObjectItem(info_root, MSG_TYPE_STR); type = cJSON_GetObjectItem(info_root, MSG_TYPE_STR);
if(_kk_filter_to_plat(type->valuestring)){ if (deviceCode == NULL || type == NULL){
cJSON_Delete(json); ERROR_PRINT(" params [%s] or [%s] can't find \n",MSG_DEVICE_CODE_STR, MSG_TYPE_STR);
cJSON_Delete(info); cJSON_Delete(json);
return; return;
} }
int devType = 0; int devType = 0;
dm_mgr_get_devicetype_by_devicecode(deviceCode->valuestring,&devType); dm_mgr_get_devicetype_by_devicecode(deviceCode->valuestring,&devType);
if(devType == KK_DM_DEVICE_GATEWAY){ //主机的device或过滤的
if(devType == KK_DM_DEVICE_CCU ||_kk_filter_to_plat(type->valuestring)){
void* buf = malloc(len);
memcpy(buf, data, len);
res = dm_queue_msg_insert((void *)buf);
if (res != SUCCESS_RETURN) {
free(buf);
}
}else if(devType == KK_DM_DEVICE_GATEWAY){
kk_sendData2gw(data, strlen(data), deviceCode->valuestring);//send to gw itself kk_sendData2gw(data, strlen(data), deviceCode->valuestring);//send to gw itself
}else if(devType == KK_DM_DEVICE_SUBDEV){ }else if(devType == KK_DM_DEVICE_SUBDEV){
dm_mgr_dev_node_t *gw_node = NULL; dm_mgr_dev_node_t *gw_node = NULL;
...@@ -100,7 +104,6 @@ void mid_cb(void* data, int len){ ...@@ -100,7 +104,6 @@ void mid_cb(void* data, int len){
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
ERROR_PRINT("res:%d\n",res); ERROR_PRINT("res:%d\n",res);
cJSON_Delete(json); cJSON_Delete(json);
cJSON_Delete(info);
return; return;
} }
kk_sendData2gw(data, strlen(data), gw_node->fatherDeviceCode);//send to sub device kk_sendData2gw(data, strlen(data), gw_node->fatherDeviceCode);//send to sub device
...@@ -109,7 +112,6 @@ void mid_cb(void* data, int len){ ...@@ -109,7 +112,6 @@ void mid_cb(void* data, int len){
ERROR_PRINT("wrong type\n"); ERROR_PRINT("wrong type\n");
} }
cJSON_Delete(json); cJSON_Delete(json);
cJSON_Delete(info);
} }
} }
......
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