Commit dbefe3a6 authored by chen.weican's avatar chen.weican

【修改内容】修改多合一面板设置场景不起作用的BUG

【提交人】陈伟灿
parent 7fed2d98
1.2.0
\ No newline at end of file
1.3.0
\ No newline at end of file
......@@ -108,7 +108,7 @@ int main(int argc, char* argv[])
return 0;
}
kk_ipc_init(IPC_APP2MID,(ipc_cb*)KK_Data_FromDev,NULL,NULL);
kk_info_report_start();
//kk_info_report_start();
again:
rc = kk_start_ccu_register();
if(rc == 0){
......
......@@ -35,6 +35,6 @@ int kk_room_update_armingstate(int state,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_device_roomInfo(const char* deviceCode,int epNum,char *roomName,char *roomId);
int kk_room_reset_armingstate(void);
#endif
......@@ -501,9 +501,11 @@ int dm_mgr_set_dev_onoffline(dm_mgr_dev_node_t *node,int isOffline)
int dm_mgr_check_heartbeat_timeout(time_t timestamp)
{
static unsigned int s_count = 0;
dm_mgr_ctx *ctx = _dm_mgr_get_ctx();
dm_mgr_dev_node_t *search_node = NULL;
_dm_mgr_mutex_lock();
s_count++;
list_for_each_entry(search_node, &ctx->dev_list, linked_list, dm_mgr_dev_node_t) {
if(search_node->hb_timeout == 0){
search_node->hb_timeout = DEFAULT_HEARTBEAT_TIMEOUT;
......@@ -511,13 +513,14 @@ int dm_mgr_check_heartbeat_timeout(time_t timestamp)
if(search_node->devid == KK_DM_DEVICE_CCU_DEVICEID){
continue;
}
#if 0
printf("[%s][%d]search_node->productCode:%s\n",__FUNCTION__,__LINE__,search_node->productCode);
printf("[%s][%d]search_node->hb_timeout:%d\n",__FUNCTION__,__LINE__,search_node->hb_timeout);
printf("[%s][%d]search_node->isOffline:%d\n",__FUNCTION__,__LINE__,search_node->isOffline);
printf("[%s][%d]search_node->timestamp:%d\n",__FUNCTION__,__LINE__,search_node->timestamp);
printf("[%s][%d]timestamp:%d\n",__FUNCTION__,__LINE__,timestamp);
#endif
if(s_count >= 60)
{
INFO_PRINT("[%s][%d]search_node->productCode:%s\n",__FUNCTION__,__LINE__,search_node->productCode);
INFO_PRINT("[%s][%d]search_node->hb_timeout:%d\n",__FUNCTION__,__LINE__,search_node->hb_timeout);
INFO_PRINT("[%s][%d]search_node->isOffline:%d\n",__FUNCTION__,__LINE__,search_node->isOffline);
INFO_PRINT("[%s][%d]search_node->timestamp:%d\n",__FUNCTION__,__LINE__,search_node->timestamp);
INFO_PRINT("[%s][%d]timestamp:%d\n",__FUNCTION__,__LINE__,timestamp);
}
if((timestamp - search_node->timestamp) >= search_node->hb_timeout){
if(search_node->isOffline != KK_DEV_OFFLINE){
dm_mgr_set_dev_onoffline(search_node,1);
......@@ -530,6 +533,9 @@ int dm_mgr_check_heartbeat_timeout(time_t timestamp)
}
}
}
if(s_count >= 60){
s_count = 0;
}
_dm_mgr_mutex_unlock();
return SUCCESS_RETURN;
}
......
......@@ -10,7 +10,7 @@
const char DM_MSG_REQUEST[] DM_READ_ONLY = "{\"msgId\":\"%s\",\"version\":\"%s\",\"params\":%s,\"time\":\"%lu\",\"method\":\"%s\"}";
const char DM_MSG_INFO[] DM_READ_ONLY = "{\"msgtype\":\"%s\",\"productCode\":\"%s\",\"deviceCode\":\"%s\"}";
extern void kk_sendData2gw(void* data, int len, char* chalMark);
void kk_sendData2app(void *info, void *payload,int isAsync){
void *buf = NULL;
cJSON *root=cJSON_CreateObject();
......
......@@ -26,7 +26,7 @@
#include "kk_property_db.h"
#include "kk_product.h"
#include "kk_hal.h"
#include "kk_history_db.h"
#define IOTX_LINKKIT_KEY_ID "id"
#define IOTX_LINKKIT_KEY_CODE "code"
#define IOTX_LINKKIT_KEY_DEVID "devid"
......@@ -55,7 +55,7 @@
#define dm_log_info INFO_PRINT
extern void kk_sendData2gw(void* data, int len, char* chalMark);
static int s_gateway_add_flag = 0;
typedef struct {
......
......@@ -401,11 +401,9 @@ int kk_subDev_check_auth(int devType)
char *zErrMsg = 0;
const char *searchCmd = "select * from SubDeviceInfo WHERE devType = '%d';";
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
printf("------------------------------------------------------->111\n");
sqlCmd = sqlite3_mprintf(searchCmd,devType);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
printf("------------------------------------------------------->222\n");
char *pDeviceCode = (char*)sqlite3_column_text(stmt, DB_SUB_DEVICECODE);
char *pProductCode = (char*)sqlite3_column_text(stmt, DB_SUB_PRODUCTCODE);
kk_msg_cloud_status_notify(pDeviceCode,pProductCode);
......@@ -702,15 +700,6 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
_kk_indoor_air_handle(pDeviceCode,sceneId,propertyName,propertyValue,type,delay,node->fatherDeviceCode);
continue;
}
#if 0
if(kk_subDev_check_scene_support(node->fatherDeviceCode) == 1){
gw_support_scene = 1;
}
else{
gw_support_scene = 0;
}
#endif
//if(!strcmp(typeArray[k],"switch")){
for(idx = 0; idx < node->dev_shadow->property_number; idx++){
property = (kk_tsl_data_t *)(node->dev_shadow->properties + idx);
if(property == NULL){
......@@ -718,7 +707,6 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
}
char *ptr = strstr(property->identifier,propertyName);
if(ptr != NULL && (ptr-property->identifier==0) ){
//if(gw_support_scene){
kk_scene_action_detail_t info = {0};
memcpy(info.deviceCode,node->deviceCode,strlen(node->deviceCode));
memcpy(info.propertyName,property->identifier,strlen(property->identifier));
......@@ -731,6 +719,15 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
}else{
info.epNum = 1;
}
if(strcmp(node->productCode,"3098") == 0 && info.epNum != 1){ //风机盘管多合一只处理第一路
continue;
}
else if(strcmp(node->productCode,"3097") == 0 && info.epNum != 2){//地暖多合一只处理第二路
continue;
}
else if(strcmp(node->productCode,"3099") == 0 && info.epNum != 3){//新风多合一只处理第三路
continue;
}
info.delay = delay;
kk_scene_action_add(node->fatherDeviceCode,sceneId,info);
res = kk_scene_insert_scene_action(type,node->deviceCode,info.epNum,
......@@ -740,7 +737,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
//return res;
continue;
}
//}
}
}
......
......@@ -936,18 +936,18 @@ 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_BOOL){
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 ||
itemData->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){
sprintf(valueBuf,"%f",itemDataIdentifier->valuedouble);
//kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,tmpStr,&itemDataIdentifier->valuedouble,NULL);
kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,tmpStr,&itemDataIdentifier->valuedouble,NULL);
}
else if(itemData->data_value.type == KK_TSL_DATA_TYPE_TEXT ||
itemData->data_value.type == KK_TSL_DATA_TYPE_DATE){
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){
kk_alarm_notify_handle(node,itemData->identifier,valueBuf);//告警信息处理
......@@ -1374,7 +1374,7 @@ int main(const int argc, const char **argv)
res = HAL_Ccuid_init();
if(res == -1){
ERROR_PRINT("CCUID GET FAIL!!!!!!!!!!!\n");
return 0;
return -1;
}
kk_sqlite_init();
kk_tsl_api_init();
......
......@@ -1019,14 +1019,17 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
}
if(kk_subDev_check_scene_support(node->fatherDeviceCode) == 1 && ArmingStateFlag == 0){
kk_scene_action_detail_t info = {0};
memset(propertyValueStr,0,sizeof(propertyValueStr));
memcpy(info.deviceCode,node->deviceCode,strlen(node->deviceCode));
//多合一面板需要根据epnum重新设置propertyName
if(strcmp(node->productCode,"3098") == 0 || strcmp(node->productCode,"3099") == 0 ||
strcmp(node->productCode,"3097") == 0){
sprintf(info.propertyName,"%s_%d",propertyName->valuestring,iepnum);
}else{
memcpy(info.propertyName,propertyName->valuestring,strlen(propertyName->valuestring));
}
if(propertyValue->type==cJSON_Number){
snprintf(propertyValueStr,sizeof(propertyValueStr),"%d",propertyValue->valueint);
}else if(propertyValue->type==cJSON_String){
snprintf(propertyValueStr,sizeof(propertyValueStr),"%s",propertyValue->valuestring);
......@@ -1041,11 +1044,13 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
kk_scene_action_add(node->fatherDeviceCode,sceneId,info);
res = kk_scene_insert_scene_action(type->valuestring,node->deviceCode,iepnum,
info.propertyName,propertyValueStr,idelay,sceneId,node->fatherDeviceCode);
}
}else{
res = kk_scene_insert_scene_action(type->valuestring,node->deviceCode,iepnum,
propertyName->valuestring,propertyValueStr,idelay,sceneId,node->fatherDeviceCode);
}
if(res != SUCCESS_RETURN){
INFO_PRINT("kk_scene_insert_scene_action fail!!!\n");
......
......@@ -81,6 +81,6 @@ kk_tsl_t * kk_scene_shadow(void);
int kk_scene_parse_updatescene(const cJSON* arg,char *sceneId);
int kk_scene_parse_deletescene(char *sceneId);
int kk_scene_delete_send_to_gw(const char *sceneId);
int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdate);
#endif
......@@ -321,16 +321,13 @@ static int _kk_msg_set_object(kk_msg_set_type_t type, kk_tsl_t *dev_shadow, char
lite_cjson_t lite_item_value;
char *new_key = NULL;
int new_key_len = 0;
for (index = 0; index < root->size; index++) {
res = lite_cjson_object_item_by_index(root, index, &lite_item_key, &lite_item_value);
if (res != SUCCESS_RETURN) {
continue;
}
/* dm_log_debug("Current Key: %.*s, Value: %.*s",
lite_item_key.value_length, lite_item_key.value,
lite_item_value.value_length, lite_item_value.value); */
//printf("Current Key: %s, Value: %s,type:%d", lite_item_key.value,lite_item_value.value,lite_item_value.type);
//new_key_len = lite_item_key.value_length + 1;
new_key_len = ((key == NULL) ? (0) : (strlen(key) + 1)) + lite_item_key.value_length + 1;
/* dm_log_debug("new_key_len: %d", new_key_len); */
......@@ -361,7 +358,7 @@ static int _kk_msg_set_object(kk_msg_set_type_t type, kk_tsl_t *dev_shadow, char
free(new_key);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
continue;
}
}
return SUCCESS_RETURN;
......@@ -375,7 +372,6 @@ int _kk_msg_property_set(kk_tsl_t *dev_shadow, kk_msg_request_payload_t
if (request == NULL) {
return INVALID_PARAMETER;
}
/* Parse Root */
memset(&lite, 0, sizeof(lite_cjson_t));
res = lite_cjson_parse(request->params.value, request->params.value_length, &lite);
......@@ -383,11 +379,9 @@ int _kk_msg_property_set(kk_tsl_t *dev_shadow, kk_msg_request_payload_t
return JSON_PARSE_FAILED;
}
/* dm_log_info("Property Set, Size: %d", lite.size); */
if (lite_cjson_is_object(&lite)) {
res = _kk_msg_set_object(KK_MSG_PROPERTY_SET, dev_shadow, NULL, &lite);
}
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
......@@ -1140,17 +1134,13 @@ int kk_tsl_property_set_by_shadow(kk_tsl_t* dev_shadow, const char *payload, uns
{
kk_msg_request_payload_t request;
int res = 0;
memset(&request, 0, sizeof(kk_msg_request_payload_t));
res = _kk_msg_request_parse((char *)payload, payload_len, &request);
if (res < SUCCESS_RETURN) {
return res ;
}
/* Operation */
res = _kk_msg_property_set(dev_shadow, &request);
return SUCCESS_RETURN;
}
#if 0
......
......@@ -3,7 +3,7 @@
"productType": "floorHeating",
"version": "1.0",
"profile": {
"heartbeat": "3000",
"heartbeat": "300",
"productCode": "3097",
"productName": "海顿系列.地暖多合一面板(KONKE)"
},
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3098.json",
"productType": "fan coil",
"productType": "airConditioning",
"version": "1.0",
"profile": {
"heartbeat": "3000",
"heartbeat": "300",
"productCode": "3098",
"productName": "海顿系列.风机盘管多合一面板(KONKE)"
},
......
1.1.1
\ No newline at end of file
1.3.1
\ No newline at end of file
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