Merge pull request #83 from Hieromon/Support/esp8266_2.5.2

- Supports ESP8266 Arduino core 2.5.2. Issue #75 
- Menu text/background color can be statically customized.
- Added ID attribute to HTML tag generated from AutoConnectText.
- Added the enable attribute to the AutoConnectElements.
- Fixed the input box layout collapsed.
- Fixed that the decoration of AutoConnectButton was disabled.
- Fixed that the value remains even after clearing the option with AutoConnectSelect.
- Fixed that an alignment violation exception occurred when loading AutoConnectAux described by JSON with PROGMEM attribute.
pull/91/head v0.9.9
Hieromon Ikasamo 5 years ago committed by GitHub
commit 2cd195e86d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .travis.yml
  2. 10
      README.md
  3. 697
      docs/404.html
  4. 1744
      docs/acelements.html
  5. 1170
      docs/achandling.html
  6. 896
      docs/acintro.html
  7. 1236
      docs/acjson.html
  8. 962
      docs/acupload.html
  9. 1184
      docs/advancedusage.html
  10. 1116
      docs/api.html
  11. 1052
      docs/apiaux.html
  12. 1214
      docs/apiconfig.html
  13. 2680
      docs/apielements.html
  14. 812
      docs/apiextra.html
  15. 21
      docs/assets/images/icons/bitbucket.1b09e088.svg
  16. 19
      docs/assets/images/icons/github.f0b8504a.svg
  17. 39
      docs/assets/images/icons/gitlab.6dd19c00.svg
  18. 4
      docs/assets/javascripts/application.b260a35d.js
  19. 2
      docs/assets/javascripts/modernizr.74668098.js
  20. 2
      docs/assets/stylesheets/application-palette.224b79ff.css
  21. 1
      docs/assets/stylesheets/application.3020aac5.css
  22. 1
      docs/assets/stylesheets/application.4031d38b.css
  23. 1000
      docs/basicusage.html
  24. 921
      docs/changelog.html
  25. 71
      docs/colorized.html
  26. 1016
      docs/credit.html
  27. 976
      docs/datatips.html
  28. 1154
      docs/faq.html
  29. 878
      docs/gettingstarted.html
  30. 1002
      docs/howtoembed.html
  31. BIN
      docs/images/ACMenu_brown.png
  32. BIN
      docs/images/ACMenu_dimgray.png
  33. BIN
      docs/images/ACMenu_indigo.png
  34. 990
      docs/index.html
  35. 736
      docs/license.html
  36. 812
      docs/lsbegin.html
  37. 922
      docs/menu.html
  38. 840
      docs/menuize.html
  39. 2
      docs/search/search_index.json
  40. 53
      docs/sitemap.xml
  41. BIN
      docs/sitemap.xml.gz
  42. 840
      docs/wojson.html
  43. 8
      examples/Elements/Elements.ino
  44. 29
      examples/FSBrowser/FSBrowser.ino
  45. 2
      library.json
  46. 2
      library.properties
  47. 1
      mkdocs.yml
  48. 61
      mkdocs/achandling.md
  49. 3
      mkdocs/api.md
  50. 9
      mkdocs/apiaux.md
  51. 270
      mkdocs/apielements.md
  52. 12
      mkdocs/changelog.md
  53. 54
      mkdocs/colorized.md
  54. BIN
      mkdocs/images/ACMenu_brown.png
  55. BIN
      mkdocs/images/ACMenu_dimgray.png
  56. BIN
      mkdocs/images/ACMenu_indigo.png
  57. 27
      src/AutoConnect.cpp
  58. 7
      src/AutoConnect.h
  59. 55
      src/AutoConnectAux.cpp
  60. 13
      src/AutoConnectAux.h
  61. 17
      src/AutoConnectDefs.h
  62. 8
      src/AutoConnectElementBasisImpl.h
  63. 12
      src/AutoConnectElementJson.h
  64. 56
      src/AutoConnectElementJsonImpl.h
  65. 174
      src/AutoConnectPage.cpp
  66. 66
      src/AutoConnectUploadImpl.h

@ -26,7 +26,7 @@ before_install:
- arduino --install-library PubSubClient,PageBuilder:1.3.3
- arduino --install-library ArduinoJson:5.13.5
- buildExampleSketch() { arduino --verify --board $BOARD $PWD/examples/$1/$1.ino; }
- arduino --install-library ArduinoJson:6.10.0
- arduino --install-library ArduinoJson:6.10.1
- buildExampleSketch() { arduino --verify --board $BOARD $PWD/examples/$1/$1.ino; }
install:
- mkdir -p ~/Arduino/libraries

