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
890c7106
Commit
890c7106
authored
Sep 03, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1,修改主机重启后属性上报采用异步模式;2,sqlite数据库源码更新(之前的源码太大)
【提交人】陈伟灿
parent
363145b7
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
111402 additions
and
232924 deletions
+111402
-232924
application/kcloud/iot.mk
application/kcloud/iot.mk
+0
-2
common/sqlite/shell.c
common/sqlite/shell.c
+0
-19550
common/sqlite/sqlite3.c
common/sqlite/sqlite3.c
+110225
-206401
common/sqlite/sqlite3.h
common/sqlite/sqlite3.h
+1054
-6273
common/sqlite/sqlite3ext.h
common/sqlite/sqlite3ext.h
+0
-659
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+22
-16
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+60
-7
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+1
-1
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+23
-0
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+7
-6
midware/midware/midware.c
midware/midware/midware.c
+2
-1
midware/tsl/tsl_handle/kk_tsl_api.c
midware/tsl/tsl_handle/kk_tsl_api.c
+7
-7
midware/tsl/tsl_handle/kk_tsl_api.h
midware/tsl/tsl_handle/kk_tsl_api.h
+1
-1
No files found.
application/kcloud/iot.mk
View file @
890c7106
LIBA_TARGET
:=
libiot_kcloud.a
LIBA_TARGET
:=
libiot_kcloud.a
SRCS_kcloud
:=
kcloud_main.c
$(call
Append_Conditional,
LIB_SRCS_EXCLUDE,
kcloud_main.c)
$(call
Append_Conditional,
LIB_SRCS_EXCLUDE,
kcloud_main.c)
$(call
Append_Conditional,
SRCS_kcloud,
kcloud_main.c)
$(call
Append_Conditional,
SRCS_kcloud,
kcloud_main.c)
$(call
Append_Conditional,
TARGET,
kcloud)
$(call
Append_Conditional,
TARGET,
kcloud)
...
...
common/sqlite/shell.c
deleted
100644 → 0
View file @
363145b7
This diff is collapsed.
Click to expand it.
common/sqlite/sqlite3.c
View file @
890c7106
This diff is collapsed.
Click to expand it.
common/sqlite/sqlite3.h
View file @
890c7106
This diff is collapsed.
Click to expand it.
common/sqlite/sqlite3ext.h
deleted
100644 → 0
View file @
363145b7
This diff is collapsed.
Click to expand it.
midware/midware/dm/kk_dm_mng.c
View file @
890c7106
...
@@ -502,7 +502,7 @@ int iotx_report_id(void)
...
@@ -502,7 +502,7 @@ int iotx_report_id(void)
return
g_report_id
++
;
return
g_report_id
++
;
}
}
int
dm_mgr_upstream_thing_property_post
(
_IN_
int
devid
,
_IN_
char
*
payload
,
_IN_
int
payload_len
)
int
dm_mgr_upstream_thing_property_post
(
_IN_
int
devid
,
_IN_
char
*
payload
,
_IN_
int
payload_len
,
_IN_
int
isAsync
)
{
{
int
res
=
0
;
int
res
=
0
;
dm_msg_request_t
request
;
dm_msg_request_t
request
;
...
@@ -522,7 +522,7 @@ int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_
...
@@ -522,7 +522,7 @@ int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_
//request.callback = dm_client_thing_event_post_reply;
//request.callback = dm_client_thing_event_post_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
isAsync
);
free
(
request
.
msgTypeStr
);
free
(
request
.
msgTypeStr
);
free
(
request
.
params
);
free
(
request
.
params
);
return
res
;
return
res
;
...
@@ -549,7 +549,7 @@ int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_
...
@@ -549,7 +549,7 @@ int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_
//request.callback = dm_client_thing_event_post_reply;
//request.callback = dm_client_thing_event_post_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
free
(
request
.
msgTypeStr
);
free
(
request
.
msgTypeStr
);
free
(
request
.
params
);
free
(
request
.
params
);
return
res
;
return
res
;
...
@@ -669,7 +669,7 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
...
@@ -669,7 +669,7 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
//request.callback = dm_client_thing_sub_register_reply;
//request.callback = dm_client_thing_sub_register_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
}
}
...
@@ -723,7 +723,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
...
@@ -723,7 +723,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -781,7 +781,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
...
@@ -781,7 +781,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -838,7 +838,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
...
@@ -838,7 +838,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -882,7 +882,7 @@ int dm_mgr_upstream_thing_topo_get(void)
...
@@ -882,7 +882,7 @@ int dm_mgr_upstream_thing_topo_get(void)
//request.callback = dm_client_thing_topo_get_reply;
//request.callback = dm_client_thing_topo_get_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
}
}
...
@@ -935,7 +935,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
...
@@ -935,7 +935,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
//request.callback = dm_client_thing_list_found_reply;
//request.callback = dm_client_thing_list_found_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
}
}
...
@@ -986,7 +986,7 @@ int dm_mgr_ccu_status_cloud(_IN_ int devid)
...
@@ -986,7 +986,7 @@ int dm_mgr_ccu_status_cloud(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -1049,7 +1049,7 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
...
@@ -1049,7 +1049,7 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -1109,7 +1109,7 @@ int dm_mgr_upstream_status_offline(_IN_ int devid)
...
@@ -1109,7 +1109,7 @@ int dm_mgr_upstream_status_offline(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -1165,7 +1165,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
...
@@ -1165,7 +1165,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -1220,7 +1220,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
...
@@ -1220,7 +1220,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
/* Send Message To Cloud */
/* Send Message To Cloud */
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -1273,7 +1273,7 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
...
@@ -1273,7 +1273,7 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
/* Send Message To Cloud */
/* Send Message To Cloud */
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
res
=
dm_msg_request
(
&
request
,
0
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
res
=
request
.
msgid
;
...
@@ -1304,12 +1304,18 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN])
...
@@ -1304,12 +1304,18 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN])
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
INFO_PRINT
(
"dm_mgr_subdev_delete deviceCode:%s
\n
"
,
deviceCode
);
INFO_PRINT
(
"dm_mgr_subdev_delete deviceCode:%s
\n
"
,
deviceCode
);
res
=
kk_subDev_delete_by_dcode
(
deviceCode
);
//delete db data
res
=
kk_subDev_delete_by_dcode
(
deviceCode
);
//delete
sub
db data
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
kk_property_delete_by_dcode
(
deviceCode
);
//delete properties db data
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
}
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
...
...
midware/midware/dm/kk_dm_msg.c
View file @
890c7106
...
@@ -11,15 +11,20 @@
...
@@ -11,15 +11,20 @@
const
char
DM_MSG_REQUEST
[]
DM_READ_ONLY
=
"{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
%s
\"
,
\"
params
\"
:%s,
\"
time
\"
:
\"
%lu
\"
,
\"
method
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_REQUEST
[]
DM_READ_ONLY
=
"{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
%s
\"
,
\"
params
\"
:%s,
\"
time
\"
:
\"
%lu
\"
,
\"
method
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_INFO
[]
DM_READ_ONLY
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_INFO
[]
DM_READ_ONLY
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
void
kk_sendData2app
(
void
*
info
,
void
*
payload
){
void
kk_sendData2app
(
void
*
info
,
void
*
payload
,
int
isAsync
){
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
infoObj
=
cJSON_Parse
(
info
);
cJSON
*
infoObj
=
cJSON_Parse
(
info
);
cJSON
*
payloadObj
=
cJSON_Parse
(
payload
);
cJSON
*
payloadObj
=
cJSON_Parse
(
payload
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
void
*
buf
=
cJSON_Print
(
root
);
kk_ipc_send
(
IPC_MID2APP
,
buf
,
strlen
(
buf
)
+
1
);
if
(
isAsync
){
free
(
buf
);
dm_queue_msg_insert4
(
buf
);
}
else
{
kk_ipc_send
(
IPC_MID2APP
,
buf
,
strlen
(
buf
)
+
1
);
free
(
buf
);
}
cJSON_Delete
(
root
);
cJSON_Delete
(
root
);
}
}
...
@@ -525,7 +530,7 @@ int dm_msg_combine_logout(_IN_ char deviceCode[DEVICE_CODE_MAXLEN],_OU_ dm_msg_r
...
@@ -525,7 +530,7 @@ int dm_msg_combine_logout(_IN_ char deviceCode[DEVICE_CODE_MAXLEN],_OU_ dm_msg_r
}
}
int
dm_msg_request
(
_IN_
dm_msg_request_t
*
request
)
int
dm_msg_request
(
_IN_
dm_msg_request_t
*
request
,
_IN_
int
isAsync
)
{
{
int
res
=
0
,
payload_len
=
0
,
req_info_len
=
0
;
int
res
=
0
,
payload_len
=
0
,
req_info_len
=
0
;
char
*
payload
=
NULL
;
char
*
payload
=
NULL
;
...
@@ -572,8 +577,8 @@ int dm_msg_request (_IN_ dm_msg_request_t *request)
...
@@ -572,8 +577,8 @@ int dm_msg_request (_IN_ dm_msg_request_t *request)
}
}
//if (type & DM_MSG_DEST_CLOUD) {
//if (type & DM_MSG_DEST_CLOUD) {
// dm_client_publish(uri, (unsigned char *)payload, strlen(payload), request->callback);
// dm_client_publish(uri, (unsigned char *)payload, strlen(payload), request->callback);
kk_sendData2app
(
req_info
,
payload
);
kk_sendData2app
(
req_info
,
payload
,
isAsync
);
//}
free
(
req_info
);
free
(
req_info
);
free
(
payload
);
free
(
payload
);
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
...
@@ -635,7 +640,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
...
@@ -635,7 +640,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
}
}
//dm_client_publish(uri, (unsigned char *)payload, strlen(payload), NULL);
//dm_client_publish(uri, (unsigned char *)payload, strlen(payload), NULL);
kk_sendData2app
(
res_info
,
payload
);
kk_sendData2app
(
res_info
,
payload
,
0
);
free
(
res_info
);
free
(
res_info
);
free
(
payload
);
free
(
payload
);
...
@@ -733,5 +738,53 @@ int dm_msg_thing_property_set_reply(char deviceCode[DEVICE_CODE_MAXLEN],char *pa
...
@@ -733,5 +738,53 @@ int dm_msg_thing_property_set_reply(char deviceCode[DEVICE_CODE_MAXLEN],char *pa
dm_msg_response
(
&
request
,
&
response
,
"{}"
,
strlen
(
"{}"
),
NULL
);
dm_msg_response
(
&
request
,
&
response
,
"{}"
,
strlen
(
"{}"
),
NULL
);
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
dm_msg_thing_property_post_all
(
char
*
deviceCode
)
{
int
res
=
0
;
int
nums
=
0
;
int
idx
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
kk_tsl_post_property
(
node
->
devid
,
NULL
,
1
);
//here need async post
return
SUCCESS_RETURN
;
}
int
dm_msg_thing_property_post_by_identify
(
char
*
deviceCode
,
cJSON
*
params
)
{
int
res
=
0
;
int
nums
=
0
;
int
idx
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
if
(
params
==
NULL
||
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
nums
=
node
->
dev_shadow
->
property_number
;
for
(
idx
=
0
;
idx
<
nums
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
continue
;
}
propertyItem
=
cJSON_GetObjectItem
(
params
,
property
->
identifier
);
if
(
propertyItem
!=
NULL
){
kk_tsl_post_property
(
node
->
devid
,
property
->
identifier
,
0
);
}
}
return
SUCCESS_RETURN
;
}
midware/midware/dm/kk_linkkit.c
View file @
890c7106
...
@@ -319,7 +319,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -319,7 +319,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
if
(
s_CloudStatus
){
if
(
s_CloudStatus
){
iotx_dm_dev_online
(
0
);
//first online,report the online status
iotx_dm_dev_online
(
0
);
//first online,report the online status
usleep
(
200000
);
usleep
(
200000
);
kk_tsl_post_property
(
0
,
NULL
);
kk_tsl_post_property
(
0
,
NULL
,
0
);
}
}
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_OTA_DEVICE_UPGRADE
)){
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_OTA_DEVICE_UPGRADE
)){
INFO_PRINT
(
"ota upgrade...
\n
"
);
INFO_PRINT
(
"ota upgrade...
\n
"
);
...
...
midware/midware/dm/kk_property_db.c
View file @
890c7106
...
@@ -379,6 +379,29 @@ int kk_property_sync_values(const char *deviceCode)
...
@@ -379,6 +379,29 @@ int kk_property_sync_values(const char *deviceCode)
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_property_delete_by_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
])
{
const
char
*
deleteCmd
=
"delete from PropertiesInfo where deviceCode = '%s';"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
deviceCode
);
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_property_db_unlock
();
return
SUCCESS_RETURN
;
}
...
...
midware/midware/dm/kk_sub_db.c
View file @
890c7106
...
@@ -115,15 +115,16 @@ static int _kk_load_subDevice(void)
...
@@ -115,15 +115,16 @@ static int _kk_load_subDevice(void)
ctx
->
subDevNum
++
;
ctx
->
subDevNum
++
;
}
}
usleep
(
100000
);
usleep
(
100000
);
//如果为认证,需要认证
// send the topc info
//再上线
iotx_dm_subscribe
(
devId
);
iotx_dm_subscribe
(
devId
);
if
(
sqlite3_column_int
(
stmt
,
DB_DEVTYPE
)
==
KK_DM_DEVICE_SUBDEV
){
//sync the data from property db
kk_property_sync_values
(
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
));
kk_property_sync_values
(
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
));
}
kk_dm_ota_report_version
(
devId
,
sqlite3_column_text
(
stmt
,
DB_VERSION
));
//version
usleep
(
100000
);
//post the property to cloud
dm_msg_thing_property_post_all
(
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
));
//kk_dm_ota_report_version(devId,sqlite3_column_text(stmt, DB_VERSION));//post version
//usleep(100000);
//usleep(100000);
}
}
sqlite3_finalize
(
stmt
);
sqlite3_finalize
(
stmt
);
...
...
midware/midware/midware.c
View file @
890c7106
...
@@ -222,6 +222,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
...
@@ -222,6 +222,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
INFO_PRINT
(
"save property and send to cloud
\n
"
);
INFO_PRINT
(
"save property and send to cloud
\n
"
);
char
*
outstr
=
cJSON_Print
(
payload
);
char
*
outstr
=
cJSON_Print
(
payload
);
kk_tsl_property_set_by_devicecode
(
info_dcode
->
valuestring
,
outstr
,
strlen
(
outstr
)
+
1
);
kk_tsl_property_set_by_devicecode
(
info_dcode
->
valuestring
,
outstr
,
strlen
(
outstr
)
+
1
);
dm_msg_thing_property_post_by_identify
(
info_dcode
->
valuestring
,
jsonPay
);
kk_property_db_update
(
info_dcode
->
valuestring
);
kk_property_db_update
(
info_dcode
->
valuestring
);
free
(
outstr
);
free
(
outstr
);
...
@@ -602,7 +603,7 @@ void *ccu_property_monitor(void *args)
...
@@ -602,7 +603,7 @@ void *ccu_property_monitor(void *args)
}
}
if
(
needReport
&&
(
kk_get_cloudstatus
()
==
1
)){
if
(
needReport
&&
(
kk_get_cloudstatus
()
==
1
)){
needReport
=
0
;
needReport
=
0
;
kk_tsl_post_property
(
0
,
NULL
);
kk_tsl_post_property
(
0
,
NULL
,
0
);
}
}
sleep
(
time_second
);
sleep
(
time_second
);
}
}
...
...
midware/tsl/tsl_handle/kk_tsl_api.c
View file @
890c7106
...
@@ -1260,7 +1260,7 @@ int kk_tsl_property_set_by_devicecode(const char deviceCode[DEVICE_CODE_MAXLEN],
...
@@ -1260,7 +1260,7 @@ int kk_tsl_property_set_by_devicecode(const char deviceCode[DEVICE_CODE_MAXLEN],
res
=
_kk_msg_property_set
(
devid
,
&
request
);
res
=
_kk_msg_property_set
(
devid
,
&
request
);
/* Response */
/* Response */
kk_tsl_post_property
(
devid
,
NULL
);
//
kk_tsl_post_property(devid,NULL);
#if 0
#if 0
#define EVENT_ERROR_IDENTIFIER "Error"
#define EVENT_ERROR_IDENTIFIER "Error"
...
@@ -1317,7 +1317,7 @@ int kk_tsl_service_property_set(const char *topic, const char *payload, unsigned
...
@@ -1317,7 +1317,7 @@ int kk_tsl_service_property_set(const char *topic, const char *payload, unsigned
res
=
_kk_msg_property_set
(
devid
,
&
request
);
res
=
_kk_msg_property_set
(
devid
,
&
request
);
/* Response */
/* Response */
kk_tsl_post_property
(
devid
,
NULL
);
kk_tsl_post_property
(
devid
,
NULL
,
0
);
#if 0
#if 0
#define EVENT_ERROR_IDENTIFIER "Error"
#define EVENT_ERROR_IDENTIFIER "Error"
...
@@ -1468,7 +1468,7 @@ int kk_tsl_post_property_add(_IN_ void *handle, _IN_ char *identifier, _IN_ int
...
@@ -1468,7 +1468,7 @@ int kk_tsl_post_property_add(_IN_ void *handle, _IN_ char *identifier, _IN_ int
}
}
return
ret
;
return
ret
;
}
}
static
int
kk_tsl_post_property_end
(
_IN_
void
*
handle
)
static
int
kk_tsl_post_property_end
(
_IN_
void
*
handle
,
_IN_
int
isAsync
)
{
{
int
res
=
0
;
int
res
=
0
;
char
*
payload
=
NULL
;
char
*
payload
=
NULL
;
...
@@ -1485,7 +1485,7 @@ static int kk_tsl_post_property_end(_IN_ void *handle)
...
@@ -1485,7 +1485,7 @@ static int kk_tsl_post_property_end(_IN_ void *handle)
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
INFO_PRINT
(
"Post Payload, Length: %d, Payload: %s
\n
"
,
strlen
(
payload
),
payload
);
INFO_PRINT
(
"Post Payload, Length: %d, Payload: %s
\n
"
,
strlen
(
payload
),
payload
);
res
=
dm_mgr_upstream_thing_property_post
(
dapi_property
->
devid
,
payload
,
strlen
(
payload
));
res
=
dm_mgr_upstream_thing_property_post
(
dapi_property
->
devid
,
payload
,
strlen
(
payload
)
,
isAsync
);
lite_cjson_delete
(
dapi_property
->
lite
);
lite_cjson_delete
(
dapi_property
->
lite
);
free
(
dapi_property
);
free
(
dapi_property
);
free
(
payload
);
free
(
payload
);
...
@@ -1493,7 +1493,7 @@ static int kk_tsl_post_property_end(_IN_ void *handle)
...
@@ -1493,7 +1493,7 @@ static int kk_tsl_post_property_end(_IN_ void *handle)
return
res
;
return
res
;
}
}
int
kk_tsl_post_property
(
int
devId
,
const
char
*
property_identifier
)
int
kk_tsl_post_property
(
int
devId
,
const
char
*
property_identifier
,
int
isAsync
)
{
{
int
res
=
0
,
msgid
=
0
,
property_identifier_len
=
0
,
post_property_reply
=
0
;
int
res
=
0
,
msgid
=
0
,
property_identifier_len
=
0
,
post_property_reply
=
0
;
void
*
property_handle
=
NULL
;
void
*
property_handle
=
NULL
;
...
@@ -1508,11 +1508,11 @@ int kk_tsl_post_property(int devId, const char *property_identifier)
...
@@ -1508,11 +1508,11 @@ int kk_tsl_post_property(int devId, const char *property_identifier)
property_identifier_len
=
(
property_identifier
)
?
(
strlen
((
char
*
)
property_identifier
))
:
(
0
);
property_identifier_len
=
(
property_identifier
)
?
(
strlen
((
char
*
)
property_identifier
))
:
(
0
);
res
=
kk_tsl_post_property_add
(
property_handle
,
(
char
*
)
property_identifier
,
property_identifier_len
);
res
=
kk_tsl_post_property_add
(
property_handle
,
(
char
*
)
property_identifier
,
property_identifier_len
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
kk_tsl_post_property_end
(
property_handle
);
kk_tsl_post_property_end
(
property_handle
,
isAsync
);
_kk_tsl_api_unlock
();
_kk_tsl_api_unlock
();
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
kk_tsl_post_property_end
(
property_handle
);
res
=
kk_tsl_post_property_end
(
property_handle
,
isAsync
);
if
(
res
<
SUCCESS_RETURN
)
{
if
(
res
<
SUCCESS_RETURN
)
{
_kk_tsl_api_unlock
();
_kk_tsl_api_unlock
();
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
...
midware/tsl/tsl_handle/kk_tsl_api.h
View file @
890c7106
...
@@ -81,7 +81,7 @@ extern int kk_msg_uri_parse_pkdn(_IN_ char *uri, _IN_ int uri_len, _IN_ int star
...
@@ -81,7 +81,7 @@ extern int kk_msg_uri_parse_pkdn(_IN_ char *uri, _IN_ int uri_len, _IN_ int star
_OU_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
_OU_
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
_OU_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
_OU_
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
extern
int
kk_tsl_service_property_set
(
const
char
*
topic
,
const
char
*
payload
,
unsigned
int
payload_len
,
extern
int
kk_tsl_service_property_set
(
const
char
*
topic
,
const
char
*
payload
,
unsigned
int
payload_len
,
void
*
context
);
void
*
context
);
extern
int
kk_tsl_post_property
(
int
devId
,
const
char
*
property_identifier
);
extern
int
kk_tsl_post_property
(
int
devId
,
const
char
*
property_identifier
,
int
isAsync
);
extern
int
kk_tsl_post_event
(
int
devId
,
const
char
*
event_identifier
);
extern
int
kk_tsl_post_event
(
int
devId
,
const
char
*
event_identifier
);
extern
int
kk_tsl_post_service
(
int
devId
,
const
char
*
service_identifier
,
int
response_id
,
int
code
);
extern
int
kk_tsl_post_service
(
int
devId
,
const
char
*
service_identifier
,
int
response_id
,
int
code
);
#endif
#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