Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
过眠
arduino-esp32
提交
2633fc3c
A
arduino-esp32
项目概览
过眠
/
arduino-esp32
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
arduino-esp32
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2633fc3c
编写于
1月 18, 2018
作者:
C
Clemens Kirchgatterer
提交者:
Me No Dev
1月 18, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add progress callback to Update::writeStream(). (#948)
上级
78acedd2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
1 deletion
+26
-1
libraries/Update/src/Update.h
libraries/Update/src/Update.h
+11
-0
libraries/Update/src/Updater.cpp
libraries/Update/src/Updater.cpp
+15
-1
未找到文件。
libraries/Update/src/Update.h
浏览文件 @
2633fc3c
...
...
@@ -3,6 +3,7 @@
#include <Arduino.h>
#include <MD5Builder.h>
#include <functional>
#include "esp_partition.h"
#define UPDATE_ERROR_OK (0)
...
...
@@ -27,7 +28,15 @@
class
UpdateClass
{
public:
typedef
std
::
function
<
void
(
size_t
,
size_t
)
>
THandlerFunction_Progress
;
UpdateClass
();
/*
This callback will be called when Update is receiving data
*/
UpdateClass
&
onProgress
(
THandlerFunction_Progress
fn
);
/*
Call this to check the space needed for the update
Will return false if there is not enough space
...
...
@@ -153,6 +162,8 @@ class UpdateClass {
bool
_verifyHeader
(
uint8_t
data
);
bool
_verifyEnd
();
THandlerFunction_Progress
_progress_callback
;
uint8_t
_error
;
uint8_t
*
_buffer
;
size_t
_bufferLen
;
...
...
libraries/Update/src/Updater.cpp
浏览文件 @
2633fc3c
...
...
@@ -71,9 +71,15 @@ UpdateClass::UpdateClass()
,
_progress
(
0
)
,
_command
(
U_FLASH
)
,
_partition
(
NULL
)
,
_progress_callback
(
NULL
)
{
}
UpdateClass
&
UpdateClass
::
onProgress
(
THandlerFunction_Progress
fn
)
{
_progress_callback
=
fn
;
return
*
this
;
}
void
UpdateClass
::
_reset
()
{
if
(
_buffer
)
delete
[]
_buffer
;
...
...
@@ -306,7 +312,9 @@ size_t UpdateClass::writeStream(Stream &data) {
_reset
();
return
0
;
}
if
(
_progress_callback
)
{
_progress_callback
(
0
,
_size
);
}
while
(
remaining
())
{
toRead
=
data
.
readBytes
(
_buffer
+
_bufferLen
,
(
SPI_FLASH_SEC_SIZE
-
_bufferLen
));
if
(
toRead
==
0
)
{
//Timeout
...
...
@@ -321,6 +329,12 @@ size_t UpdateClass::writeStream(Stream &data) {
if
((
_bufferLen
==
remaining
()
||
_bufferLen
==
SPI_FLASH_SEC_SIZE
)
&&
!
_writeBuffer
())
return
written
;
written
+=
toRead
;
if
(
_progress_callback
)
{
_progress_callback
(
_progress
,
_size
);
}
}
if
(
_progress_callback
)
{
_progress_callback
(
_size
,
_size
);
}
return
written
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录