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
38f01a95
Commit
38f01a95
authored
Mar 10, 2022
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cwc' into 'master'
【修改内容】修改相关BUG See merge request chenweican/k-sdk!203
parents
adc28c95
07f53186
Changes
18
Expand all
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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
This diff is collapsed.
Click to expand it.
midware/midware/dm/kk_linkkit.h
View file @
38f01a95
#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 @
38f01a95
...
...
@@ -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 @
38f01a95
#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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
#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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
...
...
@@ -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 @
38f01a95
{
"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