@ -96,6 +96,16 @@ Full documentation is available on https://Hieromon.github.io/AutoConnect, some
## Change log
### [0.9.9] May 25, 2019
- Supports ESP8266 Arduino core 2.5.2.
- Menu text/background color can be statically customized. refer to the [Custom colorized](https://hieromon.github.io/AutoConnect/colorized.html) for the detailed specification for the menu colorizing.
- Added ID attribute to HTML tag generated from AutoConnectText.
- Added the enable attribute to the AutoConnectElements.
- Fixed the input box layout collapsed.
- Fixed that the decoration of AutoConnectButton was disabled.
- Fixed that the value remains even after clearing the option with AutoConnectSelect.
- Fixed that an alignment violation exception occurred when loading AutoConnectAux described by JSON with PROGMEM attribute.
### [0.9.8] May 3, 2019
- Supports ArduinoJson 6.9.1 or later.
- Supports allocating JsonDocument buffer to PSRAM on ESP32 with ArduinoJson 6.10.0 or later.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,20 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="352" height="448"
viewBox="0 0 352 448" id="__bitbucket">
<path fill="currentColor" d="M203.75 214.75q2 15.75-12.625 25.25t-27.875
1.5q-9.75-4.25-13.375-14.5t-0.125-20.5 13-14.5q9-4.5 18.125-3t16 8.875
6.875 16.875zM231.5 209.5q-3.5-26.75-28.25-41t-49.25-3.25q-15.75
7-25.125 22.125t-8.625 32.375q1 22.75 19.375 38.75t41.375 14q22.75-2
38-21t12.5-42zM291.25
74q-5-6.75-14-11.125t-14.5-5.5-17.75-3.125q-72.75-11.75-141.5 0.5-10.75
1.75-16.5 3t-13.75 5.5-12.5 10.75q7.5 7 19 11.375t18.375 5.5 21.875
2.875q57 7.25 112 0.25 15.75-2 22.375-3t18.125-5.375 18.75-11.625zM305.5
332.75q-2 6.5-3.875 19.125t-3.5 21-7.125 17.5-14.5 14.125q-21.5
12-47.375 17.875t-50.5 5.5-50.375-4.625q-11.5-2-20.375-4.5t-19.125-6.75-18.25-10.875-13-15.375q-6.25-24-14.25-73l1.5-4
4.5-2.25q55.75 37 126.625 37t126.875-37q5.25 1.5 6 5.75t-1.25 11.25-2
9.25zM350.75 92.5q-6.5 41.75-27.75 163.75-1.25 7.5-6.75 14t-10.875
10-13.625 7.75q-63 31.5-152.5
22-62-6.75-98.5-34.75-3.75-3-6.375-6.625t-4.25-8.75-2.25-8.5-1.5-9.875-1.375-8.75q-2.25-12.5-6.625-37.5t-7-40.375-5.875-36.875-5.5-39.5q0.75-6.5
4.375-12.125t7.875-9.375 11.25-7.5 11.5-5.625 12-4.625q31.25-11.5
78.25-16 94.75-9.25 169 12.5 38.75 11.5 53.75 30.5 4 5 4.125
12.75t-1.375 13.5z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="352" height="448" viewBox="0 0 352 448" id="__bitbucket"><path fill="currentColor" d="M203.75 214.75q2 15.75-12.625 25.25t-27.875 1.5q-9.75-4.25-13.375-14.5t-.125-20.5 13-14.5q9-4.5 18.125-3t16 8.875 6.875 16.875zm27.75-5.25q-3.5-26.75-28.25-41T154 165.25q-15.75 7-25.125 22.125t-8.625 32.375q1 22.75 19.375 38.75t41.375 14q22.75-2 38-21t12.5-42zM291.25 74q-5-6.75-14-11.125t-14.5-5.5T245 54.25q-72.75-11.75-141.5.5-10.75 1.75-16.5 3t-13.75 5.5T60.75 74q7.5 7 19 11.375t18.375 5.5T120 93.75Q177 101 232 94q15.75-2 22.375-3t18.125-5.375T291.25 74zm14.25 258.75q-2 6.5-3.875 19.125t-3.5 21-7.125 17.5-14.5 14.125q-21.5 12-47.375 17.875t-50.5 5.5-50.375-4.625q-11.5-2-20.375-4.5T88.75 412 70.5 401.125t-13-15.375q-6.25-24-14.25-73l1.5-4 4.5-2.25q55.75 37 126.625 37t126.875-37q5.25 1.5 6 5.75t-1.25 11.25-2 9.25zM350.75 92.5q-6.5 41.75-27.75 163.75-1.25 7.5-6.75 14t-10.875 10T291.75 288q-63 31.5-152.5 22-62-6.75-98.5-34.75-3.75-3-6.375-6.625t-4.25-8.75-2.25-8.5-1.5-9.875T25 232.75q-2.25-12.5-6.625-37.5t-7-40.375T5.5 118 0 78.5Q.75 72 4.375 66.375T12.25 57t11.25-7.5T35 43.875t12-4.625q31.25-11.5 78.25-16 94.75-9.25 169 12.5Q333 47.25 348 66.25q4 5 4.125 12.75t-1.375 13.5z"/></svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -1,18 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448"
viewBox="0 0 416 448" id="__github">
<path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19-18.125
8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19 18.125-8.5
18.125 8.5 10.75 19 3.125 20.5zM320 304q0 10-3.125 20.5t-10.75
19-18.125 8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19
18.125-8.5 18.125 8.5 10.75 19 3.125 20.5zM360
304q0-30-17.25-51t-46.75-21q-10.25 0-48.75 5.25-17.75 2.75-39.25
2.75t-39.25-2.75q-38-5.25-48.75-5.25-29.5 0-46.75 21t-17.25 51q0 22 8
38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0
37.25-1.75t35-7.375 30.5-15 20.25-25.75 8-38.375zM416 260q0 51.75-15.25
82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5-41.75
1.125q-19.5 0-35.5-0.75t-36.875-3.125-38.125-7.5-34.25-12.875-30.25-20.25-21.5-28.75q-15.5-30.75-15.5-82.75
0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25
30.875q36.75-8.75 77.25-8.75 37 0 70 8 26.25-20.5
46.75-30.25t47.25-9.75q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34
99.5z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 993 B

@ -1,38 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500"
viewBox="0 0 500 500" id="__gitlab">
<g transform="translate(156.197863, 1.160267)">
<path fill="currentColor"
d="M93.667,473.347L93.667,473.347l90.684-279.097H2.983L93.667,
473.347L93.667,473.347z" />
</g>
<g transform="translate(28.531199, 1.160800)" opacity="0.7">
<path fill="currentColor"
d="M221.333,473.345L130.649,194.25H3.557L221.333,473.345L221.333,
473.345z" />
</g>
<g transform="translate(0.088533, 0.255867)" opacity="0.5">
<path fill="currentColor"
d="M32,195.155L32,195.155L4.441,279.97c-2.513,7.735,0.24,16.21,6.821,
20.99l238.514,173.29 L32,195.155L32,195.155z" />
</g>
<g transform="translate(29.421866, 280.255593)">
<path fill="currentColor"
d="M2.667-84.844h127.092L75.14-252.942c-2.811-8.649-15.047-8.649-17.856,
0L2.667-84.844 L2.667-84.844z" />
</g>
<g transform="translate(247.197860, 1.160800)" opacity="0.7">
<path fill="currentColor"
d="M2.667,473.345L93.351,194.25h127.092L2.667,473.345L2.667,
473.345z" />
</g>
<g transform="translate(246.307061, 0.255867)" opacity="0.5">
<path fill="currentColor"
d="M221.334,195.155L221.334,195.155l27.559,84.815c2.514,7.735-0.24,
16.21-6.821,20.99 L3.557,474.25L221.334,195.155L221.334,195.155z" />
</g>
<g transform="translate(336.973725, 280.255593)">
<path fill="currentColor"
d="M130.667-84.844H3.575l54.618-168.098c2.811-8.649,15.047-8.649,
17.856,0L130.667-84.844 L130.667-84.844z" />
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500" id="__gitlab"><path fill="currentColor" d="M93.667 473.347l90.684-279.097H2.983l90.684 279.097z" transform="translate(156.198 1.16)"/><path fill="currentColor" d="M221.333 473.345L130.649 194.25H3.557l217.776 279.095z" transform="translate(28.531 1.16)" opacity=".7"/><path fill="currentColor" d="M32 195.155L4.441 279.97a18.773 18.773 0 0 0 6.821 20.99l238.514 173.29L32 195.155z" transform="translate(.089 .256)" opacity=".5"/><path fill="currentColor" d="M2.667-84.844h127.092L75.14-252.942c-2.811-8.649-15.047-8.649-17.856 0L2.667-84.844z" transform="translate(29.422 280.256)"/><path fill="currentColor" d="M2.667 473.345L93.351 194.25h127.092L2.667 473.345z" transform="translate(247.198 1.16)" opacity=".7"/><path fill="currentColor" d="M221.334 195.155l27.559 84.815a18.772 18.772 0 0 1-6.821 20.99L3.557 474.25l217.777-279.095z" transform="translate(246.307 .256)" opacity=".5"/><path fill="currentColor" d="M130.667-84.844H3.575l54.618-168.098c2.811-8.649 15.047-8.649 17.856 0l54.618 168.098z" transform="translate(336.974 280.256)"/></svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -2,122 +2,127 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://Hieromon.github.io/AutoConnect/index.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/gettingstarted.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/menu.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/basicusage.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/advancedusage.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/acintro.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/acelements.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/acjson.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/achandling.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/api.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/apiaux.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/apiconfig.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/apielements.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/apiextra.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/howtoembed.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/datatips.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/menuize.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/wojson.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/lsbegin.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/credit.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/acupload.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/colorized.html</loc>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/faq.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/changelog.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect/license.html</loc>
<lastmod>2019-05-03</lastmod>
<lastmod>2019-05-29</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

Binary file not shown.

File diff suppressed because one or more lines are too long

@ -47,6 +47,7 @@ static const char PAGE_ELEMENTS[] PROGMEM = R"(
{
"name": "input",
"type": "ACInput",
"label": "Text input",
"placeholder": "This area accepts hostname patterns",
"pattern": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$"
},
@ -89,6 +90,11 @@ static const char PAGE_ELEMENTS[] PROGMEM = R"(
"type": "ACSubmit",
"value": "Save",
"uri": "/save"
},
{
"name": "adjust_width",
"type": "ACElement",
"value": "<script type=\"text/javascript\">window.onload=function(){var t=document.querySelectorAll(\"input[type='text']\");for(i=0;i<t.length;i++){var e=t[i].getAttribute(\"placeholder\");e&&t[i].setAttribute(\"size\",e.length*.8)}};</script>"
}
]
}
@ -189,7 +195,7 @@ void setup() {
param.close();
}
else {
aux["echo"].value = "<styleSPIFFS failed to open.";
aux["echo"].value = "SPIFFS failed to open.";
}
SPIFFS.end();
return String();

@ -17,7 +17,7 @@
upload the contents of the data folder with MkSPIFFS Tool ("ESP8266 Sketch Data Upload" in Tools menu in Arduino IDE)
or you can upload the contents of a folder if you CD in that folder and run the following command:
for file in `ls -A1`; do curl -F "file=@$PWD/$file" esp8266fs.local/edit; done
for file in `\ls -A1`; do curl -F "file=@$PWD/$file" esp8266fs.local/edit; done
access the sample web page at http://esp8266fs.local
edit the page by going to http://esp8266fs.local/edit
@ -61,14 +61,14 @@ File fsUploadFile;
//format bytes
String formatBytes(size_t bytes){
if (bytes < 1024){
return String(bytes)+"B";
} else if(bytes < (1024 * 1024)){
return String(bytes/1024.0)+"KB";
} else if(bytes < (1024 * 1024 * 1024)){
return String(bytes/1024.0/1024.0)+"MB";
if (bytes < 1024) {
return String(bytes) + "B";
} else if (bytes < (1024 * 1024)) {
return String(bytes / 1024.0) + "KB";
} else if (bytes < (1024 * 1024 * 1024)) {
return String(bytes / 1024.0 / 1024.0) + "MB";
} else {
return String(bytes/1024.0/1024.0/1024.0)+"GB";
return String(bytes / 1024.0 / 1024.0 / 1024.0) + "GB";
}
}
@ -337,10 +337,15 @@ void setup(void){
DBG_OUTPUT_PORT.println(WiFi.localIP());
//Relocation as follows to make AutoConnect recognition.
MDNS.begin(host);
DBG_OUTPUT_PORT.print("Open http://");
DBG_OUTPUT_PORT.print(host);
DBG_OUTPUT_PORT.println(".local/edit to see the file browser");
if (MDNS.begin(host)) {
MDNS.addService("http", "tcp", 80);
DBG_OUTPUT_PORT.print("Open http://");
DBG_OUTPUT_PORT.print(host);
DBG_OUTPUT_PORT.println(".local/edit to see the file browser");
}
else {
DBG_OUTPUT_PORT.print("mDNS start failed");
}
}
void loop(void){

@ -25,6 +25,6 @@
"espressif8266",
"espressif32"
],
"version": "0.9.8",
"version": "0.9.9",
"license": "MIT"
}

@ -1,5 +1,5 @@
name=AutoConnect
version=0.9.8
version=0.9.9
author=Hieromon Ikasamo <hieromon@gmail.com>
maintainer=Hieromon Ikasamo <hieromon@gmail.com>
sentence=ESP8266/ESP32 WLAN configuration at runtime with web interface.

@ -34,6 +34,7 @@ nav:
- 'Inside AutoConnect::begin': lsbegin.md
- 'Saved credentail access': credit.md
- 'File upload handler': acupload.md
- 'Custom colorized': colorized.md
- 'FAQ' : faq.md
- 'Change log' : changelog.md
- 'License' : license.md

