Skip to content

Commit 652200c

Browse files
committed
Updated all examples
Signed-off-by: Mikhail Grigorev <[email protected]>
1 parent f7a2177 commit 652200c

File tree

113 files changed

+5975
-811
lines changed

Some content is hidden

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

113 files changed

+5975
-811
lines changed

Diff for: Espressif/changelog.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
Changelog:
22
----------
33

4-
v2.0.6 (08.06.2015):
4+
v2.0.6 (10.06.2015):
55
* Update SDK v1.1.1 (folder ESP8266_SDK);
66
* SDK version 1.1.0 moved to a folder ESP8266_SDK_110;
77
* SDK version 1.0.1 moved to a folder ESP8266_SDK_101;
88
* Update a utility "utils\esptool.exe";
9+
- Added patch: write_flash: Show actual flash write speed.
10+
- Add optional '--entry-symbol' option to override entry point symbol name.
11+
- Fixed wrong size erase region for recording (Patch by Viktor aka pvvx).
12+
- Fixed creation of superfluous segments for the loader, if the no data in segments rodata and etc (Patch by Viktor aka pvvx).
913
* Update a utility "utils\esptool-ck.exe" to version 0.4.5:
14+
* Updated documentation:
15+
- Delete files:
16+
2C-ESP8266__SDK__Programming Guide__EN_v1.0.1.pdf
17+
+ Added files:
18+
2C-ESP8266__SDK__Programming Guide__EN_v1.1.1.pdf
19+
* Updated examples:
20+
ESPWebFramework;
21+
dht22_thingspeak;
22+
esphttpd;
1023

1124
v2.0.5 (22.05.2015):
1225
+ Added command line mode.

Diff for: Espressif/changelog_ru.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
������ ���������:
22
-----------------
33

4-
v2.0.6 (08.06.2015):
4+
v2.0.6 (10.06.2015):
55
* ��������� SDK �� ������ 1.1.1 (����� ESP8266_SDK);
66
* SDK ������ 1.1.0 ���������� � ����� ESP8266_SDK_110;
77
* SDK ������ 1.0.1 ���������� � ����� ESP8266_SDK_101;
88
* ��������� ������� "utils\esptool-ck.exe" �� ������ 0.4.5;
99
* ��������� ������� "utils\esptool.exe";
10+
- ��������� ����������� �������� ������ �� flash;
11+
- ��������� ����� '--entry-symbol' ��� ��������������� ����� �����;
12+
- ��������� ������������ ������ �������� ������� ��� ������ (������� pvvx);
13+
- ���������� �������� ������ ��������� ��� ����������, ���� ������ � rodata � �.�. ����������� (������� pvvx);
14+
* ��������� ������������:
15+
- ������� �����:
16+
2C-ESP8266__SDK__Programming Guide__EN_v1.0.1.pdf
17+
+ ��������� �����:
18+
2C-ESP8266__SDK__Programming Guide__EN_v1.1.1.pdf
19+
* ��������� �������:
20+
ESPWebFramework;
21+
dht22_thingspeak;
22+
esphttpd;
1023

1124
v2.0.5 (22.05.2015):
1225
+ �������� ����� ��������� ������.

Diff for: Espressif/examples/1wire_ds18b20/user/user_main.c

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ LOCAL void ICACHE_FLASH_ATTR ds18b20_cb(void *arg)
2525
ds18b20();
2626
}
2727

28+
void user_rf_pre_init(void)
29+
{
30+
}
31+
2832
void user_init(void)
2933
{
3034
uart_init(BIT_RATE_115200, BIT_RATE_115200);

Diff for: Espressif/examples/ESP8266_Relay_Board/user/user_main.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ void ICACHE_FLASH_ATTR mqttPublishedCb(uint32_t *args)
205205
os_printf("MQTT: Published\r\n");
206206
}
207207

208+
void user_rf_pre_init(void)
209+
{
210+
}
208211

