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
e95c0add
Commit
e95c0add
authored
Sep 11, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1,增加房间勿扰模式的功能设置
【提交人】陈伟灿
parent
e13e0d1f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
12 deletions
+77
-12
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+13
-9
midware/midware/area/kk_area_handle.c
midware/midware/area/kk_area_handle.c
+1
-1
midware/midware/dm/kk_dm_msg.h
midware/midware/dm/kk_dm_msg.h
+1
-0
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+58
-0
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+3
-2
midware/midware/dm/kk_property_db.h
midware/midware/dm/kk_property_db.h
+1
-0
No files found.
application/kcloud/mqtt_api.c
View file @
e95c0add
...
...
@@ -114,13 +114,15 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
}
void
onConnect
(
void
*
context
,
MQTTAsync_successData
*
response
)
{
INFO_PRINT
(
"Successful connection
\n
"
);
s_cloudStatus
=
DEVICE_ONLINE
;
INFO_PRINT
(
"-----------Successful connection
\n
"
);
kk_remove_disconnect_flag
();
KK_Send_CloudState
(
s_cloudStatus
);
if
(
s_cloudStatus
!=
DEVICE_ONLINE
){
s_cloudStatus
=
DEVICE_ONLINE
;
KK_Send_CloudState
(
s_cloudStatus
);
}
}
...
...
@@ -145,15 +147,18 @@ static void onDeliveryComplete(void* context, MQTTAsync_token token)
}
static
void
onConnectBuild
(
void
*
context
,
char
*
cause
)
{
INFO_PRINT
(
"onConnectBuild:%s
\n
"
,
cause
);
INFO_PRINT
(
"
----
onConnectBuild:%s
\n
"
,
cause
);
//rc = KK_Client_Gateway_Subscribe();
//if(rc != 0)
//{
//ERROR_PRINT("KK_MQTT_SubTopic ERROR rc = %d\n",rc);
//}
s_cloudStatus
=
DEVICE_ONLINE
;
kk_remove_disconnect_flag
();
KK_Send_CloudState
(
s_cloudStatus
);
if
(
s_cloudStatus
!=
DEVICE_ONLINE
){
s_cloudStatus
=
DEVICE_ONLINE
;
INFO_PRINT
(
"--11--onConnectBuild:%s
\n
"
,
cause
);
KK_Send_CloudState
(
s_cloudStatus
);
}
}
static
void
onDisConnected
(
void
*
context
,
MQTTProperties
*
properties
,
enum
MQTTReasonCodes
reasonCode
)
{
...
...
@@ -242,7 +247,7 @@ MQTTAsync KK_MQTT_Connect(void)
/*Set the mqtt callback*/
mqtt_set_callbacks
();
conn_opts
.
keepAliveInterval
=
6
0
;
conn_opts
.
keepAliveInterval
=
3
0
;
conn_opts
.
connectTimeout
=
CONNECT_TIMEOUT
;
conn_opts
.
automaticReconnect
=
AUTO_CONN
;
conn_opts
.
minRetryInterval
=
1
;
...
...
@@ -269,7 +274,6 @@ int KK_MQTT_SubTopic(char *topicName)
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
int
rc
;
opts
.
onSuccess
=
onOptSuccess
;
opts
.
onFailure
=
onOptFail
;
opts
.
context
=
(
void
*
)
OPT_SUB
;
...
...
midware/midware/area/kk_area_handle.c
View file @
e95c0add
...
...
@@ -539,7 +539,7 @@ kk_dev_list_t* kk_get_room_deviceCode(const char* roomId)
sqlite3_stmt
*
stmt
;
char
*
sqlCmd
=
NULL
;
kk_area_ctx_t
*
ctx
=
_kk_area_get_ctx
();
const
char
*
searchCmd
=
"select * from AreaDevInfo;"
;
const
char
*
searchCmd
=
"select * from AreaDevInfo
where epNum = 1
;"
;
_kk_area_lock
();
sqlCmd
=
sqlite3_mprintf
(
searchCmd
,
roomId
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
...
...
midware/midware/dm/kk_dm_msg.h
View file @
e95c0add
...
...
@@ -87,6 +87,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_THING_SERVICE_SYNCDEVICEINFO "/thing/service/syncDeviceInfo"
#define KK_THING_SERVICE_SYNCDEVICEINFO_REPLY "/thing/service/syncDeviceInfo_reply"
#define KK_THING_SERVICE_CLOUDSTATUS "/thing/service/cloudStatus"
#define KK_THING_SERVICE_EXECUTEDNDMODE "/thing/service/executeDNDMode"
...
...
midware/midware/dm/kk_linkkit.c
View file @
e95c0add
...
...
@@ -639,6 +639,57 @@ static int kk_service_execute_action(cJSON *action,dm_mgr_dev_node_t *node)
}
/************************************************************
*功能描述:设置房间勿让模式
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_executeDNDMode_handle
(
cJSON
*
params
)
{
int
res
=
0
;
char
roomIdStr
[
16
]
=
{
0
};
kk_dev_list_t
*
pList
=
NULL
;
dm_mgr_dev_node_t
*
search_node
=
NULL
;
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_ROOMID
);
if
(
roomId
==
NULL
||
roomId
->
type
!=
cJSON_Number
){
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
return
INVALID_PARAMETER
;
}
sprintf
(
roomIdStr
,
"%d"
,
roomId
->
valueint
);
pList
=
kk_get_room_deviceCode
(
roomIdStr
);
while
(
pList
!=
NULL
){
res
=
kk_check_property_exist
(
pList
->
deviceCode
,
"NoDisturbMode"
);
if
(
res
!=
1
)
{
pList
=
pList
->
next
;
continue
;
}
res
=
dm_mgr_get_device_by_devicecode
(
pList
->
deviceCode
,
&
search_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
pList
=
pList
->
next
;
continue
;
}
cJSON
*
DNDMode
=
cJSON_GetObjectItem
(
params
,
"DNDMode"
);
if
(
DNDMode
!=
NULL
&&
DNDMode
->
type
==
cJSON_Number
){
cJSON
*
param
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
param
,
"NoDisturbMode"
,
DNDMode
->
valueint
);
char
*
paramstr
=
cJSON_Print
(
param
);
kk_msg_execute_property_set
(
search_node
->
productCode
,
search_node
->
deviceCode
,
paramstr
,
search_node
->
fatherDeviceCode
);
free
(
paramstr
);
usleep
(
200000
);
}
pList
=
pList
->
next
;
}
kk_free_room_dev_list
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:批量执行房间设备处理
*输入参数:params:云端下发数据,包含房间号,productCode等
...
...
@@ -1465,6 +1516,13 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
INFO_PRINT
(
"TOPO CHANGE
\n
"
);
kk_topo_delete_handle
(
payload
,
info_root
);
//kk_sendData2gw(data, strlen(data), deviceCode->valuestring);//send to gw itself
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_EXECUTEDNDMODE
)
==
0
){
INFO_PRINT
(
"EXECUREDNDMODE
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
kk_service_common_reply
(
info_root
,
msgId
,
"/thing/service/executeDNDMode_reply"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_executeDNDMode_handle
(
paramStr
);
}
else
{
INFO_PRINT
(
"Error msgtype!!!
\n
"
);
...
...
midware/midware/dm/kk_property_db.c
View file @
e95c0add
...
...
@@ -154,7 +154,7 @@ int kk_property_db_init(void)
*返 回 值: 1:已经存在;0:不存在
*其他说明:
*************************************************************/
static
int
_
kk_check_property_exist
(
const
char
*
deviceCode
,
const
char
*
identifier
)
int
kk_check_property_exist
(
const
char
*
deviceCode
,
const
char
*
identifier
)
{
int
isExist
=
0
;
sqlite3_stmt
*
stmt
;
...
...
@@ -179,6 +179,7 @@ static int _kk_check_property_exist(const char* deviceCode,const char* identifie
_kk_property_db_unlock
();
return
isExist
;
}
char
*
human_induction_device
[]
=
{
(
char
*
){
"3049"
},
(
char
*
){
"3042"
},
...
...
@@ -236,7 +237,7 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
if
(
_
kk_check_property_exist
(
deviceCode
,
identifier
)
==
1
)
if
(
kk_check_property_exist
(
deviceCode
,
identifier
)
==
1
)
{
return
SUCCESS_RETURN
;
}
...
...
midware/midware/dm/kk_property_db.h
View file @
e95c0add
...
...
@@ -56,5 +56,6 @@ int kk_property_delete_lockkeys(char deviceCode[DEVICE_CODE_MAXLEN],char *keyId)
int
kk_indoorAir_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
epNum
);
int
kk_indoorAir_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
,
int
epNum
);
int
kk_indoorAir_query_epnums
(
const
char
*
deviceCode
,
int
epList
[]);
int
kk_check_property_exist
(
const
char
*
deviceCode
,
const
char
*
identifier
);
#endif
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