Commit 298ae08d authored by chen.weican's avatar chen.weican
parents 5604b305 4d9d15b7
...@@ -44,7 +44,7 @@ static int kk_info_get(char *str) ...@@ -44,7 +44,7 @@ static int kk_info_get(char *str)
if(str == NULL){ if(str == NULL){
return -1; return -1;
} }
HAL_GetVersion(version); //HAL_GetVersion(version);
KK_Get_ccuid(ccuid); KK_Get_ccuid(ccuid);
cJSON *root = cJSON_CreateObject(); cJSON *root = cJSON_CreateObject();
...@@ -62,7 +62,7 @@ static int kk_info_get(char *str) ...@@ -62,7 +62,7 @@ static int kk_info_get(char *str)
cJSON_AddItemToObject(args, "ccu", ccu); cJSON_AddItemToObject(args, "ccu", ccu);
cJSON_AddStringToObject(ccu, "id", &ccuid[4]); cJSON_AddStringToObject(ccu, "id", &ccuid[4]);
cJSON_AddStringToObject(ccu, "version", version); cJSON_AddStringToObject(ccu, "version", "1.1.1");
cJSON_AddStringToObject(ccu, "name", "kk_new_ccu"); cJSON_AddStringToObject(ccu, "name", "kk_new_ccu");
//INFO_PRINT("---222kk_get_cloud_status():%d\n",kk_get_cloud_status()); //INFO_PRINT("---222kk_get_cloud_status():%d\n",kk_get_cloud_status());
//if(kk_get_gw_status() == DEVICE_OFFLINE){ //if(kk_get_gw_status() == DEVICE_OFFLINE){
......
...@@ -32,7 +32,6 @@ int kk_execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len) ...@@ -32,7 +32,6 @@ int kk_execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len)
memset(buf,0,buf_len); memset(buf,0,buf_len);
FILE *fp = NULL; FILE *fp = NULL;
fp = popen(cmd,"r"); fp = popen(cmd,"r");
while(fgets(buf,buf_len,fp)!=NULL){ while(fgets(buf,buf_len,fp)!=NULL){
INFO_PRINT("%s return %s",cmd,buf); INFO_PRINT("%s return %s",cmd,buf);
......
...@@ -198,8 +198,8 @@ int devOpen(char *dev) ...@@ -198,8 +198,8 @@ int devOpen(char *dev)
if(fd == -1) if(fd == -1)
{ {
SERIAL_LOG_ERR("devOpen %s\n ",dev); //SERIAL_LOG_ERR("devOpen %s\n ",dev);
perror("devOpen"); //perror("devOpen");
return -1; return -1;
} }
......
...@@ -38,12 +38,26 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType) ...@@ -38,12 +38,26 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
return NULL; return NULL;
} }
if(n_id->type==cJSON_Number){
if((strcmp(n_dataType->valuestring,"int")==0) || if((strcmp(n_dataType->valuestring,"int")==0) ||
(strcmp(n_dataType->valuestring,"bool")==0)){ (strcmp(n_dataType->valuestring,"bool")==0)||
(strcmp(n_dataType->valuestring,"string_int")==0)||
(strcmp(n_dataType->valuestring,"string_bool")==0)){
args = cJSON_CreateBool(n_id->valueint); args = cJSON_CreateBool(n_id->valueint);
}else if(strcmp(n_dataType->valuestring,"double")==0) { }else if(strcmp(n_dataType->valuestring,"double")==0||
strcmp(n_dataType->valuestring,"string_double")==0) {
bVal = (n_id->valuedouble>0) ? 1 : 0; bVal = (n_id->valuedouble>0) ? 1 : 0;
args = cJSON_CreateBool(bVal); args = cJSON_CreateBool(bVal);
}
}else if(n_id->type==cJSON_String){
if((strcmp(n_dataType->valuestring,"int")==0) ||
(strcmp(n_dataType->valuestring,"bool")==0)||
(strcmp(n_dataType->valuestring,"string_int")==0)){
args = cJSON_CreateBool(atoi(n_id->valuestring));
}else if(strcmp(n_dataType->valuestring,"double")==0||
strcmp(n_dataType->valuestring,"string_double")==0) {
bVal = (atof(n_id->valuestring)>0) ? 1 : 0;
args = cJSON_CreateBool(bVal);
}else if(strcmp(n_dataType->valuestring,"string_bool")==0) { }else if(strcmp(n_dataType->valuestring,"string_bool")==0) {
if(strcmp(n_id->valuestring,"true")==0 || if(strcmp(n_id->valuestring,"true")==0 ||
strcmp(n_id->valuestring,"TRUE")==0){ strcmp(n_id->valuestring,"TRUE")==0){
...@@ -52,15 +66,13 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType) ...@@ -52,15 +66,13 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
strcmp(n_id->valuestring,"TRUE")==0){ strcmp(n_id->valuestring,"TRUE")==0){
args = cJSON_CreateBool(0); args = cJSON_CreateBool(0);
} }
}else if(strcmp(n_dataType->valuestring,"string_int")==0) {
int iVal = atoi(n_id->valuestring);
bVal = (iVal>0) ? 1 : 0;
args = cJSON_CreateBool(bVal);
}else if(strcmp(n_dataType->valuestring,"string_double")==0) {
double dVal = atof(n_id->valuestring);
bVal = (dVal>0) ? 1 : 0;
args = cJSON_CreateBool(bVal);
} }
}else if(n_id->type==cJSON_False){
args = cJSON_CreateNumber(0);
}else if(n_id->type==cJSON_True){
args = cJSON_CreateNumber(1);
}
return args; return args;
} }
...@@ -72,10 +84,13 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType) ...@@ -72,10 +84,13 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
return NULL; return NULL;
} }
if(n_id->type==cJSON_Number){
if((strcmp(n_dataType->valuestring,"int")==0) || if((strcmp(n_dataType->valuestring,"int")==0) ||
(strcmp(n_dataType->valuestring,"bool")==0)){ (strcmp(n_dataType->valuestring,"bool")==0)||
(strcmp(n_dataType->valuestring,"string_int")==0)){
args = cJSON_CreateNumber(n_id->valueint); args = cJSON_CreateNumber(n_id->valueint);
}else if(strcmp(n_dataType->valuestring,"double")==0) { }else if(strcmp(n_dataType->valuestring,"double")==0||
(strcmp(n_dataType->valuestring,"string_double")==0)) {
args = cJSON_CreateNumber(n_id->valuedouble); args = cJSON_CreateNumber(n_id->valuedouble);
}else if(strcmp(n_dataType->valuestring,"string_bool")==0) { }else if(strcmp(n_dataType->valuestring,"string_bool")==0) {
if(strcmp(n_id->valuestring,"true")==0 || if(strcmp(n_id->valuestring,"true")==0 ||
...@@ -85,11 +100,30 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType) ...@@ -85,11 +100,30 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
strcmp(n_id->valuestring,"TRUE")==0){ strcmp(n_id->valuestring,"TRUE")==0){
args = cJSON_CreateNumber(0); args = cJSON_CreateNumber(0);
} }
}else if(strcmp(n_dataType->valuestring,"string_int")==0) { }
}else if(n_id->type==cJSON_String){
if((strcmp(n_dataType->valuestring,"int")==0) ||
(strcmp(n_dataType->valuestring,"bool")==0)||
(strcmp(n_dataType->valuestring,"string_int")==0)){
args = cJSON_CreateNumber(atoi(n_id->valuestring)); args = cJSON_CreateNumber(atoi(n_id->valuestring));
}else if(strcmp(n_dataType->valuestring,"string_double")==0) { }else if(strcmp(n_dataType->valuestring,"double")==0||
args = cJSON_CreateNumber((int)atof(n_id->valuestring)); strcmp(n_dataType->valuestring,"string_double")==0) {
args = cJSON_CreateNumber(atof(n_id->valuestring));
}else if(strcmp(n_dataType->valuestring,"string_bool")==0) {
if(strcmp(n_id->valuestring,"true")==0 ||
strcmp(n_id->valuestring,"TRUE")==0){
args = cJSON_CreateNumber(1);
}else if(strcmp(n_id->valuestring,"true")==0 ||
strcmp(n_id->valuestring,"TRUE")==0){
args = cJSON_CreateNumber(0);
}
} }
}else if(n_id->type==cJSON_False){
args = cJSON_CreateNumber(0);
}else if(n_id->type==cJSON_True){
args = cJSON_CreateNumber(1);
}
return args; return args;
} }
...@@ -106,12 +140,28 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType) ...@@ -106,12 +140,28 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
if(strcmp(n_dataType->valuestring,"dummy")==0) { if(strcmp(n_dataType->valuestring,"dummy")==0) {
return NULL; return NULL;
} }
if(n_id->type == cJSON_True) {
flag==1;
}else if(n_id->type == cJSON_False){
flag==0;
}else if(n_id->type == cJSON_Number){
if((strcmp(n_dataType->valuestring,"int")==0) || if((strcmp(n_dataType->valuestring,"int")==0) ||
(strcmp(n_dataType->valuestring,"bool")==0)){ (strcmp(n_dataType->valuestring,"bool")==0)||
(strcmp(n_dataType->valuestring,"string_int")==0)||
(strcmp(n_dataType->valuestring,"string_bool")==0)){
flag = (n_id->valueint>0) ? 1 : 0; flag = (n_id->valueint>0) ? 1 : 0;
}else if(strcmp(n_dataType->valuestring,"double")==0) { }else if(strcmp(n_dataType->valuestring,"double")==0||
strcmp(n_dataType->valuestring,"string_double")==0) {
flag = (n_id->valuedouble>0) ? 1 : 0; flag = (n_id->valuedouble>0) ? 1 : 0;
}
}else if(n_id->type == cJSON_String){
if((strcmp(n_dataType->valuestring,"int")==0) ||
(strcmp(n_dataType->valuestring,"bool")==0)||
(strcmp(n_dataType->valuestring,"string_int")==0)){
flag = (atoi(n_id->valuestring)>0) ? 1 : 0;
}else if(strcmp(n_dataType->valuestring,"double")==0||
strcmp(n_dataType->valuestring,"string_double")==0) {
flag = (atof(n_id->valuestring)>0) ? 1 : 0;
}else if(strcmp(n_dataType->valuestring,"string_bool")==0) { }else if(strcmp(n_dataType->valuestring,"string_bool")==0) {
if(strcmp(n_id->valuestring,"true")==0 || if(strcmp(n_id->valuestring,"true")==0 ||
strcmp(n_id->valuestring,"TRUE")==0){ strcmp(n_id->valuestring,"TRUE")==0){
...@@ -120,10 +170,7 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType) ...@@ -120,10 +170,7 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
strcmp(n_id->valuestring,"FALSE")==0){ strcmp(n_id->valuestring,"FALSE")==0){
flag = 0; flag = 0;
} }
}else if(strcmp(n_dataType->valuestring,"string_int")==0) { }
flag = (atoi(n_id->valuestring)>0) ? 1 : 0;
}else if(strcmp(n_dataType->valuestring,"string_double")==0) {
flag = ( atof(n_id->valuestring)>0) ? 1 : 0;
} }
if(flag==1) { if(flag==1) {
...@@ -149,6 +196,11 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType) ...@@ -149,6 +196,11 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
return NULL; return NULL;
} }
if(n_id->type == cJSON_True) {
args = cJSON_CreateTrue();
}else if(n_id->type == cJSON_False){
args = cJSON_CreateFalse();
}else if(n_id->type==cJSON_Number){
if((strcmp(n_dataType->valuestring,"int")==0) || if((strcmp(n_dataType->valuestring,"int")==0) ||
(strcmp(n_dataType->valuestring,"bool")==0)){ (strcmp(n_dataType->valuestring,"bool")==0)){
if(type==1){ if(type==1){
...@@ -162,7 +214,24 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType) ...@@ -162,7 +214,24 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
}else{ }else{
val.iVal = n_id->valueint; val.iVal = n_id->valueint;
} }
}else if(strcmp(n_dataType->valuestring,"string_bool")==0) { }
}else if(n_id->type==cJSON_String){
if(strcmp(n_dataType->valuestring,"string_int")==0){
if(type==1){
val.dVal = atoi(n_id->valuestring);
}else{
val.iVal = atoi(n_id->valuestring);
}
}else if(strcmp(n_dataType->valuestring,"string_double")==0){
if(type==1){
val.dVal = atof(n_id->valuestring);
}else{
val.iVal = atof(n_id->valuestring);
}
}
}else if(n_id->type==cJSON_False||n_id->type==cJSON_True){
if(strcmp(n_dataType->valuestring,"string_bool")==0){
if(strcmp(n_id->valuestring,"true")==0 || if(strcmp(n_id->valuestring,"true")==0 ||
strcmp(n_id->valuestring,"TRUE")==0){ strcmp(n_id->valuestring,"TRUE")==0){
if(type==1){ if(type==1){
...@@ -171,26 +240,17 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType) ...@@ -171,26 +240,17 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
val.iVal = 1; val.iVal = 1;
} }
}else if(strcmp(n_id->valuestring,"false")==0 || }else if(strcmp(n_id->valuestring,"false")==0 ||
strcmp(n_id->valuestring,"FALSE")==0) strcmp(n_id->valuestring,"FALSE")==0){
if(type==1){ if(type==1){
val.dVal = 0; val.dVal = 0;
}else{ }else{
val.iVal = 0; val.iVal = 0;
} }
}else if(strcmp(n_dataType->valuestring,"string_int")==0) {
if(type==1){
val.dVal = atoi(n_id->valuestring);
}else{
val.iVal = atoi(n_id->valuestring);
} }
}else if(strcmp(n_dataType->valuestring,"string_double")==0) {
if(type==1){
val.dVal = atof(n_id->valuestring);
}else{
val.iVal = atof(n_id->valuestring);
} }
} }
if(type==1){ if(type==1){
snprintf(sVal,sizeof(sVal),"%f",val.dVal); snprintf(sVal,sizeof(sVal),"%f",val.dVal);
}else{ }else{
...@@ -263,13 +323,13 @@ cJSON * msg_convert_value(cJSON *d_type,cJSON *s_type,cJSON *value) ...@@ -263,13 +323,13 @@ cJSON * msg_convert_value(cJSON *d_type,cJSON *s_type,cJSON *value)
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){ d_type->type!=cJSON_String||s_type->type!=cJSON_String){
debug_log(LOG_DEBUG,"[ERR] para.\n"); debug_log(LOG_DEBUG_LEVEL,"[ERR] para.\n");
return NULL; return NULL;
} }
pVal = cJSON_Print(value); pVal = cJSON_Print(value);
debug_log(LOG_NORMAL,"[convert]type:%s->%s,val=%s.\n",s_type->valuestring,d_type->valuestring,pVal); debug_log(LOG_NORMAL_LEVEL,"[convert]type:%s->%s,val=%s.\n",s_type->valuestring,d_type->valuestring,pVal);
free(pVal); free(pVal);
...@@ -299,11 +359,11 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON ...@@ -299,11 +359,11 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
if(s_valueRange==NULL||s_valueRange->type!=cJSON_Array|| if(s_valueRange==NULL||s_valueRange->type!=cJSON_Array||
d_valueRange==NULL||d_valueRange->type!=cJSON_Array){ d_valueRange==NULL||d_valueRange->type!=cJSON_Array){
debug_log(LOG_DEBUG,"[ERR] range.\n"); debug_log(LOG_DEBUG_LEVEL,"[ERR] range.\n");
return NULL; return NULL;
} }
if(s_dataType==NULL||s_dataType->type!=cJSON_String){ if(s_dataType==NULL||s_dataType->type!=cJSON_String){
debug_log(LOG_DEBUG,"[ERR] dataType.\n"); debug_log(LOG_DEBUG_LEVEL,"[ERR] dataType.\n");
return NULL; return NULL;
} }
...@@ -314,9 +374,9 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON ...@@ -314,9 +374,9 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
sVrg = cJSON_Print(s_valueRange); sVrg = cJSON_Print(s_valueRange);
dVrg = cJSON_Print(d_valueRange); dVrg = cJSON_Print(d_valueRange);
pVal = cJSON_Print(value); pVal = cJSON_Print(value);
debug_log(LOG_NORMAL,"[convert] s_dataType:%s,val=%s\n",s_dataType->valuestring,pVal); debug_log(LOG_NORMAL_LEVEL,"[convert] s_dataType:%s,val=%s\n",s_dataType->valuestring,pVal);
debug_log(LOG_INFO,"s_valueRange=%s\n",sVrg); debug_log(LOG_INFO_LEVEL,"s_valueRange=%s\n",sVrg);
debug_log(LOG_INFO,"d_valueRange=%s\n",dVrg); debug_log(LOG_INFO_LEVEL,"d_valueRange=%s\n",dVrg);
free(sVrg); free(sVrg);
free(dVrg); free(dVrg);
free(pVal); free(pVal);
...@@ -379,8 +439,11 @@ cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_r ...@@ -379,8 +439,11 @@ cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_r
{ {
cJSON *val = NULL; cJSON *val = NULL;
if(strcmp(d_dType->valuestring,"map")==0){ if(strcmp(d_dType->valuestring,"map")==0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__); printf("[%s][%d]\n",__FUNCTION__,__LINE__);
val = map_type_convert(s_dType,s_range,value,d_range); val = map_type_convert(s_dType,s_range,value,d_range);
}else{ }else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__); printf("[%s][%d]\n",__FUNCTION__,__LINE__);
...@@ -415,11 +478,11 @@ int kk_lan_get_msg_id_str(char *msgId,int size) ...@@ -415,11 +478,11 @@ 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) 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){ if(id==NULL||obj==NULL||obj->type!=cJSON_Object||val==NULL){
debug_log(LOG_DEBUG,"[err] para.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] para.\n");
return -1; return -1;
} }
debug_log(LOG_NORMAL,"[add] id(%s),type(%d).\n",id,val->type); debug_log(LOG_NORMAL_LEVEL,"[add] id(%s),type(%d).\n",id,val->type);
if(val->type==cJSON_False){ if(val->type==cJSON_False){
cJSON_AddFalseToObject(obj,id); cJSON_AddFalseToObject(obj,id);
...@@ -432,7 +495,7 @@ int kk_lan_add_val_to_obj(cJSON *obj,cJSON *val,const char *id) ...@@ -432,7 +495,7 @@ int kk_lan_add_val_to_obj(cJSON *obj,cJSON *val,const char *id)
}else if(val->type==cJSON_String){ }else if(val->type==cJSON_String){
cJSON_AddStringToObject(obj,id,val->valuestring); cJSON_AddStringToObject(obj,id,val->valuestring);
}else{ }else{
debug_log(LOG_DEBUG,"[err] nonsupport type(%s).\n",val->type); debug_log(LOG_DEBUG_LEVEL,"[err] nonsupport type(%s).\n",val->type);
return -1; return -1;
} }
return 0; return 0;
...@@ -443,12 +506,12 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id) ...@@ -443,12 +506,12 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
{ {
char *pVal = NULL; char *pVal = NULL;
if(id==NULL||obj==NULL||obj->type!=cJSON_Object||val==NULL){ if(id==NULL||obj==NULL||obj->type!=cJSON_Object||val==NULL){
debug_log(LOG_DEBUG,"[err] para.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] para.\n");
return -1; return -1;
} }
pVal = cJSON_Print(val); pVal = cJSON_Print(val);
debug_log(LOG_NORMAL,"[replace] id=%s,type=%d,val=%s.\n",id,val->type,pVal); debug_log(LOG_NORMAL_LEVEL,"[replace] id=%s,type=%d,val=%s.\n",id,val->type,pVal);
free(pVal); free(pVal);
if(val->type==cJSON_False){ if(val->type==cJSON_False){
...@@ -462,7 +525,7 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id) ...@@ -462,7 +525,7 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
}else if(val->type==cJSON_String){ }else if(val->type==cJSON_String){
cJSON_ReplaceItemInObject(obj, id, cJSON_CreateString(val->valuestring)); cJSON_ReplaceItemInObject(obj, id, cJSON_CreateString(val->valuestring));
}else{ }else{
debug_log(LOG_DEBUG,"[err] nonsupport type(%s).\n",val->type); debug_log(LOG_DEBUG_LEVEL,"[err] nonsupport type(%s).\n",val->type);
return -1; return -1;
} }
return 0; return 0;
......
...@@ -114,7 +114,7 @@ void kk_handle_sync_info(void) ...@@ -114,7 +114,7 @@ void kk_handle_sync_info(void)
return; return;
} }
debug_log(LOG_INFO,"[sync] send.\n"); debug_log(LOG_INFO_LEVEL,"[sync] send.\n");
kk_ipc_send(IPC_APP2MID, send_data, strlen(send_data)+1); kk_ipc_send(IPC_APP2MID, send_data, strlen(send_data)+1);
free(send_data); free(send_data);
...@@ -354,7 +354,6 @@ int kk_data_handle(cJSON *json,int sockfd) ...@@ -354,7 +354,6 @@ int kk_data_handle(cJSON *json,int sockfd)
cJSON *opcode = NULL; cJSON *opcode = NULL;
cJSON *arg = NULL; cJSON *arg = NULL;
opcode = cJSON_GetObjectItem(json, OPCODE_STRING); opcode = cJSON_GetObjectItem(json, OPCODE_STRING);
if(opcode != NULL){ if(opcode != NULL){
if(strcmp(opcode->valuestring,LOGIN_OPCODE) == 0){ if(strcmp(opcode->valuestring,LOGIN_OPCODE) == 0){
...@@ -712,18 +711,18 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd) ...@@ -712,18 +711,18 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
cJSON *sceneId = NULL; cJSON *sceneId = NULL;
if(payload == NULL){ if(payload == NULL){
debug_log(LOG_DEBUG,"[err] payload.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] payload.\n");
return -1; return -1;
} }
if((params = cJSON_GetObjectItem(payload, MSG_PARAMS_STR))==NULL|| if((params = cJSON_GetObjectItem(payload, MSG_PARAMS_STR))==NULL||
params->type!=cJSON_Object){ params->type!=cJSON_Object){
debug_log(LOG_DEBUG,"[err] params err.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] params err.\n");
return -1; return -1;
} }
if((sceneId = cJSON_GetObjectItem(params, MSG_SCENE_SCENEID))==NULL || if((sceneId = cJSON_GetObjectItem(params, MSG_SCENE_SCENEID))==NULL ||
sceneId->type!=cJSON_String){ sceneId->type!=cJSON_String){
debug_log(LOG_DEBUG,"[err] sceneId err.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] sceneId err.\n");
return -1; return -1;
} }
...@@ -745,7 +744,7 @@ void KK_Data_FromMid(void* str,int len) ...@@ -745,7 +744,7 @@ void KK_Data_FromMid(void* str,int len)
cJSON *info = NULL,*payload = NULL; cJSON *info = NULL,*payload = NULL;
cJSON *msgtype = NULL,*deviceCode = NULL,*productCode = NULL; cJSON *msgtype = NULL,*deviceCode = NULL,*productCode = NULL;
debug_log(LOG_FOCUS,"[midware->lan] len=%d,data=%s\n",len,str); debug_log(LOG_FOCUS_LEVEL,"[midware->lan] len=%d,data=%s\n",len,str);
if((json= cJSON_Parse(str)) == NULL) { if((json= cJSON_Parse(str)) == NULL) {
return; return;
......
...@@ -69,34 +69,34 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON ...@@ -69,34 +69,34 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
pos = match_opcode_pos(devNode->oldccu,opcode->valuestring,channel); pos = match_opcode_pos(devNode->oldccu,opcode->valuestring,channel);
if(pos==-1){ if(pos==-1){
debug_log(LOG_FOCUS,"not find\n"); debug_log(LOG_FOCUS_LEVEL,"not find\n");
return NULL; return NULL;
} }
debug_log(LOG_FOCUS,"1\n"); debug_log(LOG_FOCUS_LEVEL,"1\n");
newccuItem = cJSON_GetArrayItem(devNode->newccu,pos); newccuItem = cJSON_GetArrayItem(devNode->newccu,pos);
oldccuItem = cJSON_GetArrayItem(devNode->oldccu,pos); oldccuItem = cJSON_GetArrayItem(devNode->oldccu,pos);
debug_log(LOG_FOCUS,"2\n"); debug_log(LOG_FOCUS_LEVEL,"2\n");
o_dataType = cJSON_GetObjectItem(oldccuItem,"dataType"); o_dataType = cJSON_GetObjectItem(oldccuItem,"dataType");
o_valueRange = cJSON_GetObjectItem(oldccuItem,"valueRange"); o_valueRange = cJSON_GetObjectItem(oldccuItem,"valueRange");
debug_log(LOG_FOCUS,"3\n"); debug_log(LOG_FOCUS_LEVEL,"3\n");
n_dataType = cJSON_GetObjectItem(newccuItem,"dataType"); n_dataType = cJSON_GetObjectItem(newccuItem,"dataType");
n_valueRange = cJSON_GetObjectItem(newccuItem,"valueRange"); n_valueRange = cJSON_GetObjectItem(newccuItem,"valueRange");
n_identifier = cJSON_GetObjectItem(newccuItem,"identifier"); n_identifier = cJSON_GetObjectItem(newccuItem,"identifier");
epNum = cJSON_GetObjectItem(newccuItem,"channel"); epNum = cJSON_GetObjectItem(newccuItem,"channel");
debug_log(LOG_FOCUS,"4\n"); debug_log(LOG_FOCUS_LEVEL,"4\n");
if(strcmp(o_dataType->valuestring,"map")==0){ if(strcmp(o_dataType->valuestring,"map")==0){
debug_log(LOG_FOCUS,"5\n"); debug_log(LOG_FOCUS_LEVEL,"5\n");
val = map_type_convert(o_dataType,o_valueRange,arg,n_valueRange); val = map_type_convert(o_dataType,o_valueRange,arg,n_valueRange);
}else{ }else{
debug_log(LOG_FOCUS,"6\n"); debug_log(LOG_FOCUS_LEVEL,"6\n");
val = msg_convert_value(o_dataType,n_dataType,arg); val = msg_convert_value(n_dataType,o_dataType,arg);
} }
debug_log(LOG_FOCUS,"7\n"); debug_log(LOG_FOCUS_LEVEL,"7\n");
cJSON_AddStringToObject(params,"epNum",epNum->valuestring); cJSON_AddStringToObject(params,"epNum",epNum->valuestring);
debug_log(LOG_FOCUS,"8\n"); debug_log(LOG_FOCUS_LEVEL,"8\n");
if(val->type==cJSON_False){ if(val->type==cJSON_False){
cJSON_AddFalseToObject(params,n_identifier->valuestring); cJSON_AddFalseToObject(params,n_identifier->valuestring);
...@@ -111,11 +111,31 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON ...@@ -111,11 +111,31 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
}else if(val->type==cJSON_Array){ }else if(val->type==cJSON_Array){
printf("......................\n"); printf("......................\n");
} }
debug_log(LOG_FOCUS,"9\n"); debug_log(LOG_FOCUS_LEVEL,"9\n");
return params; return params;
} }
static int kk_guard_ctrl_handle(int status)
{
char ccuid[33]={0};
kk_lan_get_ccuid(ccuid);
cJSON *root = cJSON_CreateObject();
cJSON *params = cJSON_CreateObject();
cJSON_AddStringToObject(params,"epNum","1");
if(status == 0){ //
cJSON_AddStringToObject(params,"ArmingState","0");
}else if(status == 2){ //ڼ
cJSON_AddStringToObject(params,"ArmingState","2");
}else{ //
cJSON_AddStringToObject(params,"ArmingState","1");
}
cJSON *info = property_info_build("/thing/service/property/set",KK_CCU_PRODUCTID,ccuid);
cJSON *payload = property_payload_build("thing.service.property.set","1","v1.0",params);
cJSON_AddItemToObject(root,INFO_STRING,info);
cJSON_AddItemToObject(root,PAYLOAD_STRING,payload);
kk_ipc_send_json(root);
return 0;
}
static int kk_indoorAir_ctrl_handle(char *epNum,cJSON *arg) static int kk_indoorAir_ctrl_handle(char *epNum,cJSON *arg)
{ {
kk_map_dev_node_t *dev = NULL; kk_map_dev_node_t *dev = NULL;
...@@ -202,6 +222,17 @@ int kk_ccu_opcode_handle(cJSON *root) ...@@ -202,6 +222,17 @@ int kk_ccu_opcode_handle(cJSON *root)
kk_indoorAir_ctrl_handle(nodeId->valuestring,arg); kk_indoorAir_ctrl_handle(nodeId->valuestring,arg);
return 0; return 0;
}else if(strcmp(requester->valuestring,"HJ_Server") == 0){
if(strcmp(opcode->valuestring,"ARMING_IN_HOME") == 0){
kk_guard_ctrl_handle(2);
return 0;
}else if(strcmp(opcode->valuestring,"ARMING_LEAVE_HOME") == 0){
kk_guard_ctrl_handle(0);
return 0;
}else if(strcmp(opcode->valuestring,"DISARMING") == 0){
kk_guard_ctrl_handle(1);
return 0;
}
} }
} }
......
...@@ -4,13 +4,15 @@ ...@@ -4,13 +4,15 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#define LOG_NORMAL 1 //亮白色
#define LOG_DEBUG 2 //绿色
#define LOG_INFO 3 //蓝色 #define LOG_NORMAL_LEVEL 1 //亮白色
#define LOG_FOCUS 4 //黄色 #define LOG_DEBUG_LEVEL 2 //绿色
#define LOG_WARNING 5 //蓝绿色 #define LOG_INFO_LEVEL 3 //蓝色
#define LOG_ERROR 6 //紫色 #define LOG_FOCUS_LEVEL 4 //黄色
#define LOG_CRITICAL 7 //红色 #define LOG_WARNING_LEVEL 5 //蓝绿色
#define LOG_ERROR_LEVEL 6 //紫色
#define LOG_CRITICAL_LEVEL 7 //红色
#define LOG_NORMAL_ACT "\033[0;1;37m" #define LOG_NORMAL_ACT "\033[0;1;37m"
#define LOG_DEBUG_ACT "\033[0;1;32m" #define LOG_DEBUG_ACT "\033[0;1;32m"
...@@ -23,7 +25,7 @@ ...@@ -23,7 +25,7 @@
#define syslog_en 1 #define syslog_en 1
#define LOG_LEVEL LOG_NORMAL #define LOG_LEVEL LOG_NORMAL_LEVEL
#define LOG_LEVEL_1 LOG_NORMAL_ACT #define LOG_LEVEL_1 LOG_NORMAL_ACT
...@@ -48,7 +50,7 @@ ...@@ -48,7 +50,7 @@
#if (syslog_en) #if (syslog_en)
#define debug_log(level,format,...) do { \ #define debug_log(level,format,...) do { \
if( level >= LOG_LEVEL && level <= LOG_CRITICAL) { \ if( level >= LOG_LEVEL && level <= LOG_CRITICAL_LEVEL) { \
char buff[64] = {0};\ char buff[64] = {0};\
time_t curTime = time(NULL); \ time_t curTime = time(NULL); \
struct tm *c = gmtime(&curTime);\ struct tm *c = gmtime(&curTime);\
......
...@@ -66,15 +66,55 @@ static void kk_lan_ccuid_init(void) ...@@ -66,15 +66,55 @@ static void kk_lan_ccuid_init(void)
} }
} }
int prg_run_singleton(const char *prg)
{
int fd;
int ret;
char pid_file[256] = {0};
char pid_data[32] = {0};
struct flock fl;
if(prg==NULL){
return -1;
}
memset(pid_file,0,sizeof(pid_file));
snprintf(pid_file, sizeof(pid_file), "/var/run/%s.pid",prg);
fd = open(pid_file, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if(fd<0){
return -1;
}
fl.l_type = F_WRLCK;
fl.l_start = 0;
fl.l_whence = SEEK_SET;
fl.l_len = 0;
ret = fcntl(fd,F_SETLK,&fl);
if(ret < 0){
return -1;
}
memset(pid_data,0,sizeof(pid_data));
snprintf(pid_data, sizeof(pid_data), "%d",getpid());
return write(fd,pid_data,strlen(pid_data));
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int rc = 0; int ret = 0;
char *ppp;
open("kk_lan",LOG_PID,LOG_USER); open("kk_lan",LOG_PID,LOG_USER);
if(prg_run_singleton(argv[0])<0){
debug_log(LOG_CRITICAL_LEVEL,"[%s]run singleton fail!\n",argv[0]);
return -1;
}
kk_lan_ccuid_init(); kk_lan_ccuid_init();
/*set the callback to get the device date to cloud*/ /*set the callback to get the device date to cloud*/
...@@ -82,7 +122,7 @@ int main(int argc, char* argv[]) ...@@ -82,7 +122,7 @@ int main(int argc, char* argv[])
kk_findccu_handle_init(); kk_findccu_handle_init();
kk_map_dev_init(); kk_map_dev_init();
kk_login_init(); kk_login_init();
kk_voice_panel_init(argc,argv); //kk_voice_panel_init(argc,argv);
//lan_queue_init(); //lan_queue_init();
kk_lan_db_node_init(); kk_lan_db_node_init();
...@@ -91,6 +131,6 @@ int main(int argc, char* argv[]) ...@@ -91,6 +131,6 @@ int main(int argc, char* argv[])
while(1){ while(1){
sleep(1); sleep(1);
} }
return rc; return 0;
} }
...@@ -428,7 +428,7 @@ int kk_sync_devices_to_sdk(cJSON *root,cJSON *data) ...@@ -428,7 +428,7 @@ int kk_sync_devices_to_sdk(cJSON *root,cJSON *data)
// //
cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node) cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node)
{ {
int i,num = 0; int i,num=0,n_num = 0,o_num = 0;
cJSON *newccu,*oldccu; cJSON *newccu,*oldccu;
cJSON *arg = cJSON_CreateObject(); cJSON *arg = cJSON_CreateObject();
...@@ -445,8 +445,11 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node) ...@@ -445,8 +445,11 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node)
return arg; return arg;
} }
n_num = cJSON_GetArraySize(newccu);
o_num = cJSON_GetArraySize(oldccu);
num = (n_num>o_num)?n_num:o_num;
num = cJSON_GetArraySize(newccu);
for(i=0;i<num;i++){ for(i=0;i<num;i++){
cJSON * newccuItem = cJSON_GetArrayItem(newccu,i); cJSON * newccuItem = cJSON_GetArrayItem(newccu,i);
cJSON * oldccuItem = cJSON_GetArrayItem(oldccu,i); cJSON * oldccuItem = cJSON_GetArrayItem(oldccu,i);
......
...@@ -315,7 +315,7 @@ void *kk_vp_manage_thread(void *arg) ...@@ -315,7 +315,7 @@ void *kk_vp_manage_thread(void *arg)
break; break;
case UPDATING_8009_CONFIG_FILE_INFO: case UPDATING_8009_CONFIG_FILE_INFO:
debug_log(LOG_INFO,"updating...\n"); //debug_log(LOG_INFO,"updating...\n");
sleep(1); sleep(1);
//todo :超时取消 //todo :超时取消
break; break;
...@@ -357,7 +357,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[]) ...@@ -357,7 +357,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[])
{NULL, 0, NULL, 0}, {NULL, 0, NULL, 0},
}; };
debug_log(LOG_FOCUS,"kk_voice_panel_uart_dev_chose\n"); debug_log(LOG_FOCUS_LEVEL,"kk_voice_panel_uart_dev_chose\n");
while((opt =getopt_long_only(argc,argv,string,long_options,&option_index))!= -1) while((opt =getopt_long_only(argc,argv,string,long_options,&option_index))!= -1)
{ {
if(opt==0xAA5555AA){ if(opt==0xAA5555AA){
...@@ -372,7 +372,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[]) ...@@ -372,7 +372,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[])
snprintf(serialDev,sizeof(serialDev),"%s",SERIAL_NAME); snprintf(serialDev,sizeof(serialDev),"%s",SERIAL_NAME);
} }
debug_log(LOG_FOCUS,"serialDev=%s\n",serialDev); debug_log(LOG_FOCUS_LEVEL,"serialDev=%s\n",serialDev);
} }
int kk_voice_panel_init(int argc, char* argv[]) int kk_voice_panel_init(int argc, char* argv[])
......
...@@ -46,16 +46,18 @@ static KK_VP_CTRL vp_ctrl_table[]={ ...@@ -46,16 +46,18 @@ static KK_VP_CTRL vp_ctrl_table[]={
{is_outlet_dev,outlet_dev_handle} {is_outlet_dev,outlet_dev_handle}
}; };
static int light_dev_pid[]={ static int light_dev_pid[]={
3023,3024 3001,3002,3003,3022,3023,3024
}; };
static int curtain_dev_pid[]={ static int curtain_dev_pid[]={
3067 3005,3006,3007,3008,3009,3010,3011,3026,3027,3067
}; };
static int outlet_dev_pid[]={ static int outlet_dev_pid[]={
3020 3019,3020,3037,3038
}; };
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
#include "kk_voice_panel_cfg.h" #include "kk_voice_panel_cfg.h"
#define VP_CONFIG_FILE_MD5 "voice_data.MD5"
#define VP_CONFIG_FILE "/etc/smarthome/voice_data.json" #define VP_CONFIG_FILE "/etc/smarthome/voice_data.json"
#define VP_CONFIG_FILE_TAR_GZ "voice_data.tar.gz" #define VP_CONFIG_FILE_MD5 "/data/kk/voice_data.MD5"
#define VP_CONFIG_FILE_TAR_GZ "/data/kk/voice_data.tar.gz"
#define OPCODE_8009_SNAPSHOOT 0x1000 #define OPCODE_8009_SNAPSHOOT 0x1000
......
...@@ -1239,7 +1239,52 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params) ...@@ -1239,7 +1239,52 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
int kk_msg_cloud_status_notify(const char *deviceCode,const char *productCode)
{
char *method = "thing.service.cloudStatus";
char *req_info = NULL,*payload = NULL;
int req_info_len = 0,payload_len = 0;
char msgId[MSG_MAX_LEN] = {0};
req_info_len = strlen(DM_MSG_INFO)+10+strlen(deviceCode)+strlen(productCode)+strlen(KK_THING_SERVICE_CLOUDSTATUS)+1;
req_info = malloc(req_info_len);
if (req_info == NULL) {
return MEMORY_NOT_ENOUGH;
}
memset(req_info, 0, req_info_len);
snprintf(req_info, req_info_len, DM_MSG_INFO, KK_THING_SERVICE_CLOUDSTATUS,productCode, deviceCode);
cJSON *params=cJSON_CreateObject();
cJSON_AddNumberToObject(params, "status", 1);
char *paramStr = cJSON_Print(params);
payload_len = strlen(DM_MSG_REQUEST) + 10 + strlen(DM_MSG_VERSION) + strlen(paramStr) + strlen(
method) + 1 + 20 + sizeof(msgId);
payload = malloc(payload_len);
if (payload == NULL) {
free(req_info);
return MEMORY_NOT_ENOUGH;
}
memset(payload, 0, payload_len);
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
snprintf(payload, payload_len, DM_MSG_REQUEST, msgId,
DM_MSG_VERSION, paramStr,HAL_GetTime(), method);
cJSON *root=cJSON_CreateObject();
cJSON* infoObj = cJSON_Parse(req_info);
cJSON* payloadObj = cJSON_Parse(payload);
cJSON_AddItemToObject(root, "info", infoObj);
cJSON_AddItemToObject(root, "payload",payloadObj);
void *buf = cJSON_Print(root);
printf("------------------------------------------------------->333\n");
kk_sendData2gw(buf, strlen(buf), deviceCode);
free(paramStr);
free(buf);
free(req_info);
free(payload);
cJSON_Delete(params);
cJSON_Delete(root);
return SUCCESS_RETURN;
}
int kk_msg_execute_property_set(const char *productCode,const char *deviceCode,const char* params,const char *fatherDeviceCode) int kk_msg_execute_property_set(const char *productCode,const char *deviceCode,const char* params,const char *fatherDeviceCode)
{ {
char *method = "thing.service.property.set"; char *method = "thing.service.property.set";
......
...@@ -85,7 +85,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY; ...@@ -85,7 +85,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_THING_SERVICE_SYNCINFO "/thing/service/syncinfo" #define KK_THING_SERVICE_SYNCINFO "/thing/service/syncinfo"
#define KK_THING_SERVICE_SYNCDEVICEINFO "/thing/service/syncDeviceInfo" #define KK_THING_SERVICE_SYNCDEVICEINFO "/thing/service/syncDeviceInfo"
#define KK_THING_SERVICE_SYNCDEVICEINFO_REPLY "/thing/service/syncDeviceInfo_reply" #define KK_THING_SERVICE_SYNCDEVICEINFO_REPLY "/thing/service/syncDeviceInfo_reply"
#define KK_THING_SERVICE_CLOUDSTATUS "/thing/service/cloudStatus"
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
static int s_gateway_add_flag = 0;
typedef struct { typedef struct {
int msgid; int msgid;
...@@ -353,7 +353,7 @@ int kk_topo_delete_handle(cJSON *payload,cJSON *buf) ...@@ -353,7 +353,7 @@ int kk_topo_delete_handle(cJSON *payload,cJSON *buf)
kk_sendData2gw(pnewout, strlen(pnewout), node->fatherDeviceCode);//send to gw itself kk_sendData2gw(pnewout, strlen(pnewout), node->fatherDeviceCode);//send to gw itself
dm_mgr_subdev_delete(deviceCode); dm_mgr_subdev_delete(deviceCode);
free(pnewout); free(pnewout);
cJSON_Delete(rootData); //cJSON_Delete(rootData);
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
...@@ -1196,7 +1196,8 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -1196,7 +1196,8 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
node->isOffline = KK_DEV_ONLINE; node->isOffline = KK_DEV_ONLINE;
dm_mgr_upstream_thing_sub_register(KK_DM_DEVICE_CCU_DEVICEID); dm_mgr_upstream_thing_sub_register(KK_DM_DEVICE_CCU_DEVICEID);
iotx_dm_dev_online(KK_DM_DEVICE_CCU_DEVICEID);//first online,report the online status iotx_dm_dev_online(KK_DM_DEVICE_CCU_DEVICEID);//first online,report the online status
usleep(200000); if(s_gateway_add_flag == 0)
kk_subDev_check_auth(KK_DM_DEVICE_GATEWAY);
dm_msg_ccu_property_post(node); dm_msg_ccu_property_post(node);
dm_mgr_resubscribe(); dm_mgr_resubscribe();
} }
...@@ -1767,7 +1768,15 @@ int kk_mid_subdev_add(int devType, char productCode[PRODUCT_CODE_MAXLEN], char d ...@@ -1767,7 +1768,15 @@ int kk_mid_subdev_add(int devType, char productCode[PRODUCT_CODE_MAXLEN], char d
} }
kk_subDev_update_productType(node->productType,deviceCode); kk_subDev_update_productType(node->productType,deviceCode);
} }
if(devType == KK_DM_DEVICE_GATEWAY){//如果还没有连上云,网关topo add不处理
if(s_CloudStatus){
//kk_subDev_update_auth(1,deviceCode);
s_gateway_add_flag = 1;
}else{
ERROR_PRINT("Cloud is not connected!!!!!!!!\n");
return FAIL_RETURN;
}
}
_iotx_linkkit_mutex_lock(); _iotx_linkkit_mutex_lock();
res = _iotx_linkkit_slave_connect(devid); res = _iotx_linkkit_slave_connect(devid);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
......
...@@ -385,7 +385,36 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode) ...@@ -385,7 +385,36 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode)
_kk_subDb_unlock(); _kk_subDb_unlock();
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
/************************************************************
*功能描述:更新设备注册标记
*输入参数:deviceCode:设备deviceCode
isAuth:1,已注册;0,未注册
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_subDev_check_auth(int devType)
{
char *sqlCmd = NULL;
sqlite3_stmt *stmt;
int rc = 0;
char *zErrMsg = 0;
const char *searchCmd = "select * from SubDeviceInfo WHERE devType = '%d';";
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
printf("------------------------------------------------------->111\n");
sqlCmd = sqlite3_mprintf(searchCmd,devType);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
printf("------------------------------------------------------->222\n");
char *pDeviceCode = (char*)sqlite3_column_text(stmt, DB_SUB_DEVICECODE);
char *pProductCode = (char*)sqlite3_column_text(stmt, DB_SUB_PRODUCTCODE);
kk_msg_cloud_status_notify(pProductCode,pDeviceCode);
//kk_subDev_update_auth(1,pDeviceCode);
}
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
return SUCCESS_RETURN;
}
/************************************************************ /************************************************************
*功能描述:更新内场景支持,此接口只针对网关设备有效 *功能描述:更新内场景支持,此接口只针对网关设备有效
*输入参数:deviceCode:设备deviceCode *输入参数:deviceCode:设备deviceCode
......
...@@ -15,7 +15,6 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode); ...@@ -15,7 +15,6 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode);
int kk_subDev_update_sceneSupport(int sceneSupport,const char *deviceCode); int kk_subDev_update_sceneSupport(int sceneSupport,const char *deviceCode);
int kk_subDev_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN]); int kk_subDev_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN]);
int kk_subDev_update_productType(char *productType,const char *deviceCode); int kk_subDev_update_productType(char *productType,const char *deviceCode);
int kk_subDev_update_auth(int isAuth,const char *deviceCode);
int kk_subDev_send_property_get_from_db(void); int kk_subDev_send_property_get_from_db(void);
int kk_subDev_send_property_get(const char *fatherDeviceCode); int kk_subDev_send_property_get(const char *fatherDeviceCode);
...@@ -24,6 +23,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen ...@@ -24,6 +23,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
int kk_subDev_update_offline(int isOffline,const char *deviceCode); int kk_subDev_update_offline(int isOffline,const char *deviceCode);
int kk_subDev_getSensors_reply(SensorType_t*list); int kk_subDev_getSensors_reply(SensorType_t*list);
int kk_load_subDevice(void); int kk_load_subDevice(void);
int kk_subDev_check_auth(int devType);
enum{ enum{
DB_SUB_IDX = 0, DB_SUB_IDX = 0,
DB_SUB_ONLINE, DB_SUB_ONLINE,
......
#!/bin/sh #!/bin/sh
#filepath="/home/kk" #filepath="/home/kk"
filepath="/app/nx5Apps" filepath="/app/ccuApps"
if [ ! -f "/sbin/jq" ] if [ ! -f "/sbin/jq" ]
then then
cp $filepath/jq /sbin cp $filepath/jq /sbin
fi fi
if [ -f "$filepath/syscfg.json" ] if [ -f "/app/nx5Apps/syscfg.json" ]
then then
if [ ! -f "/data/syscfg.json" ] if [ ! -f "/data/syscfg.json" ]
then then
cp $filepath/syscfg.json /data cp /app/nx5Apps/syscfg.json /data
fi fi
embbedflag=`cat /data/syscfg.json|jq ."ccuembbed"` embbedflag=`cat /data/syscfg.json|jq ."ccuembbed"`
#embbedflag="0" #embbedflag="0"
...@@ -64,11 +64,11 @@ export LD_LIBRARY_PATH=$filepath/lib ...@@ -64,11 +64,11 @@ export LD_LIBRARY_PATH=$filepath/lib
$filepath/bin/kk_midware & $filepath/bin/kk_midware &
sleep 3 sleep 3
$filepath/bin/kk_cloud & $filepath/bin/kk_cloud &
sleep 1 sleep 5
#/home/kk/process_check.sh >/dev/null 2>&1 & #/home/kk/process_check.sh >/dev/null 2>&1 &
$filepath/bin/smarthome_z3gw_nx5 -r0 -l3 --device-def=$filepath/kk_device_def.json --db=/data/kk/kk_z3gw.db --uart=/dev/ttyS1& $filepath/bin/smarthome_z3gw_nx5 -r0 -l3 --device-def=$filepath/kk_device_def.json --db=/data/kk/kk_z3gw.db --uart=/dev/ttyS1&
sleep 2 sleep 2
$filepath/bin/kk_lan & $filepath/bin/kk_lan --uart=/dev/ttyS3&
sleep 1 sleep 1
#echo "*/1 * * * * /app/ccuApps/process_check.sh" > /etc/cron.d/ccu || { echo "ERROR:add ccu crontab rule failed."; exit 1;} #echo "*/1 * * * * /app/ccuApps/process_check.sh" > /etc/cron.d/ccu || { echo "ERROR:add ccu crontab rule failed."; exit 1;}
ntpd -n -q -d -p stdtime.gov.hk & ntpd -n -q -d -p stdtime.gov.hk &
......
...@@ -47,13 +47,6 @@ ...@@ -47,13 +47,6 @@
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"value": 22 "value": 22
},{
"identifier":"time_off",
"opcodemap":"FLOOR_HEATING_DEV_STATUS",
"dataType":"dummy",
"channel":"1",
"valueRange":[],
"value": 0
} }
], ],
"oldccu":[ "oldccu":[
...@@ -76,7 +69,7 @@ ...@@ -76,7 +69,7 @@
},{ },{
"opcode":"SET_WORK_TEMPERATURE", "opcode":"SET_WORK_TEMPERATURE",
"identifiermap":"Temperature", "identifiermap":"Temperature",
"dataType":"double", "dataType":"string_double",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"syn":"work_temperature", "syn":"work_temperature",
...@@ -84,7 +77,7 @@ ...@@ -84,7 +77,7 @@
},{ },{
"opcode":"FLOOR_HEATING_SET_TIME_OFF", "opcode":"FLOOR_HEATING_SET_TIME_OFF",
"identifiermap":"TimingOffTime", "identifiermap":"TimingOffTime",
"dataType":"double", "dataType":"fit",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"syn":"time_off", "syn":"time_off",
......
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