209212
//Main routine
210213
void ICACHE_FLASH_ATTR user_init(void) {
@@ -276,5 +279,3 @@ void ICACHE_FLASH_ATTR user_init(void) {
276279

277280

278281

279-
280-

Diff for: Espressif/examples/ESPWebFramework/include/fdvcollections.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ class IterDict
169169
: next(NULL), key(KeyIterator()), keyEnd(KeyIterator()), value(ValueIterator()), valueEnd(ValueIterator())
170170
{
171171
}
172-
bool MTD_FLASHMEM operator==(Item const& rhs)
172+
bool TMTD_FLASHMEM operator==(Item const& rhs)
173173
{
174174
return next == rhs.next && key == rhs.key && keyEnd == rhs.keyEnd && value == rhs.value && valueEnd == rhs.valueEnd;
175175
}
176-
bool MTD_FLASHMEM operator!=(Item const& rhs)
176+
bool TMTD_FLASHMEM operator!=(Item const& rhs)
177177
{
178178
return !(*this == rhs);
179179
}
@@ -189,7 +189,7 @@ class IterDict
189189
clear();
190190
}
191191

192-
void MTD_FLASHMEM clear()
192+
void TMTD_FLASHMEM clear()
193193
{
194194
Item* item = m_items;
195195
while (item)
@@ -202,7 +202,7 @@ class IterDict
202202
m_itemsCount = 0;
203203
}
204204

205-
void MTD_FLASHMEM add(KeyIterator key, KeyIterator keyEnd, ValueIterator value, ValueIterator valueEnd)
205+
void TMTD_FLASHMEM add(KeyIterator key, KeyIterator keyEnd, ValueIterator value, ValueIterator valueEnd)
206206
{
207207
if (m_items)
208208
{
@@ -217,26 +217,26 @@ class IterDict
217217
}
218218

219219
// key and value must terminate with a Zero
220-
void MTD_FLASHMEM add(KeyIterator key, ValueIterator value)
220+
void TMTD_FLASHMEM add(KeyIterator key, ValueIterator value)
221221
{
222222
add(key, key + t_strlen(key), value, value + t_strlen(value));
223223
}
224224

225225
// automatically embeds key and value into CharIterator, so key and value can stay in RAM or Flash
226226
// key and value must terminate with a Zero
227227
// Applies only when KeyIterator == ValueIterator == CharIterator
228-
void MTD_FLASHMEM add(char const* key, char const* value)
228+
void TMTD_FLASHMEM add(char const* key, char const* value)
229229
{
230230
add(CharIterator(key), CharIterator(value));
231231
}
232232

233-
uint32_t MTD_FLASHMEM getItemsCount()
233+
uint32_t TMTD_FLASHMEM getItemsCount()
234234
{
235235
return m_itemsCount;
236236
}
237237

238238
// warn: this doesn't check "index" range!
239-
Item* MTD_FLASHMEM getItem(uint32_t index)
239+
Item* TMTD_FLASHMEM getItem(uint32_t index)
240240
{
241241
Item* item = m_items;
242242
for (; index > 0; --index)
@@ -245,7 +245,7 @@ class IterDict
245245
}
246246

247247
// key stay in RAM or Flash
248-
Item* MTD_FLASHMEM getItem(char const* key, char const* keyEnd)
248+
Item* TMTD_FLASHMEM getItem(char const* key, char const* keyEnd)
249249
{
250250
Item* item = m_items;
251251
while (item)
@@ -258,15 +258,15 @@ class IterDict
258258
}
259259

260260
// warn: this doesn't check "index" range!
261-
Item* MTD_FLASHMEM operator[](uint32_t index)
261+
Item* TMTD_FLASHMEM operator[](uint32_t index)
262262
{
263263
return getItem(index);
264264
}
265265

266266
// key can stay in RAM or Flash and must terminate with zero
267267
// creates a RAM stored temporary (with the same lifetime of IterDict class) zero terminated string with the value content
268268
// if m_urlDecode is true then the temporary in RAM string is url decoded
269-
char const* MTD_FLASHMEM operator[](char const* key)
269+
char const* TMTD_FLASHMEM operator[](char const* key)
270270
{
271271
Item* item = getItem(key, key + f_strlen(key));
272272
if (item)
@@ -282,13 +282,13 @@ class IterDict
282282
return NULL;
283283
}
284284

285-
void MTD_FLASHMEM setUrlDecode(bool value)
285+
void TMTD_FLASHMEM setUrlDecode(bool value)
286286
{
287287
m_urlDecode = value;
288288
}
289289

290290
// debug
291-
void MTD_FLASHMEM dump()
291+
void TMTD_FLASHMEM dump()
292292
{
293293
for (uint32_t i = 0; i != m_itemsCount; ++i)
294294
{

Diff for: Espressif/examples/ESPWebFramework/include/fdvcommonstr.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@ namespace fdv
7575
static char const STR_HI[] FLASHMEM = "HI";
7676
static char const STR_LO[] FLASHMEM = "LO";
7777
static char const STR_BINPRORDY[] FLASHMEM = "BINPRORDY";
78-
78+
static char const STR_TZHH[] FLASHMEM = "TZHH";
79+
static char const STR_TZMM[] FLASHMEM = "TZMM";
80+
static char const STR_DEFNTPSRV[] FLASHMEM = "DEFNTPSRV";
81+
static char const STR_date[] FLASHMEM = "date";
82+
static char const STR_time[] FLASHMEM = "time";
83+
static char const STR_tzh[] FLASHMEM = "tzh";
84+
static char const STR_tzm[] FLASHMEM = "tzm";
85+
static char const STR_ntpsrv[] FLASHMEM = "ntpsrv";
86+
static char const STR_now[] FLASHMEM = "now";
7987
}
8088

8189
#endif

Diff for: Espressif/examples/ESPWebFramework/include/fdvconfmanager.h

+97-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ namespace fdv
5050
applyDHCPServer();
5151
applyWebServer<HTTPCustomServer_T>();
5252
applyGPIO();
53+
applyDateTime();
5354
}
5455

5556

@@ -218,7 +219,18 @@ namespace fdv
218219
uint16_t webPort;
219220
getWebServerParams(&webPort);
220221
new HTTPCustomServer_T(webPort);
221-
}
222+
}
223+
224+
225+
// can be re-applied
226+
static void MTD_FLASHMEM applyDateTime()
227+
{
228+
int8_t timezoneHours;
229+
uint8_t timezoneMinutes;
230+
char const* defaultNTPServer;
231+
getDateTimeParams(&timezoneHours, &timezoneMinutes, &defaultNTPServer);
232+
DateTime::setDefaults(timezoneHours, timezoneMinutes, defaultNTPServer);
233+
}
222234

