Skip to content

Commit 94bb156

Browse files
committed
Merge branch 'master' into nosizeconf
2 parents 719f65a + 8ec93dc commit 94bb156

File tree

120 files changed

+3991
-1532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+3991
-1532
lines changed

.travis.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ jobs:
7676
env:
7777
- BUILD_PARITY=odd
7878

79+
- name: "Mac OSX can build sketches"
80+
os: osx
81+
stage: build
82+
script: $TRAVIS_BUILD_DIR/tests/build.sh
83+
env: MACOSX=1 BUILD_PARITY=custom mod=500 rem=1
84+
85+
- name: "Windows can build sketches"
86+
os: windows
87+
stage: build
88+
script: $TRAVIS_BUILD_DIR/tests/build.sh
89+
env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1
90+
7991
- name: "Host tests"
8092
stage: build
8193
script: $TRAVIS_BUILD_DIR/tests/ci/host_test.sh
@@ -98,18 +110,6 @@ jobs:
98110
stage: build
99111
script: $TRAVIS_BUILD_DIR/tests/buildm.sh
100112

101-
- name: "Mac OSX can build sketches"
102-
os: osx
103-
stage: build
104-
script: $TRAVIS_BUILD_DIR/tests/build.sh
105-
env: MACOSX=1 BUILD_PARITY=custom mod=500 rem=1
106-
107-
- name: "Windows can build sketches"
108-
os: windows
109-
stage: build
110-
script: $TRAVIS_BUILD_DIR/tests/build.sh
111-
env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1
112-
113113
- name: "Boards"
114114
stage: build
115115
script: $TRAVIS_BUILD_DIR/tests/ci/build_boards.sh

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Arduino core for ESP8266 WiFi chip
33

44
# Quick links
55