@ -126,7 +126,7 @@ AutoConnectText& text2 = aux["caption"].as<AutoConnectText>();
```
!!! note "Need cast to convert to the actual type"
An operator `[]` returns a referene of an AutoConnectElement. It is necessary to convert the type according to the actual element type with [AutoConnectElement::as<T\>](apielements.md#ast62) functon.
An operator `[]` returns a reference of an AutoConnectElement. It is necessary to convert the type according to the actual element type with [AutoConnectElement::as<T\>](apielements.md#ast62) function.
```cpp
AutoConnectButton& AutoConnectElement::as<AutoConnectButton>()
AutoConnectCheckbox& AutoConnectElement::as<AutoConnectCheckbox>()
@ -145,6 +145,65 @@ To get all the AutoConnectElements in an AutoConnectAux object use the [**getEle
AutoConnectElementVT& AutoConnectAux::getElements(void)
```
### <i class="fa fa-edit"></i> Enable AutoConnectElements during the sketch execution
AutoConnectElemets have an enable attribute to activate its own HTML generation. Sketches can change the HTMLization of their elements dynamically by setting or resetting the enable value. An element whose the enable attribute is true will generate itself HTML and place on the custom Web page. And conversely, it will not generate the HTML when the value is false.
For example, to enable the submit button only when the ESP module is connected to the access point in STA mode, you can sketch the following:
```cpp hl_lines="30 31 32 33"
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <AutoConnect.h>
static const char AUX[] PROGMEM = R"(
{
"uri" : "/aux",
"title" : "Aux.",
"menu" : true,
"element" : [
{
"name": "input",
"type": "ACInput",
"label": "Input"
},
{
"name": "send",
"type": "ACSubmit",
"value": "SEND",
"uri": "/send"
}
]
}
)";
AutoConnect portal;
AutoConnectAux page;
String onPage(AutoConnectAux& aux, PageArgument& args) {
AutoConnectSubmit& send = aux["send"].as<AutoConnectSubmit>();
if (WiFi.isConnected())
send.enable = (WiFi.getMode() == WIFI_STA);
else
send.enable = false;
return String();
}
void setup() {
page.load(AUX);
page.on(onPage);
portal.join(page);
portal.begin();
}
void loop() {
portal.handleClient();
}
```
!!! hint "Desirable to set or reset the enable attribute in the page handler"
The enable attribute can be set at any time during the sketch execution. The page handler with the [AC_EXIT_AHEAD](apiaux.md#on) option is sure to handle it.
## Loading &amp; saving AutoConnectElements with JSON
AutoConnect supports reading the custom Web page definitions written in JSON and also supports loading and saving of AutoConnectAux or AutoConnectElements. In both cases, the target object is a [JSON document for AutoConnect](acjson.md). However, it can not save all AutoConnectElements contained in the page as a custom Web page. (ie. AutoConnectAux)

@ -214,6 +214,9 @@ Join the AutoConnectAux object to AutoConnect. AutoConnectAux objects can be joi
bool load(const String& aux)
```
```cpp
bool load(PGM_P aux)
```
```cpp
bool load(const __FlashStringHelper* aux)
```
```cpp

@ -87,6 +87,9 @@ for (AutoConnectElement& elm : elements) {
bool load(const String& in)
```
```cpp
bool load(PGM_P in)
```
```cpp
bool load(const __FlashStringHelper* in)
```
```cpp
@ -118,6 +121,12 @@ bool loadElement(const String& in, const String& name = String(""))
bool loadElement(const String& in, std::vector<String> const& names)
```
```cpp
bool loadElement(PGM_P in, const String& name = String(""))
```
```cpp
bool loadElement(PGM_P in, std::vector<String> const& names)
```
```cpp
bool loadElement(const __FlashStringHelper* in, const String& name = String(""))
```
```cpp

@ -14,31 +14,39 @@ AutoConnectButton(const char* name = "", const char* value = "", const String& a
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
#### <i class="fa fa-caret-right"></i> action
The element name.
HTML native code of the action script to be executed when the button is clicked. It is mostly used with a JavaScript to activate a script.[^1]
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
[^1]:JavaScript can be inserted into a custom Web page using AutoConnectElement.
Value of the element.
#### <i class="fa fa-caret-right"></i> enable
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> action
#### <i class="fa fa-caret-right"></i> name
HTML native code of the action script to be executed when the button is clicked. It is mostly used with a JavaScript to activate a script.[^1]
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
[^1]:JavaScript can be inserted into a custom Web page using AutoConnectElement.
#### <i class="fa fa-caret-right"></i> value
Value of the element.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
### <i class="fa fa-code"></i> Public member functions
@ -70,20 +78,20 @@ Returns type of AutoConnectElement.
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
#### <i class="fa fa-caret-right"></i> checked
The element name.
It indicates the checked status of the checkbox. The value of the checked checkbox element is packed in the query string and sent by submit.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
<dd><span class="apidef">Boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
#### <i class="fa fa-caret-right"></i> enable
Value of the element. It becomes a value attribute of an HTML `#!html <input type="checkbox">` tag.
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
@ -94,12 +102,20 @@ A label is an optional string. A label is always arranged on the right side of t
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> checked
#### <i class="fa fa-caret-right"></i> name
It indicates the checked status of the checkbox. The value of the checked checkbox element is packed in the query string and sent by submit.
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">Boolean</span><span class="apidesc"></span></dd>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
Value of the element. It becomes a value attribute of an HTML `#!html <input type="checkbox">` tag.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
### <i class="fa fa-code"></i> Public member functions
@ -130,6 +146,14 @@ AutoConnectElement(const char* name = "", const char* value = "")
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> enable
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> name
The element name.
@ -190,30 +214,46 @@ AutoConnectFile(const char* name = "", const char* value = "", const char* label
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
#### <i class="fa fa-caret-right"></i> enable
The element name.
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
A label is an optional string. A label is always arranged on the left side of the file input box. Specification of a label will generate an HTML `#!html <label>` tag with an id attribute. The file input box and the label are connected by the id attribute.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
#### <i class="fa fa-caret-right"></i> mimeType
File name to be upload. The value contains the value entered by the client browser to the `#!html <input type="file">` tag and is read-only.
The mime type of the upload file which included as Media type in the http post request. Set by the client (usually the browser) that requested the upload. It is determined by the file type as `application/octet-stream`, `text` etc. which is described in [IANA Media Type](https://www.iana.org/assignments/media-types/media-types.xhtml).
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
#### <i class="fa fa-caret-right"></i> name
A label is an optional string. A label is always arranged on the left side of the file input box. Specification of a label will generate an HTML `#!html <label>` tag with an id attribute. The file input box and the label are connected by the id attribute.
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> size
Size of the uploading file.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">size_t</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> store
Specifies the save destination of the uploaded file. You can use the built-in uploader to save uploaded file to the flash of the ESP8266/ESP32 module or external SD media without writing a dedicated sketch code. It also supports saving to any destination using a custom uploader that inherits from the AutoConnectUploadHandler class.
@ -227,22 +267,14 @@ Specifies the save destination of the uploaded file. You can use the built-in up
</span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> mimeType
#### <i class="fa fa-caret-right"></i> value
The mime type of the upload file which included as Media type in the http post request. Set by the client (usually the browser) that requested the upload. It is determined by the file type as `application/octet-stream`, `text` etc. which is described in [IANA Media Type](https://www.iana.org/assignments/media-types/media-types.xhtml).
File name to be upload. The value contains the value entered by the client browser to the `#!html <input type="file">` tag and is read-only.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> size
Size of the uploading file.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">size_t</span><span class="apidesc"></span></dd>
</dl>
### <i class="fa fa-code"></i> Public member functions
#### <i class="fa fa-caret-right"></i> typeOf
@ -274,25 +306,33 @@ AutoConnectInput(const char* name = "", const char* value = "", const char* labe
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
#### <i class="fa fa-caret-right"></i> enable
The element name.
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
A label is an optional string. A label is always arranged on the left side of the input box. Specification of a label will generate an HTML `#!html <label>` tag with an id attribute. The input box and the label are connected by the id attribute.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
#### <i class="fa fa-caret-right"></i> name
Value of the element. It becomes a value attribute of an HTML `#!html <input type="text">` tag. An entered text in the custom Web page will be sent with a query string of the form. The value set before accessing the page is displayed as the initial value.
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
#### <i class="fa fa-caret-right"></i> value
A label is an optional string. A label is always arranged on the left side of the input box. Specification of a label will generate an HTML `#!html <label>` tag with an id attribute. The input box and the label are connected by the id attribute.
Value of the element. It becomes a value attribute of an HTML `#!html <input type="text">` tag. An entered text in the custom Web page will be sent with a query string of the form. The value set before accessing the page is displayed as the initial value.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
@ -316,27 +356,27 @@ A placeholder is an option string. Specification of a placeholder will generate
### <i class="fa fa-code"></i> Public member functions
#### <i class="fa fa-caret-right"></i> typeOf
#### <i class="fa fa-caret-right"></i> isValid
```cpp
ACElement_t typeOf(void)
bool isValid(void)
```
Returns type of AutoConnectElement.
Evaluate the pattern as a regexp and return whether value matches. Always return true if the pattern is undefined.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>AC_Input</dd>
<dd><span class="apidef">true</span><span class="apidesc">The value matches a pattern.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">The value does not match a pattern.</span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> isValid
#### <i class="fa fa-caret-right"></i> typeOf
```cpp
bool isValid(void)
ACElement_t typeOf(void)
```
Evaluate the pattern as a regexp and return whether value matches. Always return true if the pattern is undefined.
Returns type of AutoConnectElement.
<dl class="apidl">
<dt>**Return value**</dt>
<dd><span class="apidef">true</span><span class="apidesc">The value matches a pattern.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">The value does not match a pattern.</span></dd>
<dd>AC_Input</dd>
</dl>
## AutoConnectRadio
@ -357,20 +397,20 @@ AutoConnectRadio(const char* name = "", std::vector<String> const& values = {},
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
#### <i class="fa fa-caret-right"></i> checked
The element name.
Specifies the index number (1-based) of the **values** to be checked. If this parameter is not specified neither item is checked.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
<dd><span class="apidef">uint8_t</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> values
#### <i class="fa fa-caret-right"></i> enable
An array of String type for the radio button options. It is an initialization list can be used. The `#!html <input type="radio">` tags will be generated from each entry in the values.
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">std::vector&lt;String&gt;</span><span class="apidesc"></span></dd>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
@ -381,6 +421,14 @@ A label is an optional string. A label will be arranged in the left or top of th
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> name
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> order
Specifies the direction to arrange the radio buttons. A label will place in the left or the top according to the **_order_**. It is a value of **ACArrange_t** type and accepts one of the following:
@ -393,27 +441,16 @@ Specifies the direction to arrange the radio buttons. A label will place in the
</span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> checked
#### <i class="fa fa-caret-right"></i> values
Specifies the index number (1-based) of the **values** to be checked. If this parameter is not specified neither item is checked.
An array of String type for the radio button options. It is an initialization list can be used. The `#!html <input type="radio">` tags will be generated from each entry in the values.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">uint8_t</span><span class="apidesc"></span></dd>
<dd><span class="apidef">std::vector&lt;String&gt;</span><span class="apidesc"></span></dd>
</dl>
### <i class="fa fa-code"></i> Public member functions
#### <i class="fa fa-caret-right"></i> typeOf
```cpp
ACElement_t typeOf(void)
```
Returns type of AutoConnectElement.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>AC_Radio</dd>
</dl>
#### <i class="fa fa-caret-right"></i> add
```cpp
@ -441,7 +478,9 @@ Indicates the check of the specified option for the radio buttons. You can use t
```cpp
void empty(const size_t reserve = 0)
```
Clear the array of option strings that AutoConnectRadio has in the values. When a **_reserve_** parameter is specified, a vector container of that size is reserved.
Clear the array of option strings that AutoConnectRadio has in the values. When the **_reserve_** parameter is specified, a vector container of that size is reserved.
The empty function resets the checked value to zero. When the empty function is executed, any button will be turned off.
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">reserve</span><span class="apidesc">Reserved size of a container for the radio button option strings.</span></dd>
@ -471,6 +510,17 @@ Returns number of options which contained.
<dd>Number of options which contained.</dd>
</dl>
#### <i class="fa fa-caret-right"></i> typeOf
```cpp
ACElement_t typeOf(void)
```
Returns type of AutoConnectElement.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>AC_Radio</dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
```cpp
@ -499,20 +549,20 @@ AutoConnectSelect(const char* name = "", std::vector<String> const& options = {}
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
#### <i class="fa fa-caret-right"></i> enable
The element name.
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> options
#### <i class="fa fa-caret-right"></i> name
An array of String type for the selection options. It is an initialization list can be used. The `#!html <option value>` tags will be generated from each entry in the options.
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">std::vector&lt;String&gt;</span><span class="apidesc"></span></dd>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
@ -523,6 +573,14 @@ A label is an optional string. A label will be arranged in the top of the select
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> options
An array of String type for the selection options. It is an initialization list can be used. The `#!html <option value>` tags will be generated from each entry in the options.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">std::vector&lt;String&gt;</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> selected
A `selected` is an optional value. Specifies 1-based index value of an options array that an option should be pre-selected when the page loads.
@ -533,17 +591,6 @@ A `selected` is an optional value. Specifies 1-based index value of an options a
### <i class="fa fa-code"></i> Public member functions
#### <i class="fa fa-caret-right"></i> typeOf
```cpp
ACElement_t typeOf(void)
```
Returns type of AutoConnectElement.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>AC_Select</dd>
</dl>
#### <i class="fa fa-caret-right"></i> add
```cpp
@ -560,7 +607,9 @@ Adds a selectable option string for the selection list.
```cpp
void empty(const size_t reserve = 0)
```
Clear the array of options list that AutoConnectSelect has in the options. When a **_reserve_** parameter is specified, a vector container of that size is reserved.
Clear the array of options list that AutoConnectSelect has in the options. When the **_reserve_** parameter is specified, a vector container of that size is reserved.
The empty function resets the selected value to zero. When the empty function is executed, there are no selected options and the first item is placed at the beginning.
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">reserve</span><span class="apidesc">Reserved size of a container for the options.</span></dd>
@ -601,6 +650,17 @@ Returns number of options which contained.
<dd>Number of options which contained.</dd>
</dl>
#### <i class="fa fa-caret-right"></i> typeOf
```cpp
ACElement_t typeOf(void)
```
Returns type of AutoConnectElement.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>AC_Select</dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
```cpp
@ -628,6 +688,14 @@ AutoConnectSubmit(const char* name = "", const char* value ="", char* uri = "")
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> enable
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> name
The element name.
@ -636,17 +704,17 @@ The element name.
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
#### <i class="fa fa-caret-right"></i> uri
The name of the submit button. It will also be the label of the button.
Destination URI.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> uri
#### <i class="fa fa-caret-right"></i> value
Destination URI.
The name of the submit button. It will also be the label of the button.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
@ -682,17 +750,25 @@ AutoConnectText(const char* name = "", const char* value = "", const char* style
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
#### <i class="fa fa-caret-right"></i> enable
The element name.
Enable HTML tag generation for the element. AutoConnect will generate the element into HTML only if the enable attribute is true.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">boolean</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> format
The conversion format when outputting values. The format string conforms to C-style printf library functions.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> value
#### <i class="fa fa-caret-right"></i> name
A content string of the text element.
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
@ -706,9 +782,9 @@ A style code with CSS format that qualifiers the text.
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> format
#### <i class="fa fa-caret-right"></i> value
The conversion format when outputting values. The format string conforms to C-style printf library functions.
A content string of the text element.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>

@ -1,3 +1,13 @@
#### [0.9.9] May 25, 2019
- Supports ESP8266 Arduino core 2.5.2.
- Menu text/background color can be statically customized.
- Added the [enable](achandling.md#enable-autoconnectelements-during-the-sketch-execution) attribute to the AutoConnectElements. This attribute gives dynamically change to the element activation during the sketch executing.
- Added ID attribute to HTML tag generated from AutoConnectText.
- Fixed the input box layout collapsed.
- Fixed that the decoration of AutoConnectButton was disabled.
- Fixed that the value remains even after clearing the option with AutoConnectSelect.
- Fixed that an alignment violation exception occurred when loading AutoConnectAux described by JSON with PROGMEM attribute.
#### [0.9.8] May 3, 2019
- Supports ArduinoJson 6.9.1 or later.
- Supports allocating JsonDocument buffer to PSRAM on ESP32 with ArduinoJson 6.10.0 or later.
@ -17,7 +27,7 @@
#### [0.9.7] Jan. 25, 2019
- Fixed crash in some environments. Thank you @ageurtse
- Supports AutoConnect menu extention by user sketch with [**AutoConnectAux**](acintro.md).
- Supports AutoConnect menu extension by user sketch with [**AutoConnectAux**](acintro.md).
- Supports loading and saving of user-defined parameters with JSON format.
- Improved the WiFi connection sequence at the first WiFi.begin. Even if [**AutoConnectConfig::autoReconnect**](apiconfig.md#autoreconnect) is disabled when SSID and PSK are not specified, it will use the information of the last established access point. The autoReconnect option will achieve trying the connect after a previous connection failed.
- Supports the [**AutoConnectConfig::immediateStart**](apiconfig.md#immediatestart) option and immediately starts the portal without first trying WiFi.begin. You can start the captive portal at any time in combination with the [**AutoConnectConfig::autoRise**](apiconfig.md#autorise) option.

@ -0,0 +1,54 @@
## AutoConnect menu colorizing ##
You can easily change the color of the AutoConnect menu. Menu colors can be changed statically by the AutoConnect menu color definition determined at compile time. You cannot change the color while the sketch is running.
The menu color scheme has been separated to `AutoConnectLabels.h` placed the AutoConnect library folder.[^1] You can change the color scheme of the menu with the following three color codes. The color code also accepts CSS standard color names.[^2]
[^1]: Usually, it will locate to the Arduino/libraries/AutoConnect/src folder of user documents.
[^2]: The W3C HTML and CSS standards have listed only 16 valid color names: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. Major browsers can accept more color names, but they are not web safe in typically.
In `AutoConnectLabels.h` you can find three definition macros for menu colors:
- \#define <b>AUTOCONNECT_MENUCOLOR_TEXT</b>
Defines the menu text color.
- \#define <b>AUTOCONNECT_MENUCOLOR_BACKGROUND</b>
Defines the menu background color.
- \#define <b>AUTOCONNECT_MENUCOLOR_ACTIVE</b>
Defines the active menu item background color.
## Typical color schemes
Here are some color schemes picked up.
### <i class="fas fa-palette"></i> Indigo
```cpp
#define AUTOCONNECT_MENUCOLOR_TEXT "#ffa500"
#define AUTOCONNECT_MENUCOLOR_BACKGROUND "#1a237e"
#define AUTOCONNECT_MENUCOLOR_ACTIVE "#283593"
```
<img src="images/ACMenu_indigo.png">
### <i class="fas fa-palette"></i> Dim-gray
```cpp
#define AUTOCONNECT_MENUCOLOR_TEXT "#fffacd"
#define AUTOCONNECT_MENUCOLOR_BACKGROUND "#696969"
#define AUTOCONNECT_MENUCOLOR_ACTIVE "#808080"
```
<img src="images/ACMenu_dimgray.png">
### <i class="fas fa-palette"></i> Brown
```cpp
#define AUTOCONNECT_MENUCOLOR_TEXT "#e6e6fa"
#define AUTOCONNECT_MENUCOLOR_BACKGROUND "#3e2723"
#define AUTOCONNECT_MENUCOLOR_ACTIVE "#4e342e"
```
<img src="images/ACMenu_brown.png">

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

@ -2,8 +2,8 @@
* AutoConnect class implementation.
* @file AutoConnect.cpp
* @author hieromon@gmail.com
* @version 0.9.7
* @date 2019-01-21
* @version 0.9.9
* @date 2019-05-25
* @copyright MIT license.
*/
@ -789,26 +789,6 @@ bool AutoConnect::_classifyHandle(HTTPMethod method, String uri) {
_portalAccessPeriod = millis();
AC_DBG("Host:%s,URI:%s", _webServer->hostHeader().c_str(), uri.c_str());
// When handleClient calls RequestHandler, the parsed http argument
// remains the previous request.
// If the current request argument contains AutoConnectElement, it is
// the form data of the AutoConnectAux page and with this timing save
// the value of each element.
// if (_webServer->hasArg(String(F(AUTOCONNECT_AUXURI_PARAM)))) {
// _auxUri = _webServer->arg(AUTOCONNECT_AUXURI_PARAM);
// _auxUri.replace("&#47;", "/");
// AutoConnectAux* aux = _aux.get();
// while (aux) {
// if (aux->_uriStr == _auxUri) {
// // Save the value owned by each element contained in the POST body
// // of a current HTTP request to AutoConnectElements.
// aux->_storeElements(_webServer.get());
// break;
// }
// aux = aux->_next.get();
// }
// }
// Here, classify requested uri
if (uri == _uri) {
AC_DBG_DUMB(",already allocated\n");
@ -816,7 +796,8 @@ bool AutoConnect::_classifyHandle(HTTPMethod method, String uri) {
}
// Dispose decrepit page
_prevUri = _uri; // Save current uri for the upload request
if (_uri.length())
_prevUri = _uri; // Save current uri for the upload request
_purgePages();
// Create the page dynamically

@ -2,8 +2,8 @@
* Declaration of AutoConnect class and accompanying AutoConnectConfig class.
* @file AutoConnect.h
* @author hieromon@gmail.com
* @version 0.9.7
* @date 2019-01-21
* @version 0.9.9
* @date 2019-05-25
* @copyright MIT license.
*/
@ -189,8 +189,9 @@ class AutoConnect {
/** For AutoConnectAux described in JSON */
#ifdef AUTOCONNECT_USE_JSON
bool load(const String& aux);
bool load(PGM_P aux);
bool load(const __FlashStringHelper* aux);
bool load(const String& aux);
bool load(Stream& aux);
#endif // !AUTOCONNECT_USE_JSON

@ -2,8 +2,8 @@
* Implementation of AutoConnectAux class.
* @file AutoConnectAuxBasisImpl.h
* @author hieromon@gmail.com
* @version 0.9.8
* @date 2019-03-11
* @version 0.9.9
* @date 2019-05-25
* @copyright MIT license.
*/
#include <algorithm>
@ -495,14 +495,14 @@ void AutoConnectAux::_storeElements(WebServerClass* webServer) {
#ifdef AUTOCONNECT_USE_JSON
/**
* Load AutoConnectAux page from JSON description stored in the sketch.
* Load AutoConnectAux page from JSON description stored in PROGMEM.
* This function can load AutoConnectAux for multiple AUX pages written
* in JSON and is registered in AutoConnect.
* @param aux JSON description to be load.
* @return true Successfully loaded.
*/
bool AutoConnect::load(const String& aux) {
return _parseJson<const String&>(aux);
bool AutoConnect::load(PGM_P aux) {
return _parseJson<const __FlashStringHelper*>(reinterpret_cast<const __FlashStringHelper*>(aux));
}
/**
@ -516,6 +516,17 @@ bool AutoConnect::load(const __FlashStringHelper* aux) {
return _parseJson<const __FlashStringHelper*>(aux);
}
/**
* Load AutoConnectAux page from JSON description stored in the sketch.
* This function can load AutoConnectAux for multiple AUX pages written
* in JSON and is registered in AutoConnect.
* @param aux JSON description to be load.
* @return true Successfully loaded.
*/
bool AutoConnect::load(const String& aux) {
return _parseJson<const String&>(aux);
}
/**
* Load AutoConnectAux page from JSON description from the stream.
* This function can load AutoConnectAux for multiple AUX pages written
@ -622,6 +633,18 @@ bool AutoConnectAux::load(const String& in) {
return _parseJson<const String&>(in);
}
/**
* Constructs an AutoConnectAux instance by reading all the
* AutoConnectElements of the specified URI from the elements passing
* pointer to JSON stored in pgm_data array.
* @param in AutoConnectAux element data which is described by JSON.
* @return true The element collection successfully loaded.
* @return false Invalid JSON data occurred.
*/
bool AutoConnectAux::load(PGM_P in) {
return _parseJson<const __FlashStringHelper*>(reinterpret_cast<const __FlashStringHelper*>(in));
}
/**
* Constructs an AutoConnectAux instance by reading all the
* AutoConnectElements of the specified URI from the elements defined
@ -672,26 +695,33 @@ bool AutoConnectAux::_load(JsonObject& jb) {
* elements are to be loaded.
* @return A reference of loaded AutoConnectElement instance.
*/
bool AutoConnectAux::loadElement(const String& in, const String& name) {
return _parseElement<const String&, const String&>(in, name);
bool AutoConnectAux::loadElement(PGM_P in, const String& name) {
return _parseElement<const __FlashStringHelper*, const String&>(reinterpret_cast<const __FlashStringHelper*>(in), name);
}
bool AutoConnectAux::loadElement(const __FlashStringHelper* in, const String& name) {
return _parseElement<const __FlashStringHelper*, const String&>(in, name);
}
bool AutoConnectAux::loadElement(const String& in, const String& name) {
return _parseElement<const String&, const String&>(in, name);
}
bool AutoConnectAux::loadElement(Stream& in, const String& name) {
return _parseElement<Stream&, const String&>(in, name);
}
bool AutoConnectAux::loadElement(const String& in, std::vector<String> const& names) {
return _parseElement<const String&, std::vector<String> const&>(in, names);
bool AutoConnectAux::loadElement(PGM_P in, std::vector<String> const& names) {
return _parseElement<const __FlashStringHelper*, std::vector<String> const&>(reinterpret_cast<const __FlashStringHelper*>(in), names);
}
bool AutoConnectAux::loadElement(const __FlashStringHelper* in, std::vector<String> const& names) {
return _parseElement<const __FlashStringHelper*, std::vector<String> const&>(in, names);
}
bool AutoConnectAux::loadElement(const String& in, std::vector<String> const& names) {
return _parseElement<const String&, std::vector<String> const&>(in, names);
}
bool AutoConnectAux::loadElement(Stream& in, std::vector<String> const& names) {
return _parseElement<Stream&, std::vector<String> const&>(in, names);
}
@ -776,9 +806,10 @@ size_t AutoConnectAux::saveElement(Stream& out, std::vector<String> const& names
// Calculate JSON buffer size
if (amount == 0) {
bufferSize += JSON_OBJECT_SIZE(4);
bufferSize += sizeof(AUTOCONNECT_JSON_KEY_TITLE) + _title.length() + sizeof(AUTOCONNECT_JSON_KEY_URI) + _uriStr.length() + sizeof(AUTOCONNECT_JSON_KEY_MENU) + sizeof("false") + sizeof(AUTOCONNECT_JSON_KEY_ELEMENT);
bufferSize += sizeof(AUTOCONNECT_JSON_KEY_TITLE) + _title.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_URI) + _uriStr.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_MENU) + sizeof(AUTOCONNECT_JSON_KEY_ELEMENT);
bufferSize += JSON_ARRAY_SIZE(_addonElm.size());
}
if (amount != 1)
else
bufferSize += JSON_ARRAY_SIZE(amount);
for (AutoConnectElement& elmEach : _addonElm) {
@ -792,7 +823,7 @@ size_t AutoConnectAux::saveElement(Stream& out, std::vector<String> const& names
bufferSize += elm->getObjectSize();
}
// Round up to 16 boundary
bufferSize = bufferSize > 0 ? ((bufferSize + 128) & (~0xf)) : bufferSize;
bufferSize = bufferSize > 0 ? ((bufferSize + 16) & (~0xf)) : bufferSize;
AC_DBG("JSON buffer size:%d\n", bufferSize);
// Serialization

@ -2,8 +2,8 @@
* Declaration of AutoConnectAux basic class.
* @file AutoConnectAuxBasis.h
* @author hieromon@gmail.com
* @version 0.9.7
* @date 2018-12-17
* @version 0.9.9
* @date 2019-05-23
* @copyright MIT license.
*/
@ -71,13 +71,16 @@ class AutoConnectAux : public PageBuilder {
}
#ifdef AUTOCONNECT_USE_JSON
bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */
bool load(PGM_P in); /**< Load whole elements to AutoConnectAux Page */
bool load(const __FlashStringHelper* in); /**< Load whole elements to AutoConnectAux Page */
bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */
bool load(Stream& in); /**< Load whole elements to AutoConnectAux Page */
bool loadElement(const String& in, const String& name = String("")); /**< Load specified element */
bool loadElement(const String& in, std::vector<String> const& names);/**< Load any specified elements */
bool loadElement(PGM_P in, const String& name = String("")); /**< Load specified element */
bool loadElement(PGM_P in, std::vector<String> const& names); /**< Load any specified elements */
bool loadElement(const __FlashStringHelper* in, const String& name = String("")); /**< Load specified element */
bool loadElement(const __FlashStringHelper* in, std::vector<String> const& names); /**< Load any specified elements */
bool loadElement(const String& in, const String& name = String("")); /**< Load specified element */
bool loadElement(const String& in, std::vector<String> const& names);/**< Load any specified elements */
bool loadElement(Stream& in, const String& name = String("")); /**< Load specified element */
bool loadElement(Stream& in, std::vector<String> const& names); /**< Load any specified elements */
size_t saveElement(Stream& out, std::vector<String> const& names = {}); /**< Write elements of AutoConnectAux to the stream */

@ -2,8 +2,8 @@
* Predefined AutoConnect configuration parameters.
* @file AutoConnectDefs.h
* @author hieromon@gmail.com
* @version 0.9.7
* @date 2018-11-17
* @version 0.9.9
* @date 2019-05-25
* @copyright MIT license.
*/
@ -132,22 +132,9 @@
#define AUTOCONNECT_SSIDPAGEUNIT_LINES 5
#endif // !AUTOCONNECT_SSIDPAGEUNIT_LINES
// SD pin assignment for AutoConnectFile
#ifndef AUTOCONNECT_SD_CS
#if defined(ARDUINO_ARCH_ESP8266)
#define AUTOCONNECT_SD_CS SD_CHIP_SELECT_PIN
#elif defined(ARDUINO_ARCH_ESP32)
#define AUTOCONNECT_SD_CS SS
#endif
#endif // !AUTOCONNECT_SD_CS
// SPI transfer speed for SD
#ifndef AUTOCONNECT_SD_SPEED
#if defined(ARDUINO_ARCH_ESP8266)
#define AUTOCONNECT_SD_SPEED SPI_HALF_SPEED
#elif defined(ARDUINO_ARCH_ESP32)
#define AUTOCONNECT_SD_SPEED 4000000
#endif
#endif // !AUTOCONNECT_SD_SPEED
// ArduinoJson buffer size

@ -2,8 +2,8 @@
* Implementation of AutoConnectElementBasis classes.
* @file AutoConnectElementImpl.h
* @author hieromon@gmail.com
* @version 0.9.8
* @date 2019-03-11
* @version 0.9.9
* @date 2019-05-23
* @copyright MIT license.
*/
@ -172,6 +172,7 @@ void AutoConnectRadioBasis::empty(const size_t reserve) {
std::vector<String>().swap(_values);
if (reserve)
_values.reserve(reserve);
checked = 0;
}
/**
@ -221,6 +222,7 @@ void AutoConnectSelectBasis::empty(const size_t reserve) {
std::vector<String>().swap(_options);
if (reserve)
_options.reserve(reserve);
selected = 0;
}
/**
@ -290,7 +292,7 @@ const String AutoConnectTextBasis::toHTML(void) const {
String html = String("");
if (enable) {
html = String("<div");
html = String(F("<div id=\"")) + name + String('"');
String value_f = value;
if (style.length())

@ -2,8 +2,8 @@
* Declaration of AutoConnectElement extended classes using JSON.
* @file AutoConnectElementJson.h
* @author hieromon@gmail.com
* @version 0.9.8
* @date 2019-03-11
* @version 0.9.9
* @date 2019-05-23
* @copyright MIT license.
*/
@ -76,7 +76,13 @@ using ArduinoJsonArray = JsonArray;
// JsonDocument is assigned to PSRAM by ArduinoJson's custom allocator.
struct SpiRamAllocatorST {
void* allocate(size_t size) {
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
uint32_t caps;
if (psramFound())
caps = MALLOC_CAP_SPIRAM;
else {
caps = MALLOC_CAP_8BIT;
AC_DBG("PSRAM not found, JSON buffer allocates to the heap.\n");
}
}
void deallocate(void* pointer) {
heap_caps_free(pointer);

@ -2,8 +2,8 @@
* Implementation of AutoConnectElementJson classes.
* @file AutoConnectElementImpl.h
* @author hieromon@gmail.com
* @version 0.9.8
* @date 2019-03-11
* @version 0.9.9
* @date 2019-05-23
* @copyright MIT license.
*/
@ -17,8 +17,9 @@
* @return An object size for JsonBuffer.
*/
size_t AutoConnectElementJson::getObjectSize() const {
size_t size = JSON_OBJECT_SIZE(3) + sizeof(AUTOCONNECT_JSON_KEY_TYPE) + sizeof(AUTOCONNECT_JSON_KEY_NAME) + sizeof(AUTOCONNECT_JSON_KEY_VALUE) + 10;
size += name.length() + value.length();
size_t size = JSON_OBJECT_SIZE(3);
size += sizeof(AUTOCONNECT_JSON_KEY_NAME) + sizeof(AUTOCONNECT_JSON_KEY_TYPE) + sizeof(AUTOCONNECT_JSON_KEY_VALUE) + sizeof(AUTOCONNECT_JSON_TYPE_ACELEMENT);
size += name.length() + 1 + value.length() + 1;
return size;
}
@ -72,7 +73,7 @@ void AutoConnectElementJson::_setMember(const JsonObject& json) {
*/
size_t AutoConnectButtonJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(1);
size += sizeof(AUTOCONNECT_JSON_KEY_ACTION) + action.length();
size += sizeof(AUTOCONNECT_JSON_KEY_ACTION) + action.length() + 1;
return size;
}
@ -110,7 +111,7 @@ void AutoConnectButtonJson::serialize(JsonObject& json) {
*/
size_t AutoConnectCheckboxJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2);
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + sizeof(AUTOCONNECT_JSON_KEY_CHECKED);
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_CHECKED);
return size;
}
@ -152,7 +153,7 @@ void AutoConnectCheckboxJson::serialize(JsonObject& json) {
*/
size_t AutoConnectFileJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2);
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + sizeof(AUTOCONNECT_JSON_KEY_STORE) + sizeof(AUTOCONNECT_JSON_VALUE_FS);
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_STORE) + sizeof(AUTOCONNECT_JSON_VALUE_EXTERNAL);
return size;
}
@ -214,7 +215,7 @@ void AutoConnectFileJson::serialize(JsonObject& json) {
*/
size_t AutoConnectInputJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(3);
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + sizeof(AUTOCONNECT_JSON_KEY_PATTERN) + pattern.length() + sizeof(AUTOCONNECT_JSON_KEY_PLACEHOLDER) + placeholder.length();
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_PATTERN) + pattern.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_PLACEHOLDER) + placeholder.length() + 1;
return size;
}
@ -257,10 +258,10 @@ void AutoConnectInputJson::serialize(JsonObject& json) {
* @return An object size for JsonBuffer.
*/
size_t AutoConnectRadioJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2) + JSON_ARRAY_SIZE(_values.size());
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + sizeof(AUTOCONNECT_JSON_KEY_ARRANGE) + sizeof(AUTOCONNECT_JSON_VALUE_HORIZONTAL) + sizeof(AUTOCONNECT_JSON_KEY_CHECKED) + 2;
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(_values.size());
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_ARRANGE) + sizeof(AUTOCONNECT_JSON_VALUE_HORIZONTAL) + sizeof(AUTOCONNECT_JSON_KEY_CHECKED);
for (const String& _value : _values)
size += _value.length();
size += _value.length() + 1;
return size;
}
@ -276,6 +277,12 @@ bool AutoConnectRadioJson::loadMember(const JsonObject& json) {
_setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABEL)))
label = json[F(AUTOCONNECT_JSON_KEY_LABEL)].as<String>();
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_VALUE))) {
ArduinoJsonArray optionArray = json[AUTOCONNECT_JSON_KEY_VALUE];
empty(optionArray.size());
for (auto value : optionArray)
add(value.as<String>());
}
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_CHECKED)))
checked = static_cast<uint8_t>(json[F(AUTOCONNECT_JSON_KEY_CHECKED)].as<int>());
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_ARRANGE))) {
@ -289,13 +296,6 @@ bool AutoConnectRadioJson::loadMember(const JsonObject& json) {
return false;
}
}
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_VALUE))) {
empty();
// JsonArray& optionArray = json[AUTOCONNECT_JSON_KEY_VALUE];
ArduinoJsonArray optionArray = json[AUTOCONNECT_JSON_KEY_VALUE];
for (auto value : optionArray)
add(value.as<String>());
}
return true;
}
return false;
@ -329,10 +329,10 @@ void AutoConnectRadioJson::serialize(JsonObject& json) {
* @return An object size for JsonBuffer.
*/
size_t AutoConnectSelectJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(_options.size());
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + sizeof(AUTOCONNECT_JSON_KEY_SELECTED) + 2;
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2) + JSON_ARRAY_SIZE(_options.size());
size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_SELECTED);
for (const String& _option : _options)
size += _option.length();
size += _option.length() + 1;
return size;
}
@ -349,14 +349,14 @@ bool AutoConnectSelectJson::loadMember(const JsonObject& json) {
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABEL)))
label = json[F(AUTOCONNECT_JSON_KEY_LABEL)].as<String>();
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_OPTION))) {
empty();
ArduinoJsonArray optionArray = json[AUTOCONNECT_JSON_KEY_OPTION];
empty(optionArray.size());
for (auto value : optionArray)
add(value.as<String>());
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_SELECTED)))
selected = static_cast<uint8_t>(json[F(AUTOCONNECT_JSON_KEY_SELECTED)].as<int>());
return true;
}
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_SELECTED)))
selected = static_cast<uint8_t>(json[F(AUTOCONNECT_JSON_KEY_SELECTED)].as<int>());
return true;
}
return false;
}
@ -381,8 +381,8 @@ void AutoConnectSelectJson::serialize(JsonObject& json) {
* @return An object size for JsonBuffer.
*/
size_t AutoConnectSubmitJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(1);
size += sizeof(AUTOCONNECT_JSON_KEY_URI) + uri.length();
size_t size = AutoConnectElementJson::getObjectSize();
size += sizeof(AUTOCONNECT_JSON_KEY_URI) + uri.length() + 1;
return size;
}
@ -420,7 +420,7 @@ void AutoConnectSubmitJson::serialize(JsonObject& json) {
*/
size_t AutoConnectTextJson::getObjectSize() const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2);
size += sizeof(AUTOCONNECT_JSON_KEY_STYLE) + style.length() + sizeof(AUTOCONNECT_JSON_KEY_FORMAT) + format.length();
size += sizeof(AUTOCONNECT_JSON_KEY_STYLE) + style.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_FORMAT) + format.length() + 1;
return size;
}

