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
adc28c95
Commit
adc28c95
authored
Mar 08, 2022
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cwc' into 'master'
Cwc See merge request chenweican/k-sdk!202
parents
c2542639
0e303cf6
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1093 additions
and
602 deletions
+1093
-602
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+3
-8
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+3
-10
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+3
-9
midware/midware/dm/kk_alarm_handle.c
midware/midware/dm/kk_alarm_handle.c
+32
-15
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+2
-2
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+2
-2
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+36
-2
midware/midware/dm/kk_property_db.h
midware/midware/dm/kk_property_db.h
+1
-0
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+39
-21
midware/midware/dm/kk_sub_db.h
midware/midware/dm/kk_sub_db.h
+2
-1
midware/midware/midware.c
midware/midware/midware.c
+105
-23
midware/midware/scene/kk_mutictrl_handle.c
midware/midware/scene/kk_mutictrl_handle.c
+435
-0
midware/midware/scene/kk_mutictrl_handle.h
midware/midware/scene/kk_mutictrl_handle.h
+6
-0
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+45
-134
midware/midware/scene/kk_scene_pollution_check.c
midware/midware/scene/kk_scene_pollution_check.c
+0
-4
nx5_soc_gw/smarthome_z3gw_a133
nx5_soc_gw/smarthome_z3gw_a133
+0
-0
tsl/product_3057.json
tsl/product_3057.json
+1
-1
tsl/product_3064.json
tsl/product_3064.json
+378
-370
No files found.
application/kcloud/kcloud_main.c
View file @
adc28c95
...
...
@@ -175,8 +175,6 @@ static int mqtt_start(void)
count
=
0
;
WARNING_PRINT
(
"---------------------------------->CONNECT FAIL!!!
\n
"
);
break
;
//INFO_PRINT("i am send now\n");
//KK_MQTT_SendMsg(TOPIC,"hello my world",2);
}
}
else
{
if
(
count
>
0
){
...
...
@@ -199,7 +197,7 @@ static int mqtt_start_ex(int isdefault)
MQTTAsync
mqttClient
;
int
rc
=
0
;
if
(
isdefault
){
mqttClient
=
kk_connect_default
();
//
mqttClient = kk_connect_default();
}
else
{
mqttClient
=
kk_mqtt_connect
();
}
...
...
@@ -213,13 +211,10 @@ static int mqtt_start_ex(int isdefault)
if
(
kk_get_cloud_status
()
==
0
){
//printf("------------------------------>count:%d\n",count);
count
++
;
if
(
count
>
500
)
{
if
(
count
>
50
){
count
=
0
;
WARNING_PRINT
(
"---------------------------------->CONNECT FAIL!!!
\n
"
);
break
;
//INFO_PRINT("i am send now\n");
//KK_MQTT_SendMsg(TOPIC,"hello my world",2);
}
}
else
{
if
(
count
>
0
){
...
...
@@ -320,8 +315,8 @@ int main(int argc, char* argv[])
#endif
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromDev
,
NULL
,
NULL
);
#if 1
kk_dl_config
();
again:
kk_dl_config
();
rc
=
kk_register_auth_get
();
if
(
rc
==
0
){
rc
=
mqtt_start_ex
(
0
);
...
...
application/kcloud/kk_register.c
View file @
adc28c95
...
...
@@ -477,6 +477,7 @@ static int _kk_parse_auth_dl_host(cJSON *authInfo,char *url){
}
static
int
_kk_get_auth_dl_host
(
char
*
buf
,
char
*
url
){
cJSON
*
authInfo
=
NULL
;
int
ret
=
0
;
if
(
buf
==
NULL
||
url
==
NULL
){
return
-
1
;
}
...
...
@@ -490,9 +491,9 @@ static int _kk_get_auth_dl_host(char *buf,char *url){
}
else
{
authInfo
=
cJSON_GetObjectItem
(
data
,
"mqtt_auth_entry"
);
}
_kk_parse_auth_dl_host
(
authInfo
,
url
);
ret
=
_kk_parse_auth_dl_host
(
authInfo
,
url
);
cJSON_Delete
(
configObj
);
return
0
;
return
ret
;
}
static
int
s_getAuthSize
=
0
;
size_t
receive_auth_data
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
FILE
*
file
){
...
...
@@ -531,16 +532,8 @@ int kk_register_auth_get(){
static
int
s_count
=
0
;
CURL
*
curl
;
ret
=
kk_check_config_file
(
KK_CONFIG_FILE_PATH
,
&
configData
);
defaultCon:
if
(
ret
!=
0
){
defaultFlag
=
1
;
ret
=
kk_check_config_file
(
KK_DEFAULT_CONFIG_FILE_PATH
,
&
configData
);
}
if
(
ret
==
0
){
ret
=
_kk_get_auth_dl_host
(
configData
,
url
);
if
(
ret
==
-
2
&&
defaultFlag
==
0
){
goto
defaultCon
;
}
if
(
ret
==
0
){
again:
s_count
++
;
...
...
application/kcloud/mqtt_api.c
View file @
adc28c95
...
...
@@ -10,7 +10,6 @@ static const char* OPT_SEND = "MQTTAsync_sendMessage";
static
const
char
*
OPT_SUB
=
"MQTTAsync_subscribe"
;
static
const
char
*
OPT_UNSUB
=
"MQTTAsync_unsubscribe"
;
static
MQTTAsync
s_Client
;
static
int
s_mqttStop
=
0
;
static
int
s_cloudStatus
=
DEVICE_OFFLINE
;
static
char
*
kk_will_message_create
(
char
*
ccuid
,
cJSON
*
payload
)
...
...
@@ -50,7 +49,6 @@ static void connlost(void *context, char *cause)
if
(
context
==
NULL
||
cause
==
NULL
)
{
ERROR_PRINT
(
"PARAM ERROR
\n
"
);
s_mqttStop
=
1
;
s_cloudStatus
=
DEVICE_OFFLINE
;
kk_write_disconnect_flag
();
KK_Send_CloudState
(
s_cloudStatus
);
...
...
@@ -75,7 +73,7 @@ static void connlost(void *context, char *cause)
cJSON
*
willPayload
=
cJSON_CreateObject
();
message
=
kk_will_message_create
(
ccuid
,
willPayload
);
conn_opts
.
keepAliveInterval
=
20
;
conn_opts
.
cleansession
=
1
;
conn_opts
.
cleansession
=
0
;
will_opts
.
retained
=
0
;
//retained = 1 时, broker会一直保留消息,这里不需要,使用默认的0就行
will_opts
.
topicName
=
topicBuf
;
will_opts
.
message
=
message
;
...
...
@@ -83,7 +81,6 @@ static void connlost(void *context, char *cause)
if
((
rc
=
MQTTAsync_connect
(
client
,
&
conn_opts
))
!=
MQTTASYNC_SUCCESS
)
{
ERROR_PRINT
(
"Failed to start connect, return code %d
\n
"
,
rc
);
s_mqttStop
=
1
;
}
free
(
message
);
cJSON_Delete
(
willPayload
);
...
...
@@ -92,13 +89,11 @@ static void connlost(void *context, char *cause)
void
onDisconnectFailure
(
void
*
context
,
MQTTAsync_failureData
*
response
)
{
WARNING_PRINT
(
"Disconnect failed
\n
"
);
s_mqttStop
=
1
;
}
void
onDisconnect
(
void
*
context
,
MQTTAsync_successData
*
response
)
{
WARNING_PRINT
(
"Successful disconnection
\n
"
);
s_mqttStop
=
1
;
}
void
onSendFailure
(
void
*
context
,
MQTTAsync_failureData
*
response
)
...
...
@@ -136,7 +131,6 @@ void onSend(void* context, MQTTAsync_successData* response)
extern
void
KK_reset_sub_flag
(
void
);
void
onConnectFailure
(
void
*
context
,
MQTTAsync_failureData
*
response
)
{
s_mqttStop
=
1
;
if
(
response
==
NULL
)
{
ERROR_PRINT
(
"PARAM ERROR
\n
"
);
...
...
@@ -299,7 +293,7 @@ MQTTAsync KK_MQTT_Connect(void)
//conn_opts.password = PASSWORD;
conn_opts
.
username
=
usrname
;
conn_opts
.
password
=
token
;
conn_opts
.
cleansession
=
1
;
conn_opts
.
cleansession
=
0
;
conn_opts
.
onSuccess
=
onConnect
;
conn_opts
.
onFailure
=
onConnectFailure
;
conn_opts
.
context
=
s_Client
;
...
...
@@ -357,7 +351,7 @@ MQTTAsync KK_MQTT_Connect_ex(char *usrname,char*pwd,char*cliendId,char*host,char
//conn_opts.password = PASSWORD;
conn_opts
.
username
=
usrname
;
conn_opts
.
password
=
pwd
;
conn_opts
.
cleansession
=
1
;
conn_opts
.
cleansession
=
0
;
conn_opts
.
onSuccess
=
onConnect
;
conn_opts
.
onFailure
=
onConnectFailure
;
conn_opts
.
context
=
s_Client
;
...
...
midware/midware/dm/kk_alarm_handle.c
View file @
adc28c95
...
...
@@ -73,37 +73,50 @@ int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char *valueB
HAL_Get_ccuid
(
ccuid
);
kk_property_db_get_value
(
node
->
deviceCode
,
"SensorType"
,
&
currentValue
);
INFO_PRINT
(
"------------------------->currentValue:%d
\n
"
,
currentValue
);
INFO_PRINT
(
"------------------------->armingstate:%d
\n
"
,
atoi
(
armingstate
));
INFO_PRINT
(
"------------------------->valueBuf:%s
\n
"
,
valueBuf
);
INFO_PRINT
(
"------------------------->identifier:%s
\n
"
,
identifier
);
//INFO_PRINT("------------------------->currentValue:%d\n",currentValue);
//INFO_PRINT("------------------------->valueBuf:%s\n",valueBuf);
//INFO_PRINT("------------------------->identifier:%s\n",identifier);
kk_property_db_get_value
(
ccuid
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
,
armingstate
);
if
(
strcmp
(
node
->
productCode
,
"3064"
)
==
0
){
//门锁强报警
currentValue
=
SUB_ARMING_ALL_STATE
;
}
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
"/thing/event/alarmNotify"
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
node
->
deviceCode
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
node
->
productCode
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"method"
,
"thing.event.alarmNotify"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"identifier"
,
"alarmNotify"
);
char
msgId
[
64
]
=
{
0
};
iotx_report_id
(
msgId
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
);
//char timerStr[16] = {0};
//HAL_GetTime_s(timerStr);
cJSON_AddNumberToObject
(
payload
,
"time"
,
HAL_GetTime_ms
());
cJSON
*
param
=
cJSON_CreateObject
();
if
(
strcmp
(
identifier
,
"BatteryAlarm"
)
==
0
){
cJSON_AddStringToObject
(
param
,
"LowBatteryState"
,
"1"
);
//needSave = 1;
if
(
atoi
(
valueBuf
)
==
1
){
cJSON_AddStringToObject
(
param
,
"LowBatteryState"
,
"1"
);
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
"/thing/event/BatteryAlarm/post"
);
cJSON_AddStringToObject
(
payload
,
"method"
,
"thing.event.BatteryAlarm.post"
);
cJSON_AddStringToObject
(
payload
,
"identifier"
,
"BatteryAlarm"
);
}
else
{
cJSON_Delete
(
param
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
0
;
}
}
else
if
(
strcmp
(
identifier
,
"DismantleState"
)
==
0
){
if
(
atoi
(
valueBuf
)
==
1
){
cJSON_AddStringToObject
(
param
,
"DismantleState"
,
valueBuf
);
if
(
strcmp
(
node
->
productCode
,
"3064"
)
==
0
){
//门锁防拆特殊处理
cJSON_AddStringToObject
(
param
,
"DismantleState"
,
valueBuf
);
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
"/thing/event/LockTamperAlarm/post"
);
cJSON_AddStringToObject
(
payload
,
"method"
,
"thing.event.LockTamperAlarm.post"
);
cJSON_AddStringToObject
(
payload
,
"identifier"
,
"LockTamperAlarm"
);
}
else
{
cJSON_AddStringToObject
(
param
,
"DismantleState"
,
valueBuf
);
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
"/thing/event/alarmNotify"
);
cJSON_AddStringToObject
(
payload
,
"method"
,
"thing.event.alarmNotify"
);
cJSON_AddStringToObject
(
payload
,
"identifier"
,
"alarmNotify"
);
}
}
else
{
cJSON_Delete
(
param
);
cJSON_Delete
(
payload
);
...
...
@@ -115,6 +128,9 @@ int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char *valueB
//cJSON_AddStringToObject(param, "CommonAlarmState", valueBuf);
// }
else
{
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
"/thing/event/alarmNotify"
);
cJSON_AddStringToObject
(
payload
,
"method"
,
"thing.event.alarmNotify"
);
cJSON_AddStringToObject
(
payload
,
"identifier"
,
"alarmNotify"
);
if
(
atoi
(
valueBuf
)
==
1
){
cJSON_AddStringToObject
(
param
,
"CommonAlarmState"
,
"1"
);
}
else
{
...
...
@@ -127,6 +143,7 @@ int kk_alarm_notify_handle(dm_mgr_dev_node_t *node,char *identifier,char *valueB
}
cJSON_AddItemToObject
(
payload
,
"params"
,
param
);
char
*
payload11
=
cJSON_Print
(
payload
);
char
*
infff
=
cJSON_Print
(
info
);
if
(
currentValue
==
SUB_ARMING_ALL_STATE
)
//24小时警戒
{
INFO_PRINT
(
"payload11: %s
\n
"
,
payload11
);
...
...
midware/midware/dm/kk_dm_mng.c
View file @
adc28c95
...
...
@@ -1910,12 +1910,12 @@ int kk_is_mutiEp_device(const char *deviceCode)
int
res
=
0
;
int
idx
=
0
;
kk_tsl_data_t
*
property
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
}
}
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
...
...
midware/midware/dm/kk_linkkit.c
View file @
adc28c95
...
...
@@ -1288,9 +1288,9 @@ static int kk_service_addScreen_handle(cJSON *info,cJSON *msgId,cJSON *params)
if
(
devtype
==
NULL
)
return
INVALID_PARAMETER
;
kk_service_addScreen_handle_reply
(
info
,
msgId
,
serialid
->
valuestring
);
if
(
strcmp
(
mac_head
,
"01:01"
)
==
0
){
//moore4c mac
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
&
str_mac
[
6
],
version
->
valuestring
,
""
);
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
&
str_mac
[
6
],
version
->
valuestring
,
""
,
"MOORE4C"
);
}
else
{
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
str_mac
,
version
->
valuestring
,
""
);
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
str_mac
,
version
->
valuestring
,
""
,
"MOORE4S"
);
}
kk_service_client_online_push
(
info
,
msgId
,
serialid
->
valuestring
);
return
SUCCESS_RETURN
;
...
...
midware/midware/dm/kk_property_db.c
View file @
adc28c95
...
...
@@ -838,7 +838,41 @@ int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_
_kk_property_db_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述: 获取空调内机属性值
*输入参数: deviceCode:设备deviceCode
identifier:属性名称
*输出参数: value:属性值,返回的是字串
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_indoorair_property_db_get_value_directly
(
const
char
*
deviceCode
,
const
char
*
identifier
,
char
*
value
,
int
ep
)
{
char
*
sqlCmd
=
NULL
;
//int rc = 0;
//char *zErrMsg = 0;
int
epNum
=
0
;
sqlite3_stmt
*
stmt
;
char
*
valueStr
=
""
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
"select * from indoorAirProperties WHERE deviceCode= '%s' and identifier = '%s'"
,
deviceCode
,
identifier
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
valueStr
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_INDOORAIR_VALUE
);
epNum
=
sqlite3_column_int
(
stmt
,
DB_INDOORAIR_EPNUM
);
if
(
ep
==
epNum
){
memcpy
(
value
,
valueStr
,
strlen
(
valueStr
));
}
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
sqlite3_finalize
(
stmt
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述: 查询空调内机数量
*输入参数: deviceCode:设备deviceCode
...
...
@@ -1062,11 +1096,11 @@ int kk_property_db_get_value(const char *deviceCode,const char *identifier,void*
*
(
int
*
)
value
=
value_int
;
}
else
if
(
valueType
==
KK_TSL_DATA_TYPE_FLOAT
){
float
value_float
=
ato
i
(
valueStr
);
float
value_float
=
ato
f
(
valueStr
);
*
(
float
*
)
value
=
value_float
;
}
else
if
(
valueType
==
KK_TSL_DATA_TYPE_DOUBLE
){
double
value_double
=
ato
i
(
valueStr
);
double
value_double
=
ato
f
(
valueStr
);
*
(
double
*
)
value
=
value_double
;
}
else
{
...
...
midware/midware/dm/kk_property_db.h
View file @
adc28c95
...
...
@@ -90,5 +90,6 @@ int kk_subFreshAir_get_online(const char *deviceCode,int ep);
int
kk_indoorAir_db_update_online
(
const
char
*
deviceCode
,
int
online
,
int
epNum
);
int
kk_subFreshAir_db_update_online
(
const
char
*
deviceCode
,
int
online
,
int
epNum
);
int
kk_subAirSwitch_db_update_online
(
const
char
*
deviceCode
,
int
online
,
int
epNum
);
int
kk_indoorair_property_db_get_value_directly
(
const
char
*
deviceCode
,
const
char
*
identifier
,
char
*
value
,
int
ep
);
#endif
midware/midware/dm/kk_sub_db.c
View file @
adc28c95
...
...
@@ -311,6 +311,29 @@ int kk_LockUser_insert_db(char *keyId,char *keyType,char *keyRole,char *keyName,
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
int
kk_delete_LockUser_info_byId
(
const
char
*
id
)
{
const
char
*
deleteCmd
=
"delete from LockUserInfo where keyId = '%s';"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
id
);
INFO_PRINT
(
"Table delete data sqlCmd:%s
\n
"
,
sqlCmd
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
//INFO_PRINT("Table delete data successfully\n");
}
sqlite3_free
(
sqlCmd
);
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:获取屏类列表
*输入参数:deviceCode:设备deviceCode
...
...
@@ -820,6 +843,20 @@ int kk_indoor_air_action_add(char *propertyValue,char* deviceCode,int delay,char
if
(
json
==
NULL
)
{
return
-
1
;
}
cJSON
*
WorkMode
=
cJSON_GetObjectItem
(
json
,
"WorkMode"
);
if
(
WorkMode
==
NULL
){
cJSON_Delete
(
json
);
return
-
1
;}
memset
(
data
,
0x0
,
sizeof
(
data
));
if
(
WorkMode
->
type
==
cJSON_String
){
memcpy
(
data
,
WorkMode
->
valuestring
,
strlen
(
WorkMode
->
valuestring
));
}
else
{
sprintf
(
data
,
"%d"
,
WorkMode
->
valueint
);
}
if
(
mutiDev
){
_kk_indoor_air_info_handle
(
deviceCode
,
"WorkMode_1"
,
data
,
epnum
,
delay
,
gwDeviceCode
,
sceneId
,
type
,
0
);
}
else
{
_kk_indoor_air_info_handle
(
deviceCode
,
"WorkMode"
,
data
,
epnum
,
delay
,
gwDeviceCode
,
sceneId
,
type
,
0
);
}
cJSON
*
Temperature
=
cJSON_GetObjectItem
(
json
,
"Temperature"
);
if
(
Temperature
==
NULL
)
{
cJSON_Delete
(
json
);
return
-
1
;}
memset
(
data
,
0x0
,
sizeof
(
data
));
...
...
@@ -848,21 +885,6 @@ int kk_indoor_air_action_add(char *propertyValue,char* deviceCode,int delay,char
_kk_indoor_air_info_handle
(
deviceCode
,
"WindSpeed"
,
data
,
epnum
,
delay
,
gwDeviceCode
,
sceneId
,
type
,
0
);
}
cJSON
*
WorkMode
=
cJSON_GetObjectItem
(
json
,
"WorkMode"
);
if
(
WorkMode
==
NULL
){
cJSON_Delete
(
json
);
return
-
1
;}
memset
(
data
,
0x0
,
sizeof
(
data
));
if
(
WorkMode
->
type
==
cJSON_String
){
memcpy
(
data
,
WorkMode
->
valuestring
,
strlen
(
WorkMode
->
valuestring
));
}
else
{
sprintf
(
data
,
"%d"
,
WorkMode
->
valueint
);
}
if
(
mutiDev
){
_kk_indoor_air_info_handle
(
deviceCode
,
"WorkMode_1"
,
data
,
epnum
,
delay
,
gwDeviceCode
,
sceneId
,
type
,
0
);
}
else
{
_kk_indoor_air_info_handle
(
deviceCode
,
"WorkMode"
,
data
,
epnum
,
delay
,
gwDeviceCode
,
sceneId
,
type
,
0
);
}
cJSON_Delete
(
json
);
return
0
;
}
...
...
@@ -1265,7 +1287,7 @@ int kk_screenDev_update(int devType,char *serialId, \
*其他说明:
*************************************************************/
int
kk_screenDev_insert_db
(
int
devType
,
char
*
serialId
,
\
char
*
ip
,
char
*
mac
,
char
*
version
,
char
*
expand
)
char
*
ip
,
char
*
mac
,
char
*
version
,
char
*
expand
,
char
*
name
)
{
const
char
*
insertCmd
=
"insert into ScreenDeviceInfo (isOffline,type,serialId,deviceIp,deviceName,mac,version,roomId,roomName,expand) \
values ('%d','%d','%s','%s','%s','%s','%s','%s','%s','%s');"
;
...
...
@@ -1281,11 +1303,7 @@ int kk_screenDev_insert_db(int devType,char *serialId, \
return
SUCCESS_RETURN
;
}
_kk_subDb_lock
();
#ifdef CONFIG_A133_PLATFORM
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
1
,
devType
,
serialId
,
ip
,
"MOOR4S"
,
mac
,
version
,
""
,
""
,
expand
);
#else
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
1
,
devType
,
serialId
,
ip
,
"MOOR4C"
,
mac
,
version
,
""
,
""
,
expand
);
#endif
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
1
,
devType
,
serialId
,
ip
,
name
,
mac
,
version
,
""
,
""
,
expand
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
...
...
midware/midware/dm/kk_sub_db.h
View file @
adc28c95
...
...
@@ -43,7 +43,7 @@ int kk_subDev_getSensors_reply(SensorType_t*list);
int
kk_load_subDevice
(
void
);
int
kk_subDev_check_auth
(
int
devType
);
int
kk_screenDev_insert_db
(
int
devType
,
char
*
serialId
,
\
char
*
ip
,
char
*
mac
,
char
*
version
,
char
*
expand
);
char
*
ip
,
char
*
mac
,
char
*
version
,
char
*
expand
,
char
*
name
);
int
kk_screenDev_update_room
(
char
*
serialId
,
char
*
roomid
,
char
*
roomname
,
char
*
name
);
int
kk_screenDev_delete_by_serialId
(
char
*
serialId
);
int
kk_get_screenDev_list
(
ScreenDevInfo_t
*
list
);
...
...
@@ -55,6 +55,7 @@ int kk_subDev_find_fatherDeviceCode(const char *deviceCode,char *fatherDeviceCod
int
kk_LockUser_insert_db
(
char
*
keyId
,
char
*
keyType
,
char
*
keyRole
,
char
*
keyName
,
char
*
deviceCode
);
int
kk_get_LockUser_list
(
LockKeyInfo_t
*
list
,
const
char
*
deviceCode
);
int
kk_delete_LockUser_info
(
const
char
*
deviceCode
);
int
kk_delete_LockUser_info_byId
(
const
char
*
id
);
enum
{
DB_SUB_IDX
=
0
,
DB_SUB_ONLINE
,
...
...
midware/midware/midware.c
View file @
adc28c95
...
...
@@ -996,6 +996,7 @@ void mid_cb(void* data, int len){
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 传的是数组,无语
if(res != 0){
...
...
@@ -1011,7 +1012,9 @@ void mid_cb(void* data, int len){
free(payloadS);
free(pnewout);
}
}
else
{
}else
#endif
{
cJSON
*
rootData
=
cJSON_CreateObject
();
char
*
info_rootS
=
cJSON_Print
(
info_root
);
char
*
payloadS
=
cJSON_Print
(
payload
);
...
...
@@ -1093,7 +1096,67 @@ void gw2mid_cb(void* data, int len, char* chalMark){
mid2p_cb
(
data
,
len
,
chalMark
);
}
}
static
int
_kk_subDevice_property_single_save
(
cJSON
*
params
,
char
*
deviceCode
,
int
type
)
{
int
res
=
0
;
int
epNumInt
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
int
idx
=
0
;
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
if
(
res
<
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
cJSON
*
epNum
=
cJSON_GetObjectItem
(
params
,
"epNum"
);
if
(
epNum
==
NULL
)
return
FAIL_RETURN
;
if
(
epNum
->
type
==
cJSON_Number
){
epNumInt
=
epNum
->
valueint
;
}
else
if
(
epNum
->
type
==
cJSON_String
){
epNumInt
=
atoi
(
epNum
->
valuestring
);
}
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
continue
;
}
propertyItem
=
cJSON_GetObjectItem
(
params
,
property
->
identifier
);
if
(
propertyItem
!=
NULL
){
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_ENUM
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_BOOL
){
char
valBuf
[
16
]
=
{
0
};
int
value
=
propertyItem
->
valueint
;
sprintf
(
valBuf
,
"%d"
,
value
);
if
(
type
==
0
){
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
1
){
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
2
){
kk_subFreshAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
char
valBuf
[
16
]
=
{
0
};
sprintf
(
valBuf
,
"%f"
,
propertyItem
->
valuedouble
);
if
(
type
==
0
){
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
1
){
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
2
){
kk_subFreshAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
if
(
type
==
0
){
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
}
else
if
(
type
==
1
){
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
}
else
if
(
type
==
2
){
kk_subFreshAir_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
}
}
}
}
return
0
;
}
static
int
kk_subDevice_property_save
(
cJSON
*
payload
,
char
*
deviceCode
,
int
type
)
{
dm_mgr_dev_node_t
*
node
=
NULL
;
...
...
@@ -1106,12 +1169,13 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
if
(
params
==
NULL
)
return
FAIL_RETURN
;
cJSON
*
eps
=
cJSON_GetObjectItem
(
params
,
"eps"
);
if
(
eps
==
NULL
||
eps
->
type
!=
cJSON_Array
){
return
FAIL_RETURN
;
//return FAIL_RETURN;
return
_kk_subDevice_property_single_save
(
params
,
deviceCode
,
type
);
}
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
if
(
res
<
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
}
cJSON
*
client_list
=
eps
->
child
;
while
(
client_list
!=
NULL
){
cJSON
*
epNum
=
cJSON_GetObjectItem
(
client_list
,
"epNum"
);
...
...
@@ -1174,6 +1238,15 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
/*type : 0,air condition gw;1,air switch gw;2,fresh air switch*/
static
int
kk_subDevice_property_handle
(
cJSON
*
info
,
cJSON
*
payload
,
char
*
deviceCode
,
int
type
)
{
int
snapshot
=
0
;
cJSON
*
jsonPay
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
jsonPay
==
NULL
){
return
-
1
;
}
cJSON
*
eps
=
cJSON_GetObjectItem
(
jsonPay
,
"eps"
);
if
(
eps
!=
NULL
){
snapshot
=
1
;
}
kk_subDevice_property_save
(
payload
,
deviceCode
,
type
);
cJSON_AddStringToObject
(
payload
,
MSG_DEVICE_CODE_STR
,
deviceCode
);
char
*
payload11
=
cJSON_Print
(
payload
);
...
...
@@ -1181,6 +1254,9 @@ static int kk_subDevice_property_handle(cJSON *info,cJSON *payload,char *deviceC
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
if
(
!
snapshot
){
//快照信息不处理
kk_scene_iftt_check
(
deviceCode
,
jsonPay
);
}
return
0
;
}
static
int
_kk_subDevice_online_to_app
(
cJSON
*
info
,
cJSON
*
payload
)
...
...
@@ -1452,14 +1528,14 @@ void kk_platMsg_handle(void* data, char* chalMark){
}
else
{
/*插座类设备保存功率历史记录*/
if
(
strcmp
(
search_node
->
productType
,
"outlet"
)
==
0
){
cJSON
*
power
=
cJSON_GetObjectItem
(
jsonPay
,
"Power"
);
if
(
power
!=
NULL
){
char
buf
[
16
]
=
{
0
};
sprintf
(
buf
,
"%f"
,
power
->
valuedouble
);
kk_history_insert_Outlet_info
(
info_dcode
->
valuestring
,
buf
,
""
,
HAL_GetTime
());
}
}
//
if(strcmp(search_node->productType ,"outlet") == 0){
//
cJSON *power = cJSON_GetObjectItem(jsonPay,"Power");
//
if(power != NULL){
//
char buf[16] = {0};
//
sprintf(buf,"%f",power->valuedouble);
//
kk_history_insert_Outlet_info(info_dcode->valuestring,buf,"",HAL_GetTime());
//
}
//
}
char
*
outstr
=
cJSON_Print
(
payload
);
kk_tsl_property_set_by_shadow
(
search_node
->
dev_shadow
,
outstr
,
strlen
(
outstr
)
+
1
);
proCode
=
cJSON_GetObjectItem
(
info
,
MSG_PRODUCT_CODE_STR
);
...
...
@@ -1507,7 +1583,9 @@ void kk_platMsg_handle(void* data, char* chalMark){
dm_mgr_set_dev_onoffline
(
node
,
0
);
}
/*如果是传感器类设备,事件上报的同时需要记录数据到数据库*/
if
(
strcmp
(
node
->
productType
,
"sensor"
)
==
0
){
if
(
strcmp
(
node
->
productType
,
"sensor"
)
==
0
||
strcmp
(
node
->
productType
,
"Doorlock"
)
==
0
||
strcmp
(
node
->
productType
,
"siren"
)
==
0
){
sensorDev
=
1
;
}
if
(
strcmp
(
msgType
->
valuestring
,
"/thing/event/SceneRecall/post"
)
==
0
){
...
...
@@ -1516,11 +1594,11 @@ void kk_platMsg_handle(void* data, char* chalMark){
if
(
buttonId
==
NULL
||
buttonId
->
type
!=
cJSON_Number
){
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
goto
error
;
}
}
sprintf
(
btnId
,
"%d"
,
buttonId
->
valueint
);
kk_scene_execute_quickpanel
(
btnId
,
info_dcode
->
valuestring
);
kk_scene_execute_quickpanel
(
btnId
,
info_dcode
->
valuestring
);
}
INFO_PRINT
(
"-------------------kk_platMsg_handle event post enters
\n
"
);
INFO_PRINT
(
"-------------------kk_platMsg_handle event post enters
:%s
\n
"
,
msgType
->
valuestring
);
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
event_number
;
idx
++
){
eventItem
=
node
->
dev_shadow
->
events
+
idx
;
if
(
eventItem
!=
NULL
){
...
...
@@ -1572,7 +1650,9 @@ void kk_platMsg_handle(void* data, char* chalMark){
}
if
(
pack
==
0
){
INFO_PRINT
(
"kk_platMsg_handle data: event post,eventItem->identifier:%s
\n
"
,
eventItem
->
identifier
);
if
(
strcmp
(
eventItem
->
identifier
,
"TamperAlarm"
)
!=
0
){
//TamperAlarm不需要上报,否则APP显示会有问题
if
(
strcmp
(
eventItem
->
identifier
,
"TamperAlarm"
)
==
0
||
strcmp
(
eventItem
->
identifier
,
"sirenAlarm"
)
==
0
){
//TamperAlarm不需要上报,否则APP显示会有问题
}
else
{
dm_msg_thing_event_post
(
info_dcode
->
valuestring
,
eventItem
->
identifier
,
NULL
);
}
kk_scene_iftt_check
(
info_dcode
->
valuestring
,
jsonPay
);
...
...
@@ -1598,6 +1678,13 @@ void kk_platMsg_handle(void* data, char* chalMark){
kk_LockUser_insert_db
(
keyId
->
valuestring
,
KeyTypeBuf
,
KeyRoleBuf
,
""
,
info_dcode
->
valuestring
);
}
}
if
(
strcmp
(
eventItem
->
identifier
,
"KeyDeletedNotification"
)
==
0
)
{
cJSON
*
keyId
=
cJSON_GetObjectItem
(
jsonPay
,
"KeyID"
);
if
(
keyId
!=
NULL
){
kk_delete_LockUser_info_byId
(
keyId
->
valuestring
);
}
}
if
(
strcmp
(
eventItem
->
identifier
,
"LockOpenNotification"
)
==
0
){
kk_scene_iftt_check
(
info_dcode
->
valuestring
,
jsonPay
);
}
...
...
@@ -1605,12 +1692,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
}
else
if
(
strcmp
(
eventItem
->
identifier
,
MSG_PROPERTY_STR
)
!=
0
&&
eventItem
->
output_data_number
==
0
){
itemStr
=
cJSON_GetObjectItem
(
jsonPay
,
eventItem
->
identifier
);
if
(
itemStr
!=
NULL
){
if
(
sensorDev
){
//kk_history_insert_sensor_info(info_dcode->valuestring,eventItem->identifier,"",HAL_GetTime());
}
//kk_tsl_set_value(kk_tsl_set_event_output_value,dev_shadow,eventItem->identifier,&itemStr->valueint,NULL);
if
(
strcmp
(
eventItem
->
identifier
,
"DoorBell"
)
!=
0
){
//门铃事件不处理;
dm_msg_thing_event_post
(
info_dcode
->
valuestring
,
eventItem
->
identifier
,
NULL
);
}
...
...
midware/midware/scene/kk_mutictrl_handle.c
0 → 100644
View file @
adc28c95
#include <stdio.h>
#include "sqlite3.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "kk_product.h"
#include "kk_tsl_common.h"
#include "kk_tsl_api.h"
#include "kk_dm_api.h"
#include "kk_dm_msg.h"
#include "kk_dm_mng.h"
#include "kk_property_db.h"
#include "kk_mutictrl_handle.h"
#include "kk_scene_handle.h"
static
int
_kk_check_virtual_device
(
char
*
sceneId
)
{
int
res
=
0
;
char
*
sqlCmd
=
NULL
;
char
*
pdeviceCode
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
sqlite3_stmt
*
stmt
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
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
){
pdeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_DEVICECODE
);
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
pdeviceCode
,
&
node
);
if
(
strcmp
(
node
->
productCode
,
"5004"
)
==
0
){
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
return
1
;
}
}
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
return
0
;
}
int
_kk_virtual_mutictrl_ctrl
(
char
*
sceneId
,
int
val
,
char
*
deviceCode
,
int
ep
)
{
char
*
sqlCmd
=
NULL
;
sqlite3_stmt
*
stmt
;
char
*
pdeviceCode
=
NULL
;
int
res
=
0
;
int
epNum
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
if
(
_kk_check_virtual_device
(
sceneId
)
==
0
){
return
0
;
}
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
){
pdeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_DEVICECODE
);
epNum
=
sqlite3_column_int
(
stmt
,
DB_SCENEACTION_EPNUM
);
if
(
strcmp
(
pdeviceCode
,
deviceCode
)
==
0
&&
ep
==
epNum
){
continue
;
}
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
pdeviceCode
,
&
node
);
cJSON
*
param
=
cJSON_CreateObject
();
if
(
kk_is_mutiEp_device
(
pdeviceCode
)
==
1
){
if
(
epNum
==
1
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_1"
,
val
);
}
else
if
(
epNum
==
2
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_2"
,
val
);
}
else
if
(
epNum
==
3
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_3"
,
val
);
}
else
if
(
epNum
==
4
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_4"
,
val
);
}
else
{
cJSON_Delete
(
param
);
continue
;
}
}
else
{
cJSON_AddNumberToObject
(
param
,
"PowerSwitch"
,
val
);
}
char
*
paramstr
=
cJSON_Print
(
param
);
kk_msg_execute_property_set
(
node
->
productCode
,
node
->
deviceCode
,
paramstr
,
node
->
fatherDeviceCode
);
free
(
paramstr
);
cJSON_Delete
(
param
);
}
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
return
SUCCESS_RETURN
;
}
void
split
(
char
*
src
,
const
char
*
separator
,
char
**
dest
,
int
*
num
);
int
kk_virtual_mutictrl_check
(
const
char
*
deviceCode
,
cJSON
*
param
)
{
char
*
sqlCmd
=
NULL
;
sqlite3_stmt
*
stmt
;
char
*
type
=
NULL
;
char
*
sceneId
=
NULL
;
int
res
=
0
,
idx
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
int
value
=
-
1
;
char
scene_id_bak
[
64
][
16
]
=
{
0
};
int
i
=
0
,
count
=
0
;
int
repeat
=
0
;
int
ep
=
0
,
epNum
=
0
;
char
*
propertiesbuf
[
64
]
=
{
0
};
char
propertiesTmp
[
64
]
=
{
0
};
int
num
=
0
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
,
&
node
);
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
||
strstr
(
property
->
identifier
,
"PowerSwitch"
)
==
NULL
){
continue
;
}
propertyItem
=
cJSON_GetObjectItem
(
param
,
property
->
identifier
);
if
(
propertyItem
!=
NULL
){
if
(
strstr
(
property
->
identifier
,
"_"
)
!=
NULL
){
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
memcpy
(
propertiesTmp
,
property
->
identifier
,
strlen
(
property
->
identifier
));
split
(
propertiesTmp
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
ep
=
atoi
(
propertiesbuf
[
1
]);
}
else
{
ep
=
1
;
}
}
else
{
ep
=
1
;
}
value
=
propertyItem
->
valueint
;
break
;
}
}
if
(
value
==
-
1
){
return
FAIL_RETURN
;
}
sqlCmd
=
sqlite3_mprintf
(
"select * from SceneActionInfo WHERE deviceCode= '%s' and active = '%d'"
,
deviceCode
,
1
);
//actice判断设备是否移入待分配
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
repeat
=
0
;
type
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_TYPE
);
epNum
=
sqlite3_column_int
(
stmt
,
DB_SCENEACTION_EPNUM
);
if
(
strcmp
(
type
,
"action/thing/group"
)
!=
0
||
epNum
!=
ep
){
continue
;
}
sceneId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_SCENEID
);
for
(
i
=
0
;
i
<
count
;
i
++
){
//检测同个设备在同个场景中设置不同的动作,只需rebuild一次
if
(
strcmp
(
scene_id_bak
[
i
],
sceneId
)
==
0
){
repeat
=
1
;
break
;
}
}
if
(
repeat
){
continue
;
}
_kk_virtual_mutictrl_ctrl
(
sceneId
,
value
,(
char
*
)
deviceCode
,
ep
);
if
(
count
<
64
){
memcpy
(
scene_id_bak
[
count
],
sceneId
,
strlen
(
sceneId
));
count
++
;
}
}
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
return
SUCCESS_RETURN
;
}
#if 1
char
*
g_manualMutiCtrlDev
[]
=
{
(
char
*
){
"3062"
},
// (char *){"3031"},
// (char *){"3033"},
// (char *){"3034"},
// (char *){"3035"},
// (char *){"3036"},
// (char *){"3095"},
// (char *){"3098"},
(
char
*
){
"5004"
},
(
char
*
){
"3028"
},
};
static
int
_kk_check_manualMutiCtrlDev
(
const
char
*
deviceCode
)
{
int
i
=
0
,
num
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
num
=
sizeof
(
g_manualMutiCtrlDev
)
/
sizeof
(
char
*
);
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
,
&
node
);
for
(
i
=
0
;
i
<
num
;
i
++
){
if
(
strcmp
(
node
->
productCode
,
g_manualMutiCtrlDev
[
i
])
==
0
)
{
return
1
;
}
}
return
0
;
}
static
int
_kk_get_MutiCtrl_sceneId
(
char
*
deviceCode
,
char
*
sceneId
,
int
epNum
)
{
char
*
type
=
NULL
;
char
*
sqlCmd
=
NULL
;
char
*
psceneId
=
NULL
;
sqlite3_stmt
*
stmt
;
int
ep
=
0
;
int
exsit
=
0
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
sqlCmd
=
sqlite3_mprintf
(
"select * from SceneActionInfo WHERE deviceCode= '%s' and active = '%d'"
,
deviceCode
,
1
);
//actice判断设备是否移入待分配
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
type
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_TYPE
);
ep
=
sqlite3_column_int
(
stmt
,
DB_SCENEACTION_EPNUM
);
if
(
strcmp
(
type
,
"action/thing/group"
)
!=
0
||
epNum
!=
ep
){
continue
;
}
psceneId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_SCENEID
);
memcpy
(
sceneId
,
psceneId
,
strlen
(
psceneId
));
exsit
=
1
;
break
;
}
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
if
(
exsit
){
return
0
;
}
return
-
1
;
}
static
int
_kk_manual_mutictrl_set
(
cJSON
*
param
,
char
*
setDeviceCode
,
int
ep
,
char
*
srcDeviceCode
,
int
isMutiEp
)
{
int
res
=
0
,
idx
=
0
;
char
valueStr
[
32
]
=
{
0
};
char
oldvalueStr
[
32
]
=
{
0
};
char
newIdentifier
[
64
]
=
{
0
};
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
setDevnode
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
int
num
=
0
;
char
epStr
[
4
]
=
{
0
};
int
offflag
=
0
;
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
));
memset
(
oldvalueStr
,
0x0
,
sizeof
(
oldvalueStr
));
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
propertyItem
=
cJSON_GetObjectItem
(
param
,
property
->
identifier
);
if
(
propertyItem
!=
NULL
){
if
(
strstr
(
property
->
identifier
,
"CurrentTemperature"
)
!=
NULL
||
strstr
(
property
->
identifier
,
"TimingOffTime"
)
!=
NULL
||
strstr
(
property
->
identifier
,
"Brightness"
)
!=
NULL
){
continue
;
}
if
(
propertyItem
->
type
==
cJSON_Number
){
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_ENUM
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_BOOL
){
sprintf
(
valueStr
,
"%d"
,
propertyItem
->
valueint
);
}
else
{
sprintf
(
valueStr
,
"%f"
,
propertyItem
->
valuedouble
);
}
}
else
if
(
propertyItem
->
type
==
cJSON_String
){
memcpy
(
valueStr
,
propertyItem
->
valuestring
,
strlen
(
propertyItem
->
valuestring
));
}
char
*
propertiesbuf
[
64
]
=
{
0
};
char
propertiesTmp
[
64
]
=
{
0
};
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
memcpy
(
propertiesTmp
,
property
->
identifier
,
strlen
(
property
->
identifier
));
if
(
isMutiEp
){
split
(
propertiesTmp
,
"_"
,
propertiesbuf
,
&
num
);
}
if
(
kk_is_mutiEp_device
(
setDeviceCode
)
==
1
){
if
(
isMutiEp
){
sprintf
(
newIdentifier
,
"%s_%d"
,
propertiesbuf
[
0
],
ep
);
}
else
{
sprintf
(
newIdentifier
,
"%s_%d"
,
propertiesTmp
,
ep
);
}
}
else
{
if
(
isMutiEp
){
sprintf
(
newIdentifier
,
"%s"
,
propertiesbuf
[
0
]);
}
else
{
sprintf
(
newIdentifier
,
"%s"
,
propertiesTmp
);
}
}
INFO_PRINT
(
"[%s][%d]valueStr:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
valueStr
);
INFO_PRINT
(
"[%s][%d]newIdentifier:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
newIdentifier
);
if
(
strcmp
(
setDevnode
->
productCode
,
"3062"
)
==
0
){
kk_indoorair_property_db_get_value_directly
((
const
char
*
)
setDeviceCode
,(
const
char
*
)
newIdentifier
,
oldvalueStr
,
ep
);
}
else
{
kk_property_db_get_value_directly
((
const
char
*
)
setDeviceCode
,(
const
char
*
)
newIdentifier
,
oldvalueStr
);
}
INFO_PRINT
(
"[%s][%d]oldvalueStr:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
oldvalueStr
);
INFO_PRINT
(
"[%s][%d]setDeviceCode:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
setDeviceCode
);
if
(
strcmp
(
oldvalueStr
,
valueStr
)
==
0
){
continue
;
}
else
{
char
*
paramstr
=
NULL
;
cJSON
*
params
=
cJSON_CreateObject
();
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_ENUM
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_BOOL
){
cJSON_AddNumberToObject
(
params
,
newIdentifier
,
propertyItem
->
valueint
);
//if(strstr(newIdentifier,"PowerSwitch") != NULL && propertyItem->valueint == 0){
//offflag = 1;
//}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
cJSON_AddNumberToObject
(
params
,
newIdentifier
,
propertyItem
->
valuedouble
);
}
else
{
cJSON_AddStringToObject
(
params
,
newIdentifier
,
propertyItem
->
valuestring
);
}
if
(
strcmp
(
setDevnode
->
productCode
,
"3062"
)
==
0
){
memset
(
epStr
,
0x0
,
sizeof
(
epStr
));
sprintf
(
epStr
,
"%d"
,
ep
);
cJSON_DeleteItemFromObject
(
param
,
"epNum"
);
cJSON_AddStringToObject
(
param
,
"epNum"
,
epStr
);
paramstr
=
cJSON_Print
(
param
);
offflag
=
1
;
}
else
{
paramstr
=
cJSON_Print
(
params
);
}
kk_msg_execute_property_set
(
setDevnode
->
productCode
,
setDevnode
->
deviceCode
,
paramstr
,
setDevnode
->
fatherDeviceCode
);
free
(
paramstr
);
cJSON_Delete
(
params
);
if
(
offflag
){
break
;
}
usleep
(
500000
);
}
}
}
return
0
;
}
static
int
_kk_manual_mutictrl_ctrl
(
char
*
sceneId
,
char
*
deviceCode
,
int
ep
,
cJSON
*
param
,
int
isMutiEp
)
{
char
*
sqlCmd
=
NULL
;
sqlite3_stmt
*
stmt
;
char
*
pdeviceCode
=
NULL
;
int
res
=
0
;
int
epNum
=
0
;
int
isManualDev
=
0
;
int
isAutoCtrlDev
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
isManualDev
=
_kk_check_manualMutiCtrlDev
((
const
char
*
)
deviceCode
);
//上报的设备是否是需要手动触发多控设备
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
){
pdeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_DEVICECODE
);
epNum
=
sqlite3_column_int
(
stmt
,
DB_SCENEACTION_EPNUM
);
if
(
strcmp
(
pdeviceCode
,
deviceCode
)
==
0
&&
ep
==
epNum
){
//过滤掉刚上报的这路
continue
;
}
isAutoCtrlDev
=
_kk_check_manualMutiCtrlDev
((
const
char
*
)
pdeviceCode
);
if
(
isAutoCtrlDev
==
0
){
//过滤下自动多控设备,手动多控设备先都手动执行下
continue
;
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
_kk_manual_mutictrl_set
(
param
,
pdeviceCode
,
epNum
,
deviceCode
,
isMutiEp
);
}
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
if
(
isManualDev
){
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
){
pdeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_DEVICECODE
);
epNum
=
sqlite3_column_int
(
stmt
,
DB_SCENEACTION_EPNUM
);
if
(
strcmp
(
pdeviceCode
,
deviceCode
)
==
0
&&
ep
==
epNum
){
continue
;
}
isAutoCtrlDev
=
_kk_check_manualMutiCtrlDev
((
const
char
*
)
pdeviceCode
);
if
(
isAutoCtrlDev
==
0
){
//手动多控设备先都手动执行下,过滤下自动多控设备
_kk_manual_mutictrl_set
(
param
,
pdeviceCode
,
epNum
,
deviceCode
,
isMutiEp
);
break
;
}
}
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
}
return
SUCCESS_RETURN
;
}
int
kk_manual_mutictrl_execute
(
const
char
*
deviceCode
,
cJSON
*
param
)
{
int
res
=
0
,
idx
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
int
ep
=
0
;
char
*
propertiesbuf
[
64
]
=
{
0
};
char
propertiesTmp
[
64
]
=
{
0
};
int
num
=
0
;
int
isMutiEp
=
0
;
char
sceneId
[
16
]
=
{
0
};
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
,
&
node
);
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
//解析当前设备上报的epnum
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
propertyItem
=
cJSON_GetObjectItem
(
param
,
property
->
identifier
);
if
(
propertyItem
!=
NULL
){
if
(
strstr
(
property
->
identifier
,
"_"
)
!=
NULL
){
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
memcpy
(
propertiesTmp
,
property
->
identifier
,
strlen
(
property
->
identifier
));
split
(
propertiesTmp
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
ep
=
atoi
(
propertiesbuf
[
1
]);
isMutiEp
=
1
;
}
else
{
ep
=
1
;
}
}
else
{
ep
=
1
;
}
break
;
}
}
if
(
strcmp
(
node
->
productCode
,
"3062"
)
==
0
){
//空调网关
cJSON
*
epJson
=
cJSON_GetObjectItem
(
param
,
"epNum"
);
if
(
epJson
==
NULL
){
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
ep
=
atoi
(
epJson
->
valuestring
);
if
(
ep
==
1
){
//空调网关第一路为网关本身,不处理
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
}
res
=
_kk_get_MutiCtrl_sceneId
((
char
*
)
deviceCode
,
sceneId
,
ep
);
if
(
res
!=
0
){
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
INFO_PRINT
(
"sceneId:%s
\n
"
,
sceneId
);
_kk_manual_mutictrl_ctrl
(
sceneId
,(
char
*
)
deviceCode
,
ep
,
param
,
isMutiEp
);
return
SUCCESS_RETURN
;
}
#endif
\ No newline at end of file
midware/midware/scene/kk_mutictrl_handle.h
0 → 100644
View file @
adc28c95
#ifndef __KK_MUTICTRL_HANDLE_H__
#define __KK_MUTICTRL_HANDLE_H__
#include "cJSON.h"
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_handle.c
View file @
adc28c95
...
...
@@ -28,7 +28,7 @@
#include "kk_dm_mng.h"
#include <time.h>
#include "kk_scene_pollution_check.h"
#include "kk_mutictrl_handle.h"
/*************************************************************
全局变量定义
*************************************************************/
...
...
@@ -1293,15 +1293,7 @@ int kk_scene_parse_scene_condition(const cJSON* str,const char *sceneId)
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:解析执行动作
*输入参数:sceneId:对应场景Id;
str:执行动作的CJSON字串
isUpdate:1,updateScene;0,addScene
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
_kk_scene_LightStripSpecialAction_handle
(
cJSON
*
propertyValue
,
char
*
deviceCode
,
int
ep
,
int
idelay
,
char
*
sceneId
,
char
*
fatherDeviceCode
)
{
kk_scene_action_detail_t
info
=
{
0
};
...
...
@@ -1389,6 +1381,29 @@ static int _kk_scene_LightStripSpecialAction_handle(cJSON* propertyValue,char *d
}
return
SUCCESS_RETURN
;
}
static
int
_kk_scene_AirConditionerIndoorUnitSpecialAction_handle
(
cJSON
*
propertyValue
,
char
*
deviceCode
,
int
ep
,
int
idelay
,
char
*
sceneId
,
char
*
fatherDeviceCode
)
{
kk_scene_action_detail_t
info
=
{
0
};
cJSON
*
PowerSwitch
=
cJSON_GetObjectItem
(
propertyValue
,
"PowerSwitch"
);
if
(
PowerSwitch
!=
NULL
&&
PowerSwitch
->
type
==
cJSON_Number
){
sprintf
(
info
.
propertyValue
,
"%d"
,
PowerSwitch
->
valueint
);
memcpy
(
info
.
propertyName
,
"PowerSwitch"
,
strlen
(
"PowerSwitch"
));
memcpy
(
info
.
deviceCode
,
deviceCode
,
strlen
(
deviceCode
));
info
.
epNum
=
ep
;
info
.
delay
=
idelay
;
kk_scene_action_add
(
fatherDeviceCode
,
sceneId
,
info
);
}
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:解析执行动作
*输入参数:sceneId:对应场景Id;
str:执行动作的CJSON字串
isUpdate:1,updateScene;0,addScene
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_scene_parse_scene_action
(
const
cJSON
*
str
,
const
char
*
sceneId
,
int
isUpdate
)
{
int
res
=
0
;
...
...
@@ -1532,9 +1547,12 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
if
(
propertyValue
->
type
==
cJSON_Number
){
snprintf
(
propertyValueStr
,
sizeof
(
propertyValueStr
),
"%d"
,
propertyValue
->
valueint
);
}
else
if
(
propertyValue
->
type
==
cJSON_Object
){
if
(
strcmp
(
propertyName
->
valuestring
,
"LightStripSpecialAction"
)
==
0
){
if
(
strcmp
(
propertyName
->
valuestring
,
"LightStripSpecialAction"
)
==
0
){
//灯带场景自定义
_kk_scene_LightStripSpecialAction_handle
(
propertyValue
,
deviceCode
->
valuestring
,
iepnum
,
idelay
,(
char
*
)
sceneId
,
node
->
fatherDeviceCode
);
}
else
if
(
strcmp
(
propertyName
->
valuestring
,
"AirConditionerIndoorUnitSpecialAction"
)
==
0
){
_kk_scene_AirConditionerIndoorUnitSpecialAction_handle
(
propertyValue
,
deviceCode
->
valuestring
,
iepnum
,
idelay
,(
char
*
)
sceneId
,
node
->
fatherDeviceCode
);
}
char
*
str
=
cJSON_PrintUnformatted
(
propertyValue
);
snprintf
(
propertyValueStr
,
sizeof
(
propertyValueStr
),
"%s"
,
str
);
free
(
str
);
...
...
@@ -1557,6 +1575,8 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
}
else
{
memcpy
(
info
.
propertyName
,
propertyName
->
valuestring
,
strlen
(
propertyName
->
valuestring
));
}
}
else
if
(
strcmp
(
node
->
productCode
,
"3062"
)
==
0
){
memcpy
(
info
.
propertyName
,
propertyName
->
valuestring
,
strlen
(
propertyName
->
valuestring
));
}
else
{
if
(
iepnum
>
1
&&
strstr
(
propertyName
->
valuestring
,
"_"
)
==
NULL
){
sprintf
(
info
.
propertyName
,
"%s_%d"
,
propertyName
->
valuestring
,
iepnum
);
...
...
@@ -1568,7 +1588,8 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
info
.
epNum
=
iepnum
;
info
.
delay
=
idelay
;
if
(
strcmp
(
propertyName
->
valuestring
,
"LightStripSpecialAction"
)
!=
0
){
if
(
strcmp
(
propertyName
->
valuestring
,
"LightStripSpecialAction"
)
!=
0
&&
strcmp
(
propertyName
->
valuestring
,
"AirConditionerIndoorUnitSpecialAction"
)
!=
0
){
if
(
strcmp
(
node
->
productCode
,
"5004"
)
==
0
&&
strcmp
(
propertyValueStr
,
"2"
)
==
0
){
//虚拟灯取反由中控逻辑来处理,不需要下发给网关
}
else
{
...
...
@@ -2739,127 +2760,7 @@ int kk_scene_query_trigger_info(const char *deviceCode,cJSON *param)
sqlite3_free
(
sqlCmd
);
return
res
;
}
static
int
_kk_virtual_mutictrl_ctrl
(
char
*
sceneId
,
int
val
,
char
*
deviceCode
,
int
ep
)
{
char
*
sqlCmd
=
NULL
;
sqlite3_stmt
*
stmt
;
char
*
pdeviceCode
=
NULL
;
int
res
=
0
;
int
epNum
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
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
){
pdeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_DEVICECODE
);
epNum
=
sqlite3_column_int
(
stmt
,
DB_SCENEACTION_EPNUM
);
if
(
strcmp
(
pdeviceCode
,
deviceCode
)
==
0
&&
ep
==
epNum
){
continue
;
}
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
pdeviceCode
,
&
node
);
//if (res != SUCCESS_RETURN || strcmp(node->productCode,"5004") != 0) {
//continue;
//}
cJSON
*
param
=
cJSON_CreateObject
();
if
(
kk_is_mutiEp_device
(
pdeviceCode
)
==
1
){
if
(
epNum
==
1
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_1"
,
val
);
}
else
if
(
epNum
==
2
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_2"
,
val
);
}
else
if
(
epNum
==
3
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_3"
,
val
);
}
else
if
(
epNum
==
4
){
cJSON_AddNumberToObject
(
param
,
"PowerSwitch_4"
,
val
);
}
else
{
cJSON_Delete
(
param
);
continue
;
}
}
else
{
cJSON_AddNumberToObject
(
param
,
"PowerSwitch"
,
val
);
}
char
*
paramstr
=
cJSON_Print
(
param
);
kk_msg_execute_property_set
(
node
->
productCode
,
node
->
deviceCode
,
paramstr
,
node
->
fatherDeviceCode
);
free
(
paramstr
);
cJSON_Delete
(
param
);
}
return
SUCCESS_RETURN
;
}
void
split
(
char
*
src
,
const
char
*
separator
,
char
**
dest
,
int
*
num
);
static
int
_kk_virtual_mutictrl_check
(
const
char
*
deviceCode
,
cJSON
*
param
)
{
char
*
sqlCmd
=
NULL
;
sqlite3_stmt
*
stmt
;
char
*
type
=
NULL
;
char
*
sceneId
=
NULL
;
int
res
=
0
,
idx
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
int
value
=
-
1
;
char
scene_id_bak
[
64
][
16
]
=
{
0
};
int
i
=
0
,
count
=
0
;
int
repeat
=
0
;
int
ep
=
0
,
epNum
=
0
;
char
*
propertiesbuf
[
64
]
=
{
0
};
char
propertiesTmp
[
64
]
=
{
0
};
int
num
=
0
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
,
&
node
);
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
||
strstr
(
property
->
identifier
,
"PowerSwitch"
)
==
NULL
){
continue
;
}
propertyItem
=
cJSON_GetObjectItem
(
param
,
property
->
identifier
);
if
(
propertyItem
!=
NULL
){
if
(
strstr
(
property
->
identifier
,
"_"
)
!=
NULL
){
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
memcpy
(
propertiesTmp
,
property
->
identifier
,
strlen
(
property
->
identifier
));
split
(
propertiesTmp
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
ep
=
atoi
(
propertiesbuf
[
1
]);
}
else
{
ep
=
1
;
}
}
else
{
ep
=
1
;
}
value
=
propertyItem
->
valueint
;
break
;
}
}
if
(
value
==
-
1
){
return
FAIL_RETURN
;
}
sqlCmd
=
sqlite3_mprintf
(
"select * from SceneActionInfo WHERE deviceCode= '%s' and active = '%d'"
,
deviceCode
,
1
);
//actice判断设备是否移入待分配
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
repeat
=
0
;
type
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_TYPE
);
epNum
=
sqlite3_column_int
(
stmt
,
DB_SCENEACTION_EPNUM
);
if
(
strcmp
(
type
,
"action/thing/group"
)
!=
0
||
epNum
!=
ep
){
continue
;
}
sceneId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCENEACTION_SCENEID
);
for
(
i
=
0
;
i
<
count
;
i
++
){
//检测同个设备在同个场景中设置不同的动作,只需rebuild一次
if
(
strcmp
(
scene_id_bak
[
i
],
sceneId
)
==
0
){
repeat
=
1
;
break
;
}
}
if
(
repeat
){
continue
;
}
_kk_virtual_mutictrl_ctrl
(
sceneId
,
value
,(
char
*
)
deviceCode
,
ep
);
if
(
count
<
64
){
memcpy
(
scene_id_bak
[
count
],
sceneId
,
strlen
(
sceneId
));
count
++
;
}
}
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:IFTT场景检测
*输入参数:param:属性CJSON内容
...
...
@@ -2872,7 +2773,7 @@ int kk_scene_iftt_check(const char*deviceCode,cJSON *param)
{
INFO_PRINT
(
"deviceCode:%s
\n
"
,
deviceCode
);
BodySensorTrigger_report
(
deviceCode
,
1
,
param
);
_kk_virtual_mutictrl_check
(
deviceCode
,
param
);
//虚拟灯的多控检测
kk_manual_mutictrl_execute
(
deviceCode
,
param
);
//虚拟灯的多控检测
return
kk_scene_query_trigger_info
(
deviceCode
,
param
);
}
...
...
@@ -3041,7 +2942,17 @@ static int _kk_rebuild_device_active(char *sceneid)
_kk_scene_LightStripSpecialAction_handle
(
propertyValueJson
,
pDeviceCode
,
epNum
,
idelay
,(
char
*
)
sceneid
,(
char
*
)
gwDeviceCode
);
cJSON_Delete
(
propertyValueJson
);
}
}
else
if
(
strcmp
(
propertyName
,
"CustomAction"
)
==
0
){
//空调内机的场景属性
}
else
if
(
strcmp
(
propertyName
,
"AirConditionerIndoorUnitSpecialAction"
)
==
0
){
if
(
strstr
(
propertyValueStr
,
"{"
)
!=
NULL
&&
strstr
(
propertyValueStr
,
"}"
)
!=
NULL
){
cJSON
*
propertyValueJson
=
cJSON_Parse
(
propertyValueStr
);
if
(
propertyValueJson
==
NULL
)
{
ERROR_PRINT
(
"cJSON_Parse ERROR!!!"
);
return
FAIL_RETURN
;
}
_kk_scene_AirConditionerIndoorUnitSpecialAction_handle
(
propertyValueJson
,
pDeviceCode
,
epNum
,
idelay
,(
char
*
)
sceneid
,(
char
*
)
gwDeviceCode
);
cJSON_Delete
(
propertyValueJson
);
}
}
else
if
(
strcmp
(
propertyName
,
"CustomAction"
)
==
0
){
//所有空调内机的场景属性
if
(
strstr
(
propertyValueStr
,
"{"
)
!=
NULL
&&
strstr
(
propertyValueStr
,
"}"
)
!=
NULL
){
res
=
dm_mgr_get_device_by_devicecode
(
pDeviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
...
...
midware/midware/scene/kk_scene_pollution_check.c
View file @
adc28c95
...
...
@@ -96,15 +96,12 @@ int kk_pollution_condition_check(char *deviceCode,int grade)
char
currentValue
[
64
]
=
{
0
};
num
=
sizeof
(
g_pollutionMap
)
/
sizeof
(
kk_pollution_t
);
for
(
i
=
0
;
i
<
num
;
i
++
){
printf
(
"------------->g_pollutionMap[i].identifier:%s
\n
"
,
g_pollutionMap
[
i
].
identifier
);
memset
(
currentValue
,
0x0
,
sizeof
(
currentValue
));
kk_property_db_get_value_directly
(
deviceCode
,
g_pollutionMap
[
i
].
identifier
,
currentValue
);
if
(
strcmp
(
currentValue
,
""
)
==
0
){
continue
;
}
printf
(
"------------->currentValue:%s
\n
"
,
currentValue
);
ret
=
kk_pollution_level_check
(
g_pollutionMap
[
i
].
levelMap
,
atoi
(
currentValue
),
4
);
printf
(
"------------->ret:%d
\n
"
,
ret
);
if
(
ret
!=
-
1
){
if
(
grade
==
1
){
if
(
ret
==
1
){
...
...
@@ -131,7 +128,6 @@ int kk_pm25_condition_check(char *deviceCode)
int
i
=
0
;
int
ret
=
0
;
char
currentValue
[
64
]
=
{
0
};
kk_property_db_get_value_directly
(
deviceCode
,
"PM2.5"
,
currentValue
);
if
(
strcmp
(
currentValue
,
""
)
==
0
){
return
0
;
...
...
nx5_soc_gw/smarthome_z3gw_a133
View file @
adc28c95
No preview for this file type
tsl/product_3057.json
View file @
adc28c95
...
...
@@ -280,7 +280,7 @@
}
}
],
"identifier"
:
"Alarm"
,
"identifier"
:
"
siren
Alarm"
,
"method"
:
"thing.event.sirenAlarm.post"
,
"name"
:
"sirenAlarm"
,
"type"
:
"alarm"
,
...
...
tsl/product_3064.json
View file @
adc28c95
{
"schema"
:
"https://iot-ap.ikonke.com/model/product_3064.json"
,
"productType"
:
"Doorlock"
,
"version"
:
"1.2"
,
"profile"
:
{
"heartbeat"
:
"1200"
,
"productCode"
:
"3064"
,
"productName"
:
"秦穹智能门锁枪黑Z3S(KONKE)"
,
"sleepTime"
:
"30000"
},
"services"
:
[
{
"outputData"
:
[],
"identifier"
:
"set"
,
"inputData"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
}
],
"method"
:
"thing.service.property.set"
,
"name"
:
"set"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性设置"
},
{
"outputData"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
},
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"identifier"
:
"get"
,
"inputData"
:
[
"remoteOpenDoorSwitch"
,
"Battery"
],
"method"
:
"thing.service.property.get"
,
"name"
:
"get"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性获取"
},
{
"outputData"
:
[
{
"identifier"
:
"openfeedback"
,
"name"
:
"远程开锁反馈"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"成功"
,
"1"
:
"密码错误"
,
"16"
:
"不支持远程开锁"
,
"18"
:
"系统已锁定"
,
"19"
:
"远程开门未使能"
,
"255"
:
"未知错误"
}
}
}
],
"identifier"
:
"LockOpenNotification"
,
"inputData"
:
[
{
"identifier"
:
"password"
,
"name"
:
"远程开锁密码"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"64"
}
}
],
"method"
:
"thing.service.LockOpenNotification"
,
"name"
:
"LockOpenNotification"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"远程开锁"
}
],
"properties"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"accessMode"
:
"rw"
,
"required"
:
true
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
},
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"accessMode"
:
"r"
,
"required"
:
false
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"events"
:
[
{
"outputData"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
},
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"identifier"
:
"property"
,
"method"
:
"thing.event.property.post"
,
"name"
:
"property"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"属性上报"
},
{
"outputData"
:
[
{
"identifier"
:
"KeyID"
,
"name"
:
"用户ID"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"10"
}
},
{
"identifier"
:
"KeyRole"
,
"name"
:
"用户类型"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"管理员"
,
"2"
:
"普通用户"
,
"3"
:
"临时用户"
}
}
},
{
"identifier"
:
"KeyType"
,
"name"
:
"开锁方式"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"指纹"
,
"2"
:
"密码"
,
"3"
:
"刷卡"
,
"4"
:
"APP远程开锁"
,
"5"
:
"机械钥匙"
,
"6"
:
"蓝牙"
,
"7"
:
"劫持报警"
,
"8"
:
"限时临时密码"
}
}
}
],
"identifier"
:
"LockOpenNotification"
,
"method"
:
"thing.event.LockOpenNotification.post"
,
"name"
:
"LockOpenNotification"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"开门上报"
},
{
"outputData"
:
[
{
"identifier"
:
"KeyID"
,
"name"
:
"用户ID"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"10"
}
},
{
"identifier"
:
"KeyRole"
,
"name"
:
"用户类型"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"管理员"
,
"2"
:
"普通用户"
,
"3"
:
"临时用户"
}
}
},
{
"identifier"
:
"KeyType"
,
"name"
:
"开锁方式"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"指纹"
,
"2"
:
"密码"
,
"3"
:
"刷卡"
,
"4"
:
"APP远程开锁"
,
"5"
:
"机械钥匙"
,
"6"
:
"蓝牙"
,
"7"
:
"劫持报警"
,
"8"
:
"限时临时密码"
}
}
}
],
"identifier"
:
"KeyAddNotification"
,
"method"
:
"thing.event.KeyAddNotification.post"
,
"name"
:
"KeyAddNotification"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"添加用户上报"
},
{
"outputData"
:
[
{
"identifier"
:
"KeyID"
,
"name"
:
"用户ID"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"10"
}
},
{
"identifier"
:
"KeyRole"
,
"name"
:
"用户类型"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"管理员"
,
"2"
:
"普通用户"
,
"3"
:
"临时用户"
}
}
},
{
"identifier"
:
"KeyType"
,
"name"
:
"开锁方式"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"指纹"
,
"2"
:
"密码"
,
"3"
:
"刷卡"
,
"4"
:
"APP远程开锁"
,
"5"
:
"机械钥匙"
,
"6"
:
"蓝牙"
,
"7"
:
"劫持报警"
,
"8"
:
"限时临时密码"
}
}
}
],
"identifier"
:
"KeyDeletedNotification"
,
"method"
:
"thing.event.KeyDeletedNotification.post"
,
"name"
:
"KeyDeletedNotification"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"删除用户上报"
},
{
"identifier"
:
"DoorBell"
,
"method"
:
"thing.event.DoorBell.post"
,
"name"
:
"DoorBell"
,
"type"
:
"alarm"
,
"required"
:
true
,
"desc"
:
"门铃事件"
},
{
"outputData"
:
[
{
"identifier"
:
"DismantleState"
,
"name"
:
"拆卸状态"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"正常"
,
"1"
:
"被拆卸"
}
}
}
],
"identifier"
:
"TamperAlarm"
,
"method"
:
"thing.event.TamperAlarm.post"
,
"name"
:
"TamperAlarm"
,
"type"
:
"alert"
,
"required"
:
true
,
"desc"
:
"防拆告警"
},
{
"outputData"
:
[
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0.0"
,
"max"
:
"100.0"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"identifier"
:
"BatteryAlarm"
,
"method"
:
"thing.event.BatteryAlarm.post"
,
"name"
:
"BatteryAlarm"
,
"type"
:
"alert"
,
"required"
:
true
,
"desc"
:
"低电量告警"
}
]
{
"schema"
:
"https://iot-ap.ikonke.com/model/product_3064.json"
,
"productType"
:
"Doorlock"
,
"version"
:
"1.3"
,
"profile"
:
{
"heartbeat"
:
"1200"
,
"productCode"
:
"3064"
,
"productName"
:
"秦穹智能门锁枪黑Z3S(KONKE)"
,
"sleepTime"
:
"30000"
},
"services"
:
[
{
"outputData"
:
[],
"identifier"
:
"set"
,
"inputData"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
}
],
"method"
:
"thing.service.property.set"
,
"name"
:
"set"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性设置"
},
{
"outputData"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
},
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"identifier"
:
"get"
,
"inputData"
:
[
"remoteOpenDoorSwitch"
,
"Battery"
],
"method"
:
"thing.service.property.get"
,
"name"
:
"get"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性获取"
},
{
"outputData"
:
[
{
"identifier"
:
"openfeedback"
,
"name"
:
"远程开锁反馈"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"成功"
,
"1"
:
"密码错误"
,
"16"
:
"不支持远程开锁"
,
"18"
:
"系统已锁定"
,
"19"
:
"远程开门未使能"
,
"255"
:
"未知错误"
}
}
}
],
"identifier"
:
"LockOpenNotification"
,
"inputData"
:
[
{
"identifier"
:
"password"
,
"name"
:
"远程开锁密码"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"64"
}
}
],
"method"
:
"thing.service.LockOpenNotification"
,
"name"
:
"LockOpenNotification"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"远程开锁"
}
],
"properties"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"accessMode"
:
"rw"
,
"required"
:
true
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
},
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"accessMode"
:
"r"
,
"required"
:
false
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"events"
:
[
{
"outputData"
:
[
{
"identifier"
:
"remoteOpenDoorSwitch"
,
"name"
:
"远程控制使能"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"开启"
}
}
},
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"identifier"
:
"property"
,
"method"
:
"thing.event.property.post"
,
"name"
:
"property"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"属性上报"
},
{
"outputData"
:
[
{
"identifier"
:
"KeyID"
,
"name"
:
"用户ID"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"10"
}
},
{
"identifier"
:
"KeyRole"
,
"name"
:
"用户类型"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"管理员"
,
"2"
:
"普通用户"
,
"3"
:
"临时用户"
}
}
},
{
"identifier"
:
"KeyType"
,
"name"
:
"开锁方式"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"指纹"
,
"2"
:
"密码"
,
"3"
:
"刷卡"
,
"4"
:
"APP远程开锁"
,
"5"
:
"机械钥匙"
,
"6"
:
"蓝牙"
,
"7"
:
"劫持报警"
,
"8"
:
"限时临时密码"
}
}
}
],
"identifier"
:
"LockOpenNotification"
,
"method"
:
"thing.event.LockOpenNotification.post"
,
"name"
:
"LockOpenNotification"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"开门上报"
},
{
"outputData"
:
[
{
"identifier"
:
"KeyID"
,
"name"
:
"用户ID"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"10"
}
},
{
"identifier"
:
"KeyRole"
,
"name"
:
"用户类型"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"管理员"
,
"2"
:
"普通用户"
,
"3"
:
"临时用户"
}
}
},
{
"identifier"
:
"KeyType"
,
"name"
:
"开锁方式"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"指纹"
,
"2"
:
"密码"
,
"3"
:
"刷卡"
,
"4"
:
"APP远程开锁"
,
"5"
:
"机械钥匙"
,
"6"
:
"蓝牙"
,
"7"
:
"劫持报警"
,
"8"
:
"限时临时密码"
}
}
}
],
"identifier"
:
"KeyAddNotification"
,
"method"
:
"thing.event.KeyAddNotification.post"
,
"name"
:
"KeyAddNotification"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"添加用户上报"
},
{
"outputData"
:
[
{
"identifier"
:
"KeyID"
,
"name"
:
"用户ID"
,
"dataType"
:
{
"type"
:
"text"
,
"length"
:
"10"
}
},
{
"identifier"
:
"KeyRole"
,
"name"
:
"用户类型"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"管理员"
,
"2"
:
"普通用户"
,
"3"
:
"临时用户"
}
}
},
{
"identifier"
:
"KeyType"
,
"name"
:
"开锁方式"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"1"
:
"指纹"
,
"2"
:
"密码"
,
"3"
:
"刷卡"
,
"4"
:
"APP远程开锁"
,
"5"
:
"机械钥匙"
,
"6"
:
"蓝牙"
,
"7"
:
"劫持报警"
,
"8"
:
"限时临时密码"
}
}
}
],
"identifier"
:
"KeyDeletedNotification"
,
"method"
:
"thing.event.KeyDeletedNotification.post"
,
"name"
:
"KeyDeletedNotification"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"删除用户上报"
},
{
"identifier"
:
"DoorBell"
,
"method"
:
"thing.event.DoorBell.post"
,
"name"
:
"DoorBell"
,
"type"
:
"alarm"
,
"required"
:
true
,
"desc"
:
"门铃事件"
},
{
"outputData"
:
[
{
"identifier"
:
"DismantleState"
,
"name"
:
"拆卸状态"
,
"dataType"
:
{
"type"
:
"enum"
,
"specs"
:
{
"0"
:
"正常"
,
"1"
:
"被拆卸"
}
}
}
],
"identifier"
:
"TamperAlarm"
,
"method"
:
"thing.event.TamperAlarm.post"
,
"name"
:
"TamperAlarm"
,
"type"
:
"alert"
,
"required"
:
true
,
"desc"
:
"防拆告警"
},
{
"outputData"
:
[
{
"identifier"
:
"Battery"
,
"name"
:
"电池电量"
,
"dataType"
:
{
"type"
:
"double"
,
"specs"
:
{
"min"
:
"0.0"
,
"max"
:
"100.0"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"0.01"
}
}
}
],
"identifier"
:
"BatteryAlarm"
,
"method"
:
"thing.event.BatteryAlarm.post"
,
"name"
:
"BatteryAlarm"
,
"type"
:
"alert"
,
"required"
:
true
,
"desc"
:
"低电量告警"
},
{
"identifier"
:
"MultipleOpenLockFailedAlarm"
,
"method"
:
"thing.event.MultipleOpenLockFailedAlarm.post"
,
"name"
:
"MultipleOpenLockFailedAlarm"
,
"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