Commit 45fce4b7 authored by chen.weican's avatar chen.weican

【修改内容】修改空调内机的数据同步

【提交人】陈伟灿
parent 0bc4dfcd
...@@ -9,7 +9,7 @@ cJSON *old_ccu_msg_build_json(const char* nodeid,const char* opcode,const char* ...@@ -9,7 +9,7 @@ cJSON *old_ccu_msg_build_json(const char* nodeid,const char* opcode,const char*
cJSON *old_ccu_msg_build(const char* nodeid,const char* opcode,const char* status,const char* arg); cJSON *old_ccu_msg_build(const char* nodeid,const char* opcode,const char* status,const char* arg);
int send_msg_to_module(cJSON *root); int send_msg_to_module(cJSON *root);
cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type);
int arming_status_notify(int type); int arming_status_notify(int type);
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define PRODUCT_TPYE "kk" #define PRODUCT_TPYE "kk"
#define CCU_LAN "eth1" #define CCU_LAN "eth1"
#define KK_CCU_ID "CCU_77770" #define KK_CCU_ID "CCU_77771"
#define KK_CCU_PRODUCTID "ccu_n12" #define KK_CCU_PRODUCTID "ccu_n12"
#define KK_GW_PRODUCTID "gateway_2" #define KK_GW_PRODUCTID "gateway_2"
#define KK_CCU_RANDOM "0000000000" #define KK_CCU_RANDOM "0000000000"
......
...@@ -410,6 +410,36 @@ int kk_get_device_name(const char* deviceCode,const char *epNum,char *devName,in ...@@ -410,6 +410,36 @@ int kk_get_device_name(const char* deviceCode,const char *epNum,char *devName,in
_kk_area_unlock(); _kk_area_unlock();
return isGet; return isGet;
} }
int kk_get_device_roomInfo(const char* deviceCode,int epNum,char *roomName,char *roomId)
{
int isGet = 0;
char *sqlCmd = NULL;
char *proomName = NULL;
char *proomId = NULL;
sqlite3_stmt *stmt;
kk_area_ctx_t *ctx = _kk_area_get_ctx();
const char *searchCmd = "select * from AreaDevInfo where deviceCode = '%s' and epNum = '%d';";
_kk_area_lock();
sqlCmd = sqlite3_mprintf(searchCmd,deviceCode,epNum);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
proomName = (char*)sqlite3_column_text(stmt, DB_DEV_ROOM_NAME);
proomId = (char*)sqlite3_column_text(stmt, DB_DEV_ROOM_ID);
if(strlen(proomName) < 256){
memcpy(roomName,proomName,strlen(proomName));
}else{
memcpy(roomName,proomName,255);
}
memcpy(roomId,proomId,strlen(proomId));
isGet = 1;
}
//INFO_PRINT("\n");
sqlite3_free(sqlCmd);
sqlite3_finalize(stmt);
_kk_area_unlock();
return isGet;
}
int kk_room_dev_remove(const char *deviceCode,const char *epNum) int kk_room_dev_remove(const char *deviceCode,const char *epNum)
{ {
int res = 0; int res = 0;
......
...@@ -34,7 +34,7 @@ int kk_get_device_name(const char* deviceCode,const char *epNum,char *devName,in ...@@ -34,7 +34,7 @@ int kk_get_device_name(const char* deviceCode,const char *epNum,char *devName,in
int kk_room_update_armingstate(int state,const char *roomid); int kk_room_update_armingstate(int state,const char *roomid);
int kk_get_room_armingstate(const char* roomId); int kk_get_room_armingstate(const char* roomId);
int kk_get_roomId_by_deviceCode(const char* deviceCode,const char *epNum,char *roomId,int size); int kk_get_roomId_by_deviceCode(const char* deviceCode,const char *epNum,char *roomId,int size);
int kk_get_device_roomInfo(const char* deviceCode,int epNum,char *roomName,char *roomId);
#endif #endif
...@@ -292,9 +292,10 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA ...@@ -292,9 +292,10 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA
else{ else{
return FAIL_RETURN; return FAIL_RETURN;
} }
dm_mgr_properities_db_create(node->dev_shadow,deviceCode,dev_type);
INIT_LIST_HEAD(&node->linked_list); INIT_LIST_HEAD(&node->linked_list);
list_add_tail(&node->linked_list, &ctx->dev_list); list_add_tail(&node->linked_list, &ctx->dev_list);
dm_mgr_properities_db_create(node->dev_shadow,deviceCode,dev_type);
if(dev_type == KK_DM_DEVICE_CCU){ if(dev_type == KK_DM_DEVICE_CCU){
_dm_init_tsl_params(node->dev_shadow,node->deviceCode); _dm_init_tsl_params(node->dev_shadow,node->deviceCode);
......
This diff is collapsed.
...@@ -179,6 +179,42 @@ static int _kk_check_property_exist(const char* deviceCode,const char* identifie ...@@ -179,6 +179,42 @@ static int _kk_check_property_exist(const char* deviceCode,const char* identifie
_kk_property_db_unlock(); _kk_property_db_unlock();
return isExist; return isExist;
} }
char *human_induction_device[] = {
(char*){"3049"},
(char*){"3042"},
(char*){"3053"},
(char*){"3043"},
};
char *door_induction_device[] = {
(char*){"3045"},
(char*){"3050"},
(char*){"3051"},
(char*){"3070"},
};
static int _kk_check_human_induction_device(char *productCode){
int i = 0;
int num = sizeof(human_induction_device)/sizeof(char *);
for(i =0; i < num; i++){
if(strcmp(productCode,human_induction_device[i]) == 0)
{
return 1;
}
}
return 0;
}
static int _kk_check_door_induction_device(char *productCode){
int i = 0;
int num = sizeof(door_induction_device)/sizeof(char *);
for(i =0; i < num; i++){
if(strcmp(productCode,door_induction_device[i]) == 0)
{
return 1;
}
}
return 0;
}
/************************************************************ /************************************************************
*功能描述: 插入属性到数据库 *功能描述: 插入属性到数据库
*输入参数: deviceCode:设备deviceCode *输入参数: deviceCode:设备deviceCode
...@@ -192,21 +228,37 @@ static int _kk_check_property_exist(const char* deviceCode,const char* identifie ...@@ -192,21 +228,37 @@ static int _kk_check_property_exist(const char* deviceCode,const char* identifie
int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int devtype) int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int devtype)
{ {
printf("---------------------------------------->identifier:%s\n",identifier);
dm_mgr_dev_node_t *node = NULL;
int res = 0 ;
const char *insertCmd = "insert into PropertiesInfo (deviceCode,identifier,value,valueType,devType) \ const char *insertCmd = "insert into PropertiesInfo (deviceCode,identifier,value,valueType,devType) \
values ('%s','%s','%s','%d','%d');"; values ('%s','%s','%s','%d','%d');";
char *sqlCmd = NULL; char *sqlCmd = NULL;
int rc = 0; int rc = 0;
char *zErrMsg = 0; char *zErrMsg = 0;
kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx(); kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx();
printf("---------------------------------------->1\n");
if(_kk_check_property_exist(deviceCode,identifier) == 1) if(_kk_check_property_exist(deviceCode,identifier) == 1)
{ {
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
printf("---------------------------------------->2\n");
_kk_property_db_lock(); _kk_property_db_lock();
//传感器类默认安防等级为离家安防 //传感器类默认安防等级为离家安防
if(strcmp(identifier,"SensorType") == 0 && devtype == KK_DM_DEVICE_SUBDEV){ if(strcmp(identifier,"SensorType") == 0 && devtype == KK_DM_DEVICE_SUBDEV){
res = dm_mgr_get_device_by_devicecode(deviceCode, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
printf("---------------------------------------->3\n");
if(_kk_check_human_induction_device(node->productCode) == 1 || //门磁和人体默认室外安防
_kk_check_door_induction_device(node->productCode) == 1){
sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"1",valuetype,devtype); sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"1",valuetype,devtype);
}else{
printf("---------------------------------------->\n");
sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"2",valuetype,devtype);//其他24小时警戒
}
}else{ }else{
sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"",valuetype,devtype); sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"",valuetype,devtype);
} }
...@@ -317,6 +369,42 @@ int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_ ...@@ -317,6 +369,42 @@ int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_
_kk_property_db_unlock(); _kk_property_db_unlock();
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
/************************************************************
*功能描述: 查询空调内机数量
*输入参数: deviceCode:设备deviceCode
epNum:内机端点
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:属性的值插入的时候先置空,后续再update
*************************************************************/
int kk_indoorAir_query_epnums(const char *deviceCode,int epList[])
{
char *sqlCmd = NULL;
//int rc = 0;
//char *zErrMsg = 0;
sqlite3_stmt *stmt;
char *valueStr = NULL;
int count = 0;
kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx();
_kk_property_db_lock();
sqlCmd = sqlite3_mprintf("select * from indoorAirProperties WHERE deviceCode= '%s' and identifier = '%s'",deviceCode,"PowerSwitch");
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
if(count > 64){
return count;
}
printf("-----------------------------------------------kk_indoorAir_query_epnums\n");
epList[count] = sqlite3_column_int(stmt, DB_INDOORAIR_EPNUM);
printf("epList[count] :%d\n",epList[count]);
count++;
}
sqlite3_free(sqlCmd);
_kk_property_db_unlock();
sqlite3_finalize(stmt);
return count;
}
/************************************************************ /************************************************************
*功能描述:通过deviceCode删除空调内机 *功能描述:通过deviceCode删除空调内机
*输入参数: deviceCode:设备deviceCode *输入参数: deviceCode:设备deviceCode
......
...@@ -55,5 +55,6 @@ int kk_property_update_lockkeys(char deviceCode[DEVICE_CODE_MAXLEN],char *keyId, ...@@ -55,5 +55,6 @@ int kk_property_update_lockkeys(char deviceCode[DEVICE_CODE_MAXLEN],char *keyId,
int kk_property_delete_lockkeys(char deviceCode[DEVICE_CODE_MAXLEN],char *keyId); int kk_property_delete_lockkeys(char deviceCode[DEVICE_CODE_MAXLEN],char *keyId);
int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int epNum); int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int epNum);
int kk_indoorAir_db_update_value(const char *deviceCode,const char *identifier,const char* value,int epNum); int kk_indoorAir_db_update_value(const char *deviceCode,const char *identifier,const char* value,int epNum);
int kk_indoorAir_query_epnums(const char *deviceCode,int epList[]);
#endif #endif
...@@ -79,8 +79,9 @@ int kk_sync_init(void) ...@@ -79,8 +79,9 @@ int kk_sync_init(void)
static cJSON * kk_get_room_devices(const char *roomId) static cJSON * kk_get_room_devices(const char *roomId)
{ {
dm_mgr_dev_node_t *node = NULL;
const char *selectCmd = "select * from AreaDevInfo WHERE roomId = '%s';"; const char *selectCmd = "select * from AreaDevInfo WHERE roomId = '%s';";
int res = 0;
char *sqlCmd = NULL; char *sqlCmd = NULL;
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
char *deviceCode = NULL; char *deviceCode = NULL;
...@@ -96,12 +97,20 @@ static cJSON * kk_get_room_devices(const char *roomId) ...@@ -96,12 +97,20 @@ static cJSON * kk_get_room_devices(const char *roomId)
deviceCode = (char*)sqlite3_column_text(stmt, DB_DEV_DEVICECODE); deviceCode = (char*)sqlite3_column_text(stmt, DB_DEV_DEVICECODE);
epNum = (char*)sqlite3_column_text(stmt, DB_DEV_EPNUM); epNum = (char*)sqlite3_column_text(stmt, DB_DEV_EPNUM);
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;
}
if(kk_check_multi_ep_num(deviceCode)){ if(kk_check_multi_ep_num(deviceCode)){
cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum); cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
}else if(strcmp(node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0){
if(atoi(epNum) == 1){//epNum为1的是空调网关
continue;
}else{
cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
}
} }
cJSON_AddStringToObject(dev,KK_SYNC_DEVICECODE_STR,deviceCode); cJSON_AddStringToObject(dev,KK_SYNC_DEVICECODE_STR,deviceCode);
//cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum); //cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
kk_get_device_name(deviceCode,epNum,devName,sizeof(devName)); kk_get_device_name(deviceCode,epNum,devName,sizeof(devName));
...@@ -367,6 +376,61 @@ static cJSON *kk_get_properties_info(char *deviceCode,int devType) ...@@ -367,6 +376,61 @@ static cJSON *kk_get_properties_info(char *deviceCode,int devType)
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
return obj; return obj;
} }
static cJSON *kk_get_indoor_properties_info(char *deviceCode)
{
char *sqlCmd = NULL;
//char *zErrMsg = 0;
sqlite3_stmt *stmt;
char *propertyStr = NULL;
char *valueStr = NULL;
int valueType = 0;
int eplist[65] = {0};
int count = 0,i = 0;
char *ptr = NULL;
kk_sync_ctx_t *ctx = _kk_sync_get_ctx();
if(deviceCode == NULL){
return NULL;
}
cJSON *obj = cJSON_CreateObject();
cJSON *eps = cJSON_CreateArray();
count = kk_indoorAir_query_epnums(deviceCode,eplist);
printf("-------------->count:%d\n",count);
for(i = 0; i < count; i++){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
sqlCmd = sqlite3_mprintf("select * from indoorAirProperties WHERE deviceCode = '%s' and epNum=%d;",deviceCode,eplist[i]);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
cJSON *propertyItem = cJSON_CreateObject();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddNumberToObject(propertyItem, "epNum",eplist[i]);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
while(sqlite3_step(stmt) == SQLITE_ROW){
propertyStr = (char*)sqlite3_column_text(stmt, DB_INDOORAIR_IDENTIFITER);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
valueType = sqlite3_column_int(stmt, DB_INDOORAIR_VALUETYPE);
valueStr = (char*)sqlite3_column_text(stmt, DB_INDOORAIR_VALUE);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(valueType == KK_TSL_DATA_TYPE_TEXT){
cJSON_AddStringToObject(propertyItem, propertyStr, valueStr);
}else if(valueType == KK_TSL_DATA_TYPE_INT||
valueType == KK_TSL_DATA_TYPE_ENUM||
valueType == KK_TSL_DATA_TYPE_BOOL){
cJSON_AddNumberToObject(propertyItem, propertyStr, atoi(valueStr));
}else if(valueType == KK_TSL_DATA_TYPE_DOUBLE){
cJSON_AddNumberToObject(propertyItem, propertyStr, atof(valueStr));
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
}
cJSON_AddItemToArray(eps,propertyItem);
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(obj, "eps", eps);
cJSON_AddNumberToObject(obj, "EpTotal", count);
cJSON_AddNumberToObject(obj, "CombineDeviceFlag", 1);
sqlite3_free(sqlCmd);
sqlite3_finalize(stmt);
return obj;
}
static int kk_get_properties_info_obj(char *deviceCode) static int kk_get_properties_info_obj(char *deviceCode)
{ {
char *sqlCmd = NULL; char *sqlCmd = NULL;
...@@ -471,6 +535,7 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode) ...@@ -471,6 +535,7 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode)
kk_sync_ctx_t *ctx = _kk_sync_get_ctx(); kk_sync_ctx_t *ctx = _kk_sync_get_ctx();
char *subDeviceCode = NULL; char *subDeviceCode = NULL;
char *subProductCode = NULL; char *subProductCode = NULL;
char *subproductType = NULL;
char *subVersion = NULL; char *subVersion = NULL;
char *subIsline = NULL; char *subIsline = NULL;
if(gwdevicesItem == NULL || deviceCode == NULL){ if(gwdevicesItem == NULL || deviceCode == NULL){
...@@ -489,6 +554,7 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode) ...@@ -489,6 +554,7 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode)
subProductCode = (char*)sqlite3_column_text(stmt, DB_SUB_PRODUCTCODE); subProductCode = (char*)sqlite3_column_text(stmt, DB_SUB_PRODUCTCODE);
subVersion = (char*)sqlite3_column_text(stmt, DB_SUB_VERSION); subVersion = (char*)sqlite3_column_text(stmt, DB_SUB_VERSION);
subIsline = (char*)sqlite3_column_text(stmt, DB_SUB_ONLINE); subIsline = (char*)sqlite3_column_text(stmt, DB_SUB_ONLINE);
subproductType = (char*)sqlite3_column_text(stmt, DB_SUB_PRODUCTTYPE);
cJSON_AddStringToObject(subdevicesItem, KK_SYNC_DEVICECODE_STR, subDeviceCode); cJSON_AddStringToObject(subdevicesItem, KK_SYNC_DEVICECODE_STR, subDeviceCode);
cJSON_AddStringToObject(subdevicesItem, KK_SYNC_VERSION_STR, subVersion); cJSON_AddStringToObject(subdevicesItem, KK_SYNC_VERSION_STR, subVersion);
cJSON_AddStringToObject(subdevicesItem, KK_SYNC_MAC_STR, subDeviceCode); cJSON_AddStringToObject(subdevicesItem, KK_SYNC_MAC_STR, subDeviceCode);
...@@ -503,7 +569,10 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode) ...@@ -503,7 +569,10 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode)
if(kk_check_multi_ep_num(subDeviceCode)){ if(kk_check_multi_ep_num(subDeviceCode)){
properties=kk_get_properties_info(subDeviceCode,KK_DM_DEVICE_SUBDEV); properties=kk_get_properties_info(subDeviceCode,KK_DM_DEVICE_SUBDEV);
}else{ }else if(strcmp(subproductType,KK_DM_AIR_GATEWAY_TYPE) == 0){
properties=kk_get_indoor_properties_info(subDeviceCode);
}
else{
properties=kk_get_properties_info_obj(subDeviceCode); properties=kk_get_properties_info_obj(subDeviceCode);
} }
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#include "kk_scene_handle.h" #include "kk_scene_handle.h"
#include "dm_ota.h" #include "dm_ota.h"
#include "ccu_ver.h" #include "ccu_ver.h"
#include "kk_area_handle.h"
int g_timezone = 8; int g_timezone = 8;
char * g_filerToPlatTable[] = char * g_filerToPlatTable[] =
{ {
...@@ -568,7 +570,12 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char ...@@ -568,7 +570,12 @@ static int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char
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");
}else{ }else if(strcmp(identifier,"DismantleState") == 0 && atoi(valueBuf) == 1){
cJSON_AddStringToObject(param, "DismantleState", "1");
}else if(strcmp(identifier,"SmokeSensorState") == 0 && atoi(valueBuf) == 1){
cJSON_AddStringToObject(param, "CommonAlarmState", "1");
}
else{
cJSON_AddStringToObject(param, "CommonAlarmState", "1"); cJSON_AddStringToObject(param, "CommonAlarmState", "1");
} }
cJSON_AddItemToObject(payload, "params", param); cJSON_AddItemToObject(payload, "params", param);
...@@ -636,7 +643,7 @@ static int kk_indoorAir_property_save(cJSON *payload,char *deviceCode) ...@@ -636,7 +643,7 @@ static int kk_indoorAir_property_save(cJSON *payload,char *deviceCode)
if(epNum->type == cJSON_Number){ if(epNum->type == cJSON_Number){
epNumInt = epNum->valueint; epNumInt = epNum->valueint;
}else if(epNum->type == cJSON_String){ }else if(epNum->type == cJSON_String){
epNumInt = epNum->valuestring; epNumInt = atoi(epNum->valuestring);
} }
for(idx = 0; idx < node->dev_shadow->property_number; idx++){ for(idx = 0; idx < node->dev_shadow->property_number; idx++){
property = (kk_tsl_data_t *)(node->dev_shadow->properties + idx); property = (kk_tsl_data_t *)(node->dev_shadow->properties + idx);
...@@ -679,6 +686,10 @@ static int kk_indoorAir_property_handle(cJSON *info,cJSON *payload,char *deviceC ...@@ -679,6 +686,10 @@ static int kk_indoorAir_property_handle(cJSON *info,cJSON *payload,char *deviceC
static int kk_indoorAir_online_handle(dm_mgr_dev_node_t *node ,char *deviceCode,int epNum) static int kk_indoorAir_online_handle(dm_mgr_dev_node_t *node ,char *deviceCode,int epNum)
{ {
int idx = 0; int idx = 0;
int gwExist = 0;
char roomId[32] = {0};
char roomName[256] = {0};
char epNumStr[10] = {0};
kk_tsl_data_t *property = NULL; kk_tsl_data_t *property = NULL;
if(node == NULL){ if(node == NULL){
return -1; return -1;
...@@ -690,6 +701,14 @@ static int kk_indoorAir_online_handle(dm_mgr_dev_node_t *node ,char *deviceCode, ...@@ -690,6 +701,14 @@ static int kk_indoorAir_online_handle(dm_mgr_dev_node_t *node ,char *deviceCode,
} }
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);//获取网关房间信息
if(gwExist){
char name[128] = {0};
sprintf(name,"空调%d",epNum);
sprintf(epNumStr,"%d",epNum);
kk_room_dev_add(roomId,roomName,deviceCode,epNumStr,name);
}
return 0; return 0;
} }
void kk_platMsg_handle(void* data, char* chalMark){ void kk_platMsg_handle(void* data, char* chalMark){
...@@ -857,7 +876,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -857,7 +876,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
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++){
eventItem = node->dev_shadow->events + idx; eventItem = node->dev_shadow->events + idx;
if(eventItem != NULL){ if(eventItem != NULL){
...@@ -868,6 +887,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -868,6 +887,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;
printf("------------111--------->itemData->identifier:%s\n",itemData->identifier);
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));
...@@ -890,7 +910,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -890,7 +910,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
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,eventItem->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);
...@@ -904,7 +924,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -904,7 +924,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
itemStr = cJSON_GetObjectItem(jsonPay, eventItem->identifier); itemStr = cJSON_GetObjectItem(jsonPay, eventItem->identifier);
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);
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"method": "thing.service.property.set", "method": "thing.service.property.set",
"inputData": [ "inputData": [
{ {
"identifier": "TargetTemperature", "identifier": "Temperature",
"name": "目标温度", "name": "目标温度",
"dataType": { "dataType": {
"type": "double", "type": "double",
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
"desc": "属性获取", "desc": "属性获取",
"method": "thing.service.property.get", "method": "thing.service.property.get",
"inputData": [ "inputData": [
"TargetTemperature", "Temperature",
"CurrentTemperature", "CurrentTemperature",
"PowerSwitch", "PowerSwitch",
"ChildLockState", "ChildLockState",
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
], ],
"outputData": [ "outputData": [
{ {
"identifier": "TargetTemperature", "identifier": "Temperature",
"name": "目标温度", "name": "目标温度",
"dataType": { "dataType": {
"type": "double", "type": "double",
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
} }
}, },
{ {
"identifier": "TargetTemperature", "identifier": "Temperature",
"name": "目标温度", "name": "目标温度",
"accessMode": "rw", "accessMode": "rw",
"required": true, "required": true,
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
"method": "thing.event.property.post", "method": "thing.event.property.post",
"outputData": [ "outputData": [
{ {
"identifier": "TargetTemperature", "identifier": "Temperature",
"name": "目标温度", "name": "目标温度",
"dataType": { "dataType": {
"type": "double", "type": "double",
......
...@@ -120,7 +120,19 @@ ...@@ -120,7 +120,19 @@
"desc": "属性上报" "desc": "属性上报"
}, },
{ {
"outputData": [], "outputData":[
{
"identifier": "sosAlarmState",
"name": "紧急按钮告警状态",
"dataType": {
"type": "enum",
"specs": {
"0": "没有报警",
"1": "报警"
}
}
}
],
"identifier": "sosAlarm", "identifier": "sosAlarm",
"method": "thing.event.sosAlarm.post", "method": "thing.event.sosAlarm.post",
"name": "sosAlarm", "name": "sosAlarm",
......
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