@ -2,8 +2,8 @@
* AutoConnect portal site web page implementation.
* @file AutoConnectPage.h
* @author hieromon@gmail.com
* @version 0.9.7
* @date 2019-01-23
* @version 0.9.9
* @date 2019-05-25
* @copyright MIT license.
*/
@ -29,45 +29,45 @@ const char AutoConnect::_CSS_BASE[] PROGMEM = {
"-ms-text-size-adjust:100%;"
"-webkit-text-size-adjust:100%;"
"-moz-osx-font-smoothing:grayscale;"
"-webkit-font-smoothing:antialiased;"
"-webkit-font-smoothing:antialiased"
"}"
"body{"
"margin:0;"
"padding:0;"
"padding:0"
"}"
".base-panel{"
"margin:0 22px 0 22px;"
"margin:0 22px 0 22px"
"}"
".base-panel>*>label{"
"display:inline-block;"
"width:3.0em;"
"text-align:right;"
"text-align:right"
"}"
".base-panel>*>label.slist{"
"width:auto;"
"font-size:0.9em;"
"margin-left:10px;"
"text-align:left;"
"text-align:left"
"}"
"input{"
"-moz-appearance:none;"
"-webkit-appearance:none;"
"font-size:0.9em;"
"margin:8px 0 auto;"
"margin:8px 0 auto"
"}"
".lap{"
"visibility:collapse;"
"visibility:collapse"
"}"
".lap:target{"
"visibility:visible;"
"visibility:visible"
"}"
".lap:target .overlap{"
"opacity:0.7;"
"transition:0.3s;"
"transition:0.3s"
"}"
".lap:target .modal_button{"
"opacity:1;"
"transition:0.3s;"
"transition:0.3s"
"}"
".overlap{"
"top:0;"
@ -77,7 +77,7 @@ const char AutoConnect::_CSS_BASE[] PROGMEM = {
"position:fixed;"
"opacity:0;"
"background:#000;"
"z-index:1000;"
"z-index:1000"
"}"
".modal_button{"
"border-radius:13px;"
@ -94,7 +94,7 @@ const char AutoConnect::_CSS_BASE[] PROGMEM = {
"width:20%;"
"position:fixed;"
"opacity:0;"
"z-index:1001;"
"z-index:1001"
"}"
};
@ -103,28 +103,32 @@ const char AutoConnect::_CSS_UL[] PROGMEM = {
"ul.noorder{"
"padding:0;"
"list-style:none;"
"display:table"
"}"
"ul.noorder li{"
"display:table-row"
"}"
"ul.noorder>*>label{"
"display:inline-block;"
"display:table-cell;"
"width:auto;"
"margin-right:10px;"
"text-align:right;"
"padding:10px 0.5em;"
"padding:10px 0.5em"
"}"
"ul.noorder>input[type=\"checkbox\"]{"
"-moz-appearance:checkbox;"
"-webkit-appearance:checkbox;"
"-webkit-appearance:checkbox"
"}"
"ul.noorder>input[type=\"radio\"]{"
"margin-right:0.5em;"
"-moz-appearance:radio;"
"-webkit-appearance:radio;"
"-webkit-appearance:radio"
"}"
"ul.noorder>input[type=\"text\"]{"
"width:auto;"
"width:auto"
"}"
"ul.noorder>input[type=\"text\"]:invalid{"
"background:#fce4d6;"
"background:#fce4d6"
"}"
};
@ -136,44 +140,44 @@ const char AutoConnect::_CSS_ICON_LOCK[] PROGMEM = {
"height:22px;"
"margin-top:14px;"
"float:right;"
"background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAB1ElEQVRIibWVu0scURTGf3d2drBQFAWbbRQVCwuVLIZdi2gnWIiF/4GtKyuJGAJh8mgTcU0T8T8ICC6kiIVu44gvtFEQQWwsbExQJGHXmZtiZsOyzCN3Vz+4cDjfvec7j7l3QAF95onRZ54YKmdE1IbnS0c9mnAyAjkBxDy3LRHrjtRyu7OD52HntTAyvbw/HxP2hkCearrRb2WSCSuTTGi60S+QpzFhbwznDl/VVMHw0sF7hEjFbW2qkB38lfp8nNDipWcATil+uDM3cDWyeNRSijnfkHJnezb5Vkkgvbg3IOXD2e1ts93S+icnkZOAVaalZK3YQMa4L+pC6L1WduhYSeCf0PLBdxzOjZ93Lwvm6APAiLmlF1ubPiHotmaS41ExQjH0ZbfNM1NAFpgD0lVcICIrANqAVaAd+AFIYAy4BqaBG+Wsq5AH3vgk8xpYrzf4KLAZwhe8PYEIvQe4vc6H8Hnc2dQs0AFchvAXQGdEDF8s4A5TZS34BQqqQNaS1WMI3KD4WUbNoBJfce9CO7BSr4BfBe8A21vmUwh0VdjdTyHwscL+UK+AHxoD7FDoAX6/Cnpxn4ay/egCjcCL/w1chkqLakLQ/6ABhT57uAd+Vzv/Ara3iY6fK4WxAAAAAElFTkSuQmCC) no-repeat;"
"background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAB1ElEQVRIibWVu0scURTGf3d2drBQFAWbbRQVCwuVLIZdi2gnWIiF/4GtKyuJGAJh8mgTcU0T8T8ICC6kiIVu44gvtFEQQWwsbExQJGHXmZtiZsOyzCN3Vz+4cDjfvec7j7l3QAF95onRZ54YKmdE1IbnS0c9mnAyAjkBxDy3LRHrjtRyu7OD52HntTAyvbw/HxP2hkCearrRb2WSCSuTTGi60S+QpzFhbwznDl/VVMHw0sF7hEjFbW2qkB38lfp8nNDipWcATil+uDM3cDWyeNRSijnfkHJnezb5Vkkgvbg3IOXD2e1ts93S+icnkZOAVaalZK3YQMa4L+pC6L1WduhYSeCf0PLBdxzOjZ93Lwvm6APAiLmlF1ubPiHotmaS41ExQjH0ZbfNM1NAFpgD0lVcICIrANqAVaAd+AFIYAy4BqaBG+Wsq5AH3vgk8xpYrzf4KLAZwhe8PYEIvQe4vc6H8Hnc2dQs0AFchvAXQGdEDF8s4A5TZS34BQqqQNaS1WMI3KD4WUbNoBJfce9CO7BSr4BfBe8A21vmUwh0VdjdTyHwscL+UK+AHxoD7FDoAX6/Cnpxn4ay/egCjcCL/w1chkqLakLQ/6ABhT57uAd+Vzv/Ara3iY6fK4WxAAAAAElFTkSuQmCC) no-repeat"
"}"
};
/**< INPUT button and submit style */
const char AutoConnect::_CSS_INPUT_BUTTON[] PROGMEM = {
"input[type=\"button\"],input[type=\"submit\"],button[type=\"submit\"]{"
"input[type=\"button\"],input[type=\"submit\"],button[type=\"submit\"],button[type=\"button\"]{"
"padding:8px 0.5em;"
"font-weight:bold;"
"letter-spacing:0.8px;"
"color:#fff;"
"border:1px solid;"
"border-radius:2px;"
"margin-top:12px;"
"margin-top:12px"
"}"
"input[type=\"button\"]{"
"input[type=\"button\"],button[type=\"button\"]{"
"background-color:#1b5e20;"
"border-color:#1b5e20;"
"width:15em;"
"width:15em"
"}"
".aux-page input[type=\"button\"]{"
".aux-page input[type=\"button\"],button[type=\"button\"]{"
"font-weight:normal;"
"padding:8px 14px;"
"margin:12px;"
"width:auto;"
"width:auto"
"}"
"input#sb[type=\"submit\"]{"
"width:15em;"
"width:15em"
"}"
"input[type=\"submit\"],button[type=\"submit\"]{"
"padding:8px 30px;"
"background-color:#006064;"
"border-color:#006064;"
"border-color:#006064"
"}"
"input[type=\"button\"],input[type=\"submit\"],button[type=\"submit\"]:focus,"
"input[type=\"button\"],input[type=\"submit\"],button[type=\"submit\"]:active{"
"outline:none;"
"text-decoration:none;"
"text-decoration:none"
"}"
};
@ -185,48 +189,48 @@ const char AutoConnect::_CSS_INPUT_TEXT[] PROGMEM = {
"border-radius:2px;"
"color:#444;"
"margin:8px 0 8px 0;"
"padding:10px;"
"padding:10px"
"}"
"input[type=\"text\"],input[type=\"password\"]{"
"font-weight:300;"
"width:calc(100% - 124px);"
"width:auto;"
"-webkit-transition:all 0.20s ease-in;"
"-moz-transition:all 0.20s ease-in;"
"-o-transition:all 0.20s ease-in;"
"-ms-transition:all 0.20s ease-in;"
"transition:all 0.20s ease-in;"
"transition:all 0.20s ease-in"
"}"
"input[type=\"text\"]:focus,input[type=\"password\"]:focus{"
"outline:none;"
"border-color:#5C9DED;"
"box-shadow:0 0 3px #4B8CDC;"
"box-shadow:0 0 3px #4B8CDC"
"}"
"input.error, input.error:focus{"
"border-color:#ED5564;"
"color:#D9434E;"
"box-shadow:0 0 3px #D9434E;"
"box-shadow:0 0 3px #D9434E"
"}"
"input:disabled{"
"opacity:0.6;"
"background-color:#f7f7f7;"
"background-color:#f7f7f7"
"}"
"input:disabled:hover{"
"cursor:not-allowed;"
"cursor:not-allowed"
"}"
"input.error::-webkit-input-placeholder{"
"color:#D9434E;"
"color:#D9434E"
"}"
"input.error:-moz-placeholder{"
"color:#D9434E;"
"color:#D9434E"
"}"
"input.error::-moz-placeholder{"
"color:#D9434E;"
"color:#D9434E"
"}"
"input.error:-ms-input-placeholder{"
"color:#D9434E;"
"color:#D9434E"
"}"
".aux-page label{"
"padding:10px 0.5em;"
"padding:10px 0.5em"
"}"
};
@ -238,49 +242,49 @@ const char AutoConnect::_CSS_TABLE[] PROGMEM = {
"border:1px solid #ddd;"
"color:#444;"
"background-color:#fff;"
"margin-bottom:20px;"
"margin-bottom:20px"
"}"
"table.info,"
"table.info>tfoot,"
"table.info>thead{"
"width:100%;"
"border-color:#5C9DED;"
"border-color:#5C9DED"
"}"
"table.info>thead{"
"background-color:#5C9DED;"
"background-color:#5C9DED"
"}"
"table.info>thead>tr>th{"
"color:#fff;"
"color:#fff"
"}"
"td,"
"th{"
"padding:10px 22px;"
"padding:10px 22px"
"}"
"thead{"
"background-color:#f3f3f3;"
"border-bottom:1px solid #ddd;"
"border-bottom:1px solid #ddd"
"}"
"thead>tr>th{"
"font-weight:400;"
"text-align:left;"
"text-align:left"
"}"
"tfoot{"
"border-top:1px solid #ddd;"
"border-top:1px solid #ddd"
"}"
"tbody,"
"tbody>tr:nth-child(odd){"
"background-color:#fff;"
"background-color:#fff"
"}"
"tbody>tr>td,"
"tfoot>tr>td{"
"font-weight:300;"
"font-size:.88em;"
"font-size:.88em"
"}"
"tbody>tr:nth-child(even){"
"background-color:#f7f7f7;"
"background-color:#f7f7f7"
"}"
"table.info tbody>tr:nth-child(even){"
"background-color:#EFF5FD;"
"background-color:#EFF5FD"
"}"
};
@ -290,7 +294,7 @@ const char AutoConnect::_CSS_SPINNER[] PROGMEM = {
"width:40px;"
"height:40px;"
"position:relative;"
"margin:100px auto;"
"margin:100px auto"
"}"
".double-bounce1, .double-bounce2{"
"width:100%;"
@ -302,11 +306,11 @@ const char AutoConnect::_CSS_SPINNER[] PROGMEM = {
"top:0;"
"left:0;"
"-webkit-animation:sk-bounce 2.0s infinite ease-in-out;"
"animation:sk-bounce 2.0s infinite ease-in-out;"
"animation:sk-bounce 2.0s infinite ease-in-out"
"}"
".double-bounce2{"
"-webkit-animation-delay:-1.0s;"
"animation-delay:-1.0s;"
"animation-delay:-1.0s"
"}"
"@-webkit-keyframes sk-bounce{"
"0%, 100%{-webkit-transform:scale(0.0)}"
@ -332,7 +336,7 @@ const char AutoConnect::_CSS_LUXBAR[] PROGMEM = {
"top:0;"
"left:0;"
"z-index:1000;"
"box-shadow:0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);"
"box-shadow:0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24)"
"}"
".luxbar-burger span,"
".luxbar-burger span::before,"
@ -340,91 +344,91 @@ const char AutoConnect::_CSS_LUXBAR[] PROGMEM = {
"display:block;"
"height:2px;"
"width:26px;"
"transition:0.6s ease;"
"transition:0.6s ease"
"}"
".luxbar-checkbox:checked~.luxbar-menu li .luxbar-burger span{"
"background-color:transparent;"
"background-color:transparent"
"}"
".luxbar-checkbox:checked~.luxbar-menu li .luxbar-burger span::before,"
".luxbar-checkbox:checked~.luxbar-menu li .luxbar-burger span::after{"
"margin-top:0;"
"margin-top:0"
"}"
".luxbar-header{"
"display:flex;"
"flex-direction:row;"
"justify-content:space-between;"
"align-items:center;"
"height:58px;"
"height:58px"
"}"
".luxbar-menu-right .luxbar-burger{"
"margin-left:auto;"
"margin-left:auto"
"}"
".luxbar-brand{"
"font-size:1.6em;"
"padding:18px 24px 18px 24px;"
"padding:18px 24px 18px 24px"
"}"
".luxbar-menu{"
"min-height:58px;"
"transition:0.6s ease;"
"width:100%;"
"width:100%"
"}"
".luxbar-navigation{"
"display:flex;"
"flex-direction:column;"
"list-style:none;"
"padding-left:0;"
"margin:0;"
"margin:0"
"}"
".luxbar-menu a,"
".luxbar-item a{"
"text-decoration:none;"
"color:inherit;"
"cursor:pointer;"
"cursor:pointer"
"}"
".luxbar-item{"
"height:58px;"
"height:58px"
"}"
".luxbar-item a{"
"padding:18px 24px 18px 24px;"
"display:block;"
"display:block"
"}"
".luxbar-burger{"
"padding:18px 24px 18px 24px;"
"position:relative;"
"cursor:pointer;"
"cursor:pointer"
"}"
".luxbar-burger span::before,"
".luxbar-burger span::after{"
"content:'';"
"position:absolute;"
"position:absolute"
"}"
".luxbar-burger span::before{"
"margin-top:-8px;"
"margin-top:-8px"
"}"
".luxbar-burger span::after{"
"margin-top:8px;"
"margin-top:8px"
"}"
".luxbar-checkbox{"
"display:none;"
"display:none"
"}"
".luxbar-checkbox:not(:checked)~.luxbar-menu{"
"overflow:hidden;"
"height:58px;"
"height:58px"
"}"
".luxbar-checkbox:checked~.luxbar-menu{"
"transition:height 0.6s ease;"
"height:100vh;"
"overflow:auto;"
"overflow:auto"
"}"
".dropdown{"
"position:relative;"
"height:auto;"
"min-height:58px;"
"min-height:58px"
"}"
".dropdown:hover>ul{"
"position:relative;"
"display:block;"
"min-width:100%;"
"min-width:100%"
"}"
".dropdown>a::after{"
"position:absolute;"
@ -433,23 +437,23 @@ const char AutoConnect::_CSS_LUXBAR[] PROGMEM = {
"top:25px;"
"border-width:5px 5px 0;"
"border-color:transparent;"
"border-style:solid;"
"border-style:solid"
"}"
".dropdown>ul{"
"display:block;"
"overflow-x:hidden;"
"list-style:none;"
"padding:0;"
"padding:0"
"}"
".dropdown>ul .luxbar-item{"
"min-width:100%;"
"height:29px;"
"padding:5px 10px 5px 40px;"
"padding:5px 10px 5px 40px"
"}"
".dropdown>ul .luxbar-item a{"
"min-height:29px;"
"line-height:29px;"
"padding:0;"
"padding:0"
"}"
"@media screen and (min-width:768px){"
".luxbar-navigation{"
@ -491,10 +495,10 @@ const char AutoConnect::_CSS_LUXBAR[] PROGMEM = {
"}"
"}"
".luxbar-checkbox:checked+.luxbar-menu .luxbar-burger-doublespin span::before{"
"transform:rotate(225deg);"
"transform:rotate(225deg)"
"}"
".luxbar-checkbox:checked+.luxbar-menu .luxbar-burger-doublespin span::after{"
"transform:rotate(-225deg);"
"transform:rotate(-225deg)"
"}"
".luxbar-menu-material,"
".luxbar-menu-material .dropdown ul{"
@ -686,7 +690,7 @@ const char AutoConnect::_PAGE_CONFIGNEW[] PROGMEM = {
"<label for=\"passphrase\">Passphrase</label>"
"<input id=\"passphrase\" type=\"password\" name=\"" AUTOCONNECT_PARAMID_PASS "\" placeholder=\"Passphrase\">"
"</li>"
"<br><li><input type=\"submit\" value=\"apply\"></li>"
"<br><li><input type=\"submit\" value=\"Apply\"></li>"
"</ul>"
"</form>"
"</div>"

@ -2,8 +2,8 @@
* The default upload handler implementation.
* @file AutoConnectUploadImpl.h
* @author hieromon@gmail.com
* @version 0.9.8
* @date 2019-03-19
* @version 0.9.9
* @date 2019-05-25
* @copyright MIT license.
*/
@ -81,6 +81,7 @@ class AutoConnectUploadFS : public AutoConnectUploadHandler {
_file = _media->open(filename, mode);
return _file != false;
}
AC_DBG("SPIFFS mount failed\n");
return false;
}
@ -102,6 +103,27 @@ class AutoConnectUploadFS : public AutoConnectUploadHandler {
SPIFileT _file;
};
// Fix to be compatibility with backward for ESP8266 core 2.5.1 or later
// SD pin assignment for AutoConnectFile
#ifndef AUTOCONNECT_SD_CS
#if defined(ARDUINO_ARCH_ESP8266)
#ifndef SD_CHIP_SELECT_PIN
#define SD_CHIP_SELECT_PIN SS
#endif
#define AUTOCONNECT_SD_CS SD_CHIP_SELECT_PIN
#elif defined(ARDUINO_ARCH_ESP32)
#define AUTOCONNECT_SD_CS SS
#endif
#endif // !AUTOCONNECT_SD_CS
// Derivation of SCK frequency and ensuring SD.begin compatibility
#ifdef ARDUINO_ARCH_ESP8266
#if defined(SD_SCK_HZ)
#define AC_SD_SPEED(s) SD_SCK_HZ(s)
#else
#define AC_SD_SPEED(s) s
#endif
#endif
// Default handler for uploading to the standard SD class embedded in the core.
class AutoConnectUploadSD : public AutoConnectUploadHandler {
public:
@ -110,16 +132,52 @@ class AutoConnectUploadSD : public AutoConnectUploadHandler {
protected:
bool _open(const char* filename, const char* mode) override {
const char* sdVerify;
#if defined(ARDUINO_ARCH_ESP8266)
if (_media->begin(_cs, _speed)) {
if (_media->begin(_cs, AC_SD_SPEED(_speed))) {
uint8_t oflag = *mode == 'w' ? FILE_WRITE : FILE_READ;
uint8_t sdType = _media->type();
switch (sdType) {
case 1: // SD_CARD_TYPE_SD1
sdVerify = (const char*)"MMC";
break;
case 2: // SD_CARD_TYPE_SD2
sdVerify = (const char*)"SDSC";
break;
case 3: // SD_CARD_TYPE_SDHC
sdVerify = (const char*)"SDHC";
break;
default:
sdVerify = (const char*)"UNKNOWN";
break;
}
#elif defined(ARDUINO_ARCH_ESP32)
if (_media->begin(_cs, SPI, _speed)) {
const char* oflag = mode;
uint8_t sdType = _media->cardType();
switch (sdType) {
case CARD_NONE:
sdVerify = (const char*)"No card";
break;
case CARD_MMC:
sdVerify = (const char*)"MMC";
break;
case CARD_SD:
sdVerify = (const char*)"SDSC";
break;
case CARD_SDHC:
sdVerify = (const char*)"SDHC";
break;
default:
sdVerify = (const char*)"UNKNOWN";
break;
}
#endif
AC_DBG("%s mounted\n", sdVerify);
_file = _media->open(filename, oflag);
return _file != false;
}
AC_DBG("SD mount failed\n");
return false;
}
@ -142,7 +200,7 @@ class AutoConnectUploadSD : public AutoConnectUploadHandler {
SDClassT* _media;
SDFileT _file;
uint8_t _cs;
uint8_t _speed;
uint32_t _speed;
};
#endif // !_AUTOCONNECTUPLOADIMPL_H_

Loading…
Cancel
Save