Commit 4f844287 authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

【修改内容】增加hostname的设置

See merge request chenweican/k-sdk!134
parents faea48f8 76cca192
......@@ -120,35 +120,23 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
debug_log(LOG_FOCUS_LEVEL,"not find\n");
return NULL;
}
debug_log(LOG_FOCUS_LEVEL,"1\n");
newccuItem = cJSON_GetArrayItem(devNode->newccu,pos);
oldccuItem = cJSON_GetArrayItem(devNode->oldccu,pos);
debug_log(LOG_FOCUS_LEVEL,"2\n");
o_dataType = cJSON_GetObjectItem(oldccuItem,"dataType");
o_valueRange = cJSON_GetObjectItem(oldccuItem,"valueRange");
debug_log(LOG_FOCUS_LEVEL,"3\n");
n_dataType = cJSON_GetObjectItem(newccuItem,"dataType");
n_valueRange = cJSON_GetObjectItem(newccuItem,"valueRange");
n_identifier = cJSON_GetObjectItem(newccuItem,"identifier");
epNum = cJSON_GetObjectItem(newccuItem,"channel");
debug_log(LOG_FOCUS_LEVEL,"4\n");
if(special_handling_for_compatibility(devNode,opcode,arg,&val)!=0){
if(strcmp(o_dataType->valuestring,"map")==0){
debug_log(LOG_FOCUS_LEVEL,"5\n");
val = map_type_convert(o_dataType,o_valueRange,arg,n_valueRange);
}else{
debug_log(LOG_FOCUS_LEVEL,"6\n");
val = msg_convert_value(n_dataType,o_dataType,arg);
}
}
debug_log(LOG_FOCUS_LEVEL,"7\n");
cJSON_AddStringToObject(params,"epNum",epNum->valuestring);
debug_log(LOG_FOCUS_LEVEL,"8\n");
debug_log(LOG_WARNING_LEVEL,"[err]val->type:%d\n",val->type);
if(val->type==cJSON_False){
......@@ -164,8 +152,6 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
}else if(val->type==cJSON_Array){
printf("......................\n");
}
debug_log(LOG_FOCUS_LEVEL,"9\n");
return params;
}
static int kk_guard_ctrl_handle(int status)
......@@ -175,11 +161,11 @@ static int kk_guard_ctrl_handle(int status)
cJSON *root = cJSON_CreateObject();
cJSON *params = cJSON_CreateObject();
cJSON_AddStringToObject(params,"epNum","1");
if(status == 0){ //
if(status == 0){ //���
cJSON_AddStringToObject(params,"ArmingState","0");
}else if(status == 2){ //ڼ
}else if(status == 2){ //�ڼ�
cJSON_AddStringToObject(params,"ArmingState","2");
}else{ //
}else{ //����
cJSON_AddStringToObject(params,"ArmingState","1");
}
cJSON *info = property_info_build("/thing/service/property/set",KK_CCU_PRODUCTID,ccuid);
......@@ -358,10 +344,8 @@ int kk_ccu_opcode_handle(cJSON *root)
}
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_lan_ctrl_ack(nodeId,opcode,arg);
cJSON *params=kk_control_protocol_convert(dev,atoi(nodeId->valuestring),arg,opcode);
msg=property_set(dev->productCode,dev->deviceCode,"*","*",params);
kk_ipc_send_json(msg);
debug_log(LOG_INFO_LEVEL,"MARK!\n");
......@@ -372,19 +356,6 @@ int kk_ccu_opcode_handle(cJSON *root)
return 0;
}
char *node_string(int nodeId)
{
char *node = (char *)malloc(33);
......
......@@ -183,10 +183,10 @@ int main(int argc, char* argv[])
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;
}
//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();
......
......@@ -886,9 +886,7 @@ static int kk_get_ac_indoor_info_by_deviceCode(cJSON *data,char *pdeviceCode,cha
subitem = subitem->next;
}
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
item = item->next;
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
}
debug_log(LOG_CRITICAL_LEVEL,"[err]\n");
return -1;
......@@ -965,35 +963,19 @@ int kk_send_indoorAir_status(cJSON *info,const char *deviceCode)
cJSON_AddStringToObject(root, "nodeid", nodeStr);
cJSON_AddStringToObject(root, "opcode", "CENTRAL_AC_INDOOR_UNIT_STATUS");
cJSON_AddStringToObject(root, "status", "success");
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON *arg = cJSON_CreateObject();
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON_AddBoolToObject(arg, "online", 1);
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON *PowerSwitch = cJSON_GetObjectItem(info,"PowerSwitch");
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON_AddBoolToObject(arg, "on", PowerSwitch->valueint);
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON *Temperature = cJSON_GetObjectItem(info,"Temperature");
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON_AddNumberToObject(arg,"settingTemperature",Temperature->valuedouble);
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON *CurrentTemperature = cJSON_GetObjectItem(info,"CurrentTemperature");
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON_AddNumberToObject(arg,"roomTemperature",CurrentTemperature->valuedouble);
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON *WindSpeed = cJSON_GetObjectItem(info,"WindSpeed");
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON_AddStringToObject(arg, "fanSpeed", speedMap[WindSpeed->valueint]);
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON *WorkMode = cJSON_GetObjectItem(info,"WorkMode");
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON_AddStringToObject(arg, "runModel", modeMap[WorkMode->valueint]);
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
cJSON_AddItemToObject(root, "arg", arg);
_debug_log(LOG_CRITICAL_LEVEL,"mark\n");
send_msg_to_module(root);
cJSON_Delete(root);
return 0;
......@@ -1037,9 +1019,7 @@ cJSON *kk_sync_central_ac_to_sdk(cJSON *root,cJSON *data)
cJSON *properties = cJSON_GetObjectItem(subitem,"properties");
cJSON *indoorItem = cJSON_CreateObject();
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
kk_get_ac_indoor_info_by_deviceCode(data,deviceCode->valuestring,roomId,NULL,1);
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
debug_log(LOG_CRITICAL_LEVEL,"deviceCode->valuestring=%s",deviceCode->valuestring);
cJSON_AddStringToObject(indoorItem, "bind_central_ac_gw_node_id",ac_gw_nodeid);
cJSON_AddStringToObject(indoorItem, "dev_name", "空调网关");
......@@ -1061,43 +1041,31 @@ cJSON *kk_sync_central_ac_to_sdk(cJSON *root,cJSON *data)
cJSON *infoItem = cJSON_GetArrayItem(epsAry,k);
if(infoItem == NULL) continue;
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
kk_creater_nodeid(deviceCode->valuestring,k+2,nodeid);
kk_get_ac_indoor_info_by_deviceCode(data,deviceCode->valuestring,g_indoor_item[k].room_id,g_indoor_item[k].dev_name,k+2);
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
memcpy(g_indoor_item[k].id,nodeid,strlen(nodeid));
sprintf(tmpIdx,"%d",k);
memcpy(g_indoor_item[k].indooruint_addr,tmpIdx,strlen(tmpIdx));
memcpy(g_indoor_item[k].nodeid,ac_gw_nodeid,strlen(ac_gw_nodeid));
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
memcpy(g_indoor_item[k].nodeid,ac_gw_nodeid,strlen(ac_gw_nodeid));
cJSON *PowerSwitch = cJSON_GetObjectItem(infoItem,"PowerSwitch");
g_indoor_item[k].ac_gw_status.on = PowerSwitch->valueint == 1?true:false;
g_indoor_item[k].ac_gw_status.online = 1;
cJSON *Temperature = cJSON_GetObjectItem(infoItem,"Temperature");
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
cJSON *CurrentTemperature = cJSON_GetObjectItem(infoItem,"CurrentTemperature");
g_indoor_item[k].ac_gw_status.settingTemperature = Temperature->valuedouble;
g_indoor_item[k].ac_gw_status.roomTemperature = CurrentTemperature->valuedouble;
cJSON *WindSpeed = cJSON_GetObjectItem(infoItem,"WindSpeed");
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
memcpy(g_indoor_item[k].ac_gw_status.speed,speedMap[WindSpeed->valueint],strlen(speedMap[WindSpeed->valueint]));
cJSON *WorkMode = cJSON_GetObjectItem(infoItem,"WorkMode");
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
memcpy(g_indoor_item[k].ac_gw_status.mode,modeMap[WorkMode->valueint],strlen(modeMap[WorkMode->valueint]));
}
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
kk_create_new_central_ac(gwDeviceCode->valuestring,deviceCode->valuestring,nodeid);
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
}
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
}
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
}
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
cJSON_AddItemToObject(root, "central_ac_gws", central_ac_gws);
debug_log(LOG_CRITICAL_LEVEL,"mark...\n");
return root;
}
......
......@@ -70,16 +70,17 @@
//DEVICE PID DEFINE
//3001,3002,3003,3022,3023,3024
#define LIGHT_DEV_PID {\
3001,3002,3003,3009,3010,3011,3022,3023,3024,3069,3078,3079,3085,3086,3087,3115\
}
//3005,3006,3007,3008,3009,3010,3011,3026,3027,3067
#define CURTAIN_DEV_PID {\
3005,3006,3012,3013,3017,3026,3027,3067,3068,3088,3089\
}
//3019,3020,3037,3038
#define OUTLET_DEV_PID {\
3019,3020,3037,3038,3037,3038\
3019,3020,3037,3038\
}
#define FRESHAIR_DEV_PID {\
......
......@@ -52,18 +52,15 @@ int kk_send_data_to_sdk(char *buf)
INFO_PRINT("tmpBuf:%s\n",tmpBuf);
for(i = 0; i < LISTEN_MAX; i++){
tcp_data_mutex_lock();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(s_ConnInfo[i].socketfd != -1){
send(s_ConnInfo[i].socketfd, tmpBuf, strlen(tmpBuf), 0);
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
tcp_data_mutex_unlock();
}
free(tmpBuf);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
static int _kk_handle_data(char *buf,int sockfd){
......
......@@ -242,15 +242,11 @@ 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__);
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__);
if((name = cJSON_GetObjectItem(deviceItem,"name"))!=NULL &&
name->type==cJSON_String){
......@@ -278,7 +274,6 @@ static int kk_vp_get_device_name(_IN cJSON *devices,_IN const char*epNum,_IN con
}
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return 0;
}
......
......@@ -87,7 +87,7 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
memset(dat_bak,0x0,bytes+1);
memcpy(dat_bak,dat,bytes);
cJSON_Minify((char *)dat_bak);
INFO_PRINT("watcher_cb:%s\n", (char*)dat_bak);
//INFO_PRINT("watcher_cb:%s\n", (char*)dat_bak);
free(dat_bak);
dat_bak = NULL;
}
......
......@@ -21,7 +21,14 @@ then
exit 0
fi
fi
ccuid_hostname=`fw_printenv | grep uuid |cut -d '=' -f 2`;
curr_hostname=`cat /etc/hostname`;
if [ "$ccuid_hostname" != "$curr_hostname" ]; then
echo "$ccuid_hostname" > /etc/hostname
hostname $ccuid_hostname
/etc/init.d/S01rsyslogd restart
fi
nanomsg_File="$filepath/lib/libnanomsg.so.5"
ev_File="$filepath/lib/libev.so.4"
sqlite_File="$filepath/lib/libsqlite3.so.0"
......
......@@ -3,7 +3,7 @@
"productType": "floorHeating",
"version": "1.2",
"profile": {
"heartbeat": "3000",
"heartbeat": "300",
"productCode": "3030",
"productName": "肖邦系列.电地暖面板Z3S(KONKE)"
},
......
......@@ -3,7 +3,7 @@
"productType": "freshAir",
"version": "1.2",
"profile": {
"heartbeat": "3000",
"heartbeat": "300",
"productCode": "3032",
"productName": "肖邦系列.新风控制面板Z3S(KONKE)"
},
......
......@@ -3,7 +3,7 @@
"productType": "airConditioning",
"version": "1.2",
"profile": {
"heartbeat": "3000",
"heartbeat": "300",
"productCode": "3034",
"productName": "肖邦系列.美的中央空调线控器Z3ZA(KONKE)"
},
......
......@@ -3,7 +3,7 @@
"productType": "fresh air",
"version": "1.0",
"profile": {
"heartbeat": "3000",
"heartbeat": "300",
"productCode": "3099",
"productName": "海顿系列.新风多合一面板(KONKE)"
},
......
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