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
3ba78763
Commit
3ba78763
authored
Aug 17, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】增加开机起来版本上报
【提交人】huang.zhenling
parent
8a8c252c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
2 deletions
+94
-2
application/kcloud/kcloud_data_handle.c
application/kcloud/kcloud_data_handle.c
+2
-2
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+5
-0
common/api/com_api.h
common/api/com_api.h
+1
-0
midware/midware/dm/kk_dm_api.c
midware/midware/dm/kk_dm_api.c
+4
-0
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+50
-0
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+31
-0
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+1
-0
No files found.
application/kcloud/kcloud_data_handle.c
View file @
3ba78763
...
@@ -185,7 +185,7 @@ static char * _kk_data_create(const char *topic,const char *data)
...
@@ -185,7 +185,7 @@ static char * _kk_data_create(const char *topic,const char *data)
out
=
cJSON_Print
(
root
);
out
=
cJSON_Print
(
root
);
cJSON_Delete
(
root
);
cJSON_Delete
(
root
);
free
(
infoStr
);
free
(
infoStr
);
printf
(
"[%s][%d]%s
\n
"
,
__FUNCTION__
,
__LINE__
,
out
);
INFO_PRINT
(
"[%s][%d]%s
\n
"
,
__FUNCTION__
,
__LINE__
,
out
);
return
out
;
return
out
;
//free(out); /* Print to text, Delete the cJSON, print it, release the string. */
//free(out); /* Print to text, Delete the cJSON, print it, release the string. */
}
}
...
@@ -196,7 +196,7 @@ void KK_Sendto_DevData(const char *topic,const char *data)
...
@@ -196,7 +196,7 @@ void KK_Sendto_DevData(const char *topic,const char *data)
{
{
return
;
//ingore the message
return
;
//ingore the message
}
}
printf
(
"[%s][%d]receive from cloud,topic:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
topic
);
INFO_PRINT
(
"[%s][%d]receive from cloud,topic:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
topic
);
char
*
send_data
=
_kk_data_create
(
topic
,
data
);
char
*
send_data
=
_kk_data_create
(
topic
,
data
);
if
(
send_data
==
NULL
){
if
(
send_data
==
NULL
){
return
;
return
;
...
...
application/kcloud/kk_topic_mng.c
View file @
3ba78763
...
@@ -23,6 +23,8 @@ const char DM_URI_THING_SERVICE_RESPONSE[] = "thing/service/%.*s_reply";
...
@@ -23,6 +23,8 @@ const char DM_URI_THING_SERVICE_RESPONSE[] = "thing/service/%.*s_reply";
const
char
DM_URI_THING_SERVICE_PROPERTY_SET_REPLY
[]
=
"thing/service/property/set_reply"
;
const
char
DM_URI_THING_SERVICE_PROPERTY_SET_REPLY
[]
=
"thing/service/property/set_reply"
;
const
char
KK_URI_OTA_PREFIX
[]
=
"/ota/device/upgrade/%s/%s/#"
;
const
char
KK_URI_OTA_PREFIX
[]
=
"/ota/device/upgrade/%s/%s/#"
;
const
char
KK_URI_OTA_PROCESS
[]
=
"/ota/device/progress/%s/%s"
;
const
char
KK_URI_OTA_PROCESS
[]
=
"/ota/device/progress/%s/%s"
;
const
char
KK_URI_OTA_INFORM
[]
=
"/ota/device/inform/%s/%s"
;
int
KK_Subdev_Subscribe
(
const
cJSON
*
root
)
int
KK_Subdev_Subscribe
(
const
cJSON
*
root
)
...
@@ -223,6 +225,9 @@ char* KK_Make_Topic(cJSON *info)
...
@@ -223,6 +225,9 @@ char* KK_Make_Topic(cJSON *info)
case
MSG_OTA_PROCESS
:
case
MSG_OTA_PROCESS
:
_kk_utils_topic
(
KK_URI_OTA_PROCESS
,
product_type
->
valuestring
,
device_name
->
valuestring
,
&
topic
);
_kk_utils_topic
(
KK_URI_OTA_PROCESS
,
product_type
->
valuestring
,
device_name
->
valuestring
,
&
topic
);
break
;
break
;
case
MSG_OTA_INFORM
:
_kk_utils_topic
(
KK_URI_OTA_INFORM
,
product_type
->
valuestring
,
device_name
->
valuestring
,
&
topic
);
break
;
}
}
INFO_PRINT
(
"[%s][%d] TOPIC:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
topic
);
INFO_PRINT
(
"[%s][%d] TOPIC:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
topic
);
...
...
common/api/com_api.h
View file @
3ba78763
...
@@ -42,6 +42,7 @@ typedef enum{
...
@@ -42,6 +42,7 @@ typedef enum{
MSG_SERVICERESPONSE
,
MSG_SERVICERESPONSE
,
MSG_SETREPLY
,
MSG_SETREPLY
,
MSG_OTA_PROCESS
,
MSG_OTA_PROCESS
,
MSG_OTA_INFORM
,
/*******APP TO MIDDWARE**************/
/*******APP TO MIDDWARE**************/
MSG_REGISTER_REPLY
,
MSG_REGISTER_REPLY
,
MSG_TOPOADD_REPLY
,
MSG_TOPOADD_REPLY
,
...
...
midware/midware/dm/kk_dm_api.c
View file @
3ba78763
...
@@ -314,6 +314,10 @@ int iotx_dm_subscribe(_IN_ int devid)
...
@@ -314,6 +314,10 @@ int iotx_dm_subscribe(_IN_ int devid)
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
void
kk_dm_ota_report_version
(
_IN_
int
devid
,
char
*
version
){
dm_mgr_ota_report_version
(
devid
,
version
);
}
void
kk_dm_ota_send
(
void
*
data
,
int
len
){
void
kk_dm_ota_send
(
void
*
data
,
int
len
){
dm_queue_msg_insert3
(
data
);
dm_queue_msg_insert3
(
data
);
if
(
data
!=
NULL
){
if
(
data
!=
NULL
){
...
...
midware/midware/dm/kk_dm_mng.c
View file @
3ba78763
...
@@ -945,6 +945,56 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
...
@@ -945,6 +945,56 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
return
res
;
return
res
;
}
}
int
dm_mgr_ota_report_version
(
_IN_
int
devid
,
char
*
version
)
{
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_msg_request_t
request
;
if
(
devid
<
0
)
{
return
INVALID_PARAMETER
;
}
res
=
dm_mgr_search_dev_by_devid
(
devid
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgtype
=
MSG_OTA_INFORM
;
memcpy
(
request
.
identity
,
""
,
strlen
(
""
));
memcpy
(
request
.
product_key
,
node
->
product_key
,
PRODUCT_KEY_MAXLEN
);
memcpy
(
request
.
device_name
,
node
->
device_name
,
DEVICE_NAME_MAXLEN
);
/* Get Params And Method */
res
=
dm_msg_ota_report_version
(
version
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
/* Get Msg ID */
request
.
msgid
=
iotx_report_id
();
/* Get Dev ID */
request
.
devid
=
devid
;
/* Callback */
//request.callback = dm_client_combine_logout_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */
res
=
dm_msg_request
(
&
request
);
if
(
res
==
SUCCESS_RETURN
)
{
res
=
request
.
msgid
;
}
free
(
request
.
params
);
return
res
;
}
int
dm_mgr_subdev_create
(
_IN_
char
product_key
[
PRODUCT_KEY_MAXLEN
],
int
dm_mgr_subdev_create
(
_IN_
char
product_key
[
PRODUCT_KEY_MAXLEN
],
_IN_
char
device_name
[
DEVICE_NAME_MAXLEN
],
_IN_
char
device_secret
[
DEVICE_SECRET_MAXLEN
],
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
int
*
devid
){
_IN_
char
device_name
[
DEVICE_NAME_MAXLEN
],
_IN_
char
device_secret
[
DEVICE_SECRET_MAXLEN
],
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
int
*
devid
){
...
...
midware/midware/dm/kk_dm_msg.c
View file @
3ba78763
...
@@ -386,6 +386,37 @@ int dm_msg_combine_logout(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
...
@@ -386,6 +386,37 @@ int dm_msg_combine_logout(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
}
}
const
char
DM_MSG_OTA_VERSION_PARAMS
[]
DM_READ_ONLY
=
"{{
\"
version
\"
:
\"
%s
\"
}"
;
int
dm_msg_ota_report_version
(
_IN_
char
*
version
,
_OU_
dm_msg_request_t
*
request
)
{
char
*
params
=
NULL
;
int
params_len
=
0
;
if
(
NULL
==
version
){
return
INVALID_PARAMETER
;
}
/* Params */
request
->
method
=
(
char
*
)
""
;
params_len
=
strlen
(
DM_MSG_OTA_VERSION_PARAMS
)
+
strlen
(
version
)
+
1
;
params
=
malloc
(
params_len
);
if
(
params
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
}
memset
(
params
,
0
,
params_len
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_OTA_VERSION_PARAMS
,
version
);
request
->
params
=
params
;
request
->
params_len
=
strlen
(
request
->
params
);
return
SUCCESS_RETURN
;
}
int
dm_msg_request
(
_IN_
dm_msg_request_t
*
request
)
int
dm_msg_request
(
_IN_
dm_msg_request_t
*
request
)
{
{
int
res
=
0
,
payload_len
=
0
,
req_info_len
=
0
;
int
res
=
0
,
payload_len
=
0
,
req_info_len
=
0
;
...
...
midware/midware/dm/kk_sub_db.c
View file @
3ba78763
...
@@ -91,6 +91,7 @@ static int _kk_load_subDevice(void)
...
@@ -91,6 +91,7 @@ static int _kk_load_subDevice(void)
ctx
->
subDevNum
++
;
ctx
->
subDevNum
++
;
}
}
iotx_dm_subscribe
(
devId
);
iotx_dm_subscribe
(
devId
);
kk_dm_ota_report_version
(
devId
,
"1.0.0"
);
//todo
usleep
(
100000
);
usleep
(
100000
);
}
}
sqlite3_finalize
(
stmt
);
sqlite3_finalize
(
stmt
);
...
...
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