Commit 09e12432 authored by 尹佳钦's avatar 尹佳钦

新增群组功能(与网关侧待对接)

parent e5013c9e
......@@ -151,6 +151,19 @@ typedef struct {
#define KK_THING_SERVICE_GET_CCU_INFO "/thing/service/getCCUInfo"
#define KK_THING_SERVICE_GET_CCU_INFO_REPLY "/thing/service/getCCUInfo_reply"
#define KK_THING_SERVICE_ADDGROUP "/thing/service/addGroup"
#define KK_THING_SERVICE_ADDGROUP_REPLY "/thing/service/addGroup_reply"
#define KK_THING_SERVICE_UPDATEGROUP "/thing/service/updateGroup"
#define KK_THING_SERVICE_UPDATEGROUP_REPLY "/thing/service/updateGroup_reply"
#define KK_THING_SERVICE_DELETEGROUP "/thing/service/deleteGroup"
#define KK_THING_SERVICE_DELETEGROUP_REPLY "/thing/service/deleteGroup_reply"
#define KK_THING_SERVICE_QUERYGROUP "/thing/service/queryGroup"
#define KK_THING_SERVICE_QUERYGROUP_REPLY "/thing/service/queryGroup_reply"
#define KK_THING_SERVICE_EXCUTEGROUP "/thing/service/excuteGroup"
#define KK_THING_SERVICE_EXCUTEGROUP_REPLY "/thing/service/excuteGroup_reply"
void kk_sendData2app(void *info, void *payload,int isAsync);
int dm_msg_thing_sub_register(_IN_ char productCode[DEVICE_CODE_MAXLEN], _IN_ char deviceCode[DEVICE_CODE_MAXLEN],
_OU_ dm_msg_request_t *request);
......
This diff is collapsed.
......@@ -1283,3 +1283,35 @@ int kk_get_screenDev_info(ScreenDevInfo_t *devInfo,char*serialId)
sqlite3_free(sqlCmd);
return 0;
}
int kk_subDev_find_fatherDeviceCode(const char *deviceCode,char *fatherDeviceCode)
{
int res = 0;
sqlite3_stmt *stmt;
char *sqlCmd = NULL;
dm_mgr_dev_node_t *node = NULL;
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
const char *searchCmd = "select * from SubDeviceInfo WHERE deviceCode = '%s'";
if(deviceCode == NULL){
ERROR_PRINT("ERROR [%s][%d]\n",__FUNCTION__,__LINE__);
return INVALID_PARAMETER;
}
sqlCmd = sqlite3_mprintf(searchCmd,deviceCode);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while(sqlite3_step(stmt) == SQLITE_ROW){
char *parent = (char*)sqlite3_column_text(stmt, DB_SUB_FATHERDEVICECODE);
sprintf(fatherDeviceCode,"%s",parent);
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
return SUCCESS_RETURN;
}
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
return FAIL_RETURN;
}
......@@ -45,6 +45,7 @@ int kk_get_screenDev_info(ScreenDevInfo_t *devInfo,char*serialId);
int kk_subDev_getDeviceCodes_byProductType(DeviceCode_t *list,char *type);
int kk_indoor_air_action_add(char *propertyValue,char* deviceCode,int delay,char*gwDeviceCode,char *sceneId,char *type,int epnum);
int kk_subDev_update_fatherDeviceCode(char *fatherDeviceCode,const char *deviceCode);
enum{
DB_SUB_IDX = 0,
DB_SUB_ONLINE,
......
......@@ -25,6 +25,8 @@
#include "kk_hal.h"
#include "kk_dm_msg.h"
#include "kk_linkkit.h"
#include "kk_group_db.h"
extern sqlite3 *g_kk_pDb;
static int kk_check_multi_ep_num(char *deviceCode);
......@@ -1045,8 +1047,13 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,char* id,char *productT
type = (char*)sqlite3_column_text(stmt, DB_SCENEACTION_TYPE);
if(strcmp(type,"action/thing/cluster")==0){
actionItem = cJSON_Parse(propertyName);
cJSON_AddStringToObject(actionItem, KK_SYNC_SCENE_TYPE_STR, type);
cJSON_AddNumberToObject(actionItem,KK_SYNC_SCENE_PROPERTYVALUE_STR,atoi(propertyValue));
cJSON_AddNumberToObject(actionItem, KK_SYNC_SCENE_DELAY_STR, delay);
cJSON_AddItemToArray(actionArray, actionItem);
}else{
actionItem = cJSON_CreateObject();
cJSON_AddStringToObject(actionItem, KK_SYNC_DEVICECODE_STR, deviceCode);
......@@ -1086,6 +1093,9 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,char* id,char *productT
cJSON_AddItemToArray(actionArray, actionItem);
}
}
}
sqlite3_free(sqlCmd);
sqlite3_finalize(stmt);
return SUCCESS_RETURN;
......@@ -1370,6 +1380,14 @@ static int kk_get_scenes_info(cJSON *data)
return SUCCESS_RETURN;
}
static int kk_get_group_info(cJSON *data)
{
cJSON *group = kk_group_db_query(1);
cJSON_AddItemToObject(data, "group", group);
return SUCCESS_RETURN;
}
/*
static int kk_get_ccu_properties(cJSON *property)
{
......@@ -1425,6 +1443,7 @@ char *kk_sync_get_info()
kk_get_rooms_info(data);
kk_get_devices_info(data);
kk_get_scenes_info(data);
kk_get_group_info(data);
HAL_Get_ccuid(ccu_deviceCode);
kk_get_pid(ccu_productCode);
HAL_GetVersion(version);
......
......@@ -42,6 +42,7 @@
#include "kk_area_handle.h"
#include "kk_property_get_handle.h"
#include "kk_motor_bind_db.h"
#include "kk_group_db.h"
int g_timezone = 8;
char * g_filerToPlatTable[] =
......@@ -2086,6 +2087,7 @@ int main(const int argc, const char **argv)
kk_subDb_init();
kk_area_init();
kk_history_db_init();
kk_group_db_init();
kk_motor_bind_db_init();
kk_scene_init();
g_timezone = HAL_Get_TimeZone();
......
......@@ -106,5 +106,4 @@ int kk_scene_update_productType(const char *sceneId,char *productType);
int kk_scene_update_actionRoomId(const char *sceneId,char *roomId);
int kk_scene_update_device_active(char *deviceCode,int epNum,int value);
int kk_scene_rebuild_device_active(char *deviceCode,int epNum);
#endif
......@@ -1393,6 +1393,27 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
argStr = cJSON_PrintUnformatted(arg);
kk_scene_insert_scene_invokeService(typeStr,identifier->valuestring,argStr,sceneId);
free(argStr);
}else if(!strcmp(typeStr,"action/thing/cluster")){
propertyValue = cJSON_GetObjectItem(item,MSG_SCENE_PROPERTYVALUE);
if(propertyValue == NULL) return FAIL_RETURN;
delay = cJSON_GetObjectItem(item,MSG_SCENE_DELAY);
memset(propertyValueStr,0x0,sizeof(propertyValueStr));
snprintf(propertyValueStr,sizeof(propertyValueStr),"%d",propertyValue->valueint);
cJSON *groupId = cJSON_GetObjectItem(item,"groupId");
cJSON *controlType = cJSON_GetObjectItem(item,"controlType");
cJSON *temp = cJSON_CreateObject();
cJSON_AddStringToObject(temp,"groupId",groupId->valuestring);
cJSON_AddStringToObject(temp,"controlType",controlType->valuestring);
char *propertyNameStr = cJSON_PrintUnformatted(temp);
res = kk_scene_insert_scene_action(typeStr,"",0,
propertyNameStr,propertyValueStr,delay->valueint,sceneId,"");
free(propertyNameStr);
}
else
{
......@@ -2752,3 +2773,4 @@ int kk_scene_rebuild_device_active(char *deviceCode,int epNum)
sqlite3_finalize(stmt);
return SUCCESS_RETURN;
}
......@@ -87,6 +87,7 @@ int kk_scene_action_add(const char *gwdeviceCode,const char *sceneId,kk_scene_ac
int BodySensorTrigger_check(void);
int bodySensor_find(const char *deviceCode,int ep);
int is_BodySensor_dev(const char *productCode);
int kk_scene_rebuild_device_active(char *deviceCode,int epNum);
#endif
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