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},
......@@ -28,14 +28,11 @@ static CONVERT_ITEM_S convert_table[] = {
{"string_time",string_time_type_convert},
{"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;
}
......@@ -107,8 +102,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;
......@@ -151,8 +144,6 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
double dVal;
}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;
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;
}
int vra_size = cJSON_GetArraySize(s_valueRange);
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;
......
This diff is collapsed.
......@@ -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