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
1e3c7b60
Commit
1e3c7b60
authored
Sep 15, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】网关下载ota文件,通知oatserver
【提交人】huang.zhenling
parent
9210363f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
4 deletions
+54
-4
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_palt_ota.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_palt_ota.c
+15
-4
platform/zigbee/protocol/zigbee/app/framework/plugin/ota-server/ota-server.c
...tocol/zigbee/app/framework/plugin/ota-server/ota-server.c
+39
-0
No files found.
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_palt_ota.c
View file @
1e3c7b60
...
...
@@ -6,6 +6,7 @@
#include "curl.h"
#include "./jsonrpc/rpccJSON.h"
static
int
s_ota_server_init
=
0
;
size_t
kk_write_func
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FILE
*
stream
)
{
...
...
@@ -57,6 +58,8 @@ int kk_http_download(char* url, char* filename)
}
static
const
char
oatStorageDirectory
[]
=
"ota-files"
;
int
kk_ota_process
(
cJSON
*
root
){
cJSON
*
params
;
cJSON
*
id
;
...
...
@@ -70,7 +73,9 @@ int kk_ota_process(cJSON* root){
int
ret
=
0
;
struct
stat
st
;
int
iFileSize
;
printf
(
"===============kk_ota_process
\n
"
);
char
fileName
[
100
]
=
{
0
};
info
=
rpc_cJSON_GetObjectItem
(
root
,
"info"
);
if
(
info
!=
NULL
){
...
...
@@ -79,14 +84,15 @@ int kk_ota_process(cJSON* root){
}
payload
=
rpc_cJSON_GetObjectItem
(
root
,
"payload"
);
if
(
payload
!=
NULL
){
printf
(
"===============kk_ota_process ===========11111111
\n
"
);
params
=
rpc_cJSON_GetObjectItem
(
payload
,
"data"
);
//id = rpc_cJSON_GetObjectItem(payload, "msgId");
url
=
rpc_cJSON_GetObjectItem
(
params
,
"url"
);
md5
=
rpc_cJSON_GetObjectItem
(
params
,
"md5"
);
size
=
rpc_cJSON_GetObjectItem
(
params
,
"size"
);
printf
(
"===============kk_ota_process ===========[%s][%s][%s]
\n
"
,
url
->
valuestring
,
mac
->
valuestring
,
size
->
valuestring
);
kk_http_download
(
url
->
valuestring
,
mac
->
valuestring
);
sprintf
(
fileName
,
"%s/%s.%s"
,
oatStorageDirectory
,
mac
->
valuestring
,
"ota"
);
kk_http_download
(
url
->
valuestring
,
fileName
);
if
(
stat
(
mac
->
valuestring
,
&
st
))
printf
(
"读取出错!
\n
"
);
...
...
@@ -101,7 +107,7 @@ int kk_ota_process(cJSON* root){
char
md5str
[
34
]
=
{
0
};
FILE
*
fp
;
sprintf
(
md5File
,
"%s.md5"
,
mac
->
valuestring
);
sprintf
(
cmd
,
"md5sum %s|cut -d
\"
\"
-f1 > %s"
,
mac
->
valuestring
,
md5File
);
sprintf
(
cmd
,
"md5sum %s|cut -d
\"
\"
-f1 > %s"
,
fileName
,
md5File
);
system
(
cmd
);
...
...
@@ -124,6 +130,11 @@ int kk_ota_process(cJSON* root){
}
fclose
(
fp
);
remove
(
md5File
);
kk_ota_notify
(
fileName
);
return
ret
;
}
return
-
1
;
...
...
platform/zigbee/protocol/zigbee/app/framework/plugin/ota-server/ota-server.c
View file @
1e3c7b60
...
...
@@ -570,3 +570,42 @@ void emberAfOtaServerSendUpgradeCommandCallback(EmberNodeId dest,
"error 0x%x"
,
status
);
}
}
static
int
s_ota_server_init
=
0
;
EmberAfOtaImageId
kk_get_imageId
(
char
*
filename
){
char
*
oatfile
=
NULL
;
EmberAfOtaImageId
id
=
emberAfOtaStorageIteratorFirstCallback
();
do
{
oatfile
=
emAfOtaStorageGetFilepath
(
&
id
);
if
(
oatfile
!=
NULL
&&
strcmp
(
oatfile
,
filename
)
==
0
){
return
id
;
}
id
=
emberAfOtaStorageIteratorNextCallback
();
}
while
(
emberAfIsOtaImageIdValid
(
&
id
));
return
emberAfInvalidImageId
;
}
void
kk_ota_notify
(
char
*
filepath
){
if
(
s_ota_server_init
==
0
){
s_ota_server_init
=
1
;
emberAfOtaBootloadClusterServerInitCallback
(
0x00
);
}
//add file
emAfOtaReloadStorageDevice
();
//TODO:开启通知, 通过mac地址获取dest,endpoint
EmberNodeId
dest
;
uint8_t
endpoint
;
EmberAfOtaImageId
id
;
id
=
kk_get_imageId
(
filepath
);
emberAfOtaServerSendUpgradeCommandCallback
(
dest
,
endpoint
,
&
id
);
}
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