223235

224236
static void MTD_FLASHMEM restore()
@@ -421,6 +433,25 @@ namespace fdv
421433
*value = false;
422434
}
423435
}
436+
437+
438+
439+
//// Date-time parameters
440+
441+
static void MTD_FLASHMEM setDateTimeParams(int8_t timezoneHours, uint8_t timezoneMinutes, char const* defaultNTPServer)
442+
{
443+
FlashDictionary::setInt(STR_TZHH, timezoneHours);
444+
FlashDictionary::setInt(STR_TZMM, timezoneMinutes);
445+
FlashDictionary::setString(STR_DEFNTPSRV, defaultNTPServer);
446+
}
447+
448+
static void MTD_FLASHMEM getDateTimeParams(int8_t* timezoneHours, uint8_t* timezoneMinutes, char const** defaultNTPServer)
449+
{
450+
*timezoneHours = FlashDictionary::getInt(STR_TZHH, 0);
451+
*timezoneMinutes = FlashDictionary::getInt(STR_TZMM, 0);
452+
*defaultNTPServer = FlashDictionary::getString(STR_DEFNTPSRV, FSTR("193.204.114.232")); // 193.204.114.232 = ntp1.inrim.it
453+
}
454+
424455

425456

426457
private:
@@ -769,6 +800,71 @@ namespace fdv
769800
}
770801

771802
};
803+
804+
805+
806+
//////////////////////////////////////////////////////////////////////
807+
//////////////////////////////////////////////////////////////////////
808+
// HTTPTimeConfigurationResponse
809+
810+
struct HTTPTimeConfigurationResponse : public HTTPTemplateResponse
811+
{
812+
HTTPTimeConfigurationResponse(HTTPHandler* httpHandler, char const* filename)
813+
: HTTPTemplateResponse(httpHandler, filename)
814+
{
815+
}
816+
817+
virtual void MTD_FLASHMEM flush()
818+
{
819+
if (getRequest().method == HTTPHandler::Post)
820+
{
821+
// set current date and time
822+
char const* dateStr = getRequest().form[STR_date];
823+
char const* timeStr = getRequest().form[STR_time];
824+
if (dateStr && timeStr)
825+
{
826+
DateTime dt;
827+
dt.decode(dateStr, FSTR("%d/%m/%Y"));
828+
dt.decode(timeStr, FSTR("%H:%M:%S"));
829+
DateTime::setCurrentDateTime(dt);
830+
}
831+
832+
// set timezone and NTP server
833+
char const* tzh = getRequest().form[STR_tzh];
834+
char const* tzm = getRequest().form[STR_tzm];
835+
char const* ntpsrv = getRequest().form[STR_ntpsrv];
836+
if (tzh && tzm)
837+
{
838+
ConfigurationManager::setDateTimeParams(strtol(tzh, NULL, 10),
839+
strtol(tzm, NULL, 10),
840+
ntpsrv? ntpsrv : STR_);
841+
ConfigurationManager::applyDateTime();
842+
}
843+
}
844+
845+
// get current date
846+
char dateStr[11];
847+
DateTime::now().format(dateStr, FSTR("%d/%m/%Y"));
848+
addParamStr(STR_date, dateStr);
849+
850+
// get current time
851+
char timeStr[9];
852+
DateTime::now().format(timeStr, FSTR("%H:%M:%S"));
853+
addParamStr(STR_time, timeStr);
854+
855+
// get timezone and NTP server
856+
int8_t timezoneHours;
857+
uint8_t timezoneMinutes;
858+
char const* defaultNTPServer;
859+
ConfigurationManager::getDateTimeParams(&timezoneHours, &timezoneMinutes, &defaultNTPServer);
860+
addParamInt(STR_tzh, timezoneHours);
861+
addParamInt(STR_tzm, timezoneMinutes);
862+
addParamStr(STR_ntpsrv, defaultNTPServer);
863+
864+
HTTPTemplateResponse::flush();
865+
}
866+
867+
};
772868

