Commit b46e8c98 authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

【修改内容】3028tsl文件修改;窗帘绑定修改

See merge request chenweican/k-sdk!184
parents b1be5f3f 29dc40f7
...@@ -16,7 +16,7 @@ static cJSON *string_int_type_convert(cJSON *n_id,cJSON *n_dataType); ...@@ -16,7 +16,7 @@ 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_double_type_convert(cJSON *n_id,cJSON *n_dataType);
static cJSON *string_time_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); static cJSON *fit_type_convert(cJSON *n_id,cJSON *n_dataType);
static cJSON *string_type_convert(cJSON *n_id,cJSON *n_dataType);
static CONVERT_ITEM_S convert_table[] = { static CONVERT_ITEM_S convert_table[] = {
{"bool",bool_type_convert}, {"bool",bool_type_convert},
...@@ -26,9 +26,22 @@ static CONVERT_ITEM_S convert_table[] = { ...@@ -26,9 +26,22 @@ static CONVERT_ITEM_S convert_table[] = {
{"string_int",string_int_type_convert}, {"string_int",string_int_type_convert},
{"string_double",string_double_type_convert}, {"string_double",string_double_type_convert},
{"string_time",string_time_type_convert}, {"string_time",string_time_type_convert},
{"fit",fit_type_convert} {"fit",fit_type_convert},
{"string",string_type_convert},
}; };
static cJSON *string_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON *args = NULL;
char buf[16] = {0};
if(n_id == NULL){
return NULL;
}
if(n_id->type==cJSON_Number){
sprintf(buf,"%d",n_id->valueint);
args = cJSON_CreateString(buf);
}
return args;
}
static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType) static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
{ {
cJSON *args = NULL; cJSON *args = NULL;
...@@ -206,7 +219,8 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType) ...@@ -206,7 +219,8 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
if(type==1){ if(type==1){
val.dVal = (n_id->valueint>0) ? 1 : 0; val.dVal = (n_id->valueint>0) ? 1 : 0;
}else{ }else{
val.iVal = (n_id->valueint>0) ? 1 : 0; //printf("n_id->valueint----------------->:%d\n",n_id->valueint);
val.iVal = (n_id->valueint>0) ? n_id->valueint : 0;
} }
}else if(strcmp(n_dataType->valuestring,"double")==0) { }else if(strcmp(n_dataType->valuestring,"double")==0) {
if(type==1){ if(type==1){
......
...@@ -109,7 +109,11 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON ...@@ -109,7 +109,11 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
char ch[33]; char ch[33];
if(strcmp(opcode->valuestring,"MOVE_TO_POS") == 0 && strcmp(devNode->syn_opcode,"DOOYA_STATUS") == 0){
if(arg->type == cJSON_String){
kk_record_motorPosition(atoi(arg->valuestring));
}
}
kk_lan_db_channel_get(nodeId,&channel); kk_lan_db_channel_get(nodeId,&channel);
snprintf(ch,33,"%d",channel); snprintf(ch,33,"%d",channel);
......
...@@ -97,7 +97,11 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type) ...@@ -97,7 +97,11 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
return ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,n_value); return ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,n_value);
} }
static int s_motorPostion = -1;
void kk_record_motorPosition(int value){
s_motorPostion = value;
debug_log(LOG_DEBUG_LEVEL,"s_motorPostion:%d\n",s_motorPostion);
}
//更新设备状态 //更新设备状态
static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,const char *syn_opcode) static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,const char *syn_opcode)
{ {
...@@ -116,6 +120,7 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons ...@@ -116,6 +120,7 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons
memset(valBuff,0,sizeof(valBuff)); memset(valBuff,0,sizeof(valBuff));
if(arg->type==cJSON_String){ if(arg->type==cJSON_String){
debug_log(LOG_CRIT_LEVEL,"nodeId=%d,opcode=%s,arg=%s\n",nodeId,opcode->valuestring,arg->valuestring); debug_log(LOG_CRIT_LEVEL,"nodeId=%d,opcode=%s,arg=%s\n",nodeId,opcode->valuestring,arg->valuestring);
snprintf(valBuff,sizeof(valBuff),"%s",arg->valuestring); snprintf(valBuff,sizeof(valBuff),"%s",arg->valuestring);
}else if(arg->type==cJSON_Number){ }else if(arg->type==cJSON_Number){
...@@ -195,7 +200,7 @@ static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t * ...@@ -195,7 +200,7 @@ static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t *
{ {
cJSON *msg = NULL; cJSON *msg = NULL;
cJSON *arg = NULL; cJSON *arg = NULL;
int ignore = 0;
int nodeId = -1; int nodeId = -1;
char nodeBuff[33] = {0}; char nodeBuff[33] = {0};
...@@ -227,11 +232,23 @@ static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t * ...@@ -227,11 +232,23 @@ static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t *
memset(nodeBuff,0,sizeof(nodeBuff)); memset(nodeBuff,0,sizeof(nodeBuff));
snprintf(nodeBuff,sizeof(nodeBuff),"%d",nodeId); snprintf(nodeBuff,sizeof(nodeBuff),"%d",nodeId);
//printf("----------------------[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *motorPosCJSON = cJSON_GetObjectItem(arg,"motorPos");
//printf("----------------------[%s][%d]\n",__FUNCTION__,__LINE__);
if(motorPosCJSON != NULL&& motorPosCJSON->type == cJSON_String){//窗帘电机上报的position与设置的不一致,忽略上报
//printf("----------------------[%s][%d]s_motorPostion:%d\n",__FUNCTION__,__LINE__,s_motorPostion);
//printf("----------------------[%s][%d]atoi(motorPosCJSON->valuestring):%d\n",__FUNCTION__,__LINE__,atoi(motorPosCJSON->valuestring));
if(s_motorPostion != atoi(motorPosCJSON->valuestring) && s_motorPostion != -1){
ignore = 1;
}
}
//printf("----------------------[%s][%d]\n",__FUNCTION__,__LINE__);
msg=old_ccu_msg_build_json(nodeBuff,devNode->syn_opcode,NULL,arg); msg=old_ccu_msg_build_json(nodeBuff,devNode->syn_opcode,NULL,arg);
if(!ignore){
send_msg_to_module(msg); send_msg_to_module(msg);
s_motorPostion = -1;
}
cJSON_Delete(msg); cJSON_Delete(msg);
return 0; return 0;
} }
...@@ -289,7 +306,6 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev ...@@ -289,7 +306,6 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
debug_log(LOG_DEBUG_LEVEL,"[err] cfg file.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] cfg file.\n");
continue; continue;
} }
n_dataType = cJSON_GetObjectItem(n_item,"dataType"); n_dataType = cJSON_GetObjectItem(n_item,"dataType");
n_valueRange = cJSON_GetObjectItem(n_item,"valueRange"); n_valueRange = cJSON_GetObjectItem(n_item,"valueRange");
...@@ -356,8 +372,9 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev ...@@ -356,8 +372,9 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
kk_lan_replace_val_to_obj(n_item,valObj,"value"); 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){ if((args = ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,valObj))!=NULL){
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_lan_update_device_status(nodeId,opcode,args,devNode->syn_opcode); _kk_lan_update_device_status(nodeId,opcode,args,devNode->syn_opcode);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
} }
......
...@@ -216,8 +216,76 @@ int kk_motor_bind_db_delete_ex(const char* panelDCode) ...@@ -216,8 +216,76 @@ int kk_motor_bind_db_delete_ex(const char* panelDCode)
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
int kk_motor_bind_db_find_byDeviceCode(const char* panelDCode,struct kk_motor_bind_info* info,int max)
{
int listSize = 0;
sqlite3_stmt *stmt;
char *sqlCmd = NULL;
const unsigned char *motorDeviceCode = NULL;
int motor_ep = 0;
int dummyId = -1;
struct kk_motor_bind_info* pInfo = info;
kk_motor_bind_ctx_t *ctx = _kk_motor_bind_get_ctx();
const char *searchCmd = "select * from PanelBindMotor where panelDCode = '%s';";
_kk_motor_bind_lock();
sqlCmd = sqlite3_mprintf(searchCmd,panelDCode);
INFO_PRINT("Table searchCmd:%s\n",sqlCmd);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
motorDeviceCode = sqlite3_column_text(stmt, MOTOR_BIND_DB_MOTOR_DEVICECODE);
motor_ep = sqlite3_column_int(stmt, MOTOR_BIND_DB_MOTOR_EP);
dummyId = sqlite3_column_int(stmt, MOTOR_BIND_DB_DUMMYID);
memcpy(pInfo->deviceCode,motorDeviceCode,strlen(motorDeviceCode));
pInfo->epNum = motor_ep;
pInfo->dummyId = dummyId;
INFO_PRINT("listSize=%d,motorDeviceCode=%s,motor_ep=%d,dummyId=%d\n",listSize,motorDeviceCode,motor_ep,dummyId);
if(++listSize>=max){
break;
}
pInfo++;
}
sqlite3_finalize(stmt);
_kk_motor_bind_unlock();
return listSize;
}
int kk_motor_bind_db_find_byMotorDeviceCode(const char* motorCode,struct kk_motor_bind_info* info,int max)
{
int listSize = 0;
sqlite3_stmt *stmt;
char *sqlCmd = NULL;
const unsigned char *panelDeviceCode = NULL;
int motor_ep = 0;
int dummyId = -1;
struct kk_motor_bind_info* pInfo = info;
kk_motor_bind_ctx_t *ctx = _kk_motor_bind_get_ctx();
const char *searchCmd = "select * from PanelBindMotor where motorDCode = '%s';";
_kk_motor_bind_lock();
sqlCmd = sqlite3_mprintf(searchCmd,motorCode);
INFO_PRINT("Table searchCmd:%s\n",sqlCmd);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
panelDeviceCode = sqlite3_column_text(stmt, MOTOR_BIND_DB_PANEL_DEVICECODE);
motor_ep = sqlite3_column_int(stmt, MOTOR_BIND_DB_MOTOR_EP);
dummyId = sqlite3_column_int(stmt, MOTOR_BIND_DB_DUMMYID);
memcpy(pInfo->deviceCode,panelDeviceCode,strlen(panelDeviceCode));
pInfo->epNum = motor_ep;
pInfo->dummyId = dummyId;
INFO_PRINT("listSize=%d,panelDeviceCode=%s,motor_ep=%d,dummyId=%d\n",listSize,panelDeviceCode,motor_ep,dummyId);
if(++listSize>=max){
break;
}
pInfo++;
}
sqlite3_finalize(stmt);
_kk_motor_bind_unlock();
return listSize;
}
int kk_motor_bind_db_find(const char* panelDCode,int panelEpNum,struct kk_motor_bind_info* info,int max) int kk_motor_bind_db_find(const char* panelDCode,int panelEpNum,struct kk_motor_bind_info* info,int max)
{ {
int listSize = 0; int listSize = 0;
...@@ -241,8 +309,7 @@ int kk_motor_bind_db_find(const char* panelDCode,int panelEpNum,struct kk_motor_ ...@@ -241,8 +309,7 @@ int kk_motor_bind_db_find(const char* panelDCode,int panelEpNum,struct kk_motor_
motorDeviceCode = sqlite3_column_text(stmt, MOTOR_BIND_DB_MOTOR_DEVICECODE); motorDeviceCode = sqlite3_column_text(stmt, MOTOR_BIND_DB_MOTOR_DEVICECODE);
motor_ep = sqlite3_column_int(stmt, MOTOR_BIND_DB_MOTOR_EP); motor_ep = sqlite3_column_int(stmt, MOTOR_BIND_DB_MOTOR_EP);
dummyId = sqlite3_column_int(stmt, MOTOR_BIND_DB_DUMMYID); dummyId = sqlite3_column_int(stmt, MOTOR_BIND_DB_DUMMYID);
memset((char*)pInfo,0,sizeof(*pInfo)); memcpy(pInfo->deviceCode,motorDeviceCode,strlen(motorDeviceCode));
snprintf(pInfo->deviceCode,sizeof(*pInfo),"%s",motorDeviceCode);
pInfo->epNum = motor_ep; pInfo->epNum = motor_ep;
pInfo->dummyId = dummyId; pInfo->dummyId = dummyId;
INFO_PRINT("listSize=%d,motorDeviceCode=%s,motor_ep=%d,dummyId=%d\n",listSize,motorDeviceCode,motor_ep,dummyId); INFO_PRINT("listSize=%d,motorDeviceCode=%s,motor_ep=%d,dummyId=%d\n",listSize,motorDeviceCode,motor_ep,dummyId);
...@@ -280,8 +347,7 @@ int kk_motor_bind_db_find_ex(int dummyId,struct kk_motor_bind_info* info,int max ...@@ -280,8 +347,7 @@ int kk_motor_bind_db_find_ex(int dummyId,struct kk_motor_bind_info* info,int max
while(sqlite3_step(stmt) == SQLITE_ROW){ while(sqlite3_step(stmt) == SQLITE_ROW){
motorDeviceCode = sqlite3_column_text(stmt, MOTOR_BIND_DB_MOTOR_DEVICECODE); motorDeviceCode = sqlite3_column_text(stmt, MOTOR_BIND_DB_MOTOR_DEVICECODE);
motor_ep = sqlite3_column_int(stmt, MOTOR_BIND_DB_MOTOR_EP); motor_ep = sqlite3_column_int(stmt, MOTOR_BIND_DB_MOTOR_EP);
memset((char*)pInfo,0,sizeof(*pInfo)); memcpy(pInfo->deviceCode,motorDeviceCode,strlen(motorDeviceCode));
snprintf(pInfo->deviceCode,sizeof(*pInfo),"%s",motorDeviceCode);
pInfo->epNum = motor_ep; pInfo->epNum = motor_ep;
INFO_PRINT("listSize=%d,motorDeviceCode=%s,motor_ep=%d\n",listSize,motorDeviceCode,motor_ep); INFO_PRINT("listSize=%d,motorDeviceCode=%s,motor_ep=%d\n",listSize,motorDeviceCode,motor_ep);
...@@ -332,7 +398,8 @@ int kk_motor_bind_db_delete_by_deviceCode(const char* deviceCode) ...@@ -332,7 +398,8 @@ int kk_motor_bind_db_delete_by_deviceCode(const char* deviceCode)
int rc = 0; int rc = 0;
char *zErrMsg = 0; char *zErrMsg = 0;
kk_motor_bind_ctx_t *ctx = _kk_motor_bind_get_ctx(); kk_motor_bind_ctx_t *ctx = _kk_motor_bind_get_ctx();
//printf("---------------------------->[%s][%d]\n",__FUNCTION__,__LINE__);
kk_service_delete_bind_2gw(deviceCode,1);
_kk_motor_bind_lock(); _kk_motor_bind_lock();
sqlCmd = sqlite3_mprintf(deleteCmd,deviceCode); sqlCmd = sqlite3_mprintf(deleteCmd,deviceCode);
...@@ -346,7 +413,8 @@ int kk_motor_bind_db_delete_by_deviceCode(const char* deviceCode) ...@@ -346,7 +413,8 @@ int kk_motor_bind_db_delete_by_deviceCode(const char* deviceCode)
} }
sqlite3_free(sqlCmd); sqlite3_free(sqlCmd);
_kk_motor_bind_unlock(); _kk_motor_bind_unlock();
//printf("---------------------------->[%s][%d]\n",__FUNCTION__,__LINE__);
kk_service_delete_bind_2gw(deviceCode,0);
kk_motor_bind_db_delete_ex(deviceCode); kk_motor_bind_db_delete_ex(deviceCode);
return SUCCESS_RETURN; return SUCCESS_RETURN;
......
...@@ -51,7 +51,7 @@ static int kk_service_get_reply(char *deviceCode,char *productCode,char *msgId,d ...@@ -51,7 +51,7 @@ static int kk_service_get_reply(char *deviceCode,char *productCode,char *msgId,d
cJSON_AddNumberToObject(paramInfo, "data", (double)param1); cJSON_AddNumberToObject(paramInfo, "data", (double)param1);
}else if(strcmp(type,"ChildLockState") == 0){ }else if(strcmp(type,"ChildLockState") == 0){
cJSON_AddNumberToObject(paramInfo, "ChildLockState", (int)param1); cJSON_AddNumberToObject(paramInfo, "ChildLockState", (int)param1);
}else if(strcmp(type,"PowerMemory") == 0){ }else if(strcmp(type,"PowerDownSave") == 0){
cJSON_AddNumberToObject(paramInfo, "PowerMemory", (int)param1); cJSON_AddNumberToObject(paramInfo, "PowerMemory", (int)param1);
cJSON_AddNumberToObject(paramInfo, "Mode", (int)1); cJSON_AddNumberToObject(paramInfo, "Mode", (int)1);
}else if(strcmp(type,"Screensaver") == 0){ }else if(strcmp(type,"Screensaver") == 0){
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* *
*文件名称: midware.c *文件名称: midware.c
*内容摘要: 数据中转中心,上对云端,下对网关,承上启下 *内容摘要: 数据中转中心,上对云端,下对网关,承上启下
*其他说明: *其他说明:
*当前版本: *当前版本:
*************************************************************/ *************************************************************/
...@@ -44,24 +44,24 @@ ...@@ -44,24 +44,24 @@
#include "kk_motor_bind_db.h" #include "kk_motor_bind_db.h"
int g_timezone = 8; int g_timezone = 8;
char * g_filerToPlatTable[] = char * g_filerToPlatTable[] =
{ {
(char *){KK_REGISTER_TOPIC_REPLY}, (char *){KK_REGISTER_TOPIC_REPLY},
(char *){KK_ADD_TOPIC_REPLY}, (char *){KK_ADD_TOPIC_REPLY},
(char *){KK_LOGIN_TOPIC_REPLY}, (char *){KK_LOGIN_TOPIC_REPLY},
(char *){KK_THING_SERVICE_PROPERTY_GET}, (char *){KK_THING_SERVICE_PROPERTY_GET},
(char *){KK_THING_CLOUDSTATE_MSG}, (char *){KK_THING_CLOUDSTATE_MSG},
(char *){KK_THING_CLOUDHB_MSG}, (char *){KK_THING_CLOUDHB_MSG},
(char *){KK_THING_SERVICE_ADDSCENC}, (char *){KK_THING_SERVICE_ADDSCENC},
(char *){KK_THING_SERVICE_UPDATESCENC}, (char *){KK_THING_SERVICE_UPDATESCENC},
(char *){KK_THING_SERVICE_DELETESCENC}, (char *){KK_THING_SERVICE_DELETESCENC},
(char *){KK_THING_SERVICE_NEGATIVE}, (char *){KK_THING_SERVICE_NEGATIVE},
(char *){KK_THING_SERVICE_SYNCINFO}, (char *){KK_THING_SERVICE_SYNCINFO},
(char *){KK_THING_SERVICE_BINDSCENE}, (char *){KK_THING_SERVICE_BINDSCENE},
(char *){KK_THING_SERVICE_UNBINDSBUTTTON}, (char *){KK_THING_SERVICE_UNBINDSBUTTTON},
(char *){KK_THING_SERVICE_ACTIVEBUTTON}, (char *){KK_THING_SERVICE_ACTIVEBUTTON},
(char *){KK_THING_SERVICE_HISTORYALARM}, (char *){KK_THING_SERVICE_HISTORYALARM},
(char *){KK_THING_SERVICE_DEL_HISTORYALARM}, (char *){KK_THING_SERVICE_DEL_HISTORYALARM},
}; };
static char s_ccuid[DEVICE_CODE_LEN] = {0}; static char s_ccuid[DEVICE_CODE_LEN] = {0};
static char s_Version[VERSION_MAXLEN] = {0}; static char s_Version[VERSION_MAXLEN] = {0};
...@@ -111,7 +111,7 @@ int HAL_GetVersion(_OU_ char *version) ...@@ -111,7 +111,7 @@ int HAL_GetVersion(_OU_ char *version)
} }
int HAL_Get_ccuid(_OU_ char *device_code) int HAL_Get_ccuid(_OU_ char *device_code)
{ {
strncpy(device_code, s_ccuid, strlen(s_ccuid)); strncpy(device_code, s_ccuid, strlen(s_ccuid));
printf("HAL_Get_ccuid:%s\n",s_ccuid); printf("HAL_Get_ccuid:%s\n",s_ccuid);
return strlen(s_ccuid); return strlen(s_ccuid);
...@@ -208,7 +208,7 @@ void kk_print_long_data(char *data,int len) ...@@ -208,7 +208,7 @@ void kk_print_long_data(char *data,int len)
pTmp = malloc(KK_PRINTF_PER_LEN+1); pTmp = malloc(KK_PRINTF_PER_LEN+1);
if(pTmp == NULL){ if(pTmp == NULL){
return; return;
} }
while(1) while(1)
{ {
memset(pTmp,0x0,KK_PRINTF_PER_LEN+1); memset(pTmp,0x0,KK_PRINTF_PER_LEN+1);
...@@ -261,15 +261,15 @@ void split(char *src,const char *separator,char **dest,int *num) { ...@@ -261,15 +261,15 @@ void split(char *src,const char *separator,char **dest,int *num) {
if (src == NULL || strlen(src) == 0) if (src == NULL || strlen(src) == 0)
return; return;
if (separator == NULL || strlen(separator) == 0) if (separator == NULL || strlen(separator) == 0)
return; return;
pNext = strtok(src,separator); pNext = strtok(src,separator);
while(pNext != NULL) { while(pNext != NULL) {
*dest++ = pNext; *dest++ = pNext;
++count; ++count;
pNext = strtok(NULL,separator); pNext = strtok(NULL,separator);
} }
*num = count; *num = count;
} }
/************************************************************ /************************************************************
*功能描述:属性参数校验 *功能描述:属性参数校验
*输入参数:payload:消息内容 *输入参数:payload:消息内容
...@@ -280,9 +280,9 @@ void split(char *src,const char *separator,char **dest,int *num) { ...@@ -280,9 +280,9 @@ void split(char *src,const char *separator,char **dest,int *num) {
*************************************************************/ *************************************************************/
static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
cJSON *params = NULL; cJSON *params = NULL;
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
kk_tsl_data_t *property = NULL; kk_tsl_data_t *property = NULL;
cJSON *propertyItem = NULL; cJSON *propertyItem = NULL;
cJSON *epNum = NULL; cJSON *epNum = NULL;
int epNumInt = 1; int epNumInt = 1;
int num = 0; int num = 0;
...@@ -308,7 +308,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -308,7 +308,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
if(res != SUCCESS_RETURN) if(res != SUCCESS_RETURN)
{ {
ERROR_PRINT(" error res:%d\n",res); ERROR_PRINT(" error res:%d\n",res);
} }
char tmpValue[16] = {0}; char tmpValue[16] = {0};
sprintf(tmpValue,"%d",level); sprintf(tmpValue,"%d",level);
kk_property_db_update_value(deviceCode,"SensorType",tmpValue); kk_property_db_update_value(deviceCode,"SensorType",tmpValue);
...@@ -346,12 +346,12 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -346,12 +346,12 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
complex_struct = property->data_value.value; complex_struct = property->data_value.value;
for (index = 0; index < complex_struct->size; index++) { for (index = 0; index < complex_struct->size; index++) {
current_data = (kk_tsl_data_t *)complex_struct->value + index; current_data = (kk_tsl_data_t *)complex_struct->value + index;
cJSON *propertyItem_1 = NULL; cJSON *propertyItem_1 = NULL;
propertyItem_1 = cJSON_GetObjectItem(propertyItem, current_data->identifier); propertyItem_1 = cJSON_GetObjectItem(propertyItem, current_data->identifier);
if(propertyItem_1 == NULL){ if(propertyItem_1 == NULL){
continue; continue;
} }
if(current_data->data_value.type != KK_TSL_DATA_TYPE_STRUCT){ if(current_data->data_value.type != KK_TSL_DATA_TYPE_STRUCT){
if(current_data->data_value.type == KK_TSL_DATA_TYPE_INT){ if(current_data->data_value.type == KK_TSL_DATA_TYPE_INT){
value = propertyItem_1->valueint; value = propertyItem_1->valueint;
...@@ -362,7 +362,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -362,7 +362,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
} }
else if(current_data->data_value.type == KK_TSL_DATA_TYPE_TEXT){ else if(current_data->data_value.type == KK_TSL_DATA_TYPE_TEXT){
if(strlen(propertyItem_1->valuestring) > current_data->data_value.length ){ if(strlen(propertyItem_1->valuestring) > current_data->data_value.length ){
ERROR_PRINT("ERROR !!!strlen(propertyItem_1->valuestring):%d,current_data->data_value.length:%d\n",strlen(propertyItem_1->valuestring),current_data->data_value.length); ERROR_PRINT("ERROR !!!strlen(propertyItem_1->valuestring):%d,current_data->data_value.length:%d\n",strlen(propertyItem_1->valuestring),current_data->data_value.length);
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
...@@ -375,7 +375,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -375,7 +375,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
complex_struct_1 = current_data->data_value.value; complex_struct_1 = current_data->data_value.value;
for(index_1 = 0; index_1 < complex_struct_1->size; index_1++){ for(index_1 = 0; index_1 < complex_struct_1->size; index_1++){
current_data_1 = (kk_tsl_data_t *)complex_struct_1->value + index_1; current_data_1 = (kk_tsl_data_t *)complex_struct_1->value + index_1;
cJSON *propertyItem_2 = NULL; cJSON *propertyItem_2 = NULL;
propertyItem_2 = cJSON_GetObjectItem(propertyItem_1, current_data_1->identifier); propertyItem_2 = cJSON_GetObjectItem(propertyItem_1, current_data_1->identifier);
if(propertyItem_2 == NULL){ if(propertyItem_2 == NULL){
continue; continue;
...@@ -389,7 +389,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -389,7 +389,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
} }
else if(current_data_1->data_value.type == KK_TSL_DATA_TYPE_TEXT){ else if(current_data_1->data_value.type == KK_TSL_DATA_TYPE_TEXT){
if(strlen(propertyItem_2->valuestring) > current_data_1->data_value.length ){ if(strlen(propertyItem_2->valuestring) > current_data_1->data_value.length ){
ERROR_PRINT("ERROR !!!strlen(propertyItem_2->valuestring):%d,propertyItem_2->data_value.length:%d\n",strlen(propertyItem_2->valuestring),current_data_1->data_value.length); ERROR_PRINT("ERROR !!!strlen(propertyItem_2->valuestring):%d,propertyItem_2->data_value.length:%d\n",strlen(propertyItem_2->valuestring),current_data_1->data_value.length);
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
...@@ -429,12 +429,12 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -429,12 +429,12 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
INFO_PRINT("-----------------KK_TSL_DATA_TYPE_TEXT-------------------\n"); INFO_PRINT("-----------------KK_TSL_DATA_TYPE_TEXT-------------------\n");
cJSON_AddStringToObject(params,property->identifier,propertyItem->valuestring); cJSON_AddStringToObject(params,property->identifier,propertyItem->valuestring);
cJSON_DeleteItemFromObject(params, propertiesbuf[0]); cJSON_DeleteItemFromObject(params, propertiesbuf[0]);
} }
else if(property->data_value.type == KK_TSL_DATA_TYPE_ENUM || property->data_value.type == KK_TSL_DATA_TYPE_BOOL){ else if(property->data_value.type == KK_TSL_DATA_TYPE_ENUM || property->data_value.type == KK_TSL_DATA_TYPE_BOOL){
INFO_PRINT("-----------------KK_TSL_DATA_TYPE_ENUM-------------------\n"); INFO_PRINT("-----------------KK_TSL_DATA_TYPE_ENUM-------------------\n");
cJSON_AddNumberToObject(params,property->identifier,propertyItem->valueint); cJSON_AddNumberToObject(params,property->identifier,propertyItem->valueint);
cJSON_DeleteItemFromObject(params, propertiesbuf[0]); cJSON_DeleteItemFromObject(params, propertiesbuf[0]);
} }
} }
} }
} }
...@@ -444,7 +444,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -444,7 +444,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
//ERROR_PRINT("ERROR !!!property->accessMode:%s\n",property->accessMode); //ERROR_PRINT("ERROR !!!property->accessMode:%s\n",property->accessMode);
//return INVALID_PARAMETER; //return INVALID_PARAMETER;
//} //}
//} //}
} }
...@@ -463,7 +463,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){ ...@@ -463,7 +463,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
static int kk_panel_bind_motor_delete(const char* deviceCode,int dummyId) static int kk_panel_bind_motor_delete(const char* deviceCode,int dummyId)
{ {
int res = 0; int res = 0;
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
dm_mgr_dev_node_t *gw_node = NULL; dm_mgr_dev_node_t *gw_node = NULL;
char msgId[MSG_MAX_LEN] = {0}; char msgId[MSG_MAX_LEN] = {0};
char sceneId[33] = {0}; char sceneId[33] = {0};
...@@ -503,7 +503,7 @@ static int kk_panel_bind_motor_delete(const char* deviceCode,int dummyId) ...@@ -503,7 +503,7 @@ static int kk_panel_bind_motor_delete(const char* deviceCode,int dummyId)
kk_sendData2gw(data,strlen(data), node->fatherDeviceCode); kk_sendData2gw(data,strlen(data), node->fatherDeviceCode);
cJSON_Delete(root); cJSON_Delete(root);
free(data); free(data);
//printf("---------------------------->[%s][%d]\n",__FUNCTION__,__LINE__);
return 0; return 0;
} }
...@@ -512,7 +512,7 @@ static int kk_panel_bind_motor_delete(const char* deviceCode,int dummyId) ...@@ -512,7 +512,7 @@ static int kk_panel_bind_motor_delete(const char* deviceCode,int dummyId)
static int kk_panel_bind_motor_add_actions(const char* deviceCode,cJSON* actions,int dummyId) static int kk_panel_bind_motor_add_actions(const char* deviceCode,cJSON* actions,int dummyId)
{ {
int res = 0; int res = 0;
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
dm_mgr_dev_node_t *gw_node = NULL; dm_mgr_dev_node_t *gw_node = NULL;
char msgId[MSG_MAX_LEN] = {0}; char msgId[MSG_MAX_LEN] = {0};
char sceneId[33] = {0}; char sceneId[33] = {0};
...@@ -522,7 +522,7 @@ static int kk_panel_bind_motor_add_actions(const char* deviceCode,cJSON* actions ...@@ -522,7 +522,7 @@ static int kk_panel_bind_motor_add_actions(const char* deviceCode,cJSON* actions
cJSON *info = cJSON_CreateObject(); cJSON *info = cJSON_CreateObject();
cJSON *payload = cJSON_CreateObject(); cJSON *payload = cJSON_CreateObject();
cJSON *paras = cJSON_CreateObject(); cJSON *paras = cJSON_CreateObject();
if(SUCCESS_RETURN!=dm_mgr_get_device_by_devicecode((char*)deviceCode,&node)){ if(SUCCESS_RETURN!=dm_mgr_get_device_by_devicecode((char*)deviceCode,&node)){
return -1; return -1;
} }
...@@ -562,8 +562,9 @@ static int kk_panel_bind_motor_add(const char* deviceCode,int epNum,int dummyId) ...@@ -562,8 +562,9 @@ static int kk_panel_bind_motor_add(const char* deviceCode,int epNum,int dummyId)
cJSON *item = NULL; cJSON *item = NULL;
struct kk_motor_bind_info *info = (struct kk_motor_bind_info *)malloc(sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX); struct kk_motor_bind_info *info = (struct kk_motor_bind_info *)malloc(sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX);
memset(info,0,sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX);
int info_size = kk_motor_bind_db_find_ex(dummyId,info,KK_MOTOR_BIND_INFO_MAX); int info_size = kk_motor_bind_db_find_ex(dummyId,info,KK_MOTOR_BIND_INFO_MAX);
cJSON *actionsAry = cJSON_CreateArray(); cJSON *actionsAry = cJSON_CreateArray();
item = cJSON_CreateObject(); item = cJSON_CreateObject();
cJSON_AddStringToObject(item,"deviceCode",deviceCode); cJSON_AddStringToObject(item,"deviceCode",deviceCode);
...@@ -579,8 +580,34 @@ static int kk_panel_bind_motor_add(const char* deviceCode,int epNum,int dummyId) ...@@ -579,8 +580,34 @@ static int kk_panel_bind_motor_add(const char* deviceCode,int epNum,int dummyId)
} }
kk_panel_bind_motor_add_actions(deviceCode,actionsAry,dummyId); kk_panel_bind_motor_add_actions(deviceCode,actionsAry,dummyId);
free(info); free(info);
return 0;
} }
int kk_service_delete_bind_2gw(char *deviceCode,int type)//type 0:panel;1:motor
{
int info_size = 0;
int i = 0;
struct kk_motor_bind_info *info = (struct kk_motor_bind_info *)malloc(sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX);
if(info == NULL){
return -1;
}
memset(info,0x0,sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX);
if(type == 0){
//printf("---------------------------->[%s][%d]\n",__FUNCTION__,__LINE__);
info_size = kk_motor_bind_db_find_byDeviceCode(deviceCode,info,KK_MOTOR_BIND_INFO_MAX);
}else{
//printf("---------------------------->[%s][%d]\n",__FUNCTION__,__LINE__);
info_size = kk_motor_bind_db_find_byMotorDeviceCode(deviceCode,info,KK_MOTOR_BIND_INFO_MAX);
}
//printf("-------------------------info_size:%d--->[%s][%d]\n",info_size,__FUNCTION__,__LINE__);
for(i=0;i<info_size;i++){
kk_panel_bind_motor_delete(deviceCode,info[i].dummyId);
}
free(info);
info = NULL;
return 0;
}
int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * msgId,int act) int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * msgId,int act)
{ {
int i; int i;
...@@ -612,7 +639,7 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms ...@@ -612,7 +639,7 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms
} }
if((actions = cJSON_GetObjectItem(param,"actions"))==NULL|| if((actions = cJSON_GetObjectItem(param,"actions"))==NULL||
actions->type!=cJSON_Array){ actions->type!=cJSON_Array){
INFO_PRINT("[ERR] actions \n"); INFO_PRINT("[ERR] actions \n");
return -1; return -1;
} }
...@@ -621,16 +648,17 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms ...@@ -621,16 +648,17 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms
if(act==KK_SERVICE_REBIND_MOTORS){ if(act==KK_SERVICE_REBIND_MOTORS){
struct kk_motor_bind_info *info = (struct kk_motor_bind_info *)malloc(sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX); struct kk_motor_bind_info *info = (struct kk_motor_bind_info *)malloc(sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX);
memset(info,0x0,sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX);
int info_size = kk_motor_bind_db_find(panel_dCode->valuestring,panel_ep,info,KK_MOTOR_BIND_INFO_MAX); int info_size = kk_motor_bind_db_find(panel_dCode->valuestring,panel_ep,info,KK_MOTOR_BIND_INFO_MAX);
for(int i=0;i<info_size;i++){ for(int i=0;i<info_size;i++){
kk_panel_bind_motor_delete(panel_dCode->valuestring,info[i].dummyId); kk_panel_bind_motor_delete(panel_dCode->valuestring,info[i].dummyId);
} }
free(info); free(info);
kk_motor_bind_db_delete_ex(panel_dCode->valuestring); kk_motor_bind_db_delete_ex(panel_dCode->valuestring);
} }
actionCnt = cJSON_GetArraySize(actions); actionCnt = cJSON_GetArraySize(actions);
for(i=0;i<actionCnt;i++){ for(i=0;i<actionCnt;i++){
actionItem = cJSON_GetArrayItem(actions,i); actionItem = cJSON_GetArrayItem(actions,i);
...@@ -638,7 +666,7 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms ...@@ -638,7 +666,7 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms
INFO_PRINT("[ERR] item \n"); INFO_PRINT("[ERR] item \n");
continue; continue;
} }
motor_dCode = cJSON_GetObjectItem(actionItem,"deviceCode"); motor_dCode = cJSON_GetObjectItem(actionItem,"deviceCode");
if(motor_dCode==NULL||motor_dCode->type!=cJSON_String){ if(motor_dCode==NULL||motor_dCode->type!=cJSON_String){
INFO_PRINT("[ERR] motor_dCode \n"); INFO_PRINT("[ERR] motor_dCode \n");
...@@ -666,8 +694,9 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms ...@@ -666,8 +694,9 @@ int kk_service_panel_bind_motor_handle(cJSON *deviceCode,cJSON *param,cJSON * ms
int dummyId=kk_motor_bind_db_find_dummyId(panel_dCode->valuestring,panel_ep,motor_dCodeStr,motor_ep); int dummyId=kk_motor_bind_db_find_dummyId(panel_dCode->valuestring,panel_ep,motor_dCodeStr,motor_ep);
if(dummyId!=-1){ if(dummyId!=-1){
kk_panel_bind_motor_delete(panel_dCode->valuestring,dummyId); kk_panel_bind_motor_delete(panel_dCode->valuestring,dummyId);
kk_motor_bind_db_delete(panel_dCode->valuestring,panel_ep,motor_dCodeStr,motor_ep);
} }
kk_motor_bind_db_delete(panel_dCode->valuestring,panel_ep,motor_dCodeStr,motor_ep);
} }
} }
...@@ -689,9 +718,9 @@ int kk_service_query_bind_motor(cJSON *deviceCode,cJSON *param,struct kk_motor_b ...@@ -689,9 +718,9 @@ int kk_service_query_bind_motor(cJSON *deviceCode,cJSON *param,struct kk_motor_b
if(deviceCode==NULL||deviceCode->type!=cJSON_String){ if(deviceCode==NULL||deviceCode->type!=cJSON_String){
return -1; return -1;
} }
panel_dCode = deviceCode; panel_dCode = deviceCode;
if(param!=NULL){ if(param!=NULL){
if(param->type!=cJSON_Object){ if(param->type!=cJSON_Object){
return -1; return -1;
...@@ -707,7 +736,7 @@ int kk_service_query_bind_motor(cJSON *deviceCode,cJSON *param,struct kk_motor_b ...@@ -707,7 +736,7 @@ int kk_service_query_bind_motor(cJSON *deviceCode,cJSON *param,struct kk_motor_b
} }
info_size = kk_motor_bind_db_find(panel_dCode->valuestring,panel_ep,info,max); info_size = kk_motor_bind_db_find(panel_dCode->valuestring,panel_ep,info,max);
return info_size; return info_size;
} }
...@@ -727,22 +756,22 @@ int kk_dm_device_subdev_filter(char *data) ...@@ -727,22 +756,22 @@ int kk_dm_device_subdev_filter(char *data)
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse"); WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
return -1; return -1;
} }
if((info_root = cJSON_GetObjectItem(json, "info")) == NULL) if((info_root = cJSON_GetObjectItem(json, "info")) == NULL)
return -1; return -1;
if((typeJson = cJSON_GetObjectItem(info_root, "msgtype"))== NULL) if((typeJson = cJSON_GetObjectItem(info_root, "msgtype"))== NULL)
return -1; return -1;
if((payload = cJSON_GetObjectItem(json, "payload")) == NULL) if((payload = cJSON_GetObjectItem(json, "payload")) == NULL)
return -1; return -1;
payload_Str = cJSON_Print(payload); payload_Str = cJSON_Print(payload);
if((deviceCode = cJSON_GetObjectItem(info_root, "deviceCode")) == NULL) if((deviceCode = cJSON_GetObjectItem(info_root, "deviceCode")) == NULL)
return -1; return -1;
if(strcmp(typeJson->valuestring,KK_THING_SERVICE_REBIND_MOTORS) == 0){ if(strcmp(typeJson->valuestring,KK_THING_SERVICE_REBIND_MOTORS) == 0){
INFO_PRINT("REBIND_MOTORS \n"); INFO_PRINT("REBIND_MOTORS \n");
cJSON *msgId = cJSON_GetObjectItem(payload, "msgId"); cJSON *msgId = cJSON_GetObjectItem(payload, "msgId");
cJSON *paramStr = cJSON_GetObjectItem(payload,"params"); cJSON *paramStr = cJSON_GetObjectItem(payload,"params");
kk_service_panel_bind_motor_handle(deviceCode,paramStr,msgId,KK_SERVICE_REBIND_MOTORS); kk_service_panel_bind_motor_handle(deviceCode,paramStr,msgId,KK_SERVICE_REBIND_MOTORS);
kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_REBIND_MOTORS_REPLY); kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_REBIND_MOTORS_REPLY);
} }
...@@ -750,7 +779,7 @@ int kk_dm_device_subdev_filter(char *data) ...@@ -750,7 +779,7 @@ int kk_dm_device_subdev_filter(char *data)
INFO_PRINT("ADDBIND_MOTOR \n"); INFO_PRINT("ADDBIND_MOTOR \n");
deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR); deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR);
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID); cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR); cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
kk_service_panel_bind_motor_handle(deviceCode,paramStr,msgId,KK_SERVICE_ADDBIND_MOTORS); kk_service_panel_bind_motor_handle(deviceCode,paramStr,msgId,KK_SERVICE_ADDBIND_MOTORS);
...@@ -759,14 +788,14 @@ int kk_dm_device_subdev_filter(char *data) ...@@ -759,14 +788,14 @@ int kk_dm_device_subdev_filter(char *data)
INFO_PRINT("UNBIND_MOTORS \n"); INFO_PRINT("UNBIND_MOTORS \n");
deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR); deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR);
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID); cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR); cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
kk_service_panel_bind_motor_handle(deviceCode,paramStr,msgId,KK_SERVICE_UNBIND_MOTORS); kk_service_panel_bind_motor_handle(deviceCode,paramStr,msgId,KK_SERVICE_UNBIND_MOTORS);
kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_UNBIND_MOTORS_REPLY); kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_UNBIND_MOTORS_REPLY);
}else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_QUERY_BIND_MOTORS) == 0){ }else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_QUERY_BIND_MOTORS) == 0){
INFO_PRINT("QUERY_BIND_MOTORS \n"); INFO_PRINT("QUERY_BIND_MOTORS \n");
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID); cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR); cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
struct kk_motor_bind_info *info = (struct kk_motor_bind_info *)malloc(sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX); struct kk_motor_bind_info *info = (struct kk_motor_bind_info *)malloc(sizeof(struct kk_motor_bind_info)*KK_MOTOR_BIND_INFO_MAX);
...@@ -782,11 +811,11 @@ int kk_dm_device_subdev_filter(char *data) ...@@ -782,11 +811,11 @@ int kk_dm_device_subdev_filter(char *data)
kk_service_common_reply_ex(info_root,msgId,KK_THING_SERVICE_QUERY_BIND_MOTORS_REPLY,ary); kk_service_common_reply_ex(info_root,msgId,KK_THING_SERVICE_QUERY_BIND_MOTORS_REPLY,ary);
free(info); free(info);
}else{ }else{
return -1; return -1;
} }
return 0; return 0;
} }
...@@ -800,7 +829,7 @@ static int kk_get_ccu_info_reply(cJSON *param,char *msgType) ...@@ -800,7 +829,7 @@ static int kk_get_ccu_info_reply(cJSON *param,char *msgType)
if(param == NULL){ if(param == NULL){
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
cJSON *info = cJSON_CreateObject(); cJSON *info = cJSON_CreateObject();
cJSON_AddStringToObject(info, MSG_TYPE_STR, msgType); cJSON_AddStringToObject(info, MSG_TYPE_STR, msgType);
char *infff=cJSON_Print(info); char *infff=cJSON_Print(info);
...@@ -848,7 +877,7 @@ void mid_cb(void* data, int len){ ...@@ -848,7 +877,7 @@ void mid_cb(void* data, int len){
} }
deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR); deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR);
type = cJSON_GetObjectItem(info_root, MSG_TYPE_STR); type = cJSON_GetObjectItem(info_root, MSG_TYPE_STR);
if (deviceCode == NULL || type == NULL){ if (deviceCode == NULL || type == NULL){
ERROR_PRINT(" params [%s] or [%s] can't find \n",MSG_DEVICE_CODE_STR, MSG_TYPE_STR); ERROR_PRINT(" params [%s] or [%s] can't find \n",MSG_DEVICE_CODE_STR, MSG_TYPE_STR);
cJSON_Delete(json); cJSON_Delete(json);
...@@ -860,7 +889,7 @@ void mid_cb(void* data, int len){ ...@@ -860,7 +889,7 @@ void mid_cb(void* data, int len){
cJSON_Delete(json); cJSON_Delete(json);
return; return;
} }
if (strcmp(type->valuestring, KK_THING_SERVICE_GET_CCU_INFO)==0){ if (strcmp(type->valuestring, KK_THING_SERVICE_GET_CCU_INFO)==0){
cJSON *param = dm_mgr_get_ccu_info(); cJSON *param = dm_mgr_get_ccu_info();
kk_get_ccu_info_reply(param,KK_THING_SERVICE_GET_CCU_INFO_REPLY); kk_get_ccu_info_reply(param,KK_THING_SERVICE_GET_CCU_INFO_REPLY);
...@@ -868,7 +897,7 @@ void mid_cb(void* data, int len){ ...@@ -868,7 +897,7 @@ void mid_cb(void* data, int len){
return; return;
} }
/*****属性设置需要先检测设置参数是否超出物模型给定范围*******/ /*****属性设置需要先检测设置参数是否超出物模型给定范围*******/
if (strcmp(type->valuestring, KK_THING_SERVICE_PROPERTY_SET)==0){ if (strcmp(type->valuestring, KK_THING_SERVICE_PROPERTY_SET)==0){
res = kk_property_set_data_check(payload,deviceCode->valuestring); res = kk_property_set_data_check(payload,deviceCode->valuestring);
...@@ -959,7 +988,7 @@ void mid2p_cb(void* data, int len, char* chalMark){ ...@@ -959,7 +988,7 @@ void mid2p_cb(void* data, int len, char* chalMark){
ERROR_PRINT("mid2p_cb malloc buf failed "); ERROR_PRINT("mid2p_cb malloc buf failed ");
return; return;
} }
memcpy(buf, data, len); memcpy(buf, data, len);
queue_msg->data = buf; queue_msg->data = buf;
memset(queue_msg->chalMark, 0, sizeof(queue_msg->chalMark)); memset(queue_msg->chalMark, 0, sizeof(queue_msg->chalMark));
...@@ -973,7 +1002,7 @@ void mid2p_cb(void* data, int len, char* chalMark){ ...@@ -973,7 +1002,7 @@ void mid2p_cb(void* data, int len, char* chalMark){
buf = NULL; buf = NULL;
return ; return ;
} }
//kk_ipc_send(IPC_MID2APP, data, len); //kk_ipc_send(IPC_MID2APP, data, len);
} }
} }
...@@ -1017,7 +1046,7 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char ...@@ -1017,7 +1046,7 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char
cJSON_AddStringToObject(info, MSG_TYPE_STR, "/thing/event/alarmNotify"); cJSON_AddStringToObject(info, MSG_TYPE_STR, "/thing/event/alarmNotify");
cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, node->deviceCode); cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, node->deviceCode);
cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, node->productCode); cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, node->productCode);
char *infff=cJSON_Print(info); char *infff=cJSON_Print(info);
cJSON *payload = cJSON_CreateObject(); cJSON *payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "method", "thing.event.alarmNotify"); cJSON_AddStringToObject(payload, "method", "thing.event.alarmNotify");
...@@ -1025,11 +1054,11 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char ...@@ -1025,11 +1054,11 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char
cJSON_AddStringToObject(payload, "identifier", "alarmNotify"); cJSON_AddStringToObject(payload, "identifier", "alarmNotify");
char msgId[64] = {0}; char msgId[64] = {0};
iotx_report_id(msgId); iotx_report_id(msgId);
cJSON_AddStringToObject(payload, "msgId", msgId); cJSON_AddStringToObject(payload, "msgId", msgId);
//char timerStr[16] = {0}; //char timerStr[16] = {0};
//HAL_GetTime_s(timerStr); //HAL_GetTime_s(timerStr);
cJSON_AddNumberToObject(payload, "time", HAL_GetTime_ms()); cJSON_AddNumberToObject(payload, "time", HAL_GetTime_ms());
cJSON *param = cJSON_CreateObject(); cJSON *param = cJSON_CreateObject();
if(strcmp(identifier,"BatteryAlarm") == 0){ if(strcmp(identifier,"BatteryAlarm") == 0){
cJSON_AddStringToObject(param, "LowBatteryState", "1"); cJSON_AddStringToObject(param, "LowBatteryState", "1");
...@@ -1054,7 +1083,7 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char ...@@ -1054,7 +1083,7 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char
} }
else if(strcmp(identifier,"SmokeSensorState") == 0 && atoi(valueBuf) == 0){ else if(strcmp(identifier,"SmokeSensorState") == 0 && atoi(valueBuf) == 0){
cJSON_AddStringToObject(param, "CommonAlarmState", "0"); cJSON_AddStringToObject(param, "CommonAlarmState", "0");
} }
else if(strcmp(identifier,"GasSensorState") == 0 && atoi(valueBuf) == 0){ else if(strcmp(identifier,"GasSensorState") == 0 && atoi(valueBuf) == 0){
cJSON_AddStringToObject(param, "CommonAlarmState", "0"); cJSON_AddStringToObject(param, "CommonAlarmState", "0");
} }
...@@ -1108,14 +1137,14 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char ...@@ -1108,14 +1137,14 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char
free(payload11); free(payload11);
free(infff); free(infff);
cJSON_Delete(payload); cJSON_Delete(payload);
cJSON_Delete(info); cJSON_Delete(info);
return 0; return 0;
} }
static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type) static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
{ {
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
kk_tsl_data_t *property = NULL; kk_tsl_data_t *property = NULL;
cJSON *propertyItem = NULL; cJSON *propertyItem = NULL;
int res = 0; int res = 0;
int idx = 0; int idx = 0;
int epNumInt = 0; int epNumInt = 0;
...@@ -1124,11 +1153,11 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type) ...@@ -1124,11 +1153,11 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
cJSON *eps = cJSON_GetObjectItem(params, "eps"); cJSON *eps = cJSON_GetObjectItem(params, "eps");
if(eps == NULL || eps->type != cJSON_Array){ if(eps == NULL || eps->type != cJSON_Array){
return FAIL_RETURN; return FAIL_RETURN;
} }
res = dm_mgr_get_device_by_devicecode(deviceCode,&node); res = dm_mgr_get_device_by_devicecode(deviceCode,&node);
if (res < SUCCESS_RETURN) { if (res < SUCCESS_RETURN) {
return FAIL_RETURN; return FAIL_RETURN;
} }
cJSON *client_list = eps->child; cJSON *client_list = eps->child;
while(client_list != NULL){ while(client_list != NULL){
cJSON *epNum = cJSON_GetObjectItem(client_list, "epNum"); cJSON *epNum = cJSON_GetObjectItem(client_list, "epNum");
...@@ -1171,7 +1200,7 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type) ...@@ -1171,7 +1200,7 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
kk_subAirSwitch_db_update_value(deviceCode,property->identifier,valBuf,epNumInt); kk_subAirSwitch_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
}else if(type == 2){ }else if(type == 2){
kk_subFreshAir_db_update_value(deviceCode,property->identifier,valBuf,epNumInt); kk_subFreshAir_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
} }
}else if(property->data_value.type == KK_TSL_DATA_TYPE_TEXT ){ }else if(property->data_value.type == KK_TSL_DATA_TYPE_TEXT ){
if(type == 0){ if(type == 0){
kk_indoorAir_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt); kk_indoorAir_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt);
...@@ -1179,10 +1208,10 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type) ...@@ -1179,10 +1208,10 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
kk_subAirSwitch_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt); kk_subAirSwitch_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt);
}else if(type == 2){ }else if(type == 2){
kk_subFreshAir_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt); kk_subFreshAir_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt);
} }
} }
} }
} }
client_list = client_list->next; client_list = client_list->next;
} }
...@@ -1233,7 +1262,7 @@ static int kk_indoorAir_online_handle(dm_mgr_dev_node_t *node ,char *deviceCode, ...@@ -1233,7 +1262,7 @@ static int kk_indoorAir_online_handle(dm_mgr_dev_node_t *node ,char *deviceCode,
continue; continue;
} }
kk_indoorAir_db_insert(deviceCode,property->identifier,property->data_value.type,epNum); kk_indoorAir_db_insert(deviceCode,property->identifier,property->data_value.type,epNum);
} }
gwExist = kk_get_device_roomInfo(deviceCode,1,roomName,roomId);//获取网关房间信息 gwExist = kk_get_device_roomInfo(deviceCode,1,roomName,roomId);//获取网关房间信息
if(gwExist){ if(gwExist){
char name[128] = {0}; char name[128] = {0};
...@@ -1261,7 +1290,7 @@ static int kk_subAirSwitch_online_handle(dm_mgr_dev_node_t *node ,char *deviceCo ...@@ -1261,7 +1290,7 @@ static int kk_subAirSwitch_online_handle(dm_mgr_dev_node_t *node ,char *deviceCo
continue; continue;
} }
kk_subAirSwitch_db_insert(deviceCode,property->identifier,property->data_value.type,epNum); kk_subAirSwitch_db_insert(deviceCode,property->identifier,property->data_value.type,epNum);
} }
gwExist = kk_get_device_roomInfo(deviceCode,1,roomName,roomId);//获取网关房间信息 gwExist = kk_get_device_roomInfo(deviceCode,1,roomName,roomId);//获取网关房间信息
if(gwExist){ if(gwExist){
char name[128] = {0}; char name[128] = {0};
...@@ -1289,7 +1318,7 @@ static int kk_subFreshair_online_handle(dm_mgr_dev_node_t *node ,char *deviceCod ...@@ -1289,7 +1318,7 @@ static int kk_subFreshair_online_handle(dm_mgr_dev_node_t *node ,char *deviceCod
continue; continue;
} }
kk_subFreshAir_db_insert(deviceCode,property->identifier,property->data_value.type,epNum); kk_subFreshAir_db_insert(deviceCode,property->identifier,property->data_value.type,epNum);
} }
gwExist = kk_get_device_roomInfo(deviceCode,1,roomName,roomId);//获取网关房间信息 gwExist = kk_get_device_roomInfo(deviceCode,1,roomName,roomId);//获取网关房间信息
if(gwExist){ if(gwExist){
char name[128] = {0}; char name[128] = {0};
...@@ -1330,18 +1359,18 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1330,18 +1359,18 @@ void kk_platMsg_handle(void* data, char* chalMark){
ERROR_PRINT("msgType info_dcode or jsonPay params are error\n"); ERROR_PRINT("msgType info_dcode or jsonPay params are error\n");
goto error; goto error;
} }
//if (chalMark != NULL){ //if (chalMark != NULL){
//if(strcmp(msgType->valuestring,"/thing/service/property/set_reply") != 0){ //if(strcmp(msgType->valuestring,"/thing/service/property/set_reply") != 0){
//dm_mgr_update_timestamp_by_devicecode(chalMark,HAL_Uptimes()); //dm_mgr_update_timestamp_by_devicecode(chalMark,HAL_Uptimes());
//} //}
//} //}
//printf("msgType->valuestring:%s [%s][%d]\n",msgType->valuestring,__FUNCTION__,__LINE__); //printf("msgType->valuestring:%s [%s][%d]\n",msgType->valuestring,__FUNCTION__,__LINE__);
if(strcmp(msgType->valuestring,"/thing/service/property/get_reply") != 0 && if(strcmp(msgType->valuestring,"/thing/service/property/get_reply") != 0 &&
strcmp(msgType->valuestring,"/thing/service/property/set_reply") != 0){ strcmp(msgType->valuestring,"/thing/service/property/set_reply") != 0){
dm_mgr_update_timestamp_by_devicecode(info_dcode->valuestring,HAL_Uptimes()); dm_mgr_update_timestamp_by_devicecode(info_dcode->valuestring,HAL_Uptimes());
} }
if (strcmp(msgType->valuestring, KK_THING_TOPO_ADD_MSG)==0){ if (strcmp(msgType->valuestring, KK_THING_TOPO_ADD_MSG)==0){
jsonPay = cJSON_GetObjectItem(payload, MSG_PARAMS_STR); jsonPay = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
if(jsonPay == NULL) goto error; if(jsonPay == NULL) goto error;
...@@ -1382,7 +1411,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1382,7 +1411,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
res = dm_mgr_get_device_by_devicecode(devCode->valuestring,&search_node); res = dm_mgr_get_device_by_devicecode(devCode->valuestring,&search_node);
if (res < SUCCESS_RETURN) { if (res < SUCCESS_RETURN) {
goto error; goto error;
} }
if(strcmp(search_node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0){ if(strcmp(search_node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0){
cJSON *epNumJson = cJSON_GetObjectItem(jsonPay, "epNum"); cJSON *epNumJson = cJSON_GetObjectItem(jsonPay, "epNum");
if(epNumJson == NULL) goto error; if(epNumJson == NULL) goto error;
...@@ -1408,7 +1437,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1408,7 +1437,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
res = dm_mgr_get_device_by_devicecode(devCode->valuestring,&search_node); res = dm_mgr_get_device_by_devicecode(devCode->valuestring,&search_node);
if (res < SUCCESS_RETURN) { if (res < SUCCESS_RETURN) {
goto error; goto error;
} }
if(strcmp(search_node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0){ if(strcmp(search_node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0){
cJSON *epNumJson = cJSON_GetObjectItem(jsonPay, "epNum"); cJSON *epNumJson = cJSON_GetObjectItem(jsonPay, "epNum");
if(epNumJson == NULL) goto error; if(epNumJson == NULL) goto error;
...@@ -1425,7 +1454,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1425,7 +1454,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
kk_subFreshAir_db_update_online((char*)search_node->deviceCode,0,epNumJson->valueint); kk_subFreshAir_db_update_online((char*)search_node->deviceCode,0,epNumJson->valueint);
_kk_subDevice_online_to_app(info,payload); _kk_subDevice_online_to_app(info,payload);
} }
} }
else if (strstr(msgType->valuestring, KK_THING_TOPO_BATCH_ADD_MSG) != NULL){ else if (strstr(msgType->valuestring, KK_THING_TOPO_BATCH_ADD_MSG) != NULL){
kk_ipc_send(IPC_MID2APP,data,strlen(data)); kk_ipc_send(IPC_MID2APP,data,strlen(data));
jsonPay = cJSON_GetObjectItem(payload, MSG_PARAMS_STR); jsonPay = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
...@@ -1436,14 +1465,14 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1436,14 +1465,14 @@ void kk_platMsg_handle(void* data, char* chalMark){
while(item != NULL){ while(item != NULL){
char *deviceCode = cJSON_GetObjectItem(item,MSG_DEVICE_CODE_STR)->valuestring; char *deviceCode = cJSON_GetObjectItem(item,MSG_DEVICE_CODE_STR)->valuestring;
char *productCode = cJSON_GetObjectItem(item,MSG_PRODUCT_CODE_STR)->valuestring; char *productCode = cJSON_GetObjectItem(item,MSG_PRODUCT_CODE_STR)->valuestring;
char *mac_s = cJSON_GetObjectItem(item,MSG_DEVICE_MAC)->valuestring; char *mac_s = cJSON_GetObjectItem(item,MSG_DEVICE_MAC)->valuestring;
char *fatherMac = cJSON_GetObjectItem(item,MSG_DEVICE_PARENTCODE)->valuestring; char *fatherMac = cJSON_GetObjectItem(item,MSG_DEVICE_PARENTCODE)->valuestring;
version = cJSON_GetObjectItem(item, "version"); version = cJSON_GetObjectItem(item, "version");
if(version != NULL ){ if(version != NULL ){
memcpy(versionBuf,version->valuestring,strlen(version->valuestring)); memcpy(versionBuf,version->valuestring,strlen(version->valuestring));
}else{ }else{
memcpy(versionBuf,"1.1.0",strlen("1.1.0")); memcpy(versionBuf,"1.1.0",strlen("1.1.0"));
} }
kk_mid_subdev_batch_add(productCode,deviceCode,mac_s,fatherMac,versionBuf); kk_mid_subdev_batch_add(productCode,deviceCode,mac_s,fatherMac,versionBuf);
item = item->next; item = item->next;
} }
...@@ -1481,7 +1510,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1481,7 +1510,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
kk_tsl_property_set_by_shadow(search_node->dev_shadow, outstr, strlen(outstr)+1); kk_tsl_property_set_by_shadow(search_node->dev_shadow, outstr, strlen(outstr)+1);
proCode = cJSON_GetObjectItem(info, MSG_PRODUCT_CODE_STR); proCode = cJSON_GetObjectItem(info, MSG_PRODUCT_CODE_STR);
dm_msg_thing_property_post_by_identify(proCode->valuestring,info_dcode->valuestring,jsonPay); dm_msg_thing_property_post_by_identify(proCode->valuestring,info_dcode->valuestring,jsonPay);
//如果带version,代表的是快照信息,快照信息不需要触发iftt //如果带version,代表的是快照信息,快照信息不需要触发iftt
cJSON *version = cJSON_GetObjectItem(jsonPay, "version"); cJSON *version = cJSON_GetObjectItem(jsonPay, "version");
if(version == NULL && is_BodySensor_dev(proCode->valuestring)==0){ if(version == NULL && is_BodySensor_dev(proCode->valuestring)==0){
kk_scene_iftt_check(info_dcode->valuestring,jsonPay); kk_scene_iftt_check(info_dcode->valuestring,jsonPay);
...@@ -1497,13 +1526,13 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1497,13 +1526,13 @@ void kk_platMsg_handle(void* data, char* chalMark){
res = dm_mgr_get_device_by_devicecode(devCode->valuestring,&node); res = dm_mgr_get_device_by_devicecode(devCode->valuestring,&node);
if (res < SUCCESS_RETURN) { if (res < SUCCESS_RETURN) {
goto error; goto error;
} }
printf("--------------------------------------->11111111111111111111113333\n"); printf("--------------------------------------->11111111111111111111113333\n");
dm_mgr_update_timestamp_by_devicecode(node->deviceCode,0); dm_mgr_update_timestamp_by_devicecode(node->deviceCode,0);
dm_mgr_set_dev_onoffline(node,1); dm_mgr_set_dev_onoffline(node,1);
//kk_ipc_send(IPC_MID2APP,data,strlen(data)+1); //kk_ipc_send(IPC_MID2APP,data,strlen(data)+1);
//dm_mgr_subdev_delete(devCode->valuestring); //dm_mgr_subdev_delete(devCode->valuestring);
}else if(strstr(msgType->valuestring, KK_THING_EVENT_MESSAGE) != NULL && \ }else if(strstr(msgType->valuestring, KK_THING_EVENT_MESSAGE) != NULL && \
strstr(msgType->valuestring, KK_THING_EVENT_POST) != NULL){ strstr(msgType->valuestring, KK_THING_EVENT_POST) != NULL){
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
...@@ -1533,9 +1562,9 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1533,9 +1562,9 @@ void kk_platMsg_handle(void* data, char* chalMark){
if(buttonId == NULL || buttonId->type != cJSON_Number){ if(buttonId == NULL || buttonId->type != cJSON_Number){
ERROR_PRINT("DATA ERROR!!!\n"); ERROR_PRINT("DATA ERROR!!!\n");
goto error; goto error;
} }
sprintf(btnId,"%d",buttonId->valueint); sprintf(btnId,"%d",buttonId->valueint);
kk_scene_execute_quickpanel(btnId,info_dcode->valuestring); kk_scene_execute_quickpanel(btnId,info_dcode->valuestring);
} }
INFO_PRINT("-------------------kk_platMsg_handle event post enters \n"); INFO_PRINT("-------------------kk_platMsg_handle event post enters \n");
for(idx = 0; idx < node->dev_shadow->event_number; idx++){ for(idx = 0; idx < node->dev_shadow->event_number; idx++){
...@@ -1545,7 +1574,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1545,7 +1574,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
INFO_PRINT("eventItem->identifier = NULL\n"); INFO_PRINT("eventItem->identifier = NULL\n");
continue ; continue ;
} }
if(strcmp(eventItem->identifier,MSG_PROPERTY_STR) != 0 && if(strcmp(eventItem->identifier,MSG_PROPERTY_STR) != 0 &&
eventItem->output_data_number > 0){ eventItem->output_data_number > 0){
int index = 0; int index = 0;
...@@ -1555,7 +1584,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1555,7 +1584,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
} }
for(index = 0; index < eventItem->output_data_number;index++){ for(index = 0; index < eventItem->output_data_number;index++){
itemStr = cJSON_GetObjectItem(jsonPay, eventItem->identifier); itemStr = cJSON_GetObjectItem(jsonPay, eventItem->identifier);
itemData = eventItem->output_datas + index; itemData = eventItem->output_datas + index;
cJSON * itemDataIdentifier = cJSON_GetObjectItem(jsonPay, itemData->identifier); cJSON * itemDataIdentifier = cJSON_GetObjectItem(jsonPay, itemData->identifier);
if(itemDataIdentifier != NULL){ if(itemDataIdentifier != NULL){
memset(tmpStr,0x0,sizeof(tmpStr)); memset(tmpStr,0x0,sizeof(tmpStr));
...@@ -1564,7 +1593,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1564,7 +1593,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
itemData->data_value.type == KK_TSL_DATA_TYPE_ENUM|| itemData->data_value.type == KK_TSL_DATA_TYPE_ENUM||
itemData->data_value.type == KK_TSL_DATA_TYPE_BOOL){ itemData->data_value.type == KK_TSL_DATA_TYPE_BOOL){
sprintf(valueBuf,"%d",itemDataIdentifier->valueint); sprintf(valueBuf,"%d",itemDataIdentifier->valueint);
kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,tmpStr,&itemDataIdentifier->valueint,NULL); kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,tmpStr,&itemDataIdentifier->valueint,NULL);
} }
else if(itemData->data_value.type == KK_TSL_DATA_TYPE_FLOAT || else if(itemData->data_value.type == KK_TSL_DATA_TYPE_FLOAT ||
itemData->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){ itemData->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){
...@@ -1576,10 +1605,10 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1576,10 +1605,10 @@ void kk_platMsg_handle(void* data, char* chalMark){
itemData->data_value.type == KK_TSL_DATA_TYPE_DATE){ itemData->data_value.type == KK_TSL_DATA_TYPE_DATE){
sprintf(valueBuf,"%s",itemDataIdentifier->valuestring); sprintf(valueBuf,"%s",itemDataIdentifier->valuestring);
kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,tmpStr,NULL,itemDataIdentifier->valuestring); kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,tmpStr,NULL,itemDataIdentifier->valuestring);
} }
if(sensorDev){ if(sensorDev){
kk_alarm_notify_handle(node,itemData->identifier,valueBuf);//告警信息处理 kk_alarm_notify_handle(node,itemData->identifier,valueBuf);//告警信息处理
} }
INFO_PRINT("kk_platMsg_handle data: event post\n"); INFO_PRINT("kk_platMsg_handle data: event post\n");
dm_msg_thing_event_post(info_dcode->valuestring,eventItem->identifier,NULL); dm_msg_thing_event_post(info_dcode->valuestring,eventItem->identifier,NULL);
kk_scene_iftt_check(info_dcode->valuestring,jsonPay); kk_scene_iftt_check(info_dcode->valuestring,jsonPay);
...@@ -1593,8 +1622,8 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1593,8 +1622,8 @@ void kk_platMsg_handle(void* data, char* chalMark){
if(itemStr != NULL){ if(itemStr != NULL){
if(sensorDev){ if(sensorDev){
//kk_history_insert_sensor_info(info_dcode->valuestring,eventItem->identifier,"",HAL_GetTime()); //kk_history_insert_sensor_info(info_dcode->valuestring,eventItem->identifier,"",HAL_GetTime());
} }
//kk_tsl_set_value(kk_tsl_set_event_output_value,dev_shadow,eventItem->identifier,&itemStr->valueint,NULL); //kk_tsl_set_value(kk_tsl_set_event_output_value,dev_shadow,eventItem->identifier,&itemStr->valueint,NULL);
dm_msg_thing_event_post(info_dcode->valuestring,eventItem->identifier,NULL); dm_msg_thing_event_post(info_dcode->valuestring,eventItem->identifier,NULL);
} }
...@@ -1605,15 +1634,15 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -1605,15 +1634,15 @@ void kk_platMsg_handle(void* data, char* chalMark){
else if(strstr(msgType->valuestring, KK_THING_TOPO_BATCH_DELETE_MSG) != NULL){ else if(strstr(msgType->valuestring, KK_THING_TOPO_BATCH_DELETE_MSG) != NULL){
kk_ipc_send(IPC_MID2APP,data,strlen(data)); kk_ipc_send(IPC_MID2APP,data,strlen(data));
jsonPay = cJSON_GetObjectItem(payload, MSG_PARAMS_STR); jsonPay = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
if(jsonPay == NULL) goto error; if(jsonPay == NULL) goto error;
cJSON *devices = cJSON_GetObjectItem(jsonPay, MSG_TOPO_CHANGE_DEVICES_STR); cJSON *devices = cJSON_GetObjectItem(jsonPay, MSG_TOPO_CHANGE_DEVICES_STR);
cJSON * item = devices->child; cJSON * item = devices->child;
while(item != NULL){ while(item != NULL){
char *deviceCode = cJSON_GetObjectItem(item,MSG_DEVICE_CODE_STR)->valuestring; char *deviceCode = cJSON_GetObjectItem(item,MSG_DEVICE_CODE_STR)->valuestring;
dm_mgr_subdev_delete(deviceCode); dm_mgr_subdev_delete(deviceCode);
item = item->next; item = item->next;
} }
} }
else if(strstr(msgType->valuestring, KK_THING_SERVICE_PROPERTY_GET_REPLY) != NULL){ else if(strstr(msgType->valuestring, KK_THING_SERVICE_PROPERTY_GET_REPLY) != NULL){
INFO_PRINT("kk_platMsg_handle data: KK_THING_SERVICE_PROPERTY_GET_REPLY\n"); INFO_PRINT("kk_platMsg_handle data: KK_THING_SERVICE_PROPERTY_GET_REPLY\n");
...@@ -1679,11 +1708,11 @@ typedef struct { ...@@ -1679,11 +1708,11 @@ typedef struct {
int permit_join; int permit_join;
void *g_mid_dispatch_thread; void *g_mid_dispatch_thread;
void *g_ota_dispatch_thread; void *g_ota_dispatch_thread;
void *g_ccuProChg_dispatch_thread; void *g_ccuProChg_dispatch_thread;
void *g_udp_dispatch_thread; void *g_udp_dispatch_thread;
int g_mid_dispatch_thread_running; int g_mid_dispatch_thread_running;
int g_ota_dispatch_thread_running; int g_ota_dispatch_thread_running;
int g_ccuProChg_dispatch_thread_running; int g_ccuProChg_dispatch_thread_running;
int g_udp_dispatch_thread_running; int g_udp_dispatch_thread_running;
} mid_ctx_t; } mid_ctx_t;
#define MID_YIELD_TIMEOUT_MS (200) #define MID_YIELD_TIMEOUT_MS (200)
...@@ -1747,45 +1776,45 @@ void *ota_dispatch_yield(void *args) ...@@ -1747,45 +1776,45 @@ void *ota_dispatch_yield(void *args)
void *udp_dispatch_yield(void *args){ void *udp_dispatch_yield(void *args){
INFO_PRINT("udp_dispatch_yield udp thread create\n"); INFO_PRINT("udp_dispatch_yield udp thread create\n");
// 绑定地址 // 绑定地址
struct sockaddr_in addrto; struct sockaddr_in addrto;
bzero(&addrto, sizeof(struct sockaddr_in)); bzero(&addrto, sizeof(struct sockaddr_in));
addrto.sin_family = AF_INET; addrto.sin_family = AF_INET;
addrto.sin_addr.s_addr = htonl(INADDR_ANY); addrto.sin_addr.s_addr = htonl(INADDR_ANY);
addrto.sin_port = htons(UDP_LAN_PORT); addrto.sin_port = htons(UDP_LAN_PORT);
// 发送地址 // 发送地址
struct sockaddr_in addrto_host; struct sockaddr_in addrto_host;
bzero(&addrto_host, sizeof(struct sockaddr_in)); bzero(&addrto_host, sizeof(struct sockaddr_in));
addrto_host.sin_family = AF_INET; addrto_host.sin_family = AF_INET;
addrto_host.sin_addr.s_addr = htonl(INADDR_ANY); addrto_host.sin_addr.s_addr = htonl(INADDR_ANY);
//addrto_host.sin_port = htons(UDP_LAN_PORT); //addrto_host.sin_port = htons(UDP_LAN_PORT);
// 接收到的广播地址 // 接收到的广播地址
struct sockaddr_in from; struct sockaddr_in from;
bzero(&from, sizeof(struct sockaddr_in)); bzero(&from, sizeof(struct sockaddr_in));
int sock = -1; int sock = -1;
int sock_host = -1; int sock_host = -1;
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
{ {
ERROR_PRINT("socket error\n"); ERROR_PRINT("socket error\n");
} }
if ((sock_host = socket(AF_INET, SOCK_DGRAM, 0)) == -1) if ((sock_host = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
{ {
ERROR_PRINT("socket error\n"); ERROR_PRINT("socket error\n");
} }
if(bind(sock,(struct sockaddr *)&(addrto), sizeof(struct sockaddr_in)) == -1) if(bind(sock,(struct sockaddr *)&(addrto), sizeof(struct sockaddr_in)) == -1)
{ {
ERROR_PRINT("bind error...\n"); ERROR_PRINT("bind error...\n");
} }
socklen_t len = sizeof(struct sockaddr_in); socklen_t len = sizeof(struct sockaddr_in);
char szOut[128] = {0}; char szOut[128] = {0};
char szDec[1024] = {0}; char szDec[1024] = {0};
char host_ip[32] = {0}; char host_ip[32] = {0};
char mac[32] = {0}; char mac[32] = {0};
char device_code[DEVICE_CODE_LEN] = {0}; char device_code[DEVICE_CODE_LEN] = {0};
...@@ -1803,17 +1832,17 @@ void *udp_dispatch_yield(void *args){ ...@@ -1803,17 +1832,17 @@ void *udp_dispatch_yield(void *args){
while(1) while(1)
{ {
//从广播地址接受消息 //从广播地址接受消息
memset(szDec, 0 , sizeof(szDec)); memset(szDec, 0 , sizeof(szDec));
int size=recvfrom(sock, szDec, sizeof(szDec), 0, (struct sockaddr*)&from,(socklen_t*)&len); int size=recvfrom(sock, szDec, sizeof(szDec), 0, (struct sockaddr*)&from,(socklen_t*)&len);
if(size<=0) if(size<=0)
{ {
WARNING_PRINT("read error....\n"); WARNING_PRINT("read error....\n");
} }
else else
{ {
DEBUG_PRINT("lan recmsg: %s\n", szDec); DEBUG_PRINT("lan recmsg: %s\n", szDec);
//DEBUG_PRINT("udp client ip:%s ,port is :%d htons(UDP_LAN_PORT)=%d \n",inet_ntoa(from.sin_addr),from.sin_port, htons(UDP_LAN_PORT)); //DEBUG_PRINT("udp client ip:%s ,port is :%d htons(UDP_LAN_PORT)=%d \n",inet_ntoa(from.sin_addr),from.sin_port, htons(UDP_LAN_PORT));
//"search_kk_ccu|deviceCode=1122334455667788;protocol=tcp" //"search_kk_ccu|deviceCode=1122334455667788;protocol=tcp"
if(strstr(szDec, "search_kk_ccu|") != NULL){ if(strstr(szDec, "search_kk_ccu|") != NULL){
char* getConnet = szDec + strlen("search_kk_ccu|"); char* getConnet = szDec + strlen("search_kk_ccu|");
...@@ -1876,23 +1905,23 @@ void *udp_dispatch_yield(void *args){ ...@@ -1876,23 +1905,23 @@ void *udp_dispatch_yield(void *args){
// printf("[%s][%d]host_ip:%s\n",__FUNCTION__,__LINE__,host_ip); // printf("[%s][%d]host_ip:%s\n",__FUNCTION__,__LINE__,host_ip);
// if(strcmp(inet_ntoa(from.sin_addr),host_ip) == 0){ // if(strcmp(inet_ntoa(from.sin_addr),host_ip) == 0){
sprintf(szOut,"search_kk_ccu_ack|deviceCode=%s;ip=%s;port=%d",device_code,host_ip,16565); sprintf(szOut,"search_kk_ccu_ack|deviceCode=%s;ip=%s;port=%d",device_code,host_ip,16565);
DEBUG_PRINT("szOut:%s\n",szOut); DEBUG_PRINT("szOut:%s\n",szOut);
DEBUG_PRINT("udp client ip:%s ,port is :%d \n",inet_ntoa(from.sin_addr),from.sin_port); DEBUG_PRINT("udp client ip:%s ,port is :%d \n",inet_ntoa(from.sin_addr),from.sin_port);
//sendto(sock, szOut, strlen(szOut), 0, (struct sockaddr*)&from,len); //sendto(sock, szOut, strlen(szOut), 0, (struct sockaddr*)&from,len);
addrto_host.sin_addr.s_addr = inet_addr(inet_ntoa(from.sin_addr)); addrto_host.sin_addr.s_addr = inet_addr(inet_ntoa(from.sin_addr));
if(strlen(portStr) > 0){ if(strlen(portStr) > 0){
addrto_host.sin_port = htons(atoi(portStr)); addrto_host.sin_port = htons(atoi(portStr));
}else{ }else{
addrto_host.sin_port = htons(UDP_LAN_PORT_HOST); addrto_host.sin_port = htons(UDP_LAN_PORT_HOST);
} }
//addrto_host.sin_port = from.sin_port; //addrto_host.sin_port = from.sin_port;
//if(strcmp(host_ip,inet_ntoa(from.sin_addr)) == 0) //if(strcmp(host_ip,inet_ntoa(from.sin_addr)) == 0)
//{ //{
sendto(sock_host, szOut, strlen(szOut), 0, (struct sockaddr*)&addrto_host,sizeof(addrto_host)); sendto(sock_host, szOut, strlen(szOut), 0, (struct sockaddr*)&addrto_host,sizeof(addrto_host));
//} //}
//else //else
//{ //{
...@@ -1901,7 +1930,7 @@ void *udp_dispatch_yield(void *args){ ...@@ -1901,7 +1930,7 @@ void *udp_dispatch_yield(void *args){
// } // }
} }
} }
usleep(100000); usleep(100000);
} }
close(sock); close(sock);
...@@ -2073,7 +2102,7 @@ int main(const int argc, const char **argv) ...@@ -2073,7 +2102,7 @@ int main(const int argc, const char **argv)
//IOT_Linkkit_Close(mid_ctx->master_devid); //IOT_Linkkit_Close(mid_ctx->master_devid);
return -1; return -1;
} }
mid_ctx->g_ota_dispatch_thread_running = 1; mid_ctx->g_ota_dispatch_thread_running = 1;
res = pthread_create((pthread_t *)&mid_ctx->g_ota_dispatch_thread, NULL, ota_dispatch_yield, NULL); res = pthread_create((pthread_t *)&mid_ctx->g_ota_dispatch_thread, NULL, ota_dispatch_yield, NULL);
if (res < 0) { if (res < 0) {
...@@ -2089,7 +2118,7 @@ int main(const int argc, const char **argv) ...@@ -2089,7 +2118,7 @@ int main(const int argc, const char **argv)
//IOT_Linkkit_Close(mid_ctx->master_devid); //IOT_Linkkit_Close(mid_ctx->master_devid);
return -1; return -1;
} }
mid_ctx->g_ccuProChg_dispatch_thread_running = 1; mid_ctx->g_ccuProChg_dispatch_thread_running = 1;
res = pthread_create((pthread_t *)&mid_ctx->g_ccuProChg_dispatch_thread, NULL, ccu_property_monitor, NULL); res = pthread_create((pthread_t *)&mid_ctx->g_ccuProChg_dispatch_thread, NULL, ccu_property_monitor, NULL);
if (res < 0) { if (res < 0) {
...@@ -2097,8 +2126,6 @@ int main(const int argc, const char **argv) ...@@ -2097,8 +2126,6 @@ int main(const int argc, const char **argv)
return -1; return -1;
} }
//int ct = 0; //int ct = 0;
for (;;) { for (;;) {
usleep(200000); usleep(200000);
...@@ -2106,6 +2133,6 @@ int main(const int argc, const char **argv) ...@@ -2106,6 +2133,6 @@ int main(const int argc, const char **argv)
BodySensorTrigger_check(); BodySensorTrigger_check();
} }
} }
{ {
"productCode":"3005", "productCode":"3005",
"operateType":"1003", "operateType":"1006",
"channel":1, "channel":1,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3006", "productCode":"3006",
"operateType":"1003", "operateType":"1006",
"channel":2, "channel":2,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3012", "productCode":"3012",
"operateType":"1003", "operateType":"1006",
"channel":1, "channel":1,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3026", "productCode":"3026",
"operateType":"1003", "operateType":"1006",
"channel":1, "channel":1,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3027", "productCode":"3027",
"operateType":"1003", "operateType":"1006",
"channel":2, "channel":2,
"newccu":[ "newccu":[
{ {
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"valueRange":[0,1,2], "valueRange":[0,1,2],
"value": 2 "value": 2
},{ },{
"identifier":"motorPos", "identifier":"Position",
"opcodemap":"SWITCH", "opcodemap":"MOVE_TO_POS",
"dataType":"int", "dataType":"int",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
...@@ -22,31 +22,31 @@ ...@@ -22,31 +22,31 @@
},{ },{
"identifier":"motorDir", "identifier":"motorDir",
"opcodemap":"SWITCH", "opcodemap":"SWITCH",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"value": 0 "value": "0"
},{ },{
"identifier":"pullEnable", "identifier":"pullEnable",
"opcodemap":"SWITCH", "opcodemap":"SWITCH",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"value": 0 "value": "0"
},{ },{
"identifier":"motorStatus", "identifier":"motorStatus",
"opcodemap":"SWITCH", "opcodemap":"SWITCH",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"value": 0 "value": "0"
},{ },{
"identifier":"routeCfg", "identifier":"routeCfg",
"opcodemap":"SWITCH", "opcodemap":"SWITCH",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"value": 0 "value": "0"
} }
], ],
"oldccu":[ "oldccu":[
...@@ -59,17 +59,17 @@ ...@@ -59,17 +59,17 @@
"syn":"switchStatus", "syn":"switchStatus",
"synType":"map" "synType":"map"
},{ },{
"opcode":"SWITCH", "opcode":"MOVE_TO_POS",
"identifiermap":"motorPos", "identifiermap":"Position",
"dataType":"int", "dataType":"string_int",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"syn":"motorPos", "syn":"motorPos",
"synType":"fit" "synType":"string"
},{ },{
"opcode":"SWITCH", "opcode":"SWITCH",
"identifiermap":"motorDir", "identifiermap":"motorDir",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"syn":"motorDir", "syn":"motorDir",
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
},{ },{
"opcode":"SWITCH", "opcode":"SWITCH",
"identifiermap":"pullEnable", "identifiermap":"pullEnable",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"syn":"pullEnable", "syn":"pullEnable",
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
},{ },{
"opcode":"SWITCH", "opcode":"SWITCH",
"identifiermap":"motorStatus", "identifiermap":"motorStatus",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"syn":"motorStatus", "syn":"motorStatus",
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
},{ },{
"opcode":"SWITCH", "opcode":"SWITCH",
"identifiermap":"routeCfg", "identifiermap":"routeCfg",
"dataType":"int", "dataType":"string",
"channel":"1", "channel":"1",
"valueRange":[], "valueRange":[],
"syn":"routeCfg", "syn":"routeCfg",
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"productCode":"3068", "productCode":"3068",
"operateType":"1003", "operateType":"1003",
"channel":1, "channel":1,
"syn_type":1,
"syn_opcode":"DOOYA_STATUS",
"newccu":[ "newccu":[
{ {
"identifier":"OperationMode", "identifier":"OperationMode",
...@@ -10,6 +12,41 @@ ...@@ -10,6 +12,41 @@
"channel":"1", "channel":"1",
"valueRange":[0,1,2], "valueRange":[0,1,2],
"value": 2 "value": 2
},{
"identifier":"Position",
"opcodemap":"MOVE_TO_POS",
"dataType":"int",
"channel":"1",
"valueRange":[],
"value": 0
},{
"identifier":"motorDir",
"opcodemap":"SWITCH",
"dataType":"string",
"channel":"1",
"valueRange":[],
"value": "0"
},{
"identifier":"pullEnable",
"opcodemap":"SWITCH",
"dataType":"string",
"channel":"1",
"valueRange":[],
"value": "0"
},{
"identifier":"motorStatus",
"opcodemap":"SWITCH",
"dataType":"string",
"channel":"1",
"valueRange":[],
"value": "0"
},{
"identifier":"routeCfg",
"opcodemap":"SWITCH",
"dataType":"string",
"channel":"1",
"valueRange":[],
"value": "0"
} }
], ],
"oldccu":[ "oldccu":[
...@@ -18,7 +55,49 @@ ...@@ -18,7 +55,49 @@
"identifiermap":"OperationMode", "identifiermap":"OperationMode",
"dataType":"map", "dataType":"map",
"channel":"1", "channel":"1",
"valueRange":["CLOSE","OPEN","STOP"] "valueRange":["CLOSE","OPEN","STOP"],
"syn":"switchStatus",
"synType":"map"
},{
"opcode":"MOVE_TO_POS",
"identifiermap":"Position",
"dataType":"string_int",
"channel":"1",
"valueRange":[],
"syn":"motorPos",
"synType":"string"
},{
"opcode":"SWITCH",
"identifiermap":"motorDir",
"dataType":"string",
"channel":"1",
"valueRange":[],
"syn":"motorDir",
"synType":"fit"
},{
"opcode":"SWITCH",
"identifiermap":"pullEnable",
"dataType":"string",
"channel":"1",
"valueRange":[],
"syn":"pullEnable",
"synType":"fit"
},{
"opcode":"SWITCH",
"identifiermap":"motorStatus",
"dataType":"string",
"channel":"1",
"valueRange":[],
"syn":"motorStatus",
"synType":"fit"
},{
"opcode":"SWITCH",
"identifiermap":"routeCfg",
"dataType":"string",
"channel":"1",
"valueRange":[],
"syn":"routeCfg",
"synType":"fit"
} }
] ]
......
{ {
"productCode":"3088", "productCode":"3088",
"operateType":"1003", "operateType":"1006",
"channel":1, "channel":1,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3089", "productCode":"3089",
"operateType":"1003", "operateType":"1006",
"channel":2, "channel":2,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3147", "productCode":"3147",
"operateType":"1003", "operateType":"1006",
"channel":1, "channel":1,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3148", "productCode":"3148",
"operateType":"1003", "operateType":"1006",
"channel":2, "channel":2,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3154", "productCode":"3154",
"operateType":"1003", "operateType":"1006",
"channel":1, "channel":1,
"newccu":[ "newccu":[
{ {
......
{ {
"productCode":"3155", "productCode":"3155",
"operateType":"1003", "operateType":"1006",
"channel":2, "channel":2,
"newccu":[ "newccu":[
{ {
......
...@@ -36,6 +36,49 @@ ...@@ -36,6 +36,49 @@
} }
}, },
"name": "亮度" "name": "亮度"
},
{
"identifier": "FadeTime",
"dataType": {
"type": "int",
"specs": {
"min": "10",
"max": "50",
"unit": "1/10s",
"unitName": "1/10秒",
"step": "10"
}
},
"name": "渐变时间"
},
{
"identifier": "LowBrightness",
"dataType": {
"type": "int",
"specs": {
"min": "10",
"max": "90",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
},
"name": "最低亮度"
},
{
"identifier": "HighBrightness",
"dataType": {
"type": "int",
"specs": {
"min": "20",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
},
"name": "最高亮度"
} }
], ],
"method": "thing.service.property.set", "method": "thing.service.property.set",
......
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