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

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

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