773869

774870
}

Diff for: Espressif/examples/ESPWebFramework/include/fdvdatetime.h

+21-6
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,56 @@ namespace fdv
4545
uint8_t month;
4646
uint8_t day;
4747

48-
// timezone is used only as informative and in setNTPDateTime. Values in "seconds, minutes, etc.." aren not UTC
48+
// timezone is used only as informative and in setNTPDateTime. Values in "seconds, minutes, etc.." are not UTC
4949
int8_t timezoneHours; // only timezoneHours can be signed
5050
uint8_t timezoneMinutes;
5151

5252

5353
DateTime()
54-
: seconds(0), minutes(0), hours(0), year(2000), month(1), day(1), timezoneHours(0), timezoneMinutes(0)
55-
{
54+
: seconds(0), minutes(0), hours(0), year(2000), month(1), day(1), timezoneHours(s_defaultTimezoneHours), timezoneMinutes(s_defaultTimezoneMinutes)
55+
{
5656
}
5757

5858

59+
DateTime(uint8_t day_, uint8_t month_, uint16_t year_, uint8_t hours_, uint8_t minutes_, uint8_t seconds_)
60+
: seconds(seconds_), minutes(minutes_), hours(hours_), year(year_), month(month_), day(day_), timezoneHours(s_defaultTimezoneHours), timezoneMinutes(s_defaultTimezoneMinutes)
61+
{
62+
}
63+
64+
5965
DateTime(uint8_t day_, uint8_t month_, uint16_t year_, uint8_t hours_, uint8_t minutes_, uint8_t seconds_, int8_t timezoneHours_, uint8_t timezoneMinutes_)
6066
: seconds(seconds_), minutes(minutes_), hours(hours_), year(year_), month(month_), day(day_), timezoneHours(timezoneHours_), timezoneMinutes(timezoneMinutes_)
6167
{
6268
}
6369

6470

71+
static void setDefaults(int8_t timezoneHours, uint8_t timezoneMinutes, char const* defaultNTPServer);
72+
static void setCurrentDateTime(DateTime const& dateTime);
73+
6574
uint8_t dayOfWeek() const;
6675
uint16_t dayOfYear() const;
6776

6877
DateTime& setUnixDateTime(uint32_t unixTime);
6978
uint32_t getUnixDateTime() const;
7079

71-
bool getFromNTPServer(char const* serverIP = NULL);
80+
bool getFromNTPServer();
7281

7382
uint16_t format(char* outbuf, char const* formatstr);
83+
char const* decode(char const* inbuf, char const* formatstr);
7484

7585
static DateTime now();
76-
static void adjustNow(DateTime const& currentDateTime);
77-
86+
87+
7888
private:
7989

8090
DateTime& setNTPDateTime(uint8_t const* datetimeField);
8191

8292
static uint32_t const SECONDS_FROM_1970_TO_2000 = 946684800;
93+
94+
static int8_t s_defaultTimezoneHours;
95+
static uint8_t s_defaultTimezoneMinutes;
96+
static IPAddress s_defaultNTPServer; // NTP synchronization enabled if s_defaultNTPServer != 0.0.0.0
97+
8398
static uint8_t daysInMonth(uint8_t month);
8499
static long time2long(uint16_t days, uint8_t h, uint8_t m, uint8_t s);
85100
static uint16_t date2days(uint16_t y, uint8_t m, uint8_t d);

0 commit comments

Comments
 (0)