Commit b906dd20 authored by 尹佳钦's avatar 尹佳钦

【20210826】优化局域网部分代码。去掉多余打印。

parent 0c0a6027
#include "kk_ccu_msg.h"
typedef cJSON *(*convert_func)(cJSON *,cJSON *);
typedef struct
{
char *type;
convert_func func;
}CONVERT_ITEM_S;
static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType);
static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType);
static cJSON *double_type_convert(cJSON *n_id,cJSON *n_dataType);
......@@ -9,14 +17,6 @@ static cJSON *string_double_type_convert(cJSON *n_id,cJSON *n_dataType);
static cJSON *string_time_type_convert(cJSON *n_id,cJSON *n_dataType);
static cJSON *fit_type_convert(cJSON *n_id,cJSON *n_dataType);
typedef cJSON *(*convert_func)(cJSON *,cJSON *);
typedef struct
{
char *type;
convert_func func;
}CONVERT_ITEM_S;
static CONVERT_ITEM_S convert_table[] = {
{"bool",bool_type_convert},
......@@ -29,14 +29,11 @@ static CONVERT_ITEM_S convert_table[] = {
{"fit",fit_type_convert}
};
static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON *args = NULL;
int bVal = 0;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(strcmp(n_dataType->valuestring,"dummy")==0) {
return NULL;
}
......@@ -71,8 +68,6 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON *args = NULL;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(strcmp(n_dataType->valuestring,"dummy")==0) {
return NULL;
}
......@@ -108,8 +103,6 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
cJSON *args = NULL;
int flag = -1;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(strcmp(n_dataType->valuestring,"dummy")==0) {
return NULL;
}
......@@ -152,8 +145,6 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
}val = {0};
memset(sVal,0,sizeof(sVal));
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(strcmp(n_dataType->valuestring,"dummy")==0) {
return NULL;
}
......@@ -225,7 +216,6 @@ cJSON *string_time_type_convert(cJSON *n_id,cJSON *n_dataType)
cJSON *args = NULL;
int val;
char tm[10] = {0};
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(strcmp(n_dataType->valuestring,"dummy")==0) {
return NULL;
......@@ -248,8 +238,6 @@ cJSON *fit_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON *args = NULL;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(n_id->type == cJSON_True) {
args = cJSON_CreateTrue();
}else if(n_id->type == cJSON_False){
......@@ -265,23 +253,27 @@ cJSON *fit_type_convert(cJSON *n_id,cJSON *n_dataType)
return args;
}
cJSON * msg_convert_value(cJSON *d_type,cJSON *s_type,cJSON *value)
{
int i,size;
char *pVal = NULL;
cJSON *rlt = NULL;
CONVERT_ITEM_S *crt;
if(d_type==NULL||s_type==NULL||value==NULL){
if(d_type==NULL||s_type==NULL||value==NULL||
d_type->type!=cJSON_String||s_type->type!=cJSON_String){
debug_log(LOG_DEBUG,"[ERR] para.\n");
return NULL;
}
pVal = cJSON_Print(value);
debug_log(LOG_NORMAL,"[convert]type:%s->%s,val=%s.\n",s_type->valuestring,d_type->valuestring,pVal);
free(pVal);
size = sizeof(convert_table)/sizeof(CONVERT_ITEM_S);
crt = &convert_table[0];
......@@ -300,10 +292,36 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
{
cJSON *args = NULL;
cJSON *rlt;
char *sVrg = NULL,*dVrg = NULL,*pVal = NULL;
int j;
int vra_size;
int vra_size = cJSON_GetArraySize(s_valueRange);
if(s_valueRange==NULL||s_valueRange->type!=cJSON_Array||
d_valueRange==NULL||d_valueRange->type!=cJSON_Array){
debug_log(LOG_DEBUG,"[ERR] range.\n");
return NULL;
}
if(s_dataType==NULL||s_dataType->type!=cJSON_String){
debug_log(LOG_DEBUG,"[ERR] dataType.\n");
return NULL;
}
sVrg = cJSON_Print(s_valueRange);
dVrg = cJSON_Print(d_valueRange);
pVal = cJSON_Print(value);
debug_log(LOG_NORMAL,"[convert] s_dataType:%s,val=%s\n",s_dataType->valuestring,pVal);
debug_log(LOG_INFO,"s_valueRange=%s\n",sVrg);
debug_log(LOG_INFO,"d_valueRange=%s\n",dVrg);
free(sVrg);
free(dVrg);
free(pVal);
vra_size = cJSON_GetArraySize(s_valueRange);
for(j=0;j<vra_size;j++){
if(strcmp(s_dataType->valuestring,"dummy")==0){
continue ;
......@@ -314,6 +332,7 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
strcmp(s_dataType->valuestring,"int")==0) {
if(rlt->valueint == value->valueint) {
args = cJSON_GetArrayItem(d_valueRange,j);
printf("222:%s\n",cJSON_Print(args));
break ;
}
}else if(strcmp(s_dataType->valuestring,"double")==0){
......@@ -352,37 +371,22 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
void add_val_to_obj(cJSON *obj,cJSON *val,const char *identifier)
{
if(val->type==cJSON_False){
cJSON_AddFalseToObject(obj,identifier);
}else if(val->type==cJSON_True){
cJSON_AddTrueToObject(obj,identifier);
}else if(val->type==cJSON_NULL){
cJSON_AddNullToObject(obj,identifier);
}else if(val->type==cJSON_Number){
cJSON_AddNumberToObject(obj,identifier,val->valuedouble);
}else if(val->type==cJSON_String){
cJSON_AddStringToObject(obj,identifier,val->valuestring);
}else if(val->type==cJSON_Array){
printf("......................\n");
}
}
cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_range,cJSON *value)
{
cJSON *val = NULL;
printf("[ccu val convert] s_dType=%s,s_range=%s,d_dType=%s,d_range=%s,value=%s\n",
cJSON_Print(s_dType),cJSON_Print(s_range),cJSON_Print(d_dType),cJSON_Print(d_range),cJSON_Print(value));
if(strcmp(d_dType->valuestring,"map")==0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
val = map_type_convert(s_dType,s_range,value,d_range);
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
val = msg_convert_value(d_dType,s_dType,value);
}
//printf("[val]%s\n",cJSON_Print(val));
return val;
}
......@@ -408,7 +412,61 @@ int kk_lan_get_msg_id_str(char *msgId,int size)
int kk_lan_add_val_to_obj(cJSON *obj,cJSON *val,const char *id)
{
if(id==NULL||obj==NULL||obj->type!=cJSON_Object||val==NULL){
debug_log(LOG_DEBUG,"[err] para.\n");
return -1;
}
debug_log(LOG_NORMAL,"[add] id(%s),type(%d).\n",id,val->type);
if(val->type==cJSON_False){
cJSON_AddFalseToObject(obj,id);
}else if(val->type==cJSON_True){
cJSON_AddTrueToObject(obj,id);
}else if(val->type==cJSON_NULL){
cJSON_AddNullToObject(obj,id);
}else if(val->type==cJSON_Number){
cJSON_AddNumberToObject(obj,id,val->valuedouble);
}else if(val->type==cJSON_String){
cJSON_AddStringToObject(obj,id,val->valuestring);
}else{
debug_log(LOG_DEBUG,"[err] nonsupport type(%s).\n",val->type);
return -1;
}
return 0;
}
int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
{
char *pVal = NULL;
if(id==NULL||obj==NULL||obj->type!=cJSON_Object||val==NULL){
debug_log(LOG_DEBUG,"[err] para.\n");
return -1;
}
pVal = cJSON_Print(val);
debug_log(LOG_NORMAL,"[replace] id=%s,type=%d,val=%s.\n",id,val->type,pVal);
free(pVal);
if(val->type==cJSON_False){
cJSON_ReplaceItemInObject(obj, id, cJSON_CreateFalse());
}else if(val->type==cJSON_True){
cJSON_ReplaceItemInObject(obj, id, cJSON_CreateTrue());
}else if(val->type==cJSON_NULL){
cJSON_ReplaceItemInObject(obj, id, cJSON_CreateNull());
}else if(val->type==cJSON_Number){
cJSON_ReplaceItemInObject(obj, id, cJSON_CreateNumber(val->valuedouble));
}else if(val->type==cJSON_String){
cJSON_ReplaceItemInObject(obj, id, cJSON_CreateString(val->valuestring));
}else{
debug_log(LOG_DEBUG,"[err] nonsupport type(%s).\n",val->type);
return -1;
}
return 0;
}
......
......@@ -79,6 +79,12 @@ void add_val_to_obj(cJSON *obj,cJSON *val,const char *identifier);
cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_range,cJSON *value);
int kk_lan_add_val_to_obj(cJSON *obj,cJSON *val,const char *id);
int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id);
#endif
......@@ -17,6 +17,7 @@
#include "kk_data_mng.h"
#include "kk_lan_ctrl.h"
#include "kk_lan_sync.h"
#include "kk_lan_debug.h"
#include "kk_voice_panel_handle.h"
......@@ -112,7 +113,9 @@ void kk_handle_sync_info(void)
if(send_data == NULL){
return;
}
printf("kk_ipc_send........%s \n",send_data);
debug_log(LOG_INFO,"[sync] send.\n");
kk_ipc_send(IPC_APP2MID, send_data, strlen(send_data)+1);
free(send_data);
}
......@@ -428,7 +431,7 @@ static int kk_parse_syncinfo(cJSON *payload)
kk_map_dev_node_add(deviceCode,productCode,gwdevicecode,(onlineStatus->valueint==1)?"1":"0");
property_syn_deal(deviceCode,properties);
kk_lan_property_post_deal(deviceCode,properties);
......@@ -684,6 +687,40 @@ static int kk_device_historyalarm_handle(cJSON *payload)
cJSON_Delete(root);
return 0;
}
static int kk_lan_scene_handle(cJSON *payload,int isAdd)
{
cJSON *params = NULL;
cJSON *sceneId = NULL;
if(payload == NULL){
debug_log(LOG_DEBUG,"[err] payload.\n");
return -1;
}
if((params = cJSON_GetObjectItem(payload, MSG_PARAMS_STR))==NULL||
params->type!=cJSON_Object){
debug_log(LOG_DEBUG,"[err] params err.\n");
return -1;
}
if((sceneId = cJSON_GetObjectItem(params, MSG_SCENE_SCENEID))==NULL ||
sceneId->type!=cJSON_String){
debug_log(LOG_DEBUG,"[err] sceneId err.\n");
return -1;
}
if(isAdd!=0){
kk_lan_add_scene_notify(sceneId->valuestring);
}else{
kk_lan_delete_scene_notify(sceneId->valuestring);
}
return 0;
}
void KK_Data_FromMid(void* str,int len)
{
cJSON *json;
......@@ -727,13 +764,13 @@ void KK_Data_FromMid(void* str,int len)
int type;
if((type = is_arming_status_notify(payload))!=-1){
arming_status_notify(type);
kk_lan_arming_status_notify(type);
}
}else{
property_post_deal(deviceCode->valuestring,payload);
kk_lan_property_post_deal(deviceCode->valuestring,payload);
}
}else if(strstr(msgtype->valuestring,"/thing/topo/delete")!= NULL){
device_delete_sync(payload);
kk_lan_device_delete_notify(payload);
}else if(strstr(msgtype->valuestring,"/thing/status/online")!= NULL){
kk_device_onoffline_handle(payload,1);
}else if(strstr(msgtype->valuestring,"/thing/status/offline")!= NULL){
......@@ -749,7 +786,13 @@ void KK_Data_FromMid(void* str,int len)
kk_device_historyalarm_handle(payload);
}else if(strstr(msgtype->valuestring,"/thing/service/delAlarm_reply")!= NULL){
kk_del_historyalarm_handle(payload);
}else if(strstr(msgtype->valuestring,"/thing/event/addSceneNotification/post")!= NULL){
kk_lan_scene_handle(payload,1);
}else if(strstr(msgtype->valuestring,"/thing/event/deleteSceneNotification/post")!= NULL){
kk_lan_scene_handle(payload,0);
}
//
cJSON_Delete(json);
}
......@@ -757,3 +800,4 @@ void KK_Data_FromMid(void* str,int len)
......@@ -187,7 +187,7 @@ static char *kk_open_lan_cfg_file(char *deviceCode)
memset(buf,0x0,filesize+1);
fseek(fp, 0L, SEEK_SET);
fread(buf, 1, filesize, fp);
printf("[read lan cfg]:%s\n",buf);
//printf("[read lan cfg]:%s\n",buf);
fclose(fp);
return buf;
......@@ -409,16 +409,14 @@ int kk_map_dev_search_by_deviceCode(char *deviceCode, kk_map_dev_node_t **node)
kk_map_dev_node_t *n = NULL;
//list_for_each_entry_safe
printf("[QAQ] kk_map_dev_search_by_deviceCode\n");
list_for_each_entry(search_node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
printf("+++\n");
if ( (strlen(search_node->deviceCode) == strlen(deviceCode)) &&
(memcmp(search_node->deviceCode, deviceCode, strlen(deviceCode)) == 0)) {
/* dm_log_debug("Device Found, devid: %d", devid); */
if (node) {
*node = search_node;
}
printf("[find]%s\n",search_node->deviceCode);
return 0;
}
}
......
......@@ -80,7 +80,7 @@ int main(int argc, char* argv[])
kk_findccu_handle_init();
kk_map_dev_init();
kk_login_init();
kk_voice_panel_init();
//kk_voice_panel_init();
//lan_queue_init();
kk_lan_db_node_init();
......
......@@ -475,7 +475,7 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node)
}else{
if((val = val_conver_new2old(newccuItem,oldccuItem,1))!=NULL){
add_val_to_obj(arg,val,synKey->valuestring);
kk_lan_add_val_to_obj(arg,val,synKey->valuestring);
}
}
}
......@@ -505,13 +505,15 @@ static int _kk_sync_devices_status_arg_str(kk_map_dev_node_t *node,cJSON *devSta
}
num = cJSON_GetArraySize(newccu);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
for(i=0;i<num;i++){
cJSON * newccuItem = cJSON_GetArrayItem(newccu,i);
cJSON * oldccuItem = cJSON_GetArrayItem(oldccu,i);
cJSON *val = NULL;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if((val = val_conver_new2old(newccuItem,oldccuItem,0))!=NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
char indexId[4] = {0};
char nodeid[32] = {0};
cJSON *epNum = cJSON_GetObjectItem(newccuItem,CHANNEL_STRING);
......@@ -523,7 +525,7 @@ static int _kk_sync_devices_status_arg_str(kk_map_dev_node_t *node,cJSON *devSta
}
dev_status = cJSON_CreateObject();
add_val_to_obj(dev_status,val,"arg");
kk_lan_add_val_to_obj(dev_status,val,"arg");
kk_creater_nodeid(node->deviceCode,atoi(epNum->valuestring),nodeid);
......@@ -594,6 +596,7 @@ int kk_sync_devices_status_to_sdk(cJSON *root)
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_sync_devices_status_arg_str(node,devStatusAry,&idx);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//_kk_sync_devicestatus(node,devStatusAry);
}
......@@ -1058,7 +1061,7 @@ int kk_create_syncinfo_to_sdk(cJSON *payload)
cJSON *expand_rules;
cJSON *data = kk_get_sync_data(payload);
char *out = NULL;
cJSON *root=cJSON_CreateObject();
cJSON *aiks_controllers = cJSON_CreateArray();
......@@ -1137,15 +1140,11 @@ int kk_create_syncinfo_to_sdk(cJSON *payload)
#endif
out=cJSON_Print(root);
printf("out:%s\n",out);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,out);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *msg = old_ccu_msg_build_json("*","SYNC_INFO",NULL,root);
send_msg_to_module(msg);
cJSON_Delete(msg);
free(out);
return 0;
}
......
......@@ -8,10 +8,11 @@
#include "kk_lan_voice_panel.h"
#include "kk_voice_panel_cfg.h"
#include "kk_voice_panel_handle.h"
#include "kk_lan_debug.h"
#include "Serial.h"
#include "uart_proto.h"
static pthread_mutex_t v_mux;
......@@ -308,6 +309,8 @@ void *kk_vp_manage_thread(void *arg)
break;
case UPDATING_8009_CONFIG_FILE_INFO:
debug_log(LOG_INFO,"updating...\n");
sleep(1);
//todo :超时取消
break;
......
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kk_data_mng.h"
#include "kk_login_handle.h"
#include "kk_lan_node_db.h"
#include "kk_log.h"
#include "klist.h"
#include "kk_product.h"
#include "com_api.h"
#include "kk_opcode.h"
#include "kk_lan_ctrl.h"
#include "kk_data_mng.h"
#include "kk_oldccu_msg.h"
cJSON *old_ccu_msg_build_json_node_int(int nodeid,const char* opcode,const char* status,cJSON * arg)
{
cJSON *root;
if(opcode==NULL||arg==NULL) {
return NULL;
}
root=cJSON_CreateObject();
if(root){
cJSON_AddNumberToObject(root, "nodeid", nodeid);
cJSON_AddStringToObject(root, "opcode", opcode);
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddItemToObject(root, "arg", arg);
}
return root;
}
cJSON *old_ccu_msg_build_json(const char* nodeid,const char* opcode,const char* status,cJSON * arg)
......@@ -86,7 +67,7 @@ int send_msg_to_module(cJSON *root)
}
if((msg = cJSON_Print(root))!=NULL){
printf("[lan->module]json:\n%s\n",msg);
debug_log(LOG_INFO,"[lan->module]\n%s\n",msg);
cJSON_Minify(msg);
kk_send_data_to_sdk(msg);
free(msg);
......@@ -117,6 +98,7 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
}else{
o_dataType = cJSON_GetObjectItem(oldccuItem,DATATYPE_STRING);
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,n_value);
}
......@@ -139,8 +121,6 @@ cJSON *kk_devicestatus_build(kk_map_dev_node_t *node)
cJSON *newccu,*oldccu;
cJSON *dev_status;
printf("@@@@kk_devicestatus_build\n");
if (node == NULL ||node->syn_opcode==NULL){
return NULL;
}
......@@ -203,13 +183,12 @@ cJSON *kk_devicestatus_build(kk_map_dev_node_t *node)
}else{
if((val = val_conver_new2old(newccuItem,oldccuItem,1))!=NULL){
add_val_to_obj(dev_status,val,synKey->valuestring);
kk_lan_add_val_to_obj(dev_status,val,synKey->valuestring);
}
}
}
}
printf("@##$%^&&*(*(((*^%$$#@@@--->%s\n",cJSON_Print(dev_status));
return dev_status;
}
......@@ -218,284 +197,269 @@ cJSON *kk_devicestatus_build(kk_map_dev_node_t *node)
static int update_device_status(int nodeId,const char *opcode,const char *arg)
//更新设备状态
static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg)
{
cJSON *msg;
char *nodeStr;
cJSON *msg = NULL;
char nodeBuff[33] = {0};
if(arg==NULL){
if(opcode==NULL||opcode->type!=cJSON_String||
arg==NULL||arg->type!=cJSON_String){
debug_log(LOG_DEBUG,"[err] para.\n");
return -1;
}
printf("[%s][%d]nodeId=%d,status=%s\n",__FUNCTION__,__LINE__,nodeId,arg);
if((nodeStr=node_string(nodeId))!=NULL){
msg = old_ccu_msg_build(nodeStr,opcode,"success",arg);
debug_log(LOG_FOCUS,"nodeId=%d,opcode=%s,arg=%s\n",nodeId,opcode->valuestring,arg->valuestring);
memset(nodeBuff,0,sizeof(nodeBuff));
snprintf(nodeBuff,32,"%d",nodeId);
msg = old_ccu_msg_build(nodeBuff,opcode->valuestring,"success",arg->valuestring);
send_msg_to_module(msg);
cJSON_Delete(msg);
free(nodeStr);
return 0;
}
return -1;
return 0;
}
cJSON * attr_report_conver(const char *deviceCode,kk_map_dev_node_t *devNode,cJSON *params)
static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
{
cJSON *root;
//
cJSON *newccu;
cJSON *n_item;
cJSON *n_id,*n_valueRange,*n_dataType;
cJSON *n_value;
int channel = -1;
if(channelObj!=NULL && epNumObj!=NULL){
if(epNumObj->type!=cJSON_String){
debug_log(LOG_INFO,"[err] epNumObj.\n");
return -1;
}
if(strlen(channelObj->valuestring)!=strlen(epNumObj->valuestring) ||
strcmp(channelObj->valuestring,epNumObj->valuestring)!=0){
//debug_log(LOG_INFO,"[err] not match.\n");
return -1;
}
channel = atoi(channelObj->valuestring);
}else{
if(channelObj==NULL){
if(epNumObj->type!=cJSON_String){
debug_log(LOG_INFO,"[err] epNumObj.\n");
return -1;
}
channel = atoi(epNumObj->valuestring);
}else if(epNumObj==NULL){
if(channelObj->type!=cJSON_String){
debug_log(LOG_INFO,"[err] channelObj.\n");
return -1;
}
channel = atoi(channelObj->valuestring);
}else{
channel = 1;
}
}
//
cJSON *oldccu;
cJSON *o_item;
cJSON *o_id_map,*o_valueRange,*o_dataType;
cJSON *o_value;
return channel;
}
cJSON *val;
cJSON *item_size;
cJSON *channel;
cJSON *epNum=NULL;
cJSON *opcode;
static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t *devNode)
{
cJSON *msg = NULL;
cJSON *arg = NULL;
int nodeId = -1;
char nodeBuff[33] = {0};
int i,j;
int ch;
int nodeId;
char *node_str;
cJSON *msg;
cJSON *args;
if(devNode==NULL||devNode->syn_type!=1||devNode->syn_opcode==NULL){
return -1;
}
if((arg =_kk_sync_devicestatus_arg_build(devNode))==NULL){
debug_log(LOG_DEBUG,"[err] arg.\n");
return -1;
}
oldccu = devNode->oldccu;
newccu = devNode->newccu;
if((nodeId = kk_lan_db_node_get(deviceCode,1))==-1){
debug_log(LOG_DEBUG,"[err] nodeId.\n");
return -1;
}
debug_log(LOG_FOCUS,"[sync] device status.\n");
memset(nodeBuff,0,sizeof(nodeBuff));
snprintf(nodeBuff,sizeof(nodeBuff),"%d",nodeId);
item_size = cJSON_GetArraySize(oldccu);
for(i=0;i<item_size;i++){
o_item = cJSON_GetArrayItem(oldccu,i);
n_item = cJSON_GetArrayItem(newccu,i);
o_id_map = cJSON_GetObjectItem(o_item,"identifiermap");
n_id = cJSON_GetObjectItem(params,o_id_map->valuestring);
if(n_id!=NULL){
msg=old_ccu_msg_build_json(nodeBuff,devNode->syn_opcode,NULL,arg);
n_dataType = cJSON_GetObjectItem(n_item,"dataType");
n_valueRange = cJSON_GetObjectItem(n_item,"valueRange");
send_msg_to_module(msg);
cJSON_Delete(msg);
return 0;
}
o_dataType = cJSON_GetObjectItem(o_item,"dataType");
o_valueRange = cJSON_GetObjectItem(o_item,"valueRange");
channel = cJSON_GetObjectItem(o_item,"channel");
epNum = cJSON_GetObjectItem(params,"epNum");
//属性转换
static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *devNode,cJSON *params)
{
int i = 0,channel = -1,nodeId = -1;
cJSON *args = NULL,*valObj = NULL;
if(channel!=NULL&&epNum!=NULL){
if(strlen(channel->valuestring)!=strlen(epNum->valuestring) ||
strcmp(channel->valuestring,epNum->valuestring)!=0){
debug_log(LOG_NORMAL,"item_size=%d\n",item_size);
continue;
}
ch = atoi(channel->valuestring);
}else{
if(channel==NULL){
ch = atoi(epNum->valuestring);
}else if(epNum==NULL){
ch = atoi(channel->valuestring);
}else{
ch = 1;
}
}
cJSON *newccu = NULL,*oldccu = NULL;
cJSON *n_item = NULL,*o_item = NULL;
cJSON *o_valueRange = NULL,*n_valueRange = NULL;
cJSON *o_dataType = NULL,*n_dataType = NULL;
nodeId = kk_lan_db_node_get(deviceCode,ch);
opcode =cJSON_GetObjectItem(o_item,"opcode");
cJSON *opcode = NULL,*channelObj = NULL,*epNumObj = NULL;
printf("[%s][%d]n_dataType->valuestring=%s,opcode->valuestring=%s\n",__FUNCTION__,__LINE__,n_dataType->valuestring,opcode->valuestring);
cJSON *n_id = NULL;
//cJSON_ReplaceItemInObject(n_item, "value", cJSON_CreateString(""));//
if(n_id->type==cJSON_False){
printf("[replace] cJSON_False\n");
cJSON_ReplaceItemInObject(n_item, "value", cJSON_CreateFalse());
}else if(n_id->type==cJSON_True){
printf("[replace] cJSON_True\n");
cJSON_ReplaceItemInObject(n_item, "value", cJSON_CreateTrue());
}else if(n_id->type==cJSON_NULL){
printf("[replace] cJSON_NULL\n");
cJSON_ReplaceItemInObject(n_item, "value", cJSON_CreateNull());
}else if(n_id->type==cJSON_Number){
printf("[replace] cJSON_Number\n");
if(strcmp(n_dataType->valuestring,"double")==0){
cJSON_ReplaceItemInObject(n_item, "value", cJSON_CreateNumber(n_id->valuedouble));
}else {
cJSON_ReplaceItemInObject(n_item, "value", cJSON_CreateNumber(n_id->valueint));
}
}else if(n_id->type==cJSON_String){
printf("[replace] cJSON_String\n");
cJSON_ReplaceItemInObject(n_item, "value", cJSON_CreateString(n_id->valuestring));
}else if(n_id->type==cJSON_Array){
printf("......................\n");
}
cJSON *item_size = NULL;
if((args = ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,n_id))!=NULL){
update_device_status(nodeId,opcode->valuestring,args->valuestring);
//cJSON_Delete(args);
}
}
}
if(devNode->syn_type==1){
cJSON *arg;
char *node_str;
//arg = kk_devicestatus_build(devNode);
arg =_kk_sync_devicestatus_arg_build(devNode);
nodeId = kk_lan_db_node_get(deviceCode,1);
node_str=node_string(nodeId);
msg=old_ccu_msg_build_json(node_str,devNode->syn_opcode,NULL,arg);
send_msg_to_module(msg);
free(node_str);
cJSON_Delete(msg);
if(deviceCode==NULL||devNode==NULL||
params==NULL||params->type!=cJSON_Object){
debug_log(LOG_DEBUG,"[err] para.\n");
return -1;
}
return root;
}
oldccu = devNode->oldccu;
newccu = devNode->newccu;
item_size = cJSON_GetArraySize(newccu);
int del_device(const char *deviceCode,const char *nodeid)
{
cJSON *msg;
cJSON *arg;
char mac[32] = {0};
kk_map_dev_node_t *dev;
for(i=0;i<item_size;i++){
n_item = cJSON_GetArrayItem(newccu,i);
if(deviceCode==NULL||nodeid==NULL){
return -1;
if((o_item = cJSON_GetArrayItem(oldccu,i))==NULL||
o_item->type!=cJSON_Object){
debug_log(LOG_INFO,"[err] para.\n");
continue ;
}
arg = cJSON_CreateObject();
_deviceCode_switchto_mac(deviceCode,mac);
cJSON_AddStringToObject(arg,"mac",mac);
msg = old_ccu_msg_build_json(nodeid,"DEL_DEVICE",NULL,arg);
send_msg_to_module(msg);
cJSON_Delete(msg);
return 0;
}
int del_device_all_node(const char *deviceCode)
{
#define MAX_CHANNEL_NUM 32
int list[MAX_CHANNEL_NUM] = {0};
int i,num = 0;
char *nodeid;
num = kk_lan_db_node_get_all(deviceCode,list);
for(i=0;i<num;i++){
nodeid = node_string(list[i]);
del_device(deviceCode,nodeid);
free(nodeid);
if((n_id = cJSON_GetObjectItem(n_item,"identifier"))==NULL||
n_id->type!=cJSON_String){
debug_log(LOG_DEBUG,"[err] cfg file.\n");
continue;
}
//删除数据库
kk_lan_db_node_delete(deviceCode);
if(num){
kk_handle_sync_info();
if((valObj=cJSON_GetObjectItem(params,n_id->valuestring))==NULL){
debug_log(LOG_NORMAL,"[match] next.\n");
continue ;
}
return 0;
}
void device_delete_sync(cJSON *payload)
{
cJSON *params;
cJSON *deviceCode;
n_dataType = cJSON_GetObjectItem(n_item,"dataType");
n_valueRange = cJSON_GetObjectItem(n_item,"valueRange");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
params = cJSON_GetObjectItem(payload,"params");
deviceCode = cJSON_GetObjectItem(params, "deviceCode");
del_device_all_node(deviceCode->valuestring);
o_dataType = cJSON_GetObjectItem(o_item,"dataType");
o_valueRange = cJSON_GetObjectItem(o_item,"valueRange");
if(n_dataType==NULL||n_dataType->type!=cJSON_String||
o_dataType==NULL||o_dataType->type!=cJSON_String){
debug_log(LOG_DEBUG,"[err] dataType.\n");
continue;
}
channelObj = cJSON_GetObjectItem(o_item,"channel");
epNumObj = cJSON_GetObjectItem(params,"epNum");
if((channel = _kk_lan_check_channel(channelObj,epNumObj))==-1){
continue;
}
}
void device_add_sync(cJSON *payload)
{
if((nodeId = kk_lan_db_node_get(deviceCode,channel))==-1){
debug_log(LOG_DEBUG,"[err] not find node.\n");
continue;
}
//NEW_DEVICES
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_handle_sync_info();
}
if((opcode = cJSON_GetObjectItem(n_item,"opcodemap"))==NULL||
opcode->type!=cJSON_String){
debug_log(LOG_DEBUG,"[err] cfg file.\n");
continue;
}
kk_lan_replace_val_to_obj(n_item,valObj,"value");
if((args = ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,valObj))!=NULL){
_kk_lan_update_device_status(nodeId,opcode,args);
//todo :
//cJSON_Delete(args);
}
}
void device_new_device_sync(cJSON *payload)
{
_kk_lan_sync_device_status(deviceCode,devNode);
//NEW_DEVICES
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_handle_sync_info();
return 0;
}
void property_post_deal(const char *deviceCode,cJSON *payload)
//属性状态上报处理
int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
{
cJSON *params;
cJSON *params = NULL;
kk_map_dev_node_t *dev = NULL;
kk_map_dev_node_t *dev;
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
debug_log(LOG_FOCUS,"[property post] deviceCode(%s).\n",deviceCode);
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
params = cJSON_GetObjectItem(payload,"params");
attr_report_conver(deviceCode,dev,params);
return kk_lan_property_convert(deviceCode,dev,params);
}else{
debug_log(LOG_DEBUG,"[err] not find deviceCode(%s).\n",deviceCode);
return -1;
}
return 0;
}
void property_syn_deal(const char *deviceCode,cJSON *properties)
//属性状态同步处理
int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
{
cJSON *params;
cJSON *params = NULL;
kk_map_dev_node_t *dev = NULL;
kk_map_dev_node_t *dev;
debug_log(LOG_FOCUS,"[property syn] deviceCode(%s).\n",deviceCode);
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
attr_report_conver(deviceCode,dev,properties);
return kk_lan_property_convert(deviceCode,dev,properties);
}else{
debug_log(LOG_DEBUG,"[err] not find deviceCode(%s).\n",deviceCode);
return -1;
}
return 0;
}
//添加场景通知
void kk_lan_add_scene_notify(const char* scene_id)
{
debug_log(LOG_FOCUS,"[notify] add scene(%s).\n",scene_id);
//同步信息
//房间同步
//布防撤防
kk_handle_sync_info();
}
//删除场景通知
void kk_lan_delete_scene_notify(const char* scene_id)
{
debug_log(LOG_FOCUS,"[notify] delete scene(%s).\n",scene_id);
cJSON *msg = old_ccu_msg_build(scene_id,"DELETE_SCENE",SUCCESS_STR,WILDCARD_CHARACTER_STR);
send_msg_to_module(msg);
cJSON_Delete(msg);
kk_handle_sync_info();
}
/*
"0": "离家布防",
"1": "撤防",
"2": "在家布防",
"3": "区域布防"
*/
int arming_status_notify(int type)
//布防撤防状态通知(0-离家布防、1-撤防、2-在家布防、3-区域布防)
int kk_lan_arming_status_notify(int type)
{
cJSON *msg = NULL;
printf("[arming status notify] type=%d\n",type);
debug_log(LOG_FOCUS,"[notify] arming status(%d).\n",type);
if(type==0){
msg = old_ccu_msg_build(WILDCARD_CHARACTER_STR,GUARD_STATUS_ARMING_LEAVE_HOME,SUCCESS_STR,WILDCARD_CHARACTER_STR);
}else if(type==1){
......@@ -505,22 +469,91 @@ int arming_status_notify(int type)
}else if(type==3){
msg = old_ccu_msg_build(WILDCARD_CHARACTER_STR,ARMING_STATUS_GUARD_ZONE,SUCCESS_STR,WILDCARD_CHARACTER_STR);
}else{
printf("[unkown arming type]!!!\n");
debug_log(LOG_DEBUG,"[err] unknow type(%d).\n",type);
return -1;
}
send_msg_to_module(msg);
cJSON_Delete(msg);
return 0;
}
static int _kk_lan_delete_node(const char *deviceCode,const char *nodeid)
{
cJSON *msg;
cJSON *arg;
char mac[32] = {0};
kk_map_dev_node_t *dev;
if(deviceCode==NULL||nodeid==NULL){
debug_log(LOG_DEBUG,"[err] params.\n");
return -1;
}
debug_log(LOG_FOCUS,"[del dev node] id(%s).\n",nodeid);
arg = cJSON_CreateObject();
_deviceCode_switchto_mac(deviceCode,mac);
cJSON_AddStringToObject(arg,"mac",mac);
msg = old_ccu_msg_build_json(nodeid,"DEL_DEVICE",NULL,arg);
send_msg_to_module(msg);
cJSON_Delete(msg);
return 0;
}
static int _kk_lan_delete_device(const char *deviceCode)
{
#define MAX_CHANNEL_NUM 32
int list[MAX_CHANNEL_NUM] = {0};
int i,num = 0;
char nodeId[33] = {0};
num = kk_lan_db_node_get_all(deviceCode,list);
debug_log(LOG_FOCUS,"[del dev] deviceCode(%s)/node num(%d).\n",deviceCode,num);
for(i=0;i<num;i++){
memset(nodeId,0,sizeof(nodeId));
snprintf(nodeId,sizeof(nodeId),"%d",list[i]);
_kk_lan_delete_node(deviceCode,nodeId);
}
//删除数据库
kk_lan_db_node_delete(deviceCode);
if(num){
kk_handle_sync_info();
}
return 0;
}
int kk_lan_device_delete_notify(cJSON *payload)
{
cJSON *params = NULL;
cJSON *deviceCode = NULL;
if((params = cJSON_GetObjectItem(payload,"params"))==NULL||
params->type!=cJSON_Object){
debug_log(LOG_DEBUG,"[err] params.\n");
return -1;
}
if((deviceCode = cJSON_GetObjectItem(params, "deviceCode"))==NULL||
params->type!=cJSON_String){
debug_log(LOG_DEBUG,"[err] deviceCode.\n");
return -1;
}
_kk_lan_delete_device(deviceCode->valuestring);
return 0;
}
void device_add_sync(cJSON *payload)
{
//NEW_DEVICES
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_handle_sync_info();
}
......@@ -12,10 +12,15 @@ int send_msg_to_module(cJSON *root);
cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type);
int arming_status_notify(int type);
int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload);
int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties);
int kk_lan_arming_status_notify(int type);
void kk_lan_add_scene_notify(const char* scene_id);
void kk_lan_delete_scene_notify(const char* scene_id);
int kk_lan_device_delete_notify(cJSON *payload);
......
......@@ -53,23 +53,23 @@ static _OUT int kk_vp_get_room_id_by_scene_id(_IN cJSON *data,_IN const char *sc
if(scene_id==NULL ){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
if((roomsAry = cJSON_GetObjectItem(data,ROOMS_STR))==NULL||
roomsAry->type!=cJSON_Array){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
roomNum = cJSON_GetArraySize(roomsAry);
printf("[%s][%d]roomNum=%d,scene_id=%s\n",__FUNCTION__,__LINE__,roomNum,scene_id);
//printf("[%s][%d]roomNum=%d,scene_id=%s\n",__FUNCTION__,__LINE__,roomNum,scene_id);
for(i=0;i<roomNum;i++){
roomObj = cJSON_GetArrayItem(roomsAry,i);
if(roomObj->type!=cJSON_Object){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue ;
}
roomId = cJSON_GetObjectItem(roomObj,ROOMS_ID_STR);
......@@ -77,32 +77,32 @@ static _OUT int kk_vp_get_room_id_by_scene_id(_IN cJSON *data,_IN const char *sc
if(roomId==NULL||roomId->type!=cJSON_String||
scenes==NULL||scenes->type!=cJSON_Array){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue ;
}
sceneNum = cJSON_GetArraySize(scenes);
printf("[%s][%d]sceneNum=%d\n",__FUNCTION__,__LINE__,sceneNum);
//printf("[%s][%d]sceneNum=%d\n",__FUNCTION__,__LINE__,sceneNum);
for(j=0;j<sceneNum;j++){
sceneItem = cJSON_GetArrayItem(scenes,j);
if((sceneId = cJSON_GetObjectItem(sceneItem,"sceneId"))==NULL ||
sceneId->type!=cJSON_String){
printf("[%s][%d]sceneId->type=%d\n",__FUNCTION__,__LINE__,sceneId->type);
//printf("[%s][%d]sceneId->type=%d\n",__FUNCTION__,__LINE__,sceneId->type);
continue ;
}
printf("[%s][%d]%d,%d,%s,%s\n",__FUNCTION__,__LINE__,strlen(sceneId->valuestring),strlen(scene_id),
scene_id,sceneId->valuestring);
//printf("[%s][%d]%d,%d,%s,%s\n",__FUNCTION__,__LINE__,strlen(sceneId->valuestring),strlen(scene_id),
// scene_id,sceneId->valuestring);
if(strlen(sceneId->valuestring)==strlen(scene_id) &&
!strcmp(sceneId->valuestring,scene_id)) {
memset(buf,0,size);
snprintf(buf,size,"%s",roomId->valuestring);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 1;
}
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
......@@ -172,12 +172,12 @@ static _OUT cJSON *kk_vp_sync_scences(_IN cJSON *data)
if((scenes = cJSON_GetObjectItem(data,SCENES_STR))==NULL||
scenes->type!=cJSON_Array){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
////printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return scenes_ary_build(0,NULL);
}
if((sceneNum = cJSON_GetArraySize(scenes))==0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
////printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return scenes_ary_build(0,NULL);
}
......@@ -197,7 +197,7 @@ static _OUT cJSON *kk_vp_sync_scences(_IN cJSON *data)
if(sceneId==NULL||sceneId->type!=cJSON_String||
sceneType==NULL||sceneType->type!=cJSON_Number||
sceneName==NULL||sceneName->type!=cJSON_String){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue ;
}
......@@ -210,7 +210,7 @@ static _OUT cJSON *kk_vp_sync_scences(_IN cJSON *data)
snprintf(pScene->id,sizeof(pScene->id)-1,"%d",map_id);
snprintf(pScene->type,sizeof(pScene->type)-1,"%d",sceneType->valueint);
snprintf(pScene->name,sizeof(pScene->name)-1,"%s",sceneName->valuestring);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
}
}
vp_scene_id_map_save();
......@@ -231,11 +231,11 @@ static int kk_vp_get_device_name(_IN cJSON *devices,_IN const char*epNum,_IN con
cJSON *deviceItem = NULL,*devCodeObj = NULL;
devNum = cJSON_GetArraySize(devices);
printf("[%s][%d]devNum=%d\n",__FUNCTION__,__LINE__,devNum);
//printf("[%s][%d]devNum=%d\n",__FUNCTION__,__LINE__,devNum);
for(i=0;i<devNum;i++){
deviceItem = cJSON_GetArrayItem(devices,i);
if(deviceItem->type!=cJSON_Object){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue ;
}
......@@ -243,27 +243,26 @@ static int kk_vp_get_device_name(_IN cJSON *devices,_IN const char*epNum,_IN con
devCodeObj = cJSON_GetObjectItem(deviceItem,"deviceCode");
if(devCodeObj==NULL||devCodeObj->type!=cJSON_String){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue ;
}
printf("[%s][%d]%d,%d,%s,%s\n",__FUNCTION__,__LINE__,strlen(devCodeObj->valuestring),
strlen(deviceCode),devCodeObj->valuestring,deviceCode);
//printf("[%s][%d]%d,%d,%s,%s\n",__FUNCTION__,__LINE__,strlen(devCodeObj->valuestring),strlen(deviceCode),devCodeObj->valuestring,deviceCode);
if((strlen(devCodeObj->valuestring)==strlen(deviceCode)) &&
!strcmp(devCodeObj->valuestring,deviceCode)){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if((name = cJSON_GetObjectItem(deviceItem,"name"))!=NULL &&
name->type==cJSON_String){
printf("[%s][%d]name=%s\n",__FUNCTION__,__LINE__,name->valuestring);
//printf("[%s][%d]name=%s\n",__FUNCTION__,__LINE__,name->valuestring);
snprintf(buf,size,"%s",name->valuestring);
return 1;
}
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
......@@ -277,19 +276,19 @@ static int kk_vp_get_device_info(_IN cJSON *rooms,_IN VP_ZB_DEV_ITEM *pDevs)
roomNum = cJSON_GetArraySize(rooms);
printf("[%s][%d]roomNum=%d\n",__FUNCTION__,__LINE__,roomNum);
//printf("[%s][%d]roomNum=%d\n",__FUNCTION__,__LINE__,roomNum);
for(i=0;i<roomNum;i++){
roomItem = cJSON_GetArrayItem(rooms,i);
if((roomId = cJSON_GetObjectItem(roomItem,ROOMS_ID_STR))==NULL||
roomId->type!=cJSON_String){
printf("[prase fail]roomId...\n");
//printf("[prase fail]roomId...\n");
continue ;
}
if((devices= cJSON_GetObjectItem(roomItem,DEVICES_STR))==NULL ||
devices->type!=cJSON_Array){
printf("[prase fail]devices...\n");
//printf("[prase fail]devices...\n");
continue ;
}
......@@ -297,12 +296,12 @@ static int kk_vp_get_device_info(_IN cJSON *rooms,_IN VP_ZB_DEV_ITEM *pDevs)
if(isFind!=0){
snprintf(pDevs->room,sizeof(pDevs->room),"%s",roomId->valuestring);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return isFind;
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
......@@ -350,7 +349,7 @@ static int kk_vp_sync_device_multi_eps(_IN cJSON *zbDevsAry,_IN cJSON *dev,_IN c
num = cJSON_GetArraySize(eps);
printf("[%s][%d]num=%d\n",__FUNCTION__,__LINE__,num);
for(i=0;i<num;i++){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
memset(pDevs->ch,0,sizeof(pDevs->ch));
memset(pDevs->name,0,sizeof(pDevs->name));
......@@ -360,7 +359,7 @@ static int kk_vp_sync_device_multi_eps(_IN cJSON *zbDevsAry,_IN cJSON *dev,_IN c
if((epNum = cJSON_GetObjectItem(epItem,"epNum"))==NULL ||
epNum->type!=cJSON_String){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue ;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
......@@ -389,7 +388,7 @@ static int kk_vp_sync_device_multi_eps(_IN cJSON *zbDevsAry,_IN cJSON *dev,_IN c
}
free(pDevs);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return isFind;
}
......@@ -445,17 +444,17 @@ static int kk_vp_sync_device_single_ep(_IN cJSON *zbDevsAry,_IN cJSON *dev,_IN c
if(kk_vp_get_device_info(rooms,pDevs)!=0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if((zbDevObj = zigbee_devices_item_build(pDevs))!=NULL){
cJSON_AddItemToArray(zbDevsAry,zbDevObj);
free(pDevs);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 1;
}
}
free(pDevs);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
......@@ -533,15 +532,15 @@ static _OUT cJSON *kk_vp_sync_device(_IN cJSON *data)
}
if(eps==NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_vp_sync_device_single_ep(zbDevsAry,dev,roomsAry);
}else if(eps->type==cJSON_Array){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_vp_sync_device_multi_eps(zbDevsAry,dev,roomsAry,eps);
}
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return zbDevsAry;
}
......@@ -673,7 +672,7 @@ static _OUT cJSON *zigbee_devices_item_build(_IN VP_ZB_DEV_ITEM *item)
if(item == NULL ||item->operateType==NULL||item->nodeId==NULL||
item->name==NULL||item->room == NULL||item->mac == NULL||
item->online == NULL||item->pid == NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return NULL;
}
......@@ -935,11 +934,11 @@ _OUT int kk_vp_syncinfo(_IN cJSON *payload,_IN int ver,_OUT cJSON **root)
json.other_devices = kk_vp_sync_ac_indoors(data);
if((*root = kk_voice_panel_cfg_build(&json,ver))!=NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return -1;
}
......
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