6-
- [Latest release documentation](https://arduino-esp8266.readthedocs.io/en/2.5.2/)
6+
- [Latest release documentation](https://arduino-esp8266.readthedocs.io/en/2.6.1/)
77
- [Current "git version" documentation](https://arduino-esp8266.readthedocs.io/en/latest/)
88
- [Install git version](https://arduino-esp8266.readthedocs.io/en/latest/installing.html#using-git-version) ([sources](doc/installing.rst#using-git-version))
99

@@ -36,7 +36,7 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
3636
#### Latest release [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/)
3737
Boards manager link: `https://arduino.esp8266.com/stable/package_esp8266com_index.json`
3838

39-
Documentation: [https://arduino-esp8266.readthedocs.io/en/2.5.2/](https://arduino-esp8266.readthedocs.io/en/2.5.2/)
39+
Documentation: [https://arduino-esp8266.readthedocs.io/en/2.6.1/](https://arduino-esp8266.readthedocs.io/en/2.6.1/)
4040

4141
### Using git version
4242
[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)
@@ -123,3 +123,13 @@ ESP8266 core files are licensed under LGPL.
123123
[BearSSL](https://bearssl.org) library written by Thomas Pornin, built from https://github.com/earlephilhower/bearssl-esp8266, is used in this project. It is distributed under the [MIT License](https://bearssl.org/#legal-details).
124124

125125
[LittleFS](https://github.com/ARMmbed/littlefs) library written by ARM Limited and released under the [BSD 3-clause license](https://github.com/ARMmbed/littlefs/blob/master/LICENSE.md).
126+
127+
### Other useful links ###
128+
129+
[Toolchain repo](https://github.com/earlephilhower/esp-quick-toolchain)
130+
131+
[Lwip link layer repo](https://github.com/d-a-v/esp82xx-nonos-linklayer)
132+
133+
[SoftwareSerial repo](https://github.com/plerup/espsoftwareserial)
134+
135+
[Serial Monitor Arduino IDE plugin](https://github.com/mytrain/arduino-esp8266-serial-plugin) Original discussion [here](https://github.com/esp8266/Arduino/issues/1360), quick download [there](http://mytrain.fr/cms//images/mytrain/private/ESP8266SM.v3.zip).

boards.txt

+798-126
Large diffs are not rendered by default.

bootloaders/eboot/eboot.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,14 @@ int copy_raw(const uint32_t src_addr,
128128
void main()
129129
{
130130
int res = 9;
131+
bool clear_cmd = false;
131132
struct eboot_command cmd;
132133

133134
print_version(0);
134135

135136
if (eboot_command_read(&cmd) == 0) {
136137
// valid command was passed via RTC_MEM
137-
eboot_command_clear();
138+
clear_cmd = true;
138139
ets_putc('@');
139140
} else {
140141
// no valid command found
@@ -155,6 +156,10 @@ void main()
155156
}
156157
}
157158

159+
if (clear_cmd) {
160+
eboot_command_clear();
161+
}
162+
158163
if (cmd.action == ACTION_LOAD_APP) {
159164
ets_putc('l'); ets_putc('d'); ets_putc('\n');
160165
res = load_app_from_flash_raw(cmd.args[0]);

cores/esp8266/CallBackList.h

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#ifndef __CALLBACKLIST_H__
2+
#define __CALLBACKLIST_H__
3+
4+
5+
/*
6+
CallBackList, An implemention for handling callback execution
7+
8+
Copyright (c) 2019 Herman Reintke. All rights reserved.
9+
This file is part of the esp8266 core for Arduino environment.
10+
11+
This library is free software; you can redistribute it and/or
12+
modify it under the terms of the GNU Lesser General Public
13+
License as published by the Free Software Foundation; either
14+
version 2.1 of the License, or (at your option) any later version.
15+
16+
This library is distributed in the hope that it will be useful,
17+
but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19+
Lesser General Public License for more details.
20+
21+
You should have received a copy of the GNU Lesser General Public
22+
License along with this library; if not, write to the Free Software
23+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24+
*/
25+
26+
#include <Arduino.h>
27+
#include <memory>
28+
#include <list>
29+
#include <utility>
30+
31+
namespace experimental
32+
{
33+
namespace CBListImplentation
34+
{
35+
36+
template<class cbFunctionT>
37+
class CallBackList
38+
{
39+
public:
40+
CallBackList (){};
41+
42+
struct CallBackInfo
43+
{
44+
CallBackInfo(cbFunctionT f) : cbFunction(f, true){};
45+
CallBackInfo(cbFunctionT f, bool ar) : cbFunction(f), _allowRemove(ar) {};
46+
cbFunctionT cbFunction;
47+
bool _allowRemove = true;
48+
bool allowRemove()
49+
{
50+
return _allowRemove;
51+
}
52+
};
53+
using CallBackHandler = std::shared_ptr<CallBackInfo> ;
54+
std::list<CallBackHandler> callBackEventList;
55+
56+
CallBackHandler add(cbFunctionT af, bool ad = true) {
57+
CallBackHandler handler = std::make_shared<CallBackInfo>(CallBackInfo(af,ad));
58+
callBackEventList.emplace_back(handler);
59+
return handler;
60+
}
61+
62+
void remove(CallBackHandler& dh) {
63+
callBackEventList.remove(dh);
64+
}
65+
66+
template<typename... Args>
67+
void execute(Args... params) {
68+
for(auto it = std::begin(callBackEventList); it != std::end(callBackEventList); ) {
69+
CallBackHandler &handler = *it;
70+
if (handler->allowRemove() && handler.unique()) {
71+
it = callBackEventList.erase(it);
72+
}
73+
else {
74+
handler->cbFunction(params...);
75+
++it;
76+
}
77+
}
78+
}
79+
};
80+
81+
} //CBListImplementation
82+
}//experimental
83+
84+
#endif // __CALLBACKLIST_H__

cores/esp8266/FS.cpp

+47-3
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ String File::readString()
180180
return ret;
181181
}
182182

183+
time_t File::getLastWrite() {
184+
if (!_p)
185+
return 0;
186+
187+
return _p->getLastWrite();
188+
}
189+
190+
void File::setTimeCallback(time_t (*cb)(void)) {
191+
if (!_p)
192+
return;
193+
_p->setTimeCallback(cb);
194+
}
195+
183196
File Dir::openFile(const char* mode) {
184197
if (!_impl) {
185198
return File();
@@ -192,7 +205,9 @@ File Dir::openFile(const char* mode) {
192205
return File();
193206
}
194207

195-
return File(_impl->openFile(om, am), _baseFS);
208+
File f(_impl->openFile(om, am), _baseFS);
209+
f.setTimeCallback(timeCallback);
210+
return f;
196211
}
197212

198213
String Dir::fileName() {
@@ -203,6 +218,12 @@ String Dir::fileName() {
203218
return _impl->fileName();
204219
}
205220

221+
time_t Dir::fileTime() {
222+
if (!_impl)
223+
return 0;
224+
return _impl->fileTime();
225+
}
226+
206227
size_t Dir::fileSize() {
207228
if (!_impl) {
208229
return 0;
@@ -241,6 +262,20 @@ bool Dir::rewind() {
241262
return _impl->rewind();
242263
}
243264

265+
time_t Dir::getLastWrite() {
266+
if (!_impl)
267+
return 0;
268+
269+
return _impl->getLastWrite();
270+
}
271+
272+
void Dir::setTimeCallback(time_t (*cb)(void)) {
273+
if (!_impl)
274+
return;
275+
_impl->setTimeCallback(cb);
276+
}
277+
278+
244279
bool FS::setConfig(const FSConfig &cfg) {
245280
if (!_impl) {
246281
return false;
@@ -315,7 +350,9 @@ File FS::open(const char* path, const char* mode) {
315350
DEBUGV("FS::open: invalid mode `%s`\r\n", mode);
316351
return File();
317352
}
318-
return File(_impl->open(path, om, am), this);
353+
File f(_impl->open(path, om, am), this);
354+
f.setTimeCallback(timeCallback);
355+
return f;
319356
}
320357

321358
bool FS::exists(const char* path) {
@@ -334,7 +371,9 @@ Dir FS::openDir(const char* path) {
334371
return Dir();
335372
}
336373
DirImplPtr p = _impl->openDir(path);
337-
return Dir(p, this);
374+
Dir d(p, this);
375+
d.setTimeCallback(timeCallback);
376+
return d;
338377
}
339378

340379
Dir FS::openDir(const String& path) {
@@ -385,6 +424,11 @@ bool FS::rename(const String& pathFrom, const String& pathTo) {
385424
return rename(pathFrom.c_str(), pathTo.c_str());
386425
}
387426

427+
void FS::setTimeCallback(time_t (*cb)(void)) {
428+
if (!_impl)
429+
return;
430+
_impl->setTimeCallback(cb);
431+
}
388432

389433

390434
static bool sflags(const char* mode, OpenMode& om, AccessMode& am) {

cores/esp8266/FS.h

+31-11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <memory>
2525
#include <Arduino.h>
26+
#include <../include/time.h> // See issue #6714
2627

2728
class SDClass;
2829

@@ -110,12 +111,16 @@ class File : public Stream
110111

111112
String readString() override;
112113

114+
time_t getLastWrite();
115+
void setTimeCallback(time_t (*cb)(void));
116+
113117
protected:
114118
FileImplPtr _p;
115119

116120
// Arduino SD class emulation
117121
std::shared_ptr<Dir> _fakeDir;
118122
FS *_baseFS;
123+
time_t (*timeCallback)(void) = nullptr;
119124
};
120125

121126
class Dir {
@@ -126,15 +131,21 @@ class Dir {
126131

127132
String fileName();
128133
size_t fileSize();
134+
time_t fileTime();
129135
bool isFile() const;
130136
bool isDirectory() const;
131137

132138
bool next();
133139
bool rewind();
134140

141+
time_t getLastWrite();
142+
void setTimeCallback(time_t (*cb)(void));
143+
135144
protected:
136145
DirImplPtr _impl;
137146
FS *_baseFS;
147+
time_t (*timeCallback)(void) = nullptr;
148+
138149
};
139150

140151
// Backwards compatible, <4GB filesystem usage
@@ -161,12 +172,10 @@ struct FSInfo64 {
161172
class FSConfig
162173
{
163174
public:
164-
FSConfig(bool autoFormat = true) {
165-
_type = FSConfig::fsid::FSId;
166-
_autoFormat = autoFormat;
167-
}
175+
static constexpr uint32_t FSId = 0x00000000;
176+
177+
FSConfig(uint32_t type = FSId, bool autoFormat = true) : _type(type), _autoFormat(autoFormat) { }
168178

169-
enum fsid { FSId = 0x00000000 };
170179
FSConfig setAutoFormat(bool val = true) {
171180
_autoFormat = val;
172181
return *this;
@@ -179,17 +188,17 @@ class FSConfig
179188
class SPIFFSConfig : public FSConfig
180189
{
181190
public:
182-
SPIFFSConfig(bool autoFormat = true) {
183-
_type = SPIFFSConfig::fsid::FSId;
184-
_autoFormat = autoFormat;
185-
}
186-
enum fsid { FSId = 0x53504946 };
191+
static constexpr uint32_t FSId = 0x53504946;
192+
SPIFFSConfig(bool autoFormat = true) : FSConfig(FSId, autoFormat) { }
193+
194+
// Inherit _type and _autoFormat
195+
// nothing yet, enableTime TBD when SPIFFS has metadate
187196
};
188197

189198
class FS
190199
{
191200
public:
192-
FS(FSImplPtr impl) : _impl(impl) { }
201+
FS(FSImplPtr impl) : _impl(impl) { timeCallback = _defaultTimeCB; }
193202

194203
bool setConfig(const FSConfig &cfg);
195204

@@ -225,14 +234,25 @@ class FS
225234
bool gc();
226235
bool check();
227236

237+
void setTimeCallback(time_t (*cb)(void));
238+
228239
friend class ::SDClass; // More of a frenemy, but SD needs internal implementation to get private FAT bits
229240
protected:
230241
FSImplPtr _impl;
231242
FSImplPtr getImpl() { return _impl; }
243+
time_t (*timeCallback)(void);
244+
static time_t _defaultTimeCB(void) { return time(NULL); }
232245
};
233246

234247
} // namespace fs
235248

249+
extern "C"
250+
{
251+
void close_all_fs(void);
252+
void littlefs_request_end(void);
253+
void spiffs_request_end(void);
254+
}
255+
236256
#ifndef FS_NO_GLOBALS
237257
using fs::FS;
238258
using fs::File;

0 commit comments

Comments
 (0)