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

20210825

parent 6e9cbe48
#include "kk_ccu_msg.h"
cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType);
cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType);
cJSON *double_type_convert(cJSON *n_id,cJSON *n_dataType);
cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType);
cJSON *string_int_type_convert(cJSON *n_id,cJSON *n_dataType);
cJSON *string_double_type_convert(cJSON *n_id,cJSON *n_dataType);
cJSON *string_time_type_convert(cJSON *n_id,cJSON *n_dataType);
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);
static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType);
static cJSON *string_int_type_convert(cJSON *n_id,cJSON *n_dataType);
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 *);
......@@ -24,11 +25,12 @@ static CONVERT_ITEM_S convert_table[] = {
{"string_bool",string_bool_type_convert},
{"string_int",string_int_type_convert},
{"string_double",string_double_type_convert},
{"string_time",string_time_type_convert}
{"string_time",string_time_type_convert},
{"fit",fit_type_convert}
};
cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON *args = NULL;
int bVal = 0;
......@@ -65,7 +67,7 @@ cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
return args;
}
cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON *args = NULL;
......@@ -96,12 +98,12 @@ cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
return args;
}
cJSON *double_type_convert(cJSON *n_id,cJSON *n_dataType)
static cJSON *double_type_convert(cJSON *n_id,cJSON *n_dataType)
{
return int_type_convert(n_id,n_dataType);
}
cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON *args = NULL;
int flag = -1;
......@@ -242,6 +244,27 @@ cJSON *string_time_type_convert(cJSON *n_id,cJSON *n_dataType)
return args;
}
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){
args = cJSON_CreateFalse();
}else if(n_id->type == cJSON_NULL){
args = cJSON_CreateNull();
}else if(n_id->type == cJSON_Number){
args = cJSON_CreateNumber(n_id->valuedouble);
}else if(n_id->type == cJSON_String){
args = cJSON_CreateString(n_id->valuestring);
}
return args;
}
......@@ -255,7 +278,9 @@ cJSON * msg_convert_value(cJSON *d_type,cJSON *s_type,cJSON *value)
cJSON *rlt = NULL;
CONVERT_ITEM_S *crt;
printf("[%s][%d]%s->%s,val=%s\n",__FUNCTION__,__LINE__,cJSON_Print(s_type),cJSON_Print(d_type),cJSON_Print(value));
if(d_type==NULL||s_type==NULL||value==NULL){
return NULL;
}
size = sizeof(convert_table)/sizeof(CONVERT_ITEM_S);
crt = &convert_table[0];
......
......@@ -9,6 +9,8 @@
#include "kk_lan_ctrl.h"
#include "kk_data_mng.h"
#include "cJSON.h"
#include "kk_lan_debug.h"
#define WILDCARD_CHARACTER_STR "*"
#define SUCCESS_STR "success"
......
......@@ -350,6 +350,8 @@ int kk_data_handle(cJSON *json,int sockfd)
{
cJSON *opcode;
cJSON *arg;
opcode = cJSON_GetObjectItem(json, OPCODE_STRING);
if(opcode != NULL){
if(strcmp(opcode->valuestring,LOGIN_OPCODE) == 0){
......@@ -374,6 +376,7 @@ int kk_data_handle(cJSON *json,int sockfd)
kk_ccu_opcode_handle(json);
}
}
return 0;
}
static int kk_parse_syncinfo(cJSON *payload)
......
......@@ -60,40 +60,43 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
int channel;
char ch[33];
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_lan_db_channel_get(nodeId,&channel);
snprintf(ch,33,"%d",channel);
printf("nodeId=%d,channel=%d,ch=%s\n",nodeId,channel,ch);
pos = match_opcode_pos(devNode->oldccu,opcode->valuestring,channel);
printf("[opcode->valuestring]%s\n",opcode->valuestring);
printf("[match pos]%d\n",pos);
if(pos==-1){
debug_log(LOG_FOCUS,"not find\n");
return NULL;
}
debug_log(LOG_FOCUS,"1\n");
newccuItem = cJSON_GetArrayItem(devNode->newccu,pos);
oldccuItem = cJSON_GetArrayItem(devNode->oldccu,pos);
debug_log(LOG_FOCUS,"2\n");
o_dataType = cJSON_GetObjectItem(oldccuItem,"dataType");
o_valueRange = cJSON_GetObjectItem(oldccuItem,"valueRange");
debug_log(LOG_FOCUS,"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,"4\n");
if(strcmp(o_dataType->valuestring,"map")==0){
debug_log(LOG_FOCUS,"5\n");
val = map_type_convert(o_dataType,o_valueRange,arg,n_valueRange);
}else{
debug_log(LOG_FOCUS,"6\n");
val = msg_convert_value(o_dataType,n_dataType,arg);
}
debug_log(LOG_FOCUS,"7\n");
printf("----------->epNum=%s\n",epNum->valuestring);
cJSON_AddStringToObject(params,"epNum",epNum->valuestring);
debug_log(LOG_FOCUS,"8\n");
if(val->type==cJSON_False){
cJSON_AddFalseToObject(params,n_identifier->valuestring);
......@@ -108,6 +111,7 @@ 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,"9\n");
return params;
}
......
......@@ -33,6 +33,8 @@
#include "kk_lan_node_db.h"
#include "kk_lan_voice_panel.h"
#include "kk_data_mng.h"
#include "kk_lan_debug.h"
static char s_ccuid[DEVICE_CODE_LEN] = {0};
int kk_lan_get_ccuid(_OU_ char *device_code)
......@@ -84,7 +86,6 @@ int main(int argc, char* argv[])
kk_lan_db_node_init();
//kk_handle_sync_info();
while(1){
sleep(1);
}
......
......@@ -6,7 +6,7 @@
#include "kk_data_mng.h"
#include "kk_ccu_msg.h"
#include "kk_lan_sync.h"
#include "kk_lan_debug.h"
......@@ -407,16 +407,10 @@ int kk_sync_devices_to_sdk(cJSON *root,cJSON *data)
int i,num = cJSON_GetArraySize(rooms);
cJSON *roomId,*devices;
printf("kk_sync_devices_to_sdk,num=%d\n",num);
for(i=0;i<num;i++){
printf("i=%d\n",i);
cJSON *room = cJSON_GetArrayItem(rooms,i);
roomId = cJSON_GetObjectItem(room,ROOMS_ID_STR);
devices = cJSON_GetObjectItem(room,DEVICES_STR);
printf("devices...=%s\n",cJSON_Print(devices));
kk_sync_device(roomId,devices,deviceAry);
}
......@@ -1065,7 +1059,7 @@ int kk_create_syncinfo_to_sdk(cJSON *payload)
cJSON *data = kk_get_sync_data(payload);
char *out = NULL;
printf("!!!!!!!!!!!!!!!!!!!!------>%x\n",&out);
cJSON *root=cJSON_CreateObject();
cJSON *aiks_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "aiks_controllers", aiks_controllers);
......@@ -1087,86 +1081,62 @@ int kk_create_syncinfo_to_sdk(cJSON *payload)
cJSON_AddItemToObject(root, "cnwise_music_controllers", cnwise_music_controllers);
code_lib_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "code_lib_controllers", code_lib_controllers);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "controllers", controllers);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_sync_devices_status_to_sdk(root);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_sync_devices_to_sdk(root,data);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_sync_rooms_to_sdk(root,data);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_sync_scence_to_sdk(root,data);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_sync_gw_version_to_sdk(root,data);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_sync_ccu_version_to_sdk(root,data);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_sync_guard_to_sdk(root,data);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_sync_central_ac_to_sdk(root,data);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_sync_central_ac_indoorunits_to_sdk(root,data);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_sync_groups_to_sdk(root,data);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
kk_create_floors_to_sdk(root,data);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
#if 1
expand_rules = cJSON_CreateArray();
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(root, "expand_rules", expand_rules);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
cJSON_AddItemToObject(root, "expand_rules", expand_rules);
#endif
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,(root==NULL)?"NULL":"1");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
out=cJSON_Print(root);
printf("out:%s\n",out);
printf("[%s][%d]%s\n",__FUNCTION__,__LINE__,out);
......
......@@ -13,6 +13,7 @@
#include <signal.h>
#include "kk_login_handle.h"
#include "kk_data_handle.h"
#include "kk_lan_debug.h"
#define LISTEN_MAX 5
#define BUF_SIZE 1500
......@@ -60,6 +61,7 @@ static int _kk_handle_data(char *buf,int sockfd){
memset(tmpBuf,0x0,sizeof(tmpBuf));
memcpy(tmpBuf,pStart+1,(pEnd - pStart - 1));
}
debug_log(LOG_NORMAL,"[recv]%s\n",tmpBuf);
json=cJSON_Parse(tmpBuf);
if (!json) {
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
......@@ -193,10 +195,15 @@ void *TCPServer()
}else{
for(i=0;i<LISTEN_MAX;i++)
{
if(s_ConnInfo[i].socketfd==-1){
continue ;
}
if(FD_ISSET(s_ConnInfo[i].socketfd,&server_fd_set))
{
memset(Buf,0,sizeof(Buf));
ret = recv(s_ConnInfo[index].socketfd,Buf,sizeof(Buf), 0);//最后一个参数为0,表示默认阻塞接收,前面select解除了阻塞说明有数据可读
if(ret > 0)
{
_kk_handle_data(Buf,s_ConnInfo[index].socketfd);
......@@ -217,6 +224,8 @@ void *TCPServer()
}
FD_CLR(Listenfd, &fds);// 清除 fds中相应的文件描述符
close(Listenfd);
return NULL;
}
......
......@@ -278,7 +278,9 @@ cJSON * attr_report_conver(const char *deviceCode,kk_map_dev_node_t *devNode,cJS
oldccu = devNode->oldccu;
newccu = devNode->newccu;
item_size = cJSON_GetArraySize(oldccu);
for(i=0;i<item_size;i++){
o_item = cJSON_GetArrayItem(oldccu,i);
n_item = cJSON_GetArrayItem(newccu,i);
......@@ -295,15 +297,24 @@ cJSON * attr_report_conver(const char *deviceCode,kk_map_dev_node_t *devNode,cJS
channel = cJSON_GetObjectItem(o_item,"channel");
epNum = cJSON_GetObjectItem(params,"epNum");
if(channel==NULL||epNum==NULL){
continue;
}
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;
}
}
nodeId = kk_lan_db_node_get(deviceCode,ch);
opcode =cJSON_GetObjectItem(o_item,"opcode");
......
......@@ -100,7 +100,7 @@ static cJSON * kk_get_room_devices(const char *roomId)
res = dm_mgr_get_device_by_devicecode((char*)deviceCode,&node);
if (res != SUCCESS_RETURN) {
ERROR_PRINT("ERROR [%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
return devs;
}
if(kk_check_multi_ep_num(deviceCode)){
cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
......
......@@ -24,10 +24,10 @@
"opcodemap":"FAN_COIL_SET_FUN_SPEED",
"dataType":"int",
"channel":"1",
"valueRange":[1,2,3,4],
"valueRange":[0,2,3,4],
"value": 1
},{
"identifier":"TargetTemperature",
"identifier":"Temperature",
"opcodemap":"FAN_COIL_SET_TEMPERATURE",
"dataType":"double",
"channel":"1",
......@@ -123,12 +123,12 @@
"identifiermap":"WindSpeed",
"dataType":"map",
"channel":"1",
"valueRange":["AUTO","HIGH","MID","LOW"],
"valueRange":["AUTO","LOW","MID","HIGH"],
"syn":"fan_speed",
"synType":"map"
},{
"opcode":"FAN_COIL_SET_TEMPERATURE",
"identifiermap":"TargetTemperature",
"identifiermap":"Temperature",
"dataType":"double",
"channel":"1",
"valueRange":[],
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3029.json",
"productType": "floorHeating",
"version": "1.0",
"version": "1.2",
"profile": {
"heartbeat": "300",
"productCode": "3029",
......@@ -67,13 +67,9 @@
"identifier": "TimingOffTime",
"name": "延时关机时间",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "24",
"unit": "h",
"unitName": "小时",
"step": "0.5"
"type":"text",
"specs":{
"length":"10"
}
}
}
......@@ -161,13 +157,9 @@
"identifier": "TimingOffTime",
"name": "延时关机时间",
"dataType": {
"type" : "double",
"specs": {
"min": "0",
"max": "24",
"unit": "h",
"unitName": "小时",
"step": "0.5"
"type":"text",
"specs":{
"length":"10"
}
}
}
......@@ -252,13 +244,9 @@
"accessMode": "rw",
"required": true,
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "24",
"unit": "h",
"unitName": "小时",
"step": "0.5"
"type":"text",
"specs":{
"length":"10"
}
}
}
......@@ -337,13 +325,9 @@
"identifier": "TimingOffTime",
"name": "延时关机时间",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "24",
"unit": "h",
"unitName": "小时",
"step": "0.5"
"type":"text",
"specs":{
"length":"10"
}
}
}
......
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