Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
07f53186
Commit
07f53186
authored
Mar 10, 2022
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】修改相关BUG
【提交人】陈伟灿
parent
adc28c95
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
299 additions
and
226 deletions
+299
-226
application/kcloud/kcloud_data_handle.c
application/kcloud/kcloud_data_handle.c
+5
-2
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+15
-3
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+2
-2
common/hal/kk_product.h
common/hal/kk_product.h
+1
-1
midware/midware/dm/kk_alarm_handle.c
midware/midware/dm/kk_alarm_handle.c
+9
-4
midware/midware/dm/kk_alarm_handle.h
midware/midware/dm/kk_alarm_handle.h
+1
-1
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+128
-158
midware/midware/dm/kk_linkkit.h
midware/midware/dm/kk_linkkit.h
+3
-1
midware/midware/dm/kk_property_get_handle.c
midware/midware/dm/kk_property_get_handle.c
+24
-2
midware/midware/dm/kk_property_get_handle.h
midware/midware/dm/kk_property_get_handle.h
+1
-1
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+8
-9
midware/midware/midware.c
midware/midware/midware.c
+26
-26
midware/midware/scene/kk_mutictrl_handle.c
midware/midware/scene/kk_mutictrl_handle.c
+9
-1
midware/midware/scene/kk_mutictrl_handle.h
midware/midware/scene/kk_mutictrl_handle.h
+4
-0
midware/midware/scene/kk_scene_db.c
midware/midware/scene/kk_scene_db.c
+0
-1
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+14
-12
midware/tsl/tsl_handle/kk_tsl_common.h
midware/tsl/tsl_handle/kk_tsl_common.h
+15
-1
tsl/product_3015.json
tsl/product_3015.json
+34
-1
No files found.
application/kcloud/kcloud_data_handle.c
View file @
07f53186
...
...
@@ -606,7 +606,10 @@ int KK_Send_CloudState(int state)
int
payloadStr_len
=
0
;
cJSON
*
root
;
char
*
out
;
char
pid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
kk_cloud_get_pid
(
pid
);
KK_Get_ccuid
(
ccuid
);
infoStr_len
=
strlen
(
DM_MSG_TO_MIDDWARE
)
+
strlen
(
KK_CLOUDSTATE_MSG_REPLY
)
+
10
;
infoStr
=
malloc
(
infoStr_len
);
if
(
infoStr
==
NULL
){
...
...
@@ -614,7 +617,7 @@ int KK_Send_CloudState(int state)
return
RETURN_FAIL
;
}
memset
(
infoStr
,
0x0
,
infoStr_len
);
snprintf
(
infoStr
,
infoStr_len
,
DM_MSG_TO_MIDDWARE
,
KK_CLOUDSTATE_MSG_REPLY
,
""
,
""
);
snprintf
(
infoStr
,
infoStr_len
,
DM_MSG_TO_MIDDWARE
,
KK_CLOUDSTATE_MSG_REPLY
,
pid
,
ccuid
);
payloadStr_len
=
strlen
(
DM_MSG_CLOUDSTATE
)
+
10
;
payloadStr
=
malloc
(
payloadStr_len
);
...
...
application/klansdk/kk_data_handle.c
View file @
07f53186
...
...
@@ -129,7 +129,11 @@ void kk_handle_sync_push_info(void)
void
kk_handle_get_history_info
(
void
)
{
char
*
send_data
=
NULL
;
send_data
=
_kk_data_create
(
GET_HISTORY_MSG_TYPE
,
"*"
,
"*"
,
"*"
);
char
pid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
kk_lan_get_pid
(
pid
);
kk_lan_get_ccuid
(
ccuid
);
send_data
=
_kk_data_create
(
GET_HISTORY_MSG_TYPE
,
pid
,
ccuid
,
"*"
);
if
(
send_data
==
NULL
){
return
;
}
...
...
@@ -388,7 +392,11 @@ static void kk_zb_devs_hw_ack(int sockfd,cJSON *conditions)
static
void
kk_handle_del_history_info
(
char
*
key
)
{
char
*
send_data
=
NULL
;
send_data
=
_kk_data_create
(
DEL_HISTORY_MSG_TYPE
,
"*"
,
"*"
,
key
);
char
pid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
kk_lan_get_pid
(
pid
);
kk_lan_get_ccuid
(
ccuid
);
send_data
=
_kk_data_create
(
DEL_HISTORY_MSG_TYPE
,
pid
,
ccuid
,
key
);
if
(
send_data
==
NULL
){
return
;
}
...
...
@@ -430,7 +438,11 @@ int kk_data_handle(cJSON *json,int sockfd)
kk_handle_del_history_info
(
key
->
valuestring
);
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
GET_CCU_INFO
)
==
0
){
char
*
send_data
=
_kk_data_create
(
KK_THING_SERVICE_GET_CCU_INFO
,
"*"
,
"*"
,
"*"
);
char
pid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
kk_lan_get_pid
(
pid
);
kk_lan_get_ccuid
(
ccuid
);
char
*
send_data
=
_kk_data_create
(
KK_THING_SERVICE_GET_CCU_INFO
,
pid
,
ccuid
,
"*"
);
kk_ipc_send
(
IPC_APP2MID
,
send_data
,
strlen
(
send_data
)
+
1
);
}
#ifdef VOICE_SUPPORT
...
...
application/klansdk/kk_lan_main.c
View file @
07f53186
...
...
@@ -282,12 +282,12 @@ int main(int argc, char* argv[])
if
(
g_sync_flag
&
SYNC_INFO_FLAG
){
DEBUG_PRINT
(
"[SYNC INFO].
\n
"
);
send_data
=
_kk_data_create
(
SYNC_MSG_TYPE
,
"*"
,
"*"
,
"*"
);
send_data
=
_kk_data_create
(
SYNC_MSG_TYPE
,
s_pid
,
s_ccuid
,
"*"
);
g_sync_flag
&=~
SYNC_INFO_FLAG
;
}
else
if
(
g_sync_flag
&
SYNC_INFO_PUSH_FLAG
){
DEBUG_PRINT
(
"[SYNC INFO PUSH].
\n
"
);
send_data
=
_kk_data_create
(
SYNCPUSH_MSG_TYPE
,
"*"
,
"*"
,
"*"
);
send_data
=
_kk_data_create
(
SYNCPUSH_MSG_TYPE
,
s_pid
,
s_ccuid
,
"*"
);
kk_handle_sync_push_info
();
g_sync_flag
&=~
SYNC_INFO_PUSH_FLAG
;
}
else
{
...
...
common/hal/kk_product.h
View file @
07f53186
...
...
@@ -162,7 +162,7 @@ __attribute__((weak)) char KK_VERSION_FILE_PATH[128] = STORSGE_DIR"/"KK_VERSIO
#else
__attribute__
((
weak
))
char
KK_DEFAULT_CONFIG_FILE_PATH
[
128
]
=
"/app/ccuApps/config/cloud_default_config.json"
;
__attribute__
((
weak
))
char
KK_AUTH_CONFIG_FILE_PATH
[
128
]
=
"/tmp/auth_conf.json"
;
__attribute__
((
weak
))
char
KK_VERSION_FILE_PATH
[
128
]
=
"/app/ccuApps/VERSION"
__attribute__
((
weak
))
char
KK_VERSION_FILE_PATH
[
128
]
=
"/app/ccuApps/VERSION"
;
#endif
...
...
midware/midware/dm/kk_alarm_handle.c
View file @
07f53186
...
...
@@ -60,7 +60,7 @@ int kk_is_CommonAlarmState(char * identifier)
2:在家布防
3:区域布防
*************************************************************/
int
kk_alarm_notify_handle
(
dm_mgr_dev_node_t
*
node
,
char
*
identifier
,
char
*
valueBuf
)
int
kk_alarm_notify_handle
(
dm_mgr_dev_node_t
*
node
,
char
*
identifier
,
char
*
valueBuf
,
char
*
eventIdebtifier
)
{
char
ccuid
[
32
]
=
{
0
};
int
currentValue
=
0
;
...
...
@@ -70,7 +70,12 @@ int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char *valueB
if
(
node
==
NULL
||
identifier
==
NULL
){
return
-
1
;
}
if
(
strcmp
(
eventIdebtifier
,
"LockOpenNotification"
)
==
0
||
strcmp
(
eventIdebtifier
,
"KeyDeletedNotification"
)
==
0
||
strcmp
(
eventIdebtifier
,
"KeyAddNotification"
)
==
0
||
strcmp
(
eventIdebtifier
,
"BatteryAlarm"
)
==
0
){
return
-
1
;
}
HAL_Get_ccuid
(
ccuid
);
kk_property_db_get_value
(
node
->
deviceCode
,
"SensorType"
,
&
currentValue
);
//INFO_PRINT("------------------------->currentValue:%d\n",currentValue);
...
...
@@ -92,8 +97,8 @@ int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char *valueB
//HAL_GetTime_s(timerStr);
cJSON_AddNumberToObject
(
payload
,
"time"
,
HAL_GetTime_ms
());
cJSON
*
param
=
cJSON_CreateObject
();
if
(
strcmp
(
identifier
,
"Battery
Alarm
"
)
==
0
){
if
(
atoi
(
valueBuf
)
==
1
){
if
(
strcmp
(
identifier
,
"Battery"
)
==
0
){
if
(
atoi
(
valueBuf
)
==
1
||
strcmp
(
valueBuf
,
"1.000000"
)
==
0
){
cJSON_AddStringToObject
(
param
,
"LowBatteryState"
,
"1"
);
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
"/thing/event/BatteryAlarm/post"
);
cJSON_AddStringToObject
(
payload
,
"method"
,
"thing.event.BatteryAlarm.post"
);
...
...
midware/midware/dm/kk_alarm_handle.h
View file @
07f53186
...
...
@@ -3,5 +3,5 @@
#define _KK_ALARM_NOTIFY_H_
#include "kk_hal.h"
#include "kk_log.h"
int
kk_alarm_notify_handle
(
dm_mgr_dev_node_t
*
node
,
char
*
identifier
,
char
*
valueBuf
);
int
kk_alarm_notify_handle
(
dm_mgr_dev_node_t
*
node
,
char
*
identifier
,
char
*
valueBuf
,
char
*
eventIdebtifier
);
#endif
\ No newline at end of file
midware/midware/dm/kk_linkkit.c
View file @
07f53186
...
...
@@ -550,24 +550,26 @@ static int kk_service_addRoom_handle(const char *deviceCode, cJSON *params,cJSON
}
return
SUCCESS_RETURN
;
}
int
kk_service_common_reply
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
)
int
kk_service_common_reply
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
,
int
errorCode
)
{
int
res
=
0
;
int
i
=
0
,
num
=
0
;
SensorType_t
*
pList
=
NULL
;
char
method
[
128
]
=
{
0
};
char
errorCodeBuf
[
32
]
=
{
0
};
char
version
[
VERSION_MAXLEN
]
=
{
0
};
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
param
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
productCode
=
cJSON_GetObjectItem
(
param
,
MSG_PRODUCT_CODE_STR
);
if
(
productCode
==
NULL
){
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
sprintf
(
errorCodeBuf
,
"%d"
,
errorCode
);
kk_strrpl
(
msgType
+
1
,
method
,
sizeof
(
method
),
"/"
,
"."
);
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
msgType
);
...
...
@@ -578,18 +580,19 @@ int kk_service_common_reply(cJSON *param,cJSON *msgId,char *msgType)
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
errorCodeBuf
);
cJSON_AddStringToObject
(
payload
,
"method"
,
method
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
->
valuestring
);
cJSON
*
Item
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
payload
,
"params"
,
Item
);
char
*
payload11
=
cJSON_Print
(
payload
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
res
;
return
NO_ERROR
;
}
int
kk_service_common_reply_ex
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
,
cJSON
*
Item
)
...
...
@@ -664,7 +667,7 @@ static int kk_service_updateRoom_handle(const char *deviceCode, cJSON *params,cJ
kk_service_addRoom_reply
(
inforoot
,
msgid
,
roomIdStr
->
valuestring
,
1
);
}
else
{
kk_room_set_floor_info
(
floorId
->
valuestring
,
""
,
roomIdStr
->
valuestring
);
kk_service_common_reply
(
inforoot
,
msgid
,
KK_THING_SERVICE_UPDATEROOM_REPLY
);
kk_service_common_reply
(
inforoot
,
msgid
,
KK_THING_SERVICE_UPDATEROOM_REPLY
,
NO_ERROR
);
}
//INFO_PRINT(" update room 111!!!\n");
...
...
@@ -744,30 +747,30 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
dev_name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
dev_name
==
NULL
){
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
room_name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
if
(
room_name
==
NULL
){
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_CCUROOMID
);
if
(
roomId
==
NULL
){
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
//kk_room_add(room_name->valuestring,roomId->valuestring);
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
->
valuestring
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
DEVICE_NOT_EXSIT
;
}
cJSON
*
epNum
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_EPNUM
);
if
(
epNum
==
NULL
){
...
...
@@ -783,52 +786,10 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
strcpy
(
epNumStr
,
epNum
->
valuestring
);
}
res
=
kk_room_dev_add
(
roomId
->
valuestring
,
room_name
->
valuestring
,
deviceCode
->
valuestring
,
epNumStr
,
dev_name
->
valuestring
);
//kk_scene_update_device_active(deviceCode->valuestring,atoi(epNumStr),1);
//kk_scene_rebuild_device_active(deviceCode->valuestring,atoi(epNumStr));
//内机默认添加到跟网关同个房间
#if 0
if(strcmp(node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0 && isAirGwFlag == 1){
int eplist[64] = {0};
char name[128] = {0};
int i = 0;
int count = kk_indoorAir_query_epnums(deviceCode->valuestring,eplist);
for(i = 0; i < count; i++){
memset(epNumStr,0x0,sizeof(epNumStr));
memset(name,0x0,sizeof(name));
sprintf(epNumStr,"%d",eplist[i]);
sprintf(name,"空调%d",eplist[i]);
kk_room_dev_add(roomId->valuestring,room_name->valuestring,deviceCode->valuestring,epNumStr,name);
}
INFO_PRINT("addDeviceToRoom air gw count:%d\n",count);
}
if(strcmp(node->productType,KK_DM_AIR_SWITCH_GATEWAY_TYPE) == 0 && isAirGwFlag == 2){
int eplist[64] = {0};
char name[128] = {0};
int i = 0;
int count = kk_subAirSwitch_query_epnums(deviceCode->valuestring,eplist);
for(i = 0; i < count; i++){
memset(epNumStr,0x0,sizeof(epNumStr));
memset(name,0x0,sizeof(name));
sprintf(epNumStr,"%d",eplist[i]);
sprintf(name,"空开%d",eplist[i]);
kk_room_dev_add(roomId->valuestring,room_name->valuestring,deviceCode->valuestring,epNumStr,name);
}
}
if(strcmp(node->productType,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0 && isAirGwFlag == 3){
int eplist[64] = {0};
char name[128] = {0};
int i = 0;
int count = kk_subFreshAir_query_epnums(deviceCode->valuestring,eplist);
for(i = 0; i < count; i++){
memset(epNumStr,0x0,sizeof(epNumStr));
memset(name,0x0,sizeof(name));
sprintf(epNumStr,"%d",eplist[i]);
sprintf(name,"新风%d",eplist[i]);
kk_room_dev_add(roomId->valuestring,room_name->valuestring,deviceCode->valuestring,epNumStr,name);
}
}
#endif
return
res
;
if
(
res
!=
SUCCESS_RETURN
){
return
DEVICE_CTRL_FAIL
;
}
return
NO_ERROR
;
}
/************************************************************
*功能描述:删除设备从房间处理函数
...
...
@@ -842,12 +803,12 @@ static int kk_service_removeDeviceFromRoom_handle(cJSON *params)
char
epNumStr
[
10
]
=
{
0
};
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
epNum
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_EPNUM
);
if
(
epNum
==
NULL
){
...
...
@@ -858,7 +819,7 @@ static int kk_service_removeDeviceFromRoom_handle(cJSON *params)
kk_room_dev_remove
(
deviceCode
->
valuestring
,
epNumStr
);
kk_scene_update_device_active
(
deviceCode
->
valuestring
,
atoi
(
epNumStr
),
0
);
kk_scene_rebuild_device_active
(
deviceCode
->
valuestring
,
atoi
(
epNumStr
));
return
SUCCESS_RETURN
;
return
NO_ERROR
;
}
/************************************************************
...
...
@@ -900,12 +861,12 @@ static int kk_service_executeDNDMode_handle(cJSON *params)
dm_mgr_dev_node_t
*
search_node
=
NULL
;
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_CCUROOMID
);
if
(
roomId
==
NULL
){
ERROR_PRINT
(
" DND DATA ERROR !!!
\n
"
);
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
if
(
roomId
->
type
==
cJSON_Number
){
sprintf
(
roomIdStr
,
"%d"
,
roomId
->
valueint
);
...
...
@@ -950,30 +911,30 @@ static int kk_service_executeDNDMode_handle(cJSON *params)
static
int
kk_service_setFloor_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
floorArray
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOORS
);
if
(
floorArray
==
NULL
){
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
kk_floor_delete_all
();
cJSON
*
item
=
floorArray
->
child
;
while
(
item
!=
NULL
){
cJSON
*
floorId
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
floorId
==
NULL
)
return
DEVICE_PARAM_ER
R
;
cJSON
*
name
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
name
==
NULL
)
return
DEVICE_PARAM_ER
R
;
kk_floor_add
(
name
->
valuestring
,
floorId
->
valuestring
);
cJSON
*
rooms
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ROOM_FLOOR_ROOMS
);
if
(
rooms
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
rooms
==
NULL
)
return
DEVICE_PARAM_ER
R
;
cJSON
*
itemroom
=
rooms
->
child
;
while
(
itemroom
!=
NULL
){
cJSON
*
roomid
=
cJSON_GetObjectItem
(
itemroom
,
MSG_AREA_ROOM_CCUROOMID
);
if
(
roomid
==
NULL
){
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
kk_room_set_floor_info
(
floorId
->
valuestring
,
""
,
roomid
->
valuestring
);
itemroom
=
itemroom
->
next
;
...
...
@@ -992,12 +953,12 @@ static int kk_service_setFloor_handle(cJSON *params)
static
int
kk_service_updateFloor_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
floorId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
floorId
==
NULL
)
return
DEVICE_PARAM_ER
R
;
cJSON
*
name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
name
==
NULL
)
return
DEVICE_PARAM_ER
R
;
kk_floor_add
(
name
->
valuestring
,
floorId
->
valuestring
);
return
SUCCESS_RETURN
;
}
...
...
@@ -1077,13 +1038,17 @@ static int kk_service_addFloor_handle(cJSON *params,cJSON *msgId,cJSON *root)
*************************************************************/
static
int
kk_service_deleteFloor_handle
(
cJSON
*
params
)
{
int
res
=
0
;
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
floorId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
)
return
INVALID_PARAMETER
;
kk_floor_delete_by_id
(
floorId
->
valuestring
);
return
SUCCESS_RETURN
;
if
(
floorId
==
NULL
)
return
DEVICE_PARAM_ERR
;
res
=
kk_floor_delete_by_id
(
floorId
->
valuestring
);
if
(
res
!=
SUCCESS_RETURN
){
res
=
DEVICE_CTRL_FAIL
;
}
return
res
;
}
/************************************************************
*功能描述:获取楼层
...
...
@@ -1308,17 +1273,17 @@ static int kk_service_addScreenToRoom_handle(cJSON *params)
char
str_mac
[
32
]
=
{
0
};
char
mac_head
[
6
]
=
{
0
};
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
mac
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
mac
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
mac
==
NULL
)
return
DEVICE_PARAM_ER
R
;
strcpy
(
str_mac
,
mac
->
valuestring
);
cJSON
*
roomname
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
if
(
roomname
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
roomname
==
NULL
)
return
DEVICE_PARAM_ER
R
;
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_CCUROOMID
);
if
(
roomId
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
roomId
==
NULL
)
return
DEVICE_PARAM_ER
R
;
cJSON
*
name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
name
==
NULL
)
return
DEVICE_PARAM_ER
R
;
_kk_mac_str_to_upper
(
str_mac
);
memcpy
(
mac_head
,
str_mac
,
5
);
if
(
strcmp
(
mac_head
,
"00:00"
)
==
0
){
...
...
@@ -1339,10 +1304,10 @@ static int kk_service_addScreenToRoom_handle(cJSON *params)
static
int
kk_service_removeScreenToRoom_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
serialid
==
NULL
)
return
DEVICE_PARAM_ER
R
;
kk_screenDev_update_room
(
serialid
->
valuestring
,
""
,
""
,
""
);
return
SUCCESS_RETURN
;
}
...
...
@@ -1356,10 +1321,10 @@ static int kk_service_removeScreenToRoom_handle(cJSON *params)
static
int
kk_service_deleteScreen_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETE
R
;
if
(
serialid
==
NULL
)
return
DEVICE_PARAM_ER
R
;
kk_screenDev_delete_by_serialId
(
serialid
->
valuestring
);
return
SUCCESS_RETURN
;
}
...
...
@@ -1447,6 +1412,7 @@ static int kk_service_LockKeyList_handle(cJSON *inforoot,cJSON *msgId)
{
int
res
=
0
;
int
i
=
0
,
num
=
0
;
LockKeyInfo_t
*
pList
=
NULL
;
if
(
inforoot
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETER
;
...
...
@@ -1584,7 +1550,7 @@ static int kk_service_addScene_handle(cJSON *param,cJSON *msgId)
char
sceneId
[
32
]
=
{
0
};
//kk_tsl_t *pSceneShadow = NULL;
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
res
=
kk_scene_parse_addscene
(
param
,
sceneId
,
0
,
msgId
->
valuestring
);
...
...
@@ -1603,10 +1569,10 @@ static int kk_service_updateScene_handle(cJSON *param,cJSON *msgId)
int
res
=
0
;
kk_tsl_t
*
pSceneShadow
=
NULL
;
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
sceneId
=
cJSON_GetObjectItem
(
param
,
MSG_SCENE_SCENEID
);
if
(
sceneId
==
NULL
)
return
FAIL_RETURN
;
if
(
sceneId
==
NULL
)
return
DEVICE_PARAM_ERR
;
pSceneShadow
=
kk_scene_shadow
();
if
(
pSceneShadow
!=
NULL
){
kk_tsl_set_value
(
kk_tsl_set_event_output_value
,
pSceneShadow
,
MSG_SCENE_UPDATENOTIFICATION_SCENEID
,
NULL
,
sceneId
->
valuestring
);
...
...
@@ -1628,14 +1594,17 @@ static int kk_service_enableScene_handle(cJSON *param,cJSON *msgId)
int
res
=
0
;
kk_tsl_t
*
pSceneShadow
=
NULL
;
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
sceneId
=
cJSON_GetObjectItem
(
param
,
MSG_SCENE_SCENEID
);
if
(
sceneId
==
NULL
)
return
FAIL_RETURN
;
if
(
sceneId
==
NULL
)
return
DEVICE_PARAM_ERR
;
cJSON
*
enable
=
cJSON_GetObjectItem
(
param
,
MSG_SCENE_ENABLE
);
if
(
enable
==
NULL
)
return
FAIL_RETURN
;
kk_scene_update_scene_enable
(
enable
->
valueint
,
sceneId
->
valuestring
);
return
res
;
if
(
enable
==
NULL
)
return
DEVICE_PARAM_ERR
;
res
=
kk_scene_update_scene_enable
(
enable
->
valueint
,
sceneId
->
valuestring
);
if
(
res
!=
SUCCESS_RETURN
){
return
DEVICE_CTRL_FAIL
;
}
return
NO_ERROR
;
}
/************************************************************
*功能描述:删除场景处理
...
...
@@ -1651,10 +1620,10 @@ static int kk_service_deleteScene_handle(cJSON *param,cJSON *msgId)
kk_tsl_t
*
pSceneShadow
=
NULL
;
char
sceneIdBuf
[
16
]
=
{
0
};
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
sceneId
=
cJSON_GetObjectItem
(
param
,
MSG_SCENE_SCENEID
);
if
(
sceneId
==
NULL
)
return
FAIL_RETURN
;
if
(
sceneId
==
NULL
)
return
DEVICE_PARAM_ERR
;
if
(
sceneId
->
valuestring
==
NULL
){
sprintf
(
sceneIdBuf
,
"%d"
,
sceneId
->
valueint
);
res
=
kk_scene_parse_deletescene
(
sceneIdBuf
);
...
...
@@ -1673,6 +1642,8 @@ static int kk_service_deleteScene_handle(cJSON *param,cJSON *msgId)
}
dm_msg_scene_event_post
(
MSG_SCENE_DELETENOTIFICATION
,
pSceneShadow
,
msgId
->
valuestring
);
}
}
else
{
res
=
DEVICE_CTRL_FAIL
;
}
return
res
;
}
...
...
@@ -1689,10 +1660,10 @@ static int kk_service_executeScene_handle(cJSON *param,cJSON *msgId)
int
res
=
0
;
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
sceneId
=
cJSON_GetObjectItem
(
param
,
MSG_SCENE_SCENEID
);
if
(
sceneId
==
NULL
)
return
FAIL_RETURN
;
if
(
sceneId
==
NULL
)
return
DEVICE_PARAM_ERR
;
res
=
kk_scene_execute_scene
(
sceneId
->
valuestring
,
msgId
->
valuestring
);
...
...
@@ -1964,18 +1935,18 @@ static int kk_service_bindScene_handle(cJSON *params,char *deviceCodeStr)
char
btnId
[
16
]
=
{
0
};
SensorType_t
*
pList
=
NULL
;
if
(
params
==
NULL
||
deviceCodeStr
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
bindType
=
cJSON_GetObjectItem
(
params
,
"bindType"
);
if
(
bindType
==
NULL
||
bindType
->
type
!=
cJSON_Number
){
ERROR_PRINT
(
"DATA ERROR!!!"
);
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
ButtonId
=
cJSON_GetObjectItem
(
params
,
"ButtonId"
);
if
(
ButtonId
==
NULL
||
ButtonId
->
type
!=
cJSON_Number
){
ERROR_PRINT
(
"DATA ERROR!!!"
);
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
sprintf
(
btnId
,
"%d"
,
ButtonId
->
valueint
);
kk_scene_delete_panel_scene_info
(
btnId
,
deviceCodeStr
);
//如果已经关联,先删除关联
...
...
@@ -1988,7 +1959,7 @@ static int kk_service_bindScene_handle(cJSON *params,char *deviceCodeStr)
cJSON
*
action
=
cJSON_GetObjectItem
(
params
,
MSG_SCENE_ACTIONS
);
if
(
action
==
NULL
||
action
->
type
!=
cJSON_Array
){
ERROR_PRINT
(
"DATA ERROR!!!"
);
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
client_list
=
action
->
child
;
while
(
client_list
!=
NULL
){
...
...
@@ -2016,7 +1987,7 @@ static int kk_service_bindScene_handle(cJSON *params,char *deviceCodeStr)
cJSON
*
action
=
cJSON_GetObjectItem
(
params
,
MSG_SCENE_ACTIONS
);
if
(
action
==
NULL
||
action
->
type
!=
cJSON_Array
){
ERROR_PRINT
(
"DATA ERROR!!!"
);
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
client_list
=
action
->
child
;
while
(
client_list
!=
NULL
){
...
...
@@ -2031,7 +2002,7 @@ static int kk_service_bindScene_handle(cJSON *params,char *deviceCodeStr)
cJSON
*
action
=
cJSON_GetObjectItem
(
params
,
MSG_SCENE_ACTIONS
);
if
(
action
==
NULL
||
action
->
type
!=
cJSON_Array
)
{
ERROR_PRINT
(
"DATA ERROR!!!"
);
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
cJSON
*
item
=
action
->
child
;
while
(
item
!=
NULL
){
...
...
@@ -2051,7 +2022,7 @@ static int kk_service_bindScene_handle(cJSON *params,char *deviceCodeStr)
}
}
return
res
;
return
NO_ERROR
;
}
int
kk_service_arming_set
(
char
*
state
)
{
...
...
@@ -2098,6 +2069,7 @@ static int _kk_cancel_warning_handle(char *deviceCode){
static
void
_iotx_linkkit_event_callback
(
iotx_dm_event_types_t
type
,
char
*
data
)
{
char
*
out
;
int
result
=
0
;
int
res
=
0
;
cJSON
*
json
;
cJSON
*
info_root
;
...
...
@@ -2203,6 +2175,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
char
ccuid
[
32
]
=
{
0
};
static
time_t
s_last_notify_time
=
0
;
s_CloudStatusRecv
=
1
;
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
state
=
cJSON_GetObjectItem
(
paramStr
,
MSG_IOTClOUDSTATE_STR
);
s_CloudStatus
=
atoi
(
state
->
valuestring
);
...
...
@@ -2276,58 +2249,55 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
INFO_PRINT
(
" adddevicetoroom
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
kk_service_addDeviceToRoom_handle
(
paramStr
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ADDDEVICETOROOM_REPLY
);
}
result
=
kk_service_addDeviceToRoom_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ADDDEVICETOROOM_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_REMOVEDEVICEFROMROOM
)
==
0
){
INFO_PRINT
(
" removedevicefromroom
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
kk_service_removeDeviceFromRoom_handle
(
paramStr
)
==
0
){
//kk_service_addDeviceToRoom_reply(info_root,msgId,1);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_REMOVEDEVICEFROMROOM_REPLY
);
}
result
=
kk_service_removeDeviceFromRoom_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_REMOVEDEVICEFROMROOM_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_ADDSCENC
)
==
0
){
INFO_PRINT
(
" add scene
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
kk_service_addScene_handle
(
paramStr
,
msgId
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ADDSCENC_REPLY
);
}
result
=
kk_service_addScene_handle
(
paramStr
,
msgId
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ADDSCENC_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_UPDATESCENC
)
==
0
){
INFO_PRINT
(
" update scene
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
kk_service_updateScene_handle
(
paramStr
,
msgId
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_UPDATESCENC_REPLY
);
}
result
=
kk_service_updateScene_handle
(
paramStr
,
msgId
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_UPDATESCENC_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_ENABLESCENC
)
==
0
){
INFO_PRINT
(
" enable scene
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
kk_service_enableScene_handle
(
paramStr
,
msgId
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ENABLESCENC_REPLY
);
}
result
=
kk_service_enableScene_handle
(
paramStr
,
msgId
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ENABLESCENC_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_DELETESCENC
)
==
0
){
INFO_PRINT
(
"delete scene
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
kk_service_deleteScene_handle
(
paramStr
,
msgId
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_DELETESCENC_REPLY
);
}
result
=
kk_service_deleteScene_handle
(
paramStr
,
msgId
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_DELETESCENC_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_EXECUTESCENE
)
==
0
){
INFO_PRINT
(
"execute scene
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
kk_service_executeScene_handle
(
paramStr
,
msgId
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_EXECUTESCENE_REPLY
);
}
result
=
kk_service_executeScene_handle
(
paramStr
,
msgId
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_EXECUTESCENE_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_SYNCDEVICEINFO
)
==
0
){
INFO_PRINT
(
"SYNCDEVICEINFO service
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
...
...
@@ -2372,10 +2342,9 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
INFO_PRINT
(
"bind scene
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
paramStr
!=
NULL
){
if
(
kk_service_bindScene_handle
(
paramStr
,
deviceCode
->
valuestring
)
==
0
){
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/bindScene_reply"
);
}
result
=
kk_service_bindScene_handle
(
paramStr
,
deviceCode
->
valuestring
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/bindScene_reply"
,
result
);
}
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_UNBINDSBUTTTON
)
==
0
){
...
...
@@ -2389,9 +2358,9 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
goto
directReturn
;
}
sprintf
(
btnId
,
"%d"
,
buttonId
->
valueint
);
kk_scene_delete_panel_scene_info
(
btnId
,
deviceCode
->
valuestring
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/unbindButton_reply"
);
result
=
kk_scene_delete_panel_scene_info
(
btnId
,
deviceCode
->
valuestring
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/unbindButton_reply"
,
result
);
}
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_ACTIVEBUTTON
)
==
0
){
...
...
@@ -2405,10 +2374,10 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
goto
directReturn
;
}
sprintf
(
btnId
,
"%d"
,
buttonId
->
valueint
);
if
(
kk_scene_execute_quickpanel
(
btnId
,
deviceCode
->
valuestring
)
==
0
){
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/activeButton_reply"
);
}
result
=
kk_scene_execute_quickpanel
(
btnId
,
deviceCode
->
valuestring
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/activeButton_reply"
,
result
);
}
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_GETCCUVERSION
)
==
0
){
...
...
@@ -2435,17 +2404,18 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_EXECUTEDNDMODE
)
==
0
){
INFO_PRINT
(
"EXECUREDNDMODE
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/executeDNDMode_reply"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_executeDNDMode_handle
(
paramStr
);
result
=
kk_service_executeDNDMode_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/executeDNDMode_reply"
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_SETFLOOR
)
==
0
){
INFO_PRINT
(
"SETFLOOR
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
kk_service_setFloor_handle
(
paramStr
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_SETFLOOR_REPLY
);
}
result
=
kk_service_setFloor_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_SETFLOOR_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_ADDFLOORS
)
==
0
){
INFO_PRINT
(
"ADDFLOOR
\n
"
);
...
...
@@ -2457,9 +2427,9 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
INFO_PRINT
(
"DELETEFLOOR
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
kk_service_deleteFloor_handle
(
paramStr
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_DELETEFLOORS_REPLY
);
}
result
=
kk_service_deleteFloor_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_DELETEFLOORS_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_GETFLOOR
)
==
0
){
INFO_PRINT
(
"GETFLOOR
\n
"
);
...
...
@@ -2471,9 +2441,9 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
INFO_PRINT
(
"UPDATEFLOOR
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
kk_service_updateFloor_handle
(
paramStr
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_UPDATEFLOORS_REPLY
);
}
result
=
kk_service_updateFloor_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_UPDATEFLOORS_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_CLIENTREPORT
)
==
0
){
INFO_PRINT
(
"CLIENTREPORT
\n
"
);
...
...
@@ -2485,23 +2455,23 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
INFO_PRINT
(
"SPECIALDEV TO ROOM
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
kk_service_addScreenToRoom_handle
(
paramStr
)
==
0
){
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_SPECIALDEVTOROOM_REPLY
);
}
result
=
kk_service_addScreenToRoom_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_SPECIALDEVTOROOM_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_RMSPECIALDEVFROMROOM
)
==
0
){
INFO_PRINT
(
"RM SPECIALDEV FROM ROOM
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_removeScreenToRoom_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_RMSPECIALDEVFROM_REPLY
);
result
=
kk_service_removeScreenToRoom_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_RMSPECIALDEVFROM_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_DELETESPECIALDEV
)
==
0
){
INFO_PRINT
(
"DELETE SPECIALDEV
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_deleteScreen_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_DELETESPECIALDEV_REPLY
);
result
=
kk_service_deleteScreen_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_DELETESPECIALDEV_REPLY
,
result
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_GETMOORELIST
)
==
0
){
INFO_PRINT
(
"SPECIALDEV GETLIST
\n
"
);
...
...
midware/midware/dm/kk_linkkit.h
View file @
07f53186
#ifndef _KK_LINKKIT_H_
#define _KK_LINKKIT_H_
#include "kk_tsl_common.h"
int
kk_mid_subdev_batch_add
(
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
],
char
*
version
);
int
kk_topo_delete_handle
(
cJSON
*
payload
,
cJSON
*
buf
);
int
kk_get_cloudstatus
(
void
);
...
...
@@ -12,7 +14,7 @@ void IOT_Linkkit_Yield(int timeout_ms);
int
IOT_Linkkit_Close
(
int
devid
);
int
kk_mid_subdev_add
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
],
char
version
[
32
]);
int
kk_service_arming_set
(
char
*
state
);
int
kk_service_common_reply
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
);
int
kk_service_common_reply
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
,
int
errorCode
);
int
kk_service_common_reply_ex
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
,
cJSON
*
Item
);
#endif
midware/midware/dm/kk_property_get_handle.c
View file @
07f53186
...
...
@@ -24,6 +24,7 @@
#include "kk_hal.h"
#include "kk_dm_msg.h"
#include "kk_linkkit.h"
extern
void
kk_sendData2gw
(
void
*
data
,
int
len
,
char
*
chalMark
);
static
int
kk_service_get_reply
(
char
*
deviceCode
,
char
*
productCode
,
char
*
msgId
,
double
param1
,
double
param2
,
double
param3
,
int
epNum
,
char
*
type
)
{
if
(
deviceCode
==
NULL
||
productCode
==
NULL
){
...
...
@@ -229,6 +230,25 @@ static int kk_property_AirSwitchConfig_handle(char *deviceCode,int epNum,char *m
cJSON_Delete
(
info
);
return
SUCCESS_RETURN
;
}
static
int
kk_property_sendtogw_handle
(
cJSON
*
payload
,
cJSON
*
info_root
,
char
*
deviceCode
)
{
int
res
=
0
;
cJSON
*
rootData
=
cJSON_CreateObject
();
dm_mgr_dev_node_t
*
node
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
char
*
info_rootS
=
cJSON_Print
(
info_root
);
char
*
payloadS
=
cJSON_Print
(
payload
);
cJSON_AddItemToObject
(
rootData
,
MSG_INFO_STR
,
cJSON_Parse
(
info_rootS
));
cJSON_AddItemToObject
(
rootData
,
MSG_PAYLOAD_STR
,
cJSON_Parse
(
payloadS
));
char
*
pnewout
=
cJSON_Print
(
rootData
);
kk_sendData2gw
(
pnewout
,
strlen
(
pnewout
),
node
->
fatherDeviceCode
);
//send to sub device
cJSON_Delete
(
rootData
);
free
(
info_rootS
);
free
(
payloadS
);
free
(
pnewout
);
return
res
;
}
static
int
kk_property_SocketRealTimePower_handle
(
char
*
deviceCode
,
int
epNum
,
char
*
msgid
)
{
int
res
=
0
;
...
...
@@ -452,7 +472,7 @@ static int kk_property_remoteOpenDoor_handle(char *deviceCode,int epNum,char *ms
kk_service_get_reply
(
deviceCode
,
node
->
productCode
,
msgid
,
remoteOpenDoor
,
-
1
,
-
1
,
epNum
,
"remoteOpenDoor"
);
return
SUCCESS_RETURN
;
}
int
kk_property_get_handle
(
cJSON
*
payload
,
char
*
deviceCode
)
int
kk_property_get_handle
(
cJSON
*
payload
,
char
*
deviceCode
,
cJSON
*
inforoot
)
{
cJSON
*
params
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
...
...
@@ -492,7 +512,7 @@ int kk_property_get_handle(cJSON * payload,char *deviceCode)
}
else
if
(
strcmp
(
pSub
->
valuestring
,
"LightProperty"
)
==
0
){
kk_property_LightProperty_handle
(
deviceCode
,
epNumInt
,
msgId
->
valuestring
);
}
else
if
(
strcmp
(
pSub
->
valuestring
,
"AirSwitchConfig"
)
==
0
){
kk_property_
AirSwitchConfig_handle
(
deviceCode
,
epNumInt
,
msgId
->
valuestring
);
kk_property_
sendtogw_handle
(
payload
,
inforoot
,
deviceCode
);
}
else
if
(
strcmp
(
pSub
->
valuestring
,
"SocketRealTimePower"
)
==
0
){
kk_property_SocketRealTimePower_handle
(
deviceCode
,
epNumInt
,
msgId
->
valuestring
);
}
else
if
(
strcmp
(
pSub
->
valuestring
,
"DeviceStatus"
)
==
0
){
...
...
@@ -509,6 +529,8 @@ int kk_property_get_handle(cJSON * payload,char *deviceCode)
kk_property_SwapState_handle
(
deviceCode
,
epNumInt
,
msgId
->
valuestring
);
}
else
if
(
strcmp
(
pSub
->
valuestring
,
"remoteOpenDoor"
)
==
0
){
kk_property_remoteOpenDoor_handle
(
deviceCode
,
epNumInt
,
msgId
->
valuestring
);
}
else
if
(
strcmp
(
pSub
->
valuestring
,
"AirSwitchStatus"
)
==
0
){
kk_property_sendtogw_handle
(
payload
,
inforoot
,
deviceCode
);
}
}
}
...
...
midware/midware/dm/kk_property_get_handle.h
View file @
07f53186
#ifndef _KK_PROPERTY_GET_H_
#define _KK_PROPERTY_GET_H_
int
kk_property_get_handle
(
cJSON
*
payload
,
char
*
deviceCode
);
int
kk_property_get_handle
(
cJSON
*
payload
,
char
*
deviceCode
,
cJSON
*
inforoot
);
#endif
\ No newline at end of file
midware/midware/dm/kk_sub_db.c
View file @
07f53186
...
...
@@ -1049,6 +1049,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *room
_kk_indoor_air_handle
(
pDeviceCode
,(
char
*
)
sceneId
,(
char
*
)
propertyName
,(
char
*
)
propertyValue
,(
char
*
)
type
,
delay
,
node
->
fatherDeviceCode
,(
char
*
)
roomId
);
continue
;
}
else
if
(
strcmp
(
typeArray
[
k
],
KK_DM_AIR_SWITCH_GATEWAY_TYPE
)
==
0
){
devIsExsit
=
1
;
_kk_air_switch_handle
(
pDeviceCode
,(
char
*
)
sceneId
,(
char
*
)
propertyName
,(
char
*
)
propertyValue
,(
char
*
)
type
,
delay
,
node
->
fatherDeviceCode
);
continue
;
}
...
...
@@ -1111,19 +1112,17 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *room
}
}
}
}
if
(
devIsExsit
==
0
){
//设置场景,但是又没有对应的设备需要插入一条无效action用于记录propertyName,同步需要
//res = kk_scene_insert_scene_action(type,"",1,
//propertyName,propertyValue,delay,sceneId,"");
//if(res != SUCCESS_RETURN){
//INFO_PRINT("kk_subDev_set_action_by_productType fail!!!\n");
//return res;
//continue;
//}
}
sqlite3_finalize
(
stmt
);
sqlite3_free
(
sqlCmd
);
}
if
(
devIsExsit
==
0
){
//设置场景,但是又没有对应的设备需要插入一条无效action用于记录propertyName,同步需要
res
=
kk_scene_insert_scene_action
(
type
,
""
,
1
,
propertyName
,
propertyValue
,
delay
,
sceneId
,
""
,
2
);
if
(
res
!=
SUCCESS_RETURN
){
INFO_PRINT
(
"kk_subDev_set_action_by_productType fail!!!
\n
"
);
}
}
return
SUCCESS_RETURN
;
}
...
...
midware/midware/midware.c
View file @
07f53186
...
...
@@ -778,7 +778,7 @@ int kk_dm_device_subdev_filter(char *data)
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
"params"
);
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
,
NO_ERROR
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_ADDBIND_MOTOR
)
==
0
){
INFO_PRINT
(
"ADDBIND_MOTOR
\n
"
);
...
...
@@ -788,7 +788,7 @@ int kk_dm_device_subdev_filter(char *data)
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_panel_bind_motor_handle
(
deviceCode
,
paramStr
,
msgId
,
KK_SERVICE_ADDBIND_MOTORS
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ADDBIND_MOTOR_REPLY
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_ADDBIND_MOTOR_REPLY
,
NO_ERROR
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_UNBIND_MOTORS
)
==
0
){
INFO_PRINT
(
"UNBIND_MOTORS
\n
"
);
...
...
@@ -797,7 +797,7 @@ int kk_dm_device_subdev_filter(char *data)
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
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
,
NO_ERROR
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_QUERY_BIND_MOTORS
)
==
0
){
INFO_PRINT
(
"QUERY_BIND_MOTORS
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
...
...
@@ -926,7 +926,6 @@ void mid_cb(void* data, int len){
}
deviceCode
=
cJSON_GetObjectItem
(
info_root
,
MSG_DEVICE_CODE_STR
);
type
=
cJSON_GetObjectItem
(
info_root
,
MSG_TYPE_STR
);
if
(
deviceCode
==
NULL
||
type
==
NULL
){
ERROR_PRINT
(
" params [%s] or [%s] can't find
\n
"
,
MSG_DEVICE_CODE_STR
,
MSG_TYPE_STR
);
cJSON_Delete
(
json
);
...
...
@@ -945,8 +944,18 @@ void mid_cb(void* data, int len){
cJSON_Delete
(
json
);
return
;
}
dm_mgr_dev_node_t
*
node
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
->
valuestring
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"res:%d
\n
"
,
res
);
cJSON_Delete
(
json
);
return
;
}
if
(
node
->
dev_type
==
KK_DM_DEVICE_SUBDEV
&&
node
->
isOffline
==
KK_DEV_OFFLINE
){
ERROR_PRINT
(
"do not handle the device is offline:%s
\n
"
,
deviceCode
->
valuestring
);
cJSON_Delete
(
json
);
return
;
}
/*****属性设置需要先检测设置参数是否超出物模型给定范围*******/
if
(
strcmp
(
type
->
valuestring
,
KK_THING_SERVICE_PROPERTY_SET
)
==
0
){
res
=
kk_property_set_data_check
(
payload
,
deviceCode
->
valuestring
);
...
...
@@ -956,46 +965,34 @@ void mid_cb(void* data, int len){
}
}
if
(
strcmp
(
type
->
valuestring
,
KK_THING_SERVICE_PROPERTY_GET
)
==
0
){
res
=
kk_property_get_handle
(
payload
,
deviceCode
->
valuestring
);
res
=
kk_property_get_handle
(
payload
,
deviceCode
->
valuestring
,
info_root
);
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
" kk_property_get_handle error
\n
"
);
}
cJSON_Delete
(
json
);
return
;
}
int
devType
=
0
;
dm_mgr_get_devicetype_by_devicecode
(
deviceCode
->
valuestring
,
&
devType
);
//主机的device或过滤的
if
(
devT
ype
==
KK_DM_DEVICE_CCU
||
_kk_filter_to_plat
(
type
->
valuestring
)){
if
(
node
->
dev_t
ype
==
KK_DM_DEVICE_CCU
||
_kk_filter_to_plat
(
type
->
valuestring
)){
void
*
buf
=
malloc
(
len
);
memcpy
(
buf
,
data
,
len
);
res
=
dm_queue_msg_insert
((
void
*
)
buf
);
if
(
res
!=
SUCCESS_RETURN
)
{
free
(
buf
);
}
}
else
if
(
devType
==
KK_DM_DEVICE_GATEWAY
){
}
else
if
(
node
->
dev_type
==
KK_DM_DEVICE_GATEWAY
){
/*手机端主动删除设备,需要删除数据库相关内容,再下发给网关*/
if
(
strcmp
(
type
->
valuestring
,
KK_THING_TOPO_CHANGE_MSG
)
==
0
){
//kk_topo_delete_handle(payload,data);
}
kk_sendData2gw
(
data
,
strlen
(
data
),
deviceCode
->
valuestring
);
//send to gw itself
}
else
if
(
devType
==
KK_DM_DEVICE_SUBDEV
){
}
else
if
(
node
->
dev_type
==
KK_DM_DEVICE_SUBDEV
){
if
(
kk_dm_device_subdev_filter
(
data
)
==
0
){
ERROR_PRINT
(
"
\n\n
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\n\n
"
);
//
}
else
{
dm_mgr_dev_node_t
*
gw_node
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
->
valuestring
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"res:%d
\n
"
,
res
);
cJSON_Delete
(
json
);
return
;
}
if
(
gw_node
->
isOffline
==
KK_DEV_OFFLINE
){
ERROR_PRINT
(
"do not handle the device is offline:%s
\n
"
,
deviceCode
->
valuestring
);
cJSON_Delete
(
json
);
return
;
}
#if 0
if(strcmp(gw_node->productType,KK_DM_AIR_SWITCH_GATEWAY_TYPE) == 0){
res = _kk_handle_airswitch_property(gw_node->fatherDeviceCode,info_root,payload);//空开epnum 传的是数组,无语
...
...
@@ -1021,7 +1018,7 @@ void mid_cb(void* data, int len){
cJSON_AddItemToObject
(
rootData
,
MSG_INFO_STR
,
cJSON_Parse
(
info_rootS
));
cJSON_AddItemToObject
(
rootData
,
MSG_PAYLOAD_STR
,
cJSON_Parse
(
payloadS
));
char
*
pnewout
=
cJSON_Print
(
rootData
);
kk_sendData2gw
(
pnewout
,
strlen
(
pnewout
),
gw_
node
->
fatherDeviceCode
);
//send to sub device
kk_sendData2gw
(
pnewout
,
strlen
(
pnewout
),
node
->
fatherDeviceCode
);
//send to sub device
cJSON_Delete
(
rootData
);
free
(
info_rootS
);
free
(
payloadS
);
...
...
@@ -1646,7 +1643,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
);
}
if
(
sensorDev
){
kk_alarm_notify_handle
(
node
,
itemData
->
identifier
,
valueBuf
);
//告警信息处理
kk_alarm_notify_handle
(
node
,
itemData
->
identifier
,
valueBuf
,
eventItem
->
identifier
);
//告警信息处理
}
if
(
pack
==
0
){
INFO_PRINT
(
"kk_platMsg_handle data: event post,eventItem->identifier:%s
\n
"
,
eventItem
->
identifier
);
...
...
@@ -1692,6 +1689,9 @@ void kk_platMsg_handle(void* data, char* chalMark){
}
else
if
(
strcmp
(
eventItem
->
identifier
,
MSG_PROPERTY_STR
)
!=
0
&&
eventItem
->
output_data_number
==
0
){
if
(
strstr
(
msgType
->
valuestring
,
eventItem
->
identifier
)
==
NULL
){
continue
;
}
if
(
strcmp
(
eventItem
->
identifier
,
"DoorBell"
)
!=
0
){
//门铃事件不处理;
dm_msg_thing_event_post
(
info_dcode
->
valuestring
,
eventItem
->
identifier
,
NULL
);
}
...
...
midware/midware/scene/kk_mutictrl_handle.c
View file @
07f53186
...
...
@@ -11,7 +11,7 @@
#include "kk_property_db.h"
#include "kk_mutictrl_handle.h"
#include "kk_scene_handle.h"
mutictrl_timestamp_t
g_mc_stamp
=
{
0
};
static
int
_kk_check_virtual_device
(
char
*
sceneId
)
{
int
res
=
0
;
...
...
@@ -233,6 +233,7 @@ static int _kk_manual_mutictrl_set(cJSON *param,char *setDeviceCode,int ep,char*
cJSON
*
propertyItem
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
srcDeviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
setDeviceCode
,
&
setDevnode
);
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
offflag
=
0
;
memset
(
valueStr
,
0x0
,
sizeof
(
valueStr
));
...
...
@@ -337,6 +338,9 @@ static int _kk_manual_mutictrl_ctrl(char *sceneId,char *deviceCode,int ep,cJSON
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
isManualDev
=
_kk_check_manualMutiCtrlDev
((
const
char
*
)
deviceCode
);
//上报的设备是否是需要手动触发多控设备
memset
(
g_mc_stamp
.
sceneId
,
0x0
,
sizeof
(
g_mc_stamp
.
sceneId
));
memcpy
(
g_mc_stamp
.
sceneId
,
sceneId
,
strlen
(
sceneId
));
g_mc_stamp
.
timestamp
=
HAL_Uptimes
();
sqlCmd
=
sqlite3_mprintf
(
"select * from SceneActionInfo WHERE sceneId= '%s' and type = '%s'"
,
sceneId
,
"action/thing/group"
);
//actice判断设备是否移入待分配
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
...
...
@@ -427,6 +431,10 @@ int kk_manual_mutictrl_execute(const char*deviceCode,cJSON *param)
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
if
(
strcmp
(
sceneId
,
g_mc_stamp
.
sceneId
)
==
0
&&
HAL_Uptimes
()
-
g_mc_stamp
.
timestamp
<=
2
){
INFO_PRINT
(
"muti ctrl alread exexute !!!
\n
"
);
//return -1;
}
INFO_PRINT
(
"sceneId:%s
\n
"
,
sceneId
);
_kk_manual_mutictrl_ctrl
(
sceneId
,(
char
*
)
deviceCode
,
ep
,
param
,
isMutiEp
);
...
...
midware/midware/scene/kk_mutictrl_handle.h
View file @
07f53186
#ifndef __KK_MUTICTRL_HANDLE_H__
#define __KK_MUTICTRL_HANDLE_H__
#include "cJSON.h"
typedef
struct
{
char
sceneId
[
16
];
time_t
timestamp
;
}
mutictrl_timestamp_t
;
int
kk_virtual_mutictrl_check
(
const
char
*
deviceCode
,
cJSON
*
param
);
int
kk_manual_mutictrl_execute
(
const
char
*
deviceCode
,
cJSON
*
param
);
#endif
\ No newline at end of file
midware/midware/scene/kk_scene_db.c
View file @
07f53186
...
...
@@ -1082,7 +1082,6 @@ int kk_scene_delete_scene_action(const char *sceneId,int isforword)
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_scene_insert_sceneProType_info
(
const
char
*
roomId
,
char
*
propertyName
,
char
*
propertyValue
,
const
char
*
sceneId
,
char
*
productType
,
int
delay
)
{
int
res
=
0
;
...
...
midware/midware/scene/kk_scene_handle.c
View file @
07f53186
...
...
@@ -1692,7 +1692,7 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
kk_tsl_t
*
pSceneShadow
=
NULL
;
if
(
args
==
NULL
||
sceneId
==
NULL
){
ERROR_PRINT
(
"[%d]kk_scene_parse_addscene fail!!!
\n
"
,
__LINE__
);
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
cJSON
*
room_id
=
cJSON_GetObjectItem
(
args
,
MSG_AREA_ROOM_CCUROOMID
);
if
(
room_id
==
NULL
)
...
...
@@ -1700,11 +1700,11 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
INFO_PRINT
(
"NOT Contain the room info
\n
"
);
}
cJSON
*
name
=
cJSON_GetObjectItem
(
args
,
MSG_SCENE_SCENE_NAME
);
if
(
name
==
NULL
)
return
FAIL_RETURN
;
if
(
name
==
NULL
)
return
DEVICE_PARAM_ERR
;
cJSON
*
sceneType
=
cJSON_GetObjectItem
(
args
,
MSG_SCENE_SCENCTYPE
);
if
(
sceneType
==
NULL
)
return
FAIL_RETURN
;
if
(
sceneType
==
NULL
)
return
DEVICE_PARAM_ERR
;
cJSON
*
enable
=
cJSON_GetObjectItem
(
args
,
MSG_SCENE_ENABLE
);
if
(
enable
==
NULL
)
return
FAIL_RETURN
;
if
(
enable
==
NULL
)
return
DEVICE_PARAM_ERR
;
if
(
!
isUpdate
){
HAL_GetTime_s
(
sceneId
);
//use time to create the sceneId
pSceneShadow
=
kk_scene_shadow
();
...
...
@@ -1728,13 +1728,13 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
else
{
if
(
res
!=
SUCCESS_RETURN
){
INFO_PRINT
(
"kk_scene_insert_scene_info fail!!!
\n
"
);
return
res
;
return
DEVICE_CTRL_OFTEN
;
}
res
=
kk_scene_parse_scene_trigger
(
args
,
sceneId
);
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
"kk_scene_parse_scene_trigger failed
\n
"
);
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
res
=
kk_scene_parse_scene_condition
(
args
,
sceneId
);
if
(
res
!=
SUCCESS_RETURN
){
...
...
@@ -1746,7 +1746,7 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
"kk_scene_parse_scene_action failed
\n
"
);
kk_scene_delete
(
sceneId
,
0
);
return
FAIL_RETURN
;
return
DEVICE_PARAM_ERR
;
}
}
if
(
pSceneShadow
!=
NULL
){
...
...
@@ -1769,7 +1769,7 @@ int kk_scene_parse_updatescene(const cJSON* arg,char *sceneId)
if
(
arg
==
NULL
||
sceneId
==
NULL
){
ERROR_PRINT
(
"[%d]kk_scene_parse_addscene fail!!!
\n
"
,
__LINE__
);
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
kk_scene_delete
(
sceneId
,
0
);
return
kk_scene_parse_addscene
(
arg
,
sceneId
,
1
,
NULL
);
...
...
@@ -2640,7 +2640,7 @@ static int _kk_check_lock_trigger_info(char *proName,char *value,char *keyId,cha
continue
;
}
}
if
(
strcmp
(
propertyName
->
valuestring
,
"KeyID"
)
!
=
0
){
if
(
strcmp
(
propertyName
->
valuestring
,
"KeyID"
)
=
=
0
){
compareValue
=
cJSON_GetObjectItem
(
pSub
,
"compareValue"
);
if
(
strcmp
(
compareValue
->
valuestring
,
keyId
)
!=
0
){
return
FAIL_RETURN
;
...
...
@@ -2790,7 +2790,7 @@ int kk_scene_execute_scene(const char *sceneId,const char *msgId)
int
sceneType
=
0
;
int
isEnable
=
0
;
if
(
sceneId
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
res
=
kk_scene_get_scene_info
(
sceneId
,
&
sceneType
,
&
isEnable
);
if
(
res
==
SUCCESS_RETURN
&&
sceneType
==
DB_SCENETYPE_SCENE
&&
isEnable
){
...
...
@@ -2802,7 +2802,7 @@ int kk_scene_execute_scene(const char *sceneId,const char *msgId)
//}
}
INFO_PRINT
(
"[%d]kk_scene_execute_scene called!!!
\n
"
,
__LINE__
);
return
res
;
return
NO_ERROR
;
}
void
kk_scene_execute_event_post
(
const
char
*
sceneId
,
const
char
*
msgId
)
{
...
...
@@ -2860,7 +2860,7 @@ int kk_scene_execute_quickpanel(const char *buttonId,char *deviceCode)
int
bindType
=
0
;
char
sceneId
[
32
]
=
{
0
};
if
(
buttonId
==
NULL
||
deviceCode
==
NULL
){
return
INVALID_PARAMETE
R
;
return
DEVICE_PARAM_ER
R
;
}
res
=
kk_scene_get_quickpanel_info
(
buttonId
,
deviceCode
,
sceneId
,
&
bindType
);
if
(
res
==
SUCCESS_RETURN
){
...
...
@@ -2872,6 +2872,8 @@ int kk_scene_execute_quickpanel(const char *buttonId,char *deviceCode)
}
else
{
kk_scene_execute_action
(
sceneId
,
NULL
);
}
}
else
{
res
=
DEVICE_CTRL_FAIL
;
}
INFO_PRINT
(
"[%d]kk_scene_execute_quickpanel called!!!
\n
"
,
__LINE__
);
return
res
;
...
...
midware/tsl/tsl_handle/kk_tsl_common.h
View file @
07f53186
...
...
@@ -99,7 +99,21 @@ typedef enum {
KK_TSL_DATA_TARGET_SERVICE_INPUT_DATA
,
KK_TSL_DATA_TARGET_SERVICE_OUTPUT_DATA
}
kk_tsl_data_target_e
;
typedef
enum
{
NO_ERROR
=
0
,
DEVICE_CTRL_FAIL
=
10100
,
DEVICE_OFFLINE_ERR
=
10101
,
DEVICE_NOT_EXSIT
=
10102
,
DEVICE_DELETE_FAIL
=
10103
,
DEVICE_NOT_SUPPORT
=
10104
,
DEVICE_BUSY
=
10105
,
DEVICE_NOT_RESPONSE
=
10106
,
DEVICE_PARAM_ERR
=
10001
,
DEVICE_TIMEOUR
=
10003
,
DEVICE_CTRL_OFTEN
=
10712
,
DEVICE_SCENE_TOO_MUSH
=
13001
,
}
kk_to_cloud_code_t
;
typedef
enum
{
DEVICE_HEARTBEAT_TIMEOUT
=
-
15
,
TSL_ALREADY_EXIST
=
-
14
,
...
...
tsl/product_3015.json
View file @
07f53186
{
"schema"
:
"https://iot-ap.ikonke.com/model/product_3015.json"
,
"productType"
:
"sensor"
,
"version"
:
"1.
1
"
,
"version"
:
"1.
2
"
,
"profile"
:
{
"heartbeat"
:
"300"
,
"productCode"
:
"3015"
,
"productName"
:
"铂金系列.零火线SOS紧急呼叫面板Z3S(KONKE)"
},
"services"
:
[
{
"outputData"
:
[
],
"identifier"
:
"set"
,
"inputData"
:
[
{
"identifier"
:
"SosState"
,
"name"
:
"紧急按钮告警状态"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"没有报警"
,
"1"
:
"报警"
}
}
}
],
"method"
:
"thing.service.property.set"
,
"name"
:
"set"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性设置"
},
{
"outputData"
:
[
{
...
...
@@ -96,6 +120,15 @@
"type"
:
"alarm"
,
"required"
:
true
,
"desc"
:
"紧急按钮告警"
},
{
"outputData"
:
[],
"identifier"
:
"clearSosAlarm"
,
"method"
:
"thing.event.clearSosAlarm.post"
,
"name"
:
"clearSosAlarm"
,
"type"
:
"alarm"
,
"required"
:
true
,
"desc"
:
"紧急按钮告警解除"
}
]
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment