diff --git a/FAQ.md b/FAQ.md deleted file mode 100644 index 04479735e..000000000 --- a/FAQ.md +++ /dev/null @@ -1,197 +0,0 @@ -# Arduino Library Manager FAQ - -## Table of Contents - - - -- [General](#general) - - [What is the Arduino Library Manager?](#what-is-the-arduino-library-manager) - - [How is the Library Manager index generated?](#how-is-the-library-manager-index-generated) -- [Submission](#submission) - - [How can I add a library to Library Manager?](#how-can-i-add-a-library-to-library-manager) - - [What are the requirements for a library to be added to Library Manager?](#what-are-the-requirements-for-a-library-to-be-added-to-library-manager) - - [Who is allowed to add a library to Library Manager?](#who-is-allowed-to-add-a-library-to-library-manager) -- [Updates](#updates) - - [How can I publish a new release once my library is in the list?](#how-can-i-publish-a-new-release-once-my-library-is-in-the-list) - - [What are the requirements for publishing new releases of libraries already in the Library Manager list?](#what-are-the-requirements-for-publishing-new-releases-of-libraries-already-in-the-library-manager-list) - - [Why aren't releases of my library being picked up by Library Manager?](#why-arent-releases-of-my-library-being-picked-up-by-library-manager) - - [Can I check on library releases being added to Library Manager?](#can-i-check-on-library-releases-being-added-to-library-manager) - - [How can I remove a release of my library from Library Manager?](#how-can-i-remove-a-release-of-my-library-from-library-manager) - - [How can I change a library's name?](#how-can-i-change-a-librarys-name) -- [Limitations](#limitations) - - [Is my Git repository OK?](#is-my-git-repository-ok) - - [Are Git submodules supported?](#are-git-submodules-supported) -- [Usage](#usage) - - [Can I add my own URL with my own library index?](#can-i-add-my-own-url-with-my-own-library-index) - - [When I install a library that I know depends on another library, will this other library be installed as well?](#when-i-install-a-library-that-i-know-depends-on-another-library-will-this-other-library-be-installed-as-well) - - [Can I install multiple versions of one library and use the proper one in my sketches?](#can-i-install-multiple-versions-of-one-library-and-use-the-proper-one-in-my-sketches) - - [How can I remove a library I installed via Library Manager?](#how-can-i-remove-a-library-i-installed-via-library-manager) - - - -## General - -### What is the Arduino Library Manager? - -Library Manager is a feature of the Arduino development software which makes it easy for users to find, install, and update both official and 3rd party libraries. - -- In the Arduino IDE: **Sketch > Include Library > Manage Libraries...** -- In Arduino CLI: `arduino-cli lib --help` -- In Arduino Web Editor: all Library Manager libraries are pre-installed. - -When a library is [added to the library list](README.md#adding-a-library-to-library-manager), every release of the library will automatically be made available for installation via Library Manager. Users can set their preferences to display an update notification when a new version of any installed library on the list is available and easily update to the new version with just a couple clicks. - -More information: - -- https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries#using-the-library-manager -- https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_lib/ -- https://create.arduino.cc/projecthub/Arduino_Genuino/getting-started-with-arduino-web-editor-on-various-platforms-4b3e4a - -### How is the Library Manager index generated? - -[The Library Manager index](http://downloads.arduino.cc/libraries/library_index.json) contains the data for every release of every one of the thousands of libraries that have been added to the Library Manager list. This index is used by Library Manager to provide installation and updates of the libraries as well as to generate automated documentation pages for the [Arduino Library Reference](https://www.arduino.cc/reference/en/libraries/). - -Every hour, the automated Library Manager indexer system: - -1. checks every repository in the Library Manager list for new tags, updating [the logs](#can-i-check-on-library-releases-being-added-to-library-manager) accordingly -1. checks whether those tags meet [the requirements for addition to the index](#update-requirements) -1. adds entries to the index for compliant tags -1. pushes the updated index to Arduino's download server - -## Submission - - - -### How can I add a library to Library Manager? - -Follow the instructions [here](README.md#adding-a-library-to-library-manager). - - - -### What are the requirements for a library to be added to Library Manager? - -- [ ] The library must be fully compliant with the [Arduino Library Specification](https://arduino.github.io/arduino-cli/latest/library-specification). -- [ ] The library must have [a library.properties file](https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata), in compliance with the Arduino Library 1.5 format. -- [ ] The library.properties file must be located in the root of the repository. -- [ ] The library must not have the same library.properties `name` value (regardless of case) as another library previously added to the Library Manager list. -- [ ] For 3rd party libraries, the `name` field in library.properties must not start with `Arduino`. -- [ ] The library repository must not contain any `.exe` files. -- [ ] The library repository must not contain a [`.development` file](https://arduino.github.io/arduino-cli/latest/library-specification/#development-flag-file). -- [ ] The library repository must not contain any [symlinks](https://wikipedia.org/wiki/Symbolic_link). -- [ ] The library repository must not contain any files detected as infected by our antivirus scan. -- [ ] The library repository must have a [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) (or [release](https://docs.github.com/repositories/releasing-projects-on-github/managing-releases-in-a-repository)) and must have been compliant with all the above requirements at the time of that tag. -- [ ] The library repository must be hosted on a major Git-hosting website like GitHub, BitBucket or GitLab (other hosting sites may be considered on request). - -Arduino has created a command line tool to check libraries for compliance with all the Library Manager requirements: - -https://github.com/arduino/arduino-lint - -Arduino Lint is also available as a GitHub Actions action that can be used in the CI systems of Arduino library repositories to ensure continued compliance: - -https://github.com/arduino/arduino-lint-action - -### Who is allowed to add a library to Library Manager? - -Everyone is welcome to submit libraries for inclusion in Library Manager, regardless of whether you are involved in the library's development. - -Note that libraries will need to be compliant with [all requirements](#update-requirements) in order to be accepted. If not, you will need to work with the library maintainer to achieve compliance. - -## Updates - -### How can I publish a new release once my library is in the list? - -1. Make sure the library is compliant with [all requirements](#update-requirements). -1. Update the `version` in the library's [`library.properties`](https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata)). -1. Tag the library's repository once more and push the new tag (or create a release if the library's Git-hosting site offers a way to do it, for example with [GitHub "releases"](https://docs.github.com/repositories/releasing-projects-on-github/managing-releases-in-a-repository)). - -[Our indexer](#how-is-the-library-manager-index-generated) checks for new releases every hour and will eventually fetch and publish the new release. - - - -### What are the requirements for publishing new releases of libraries already in the Library Manager list? - -- [ ] The library must be compliant with all the same [requirements that apply to submissions](#submission-requirements). -- [ ] The `name` property in library.properties must not have changed from the value it had when the library was submitted. If you must change the library name, see [this](#how-can-i-change-my-librarys-name). -- [ ] The `version` property in library.properties must not be the same as it was in a tag previously added to the Library Manager index. - -### Why aren't releases of my library being picked up by Library Manager? - -The Library Manager indexer job will reject any releases which aren't compliant with all [the requirements](#update-requirements). - -You can check [the indexer logs](#can-i-check-on-library-releases-being-added-to-library-manager) for information about what happened. - -### Can I check on library releases being added to Library Manager? - -There is a dedicated web page for each library that shows the logs from the Library Manager indexer. The URL of the logs page is based on the library's repository URL: - -``` -http://downloads.arduino.cc/libraries/logs/// -``` - -For example, the Servo library is hosted at https://github.com/arduino-libraries/Servo, so its logs are at: - -http://downloads.arduino.cc/libraries/logs/github.com/arduino-libraries/Servo/ - - - -### How can I remove a release of my library from Library Manager? - -If you discover a problem with the library release, simply fix the problem and make a new [release](#how-can-i-publish-a-new-release-once-my-library-is-in-the-list). Library Manager defaults to installing the latest version of the library and offers updates to those with an older version installed, so this is the fastest and most effective method for distributing a fix to the users. - -In the event a library release is later discovered to contain something that absolutely can not be published, we do allow removing releases from Library Manager on request by the following procedure: - -1. Delete the [tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of the problematic release from the library's repository. -1. Open an issue [here](https://github.com/arduino/library-registry/issues/new?labels=topic%3A+release+removal&template=release-removal.yml&title=Library+release+removal+request), specifying the name of the library and the version number of the release that should be removed. - - - -### How can I change a library's name? - -For the sake of continuity, libraries in the Library Manager list are locked to the name they had at the time they were added to the list. Changing the library name can be disruptive to its users because this is the unique identifier for the library used by the Arduino development software [command line interfaces](https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_lib/), sketch [metadata](https://arduino.github.io/arduino-cli/latest/sketch-specification/#metadata), library [dependencies](https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format), and installation location. - -If you wish to change the name it will need to be done manually by request: - -1. Change the `name` value in the [library.properties file](https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format) and update the `version`. -1. Create a release or tag. -1. Open an issue [here](https://github.com/arduino/library-registry/issues/new?labels=topic%3A+rename&template=rename.yml&title=Library+name+change+request) specifying the URL of the library's repository. - -## Limitations - -### Is my Git repository OK? - -Your repo is OK if it meets all [the requirements listed here](#submission-requirements). - -### Are Git submodules supported? - -No. The library archive distributed by Library Manager will only contain an empty folder where the submodule should be. - -## Usage - -### Can I add my own URL with my own library index? - -No. At the moment, the Arduino development software handles one URL only, and that's written into the code (dev jargon: it's hardcoded), this is a known limitation. -However, if you know your way through the code, you can change that URL with another one. - -### When I install a library that I know depends on another library, will this other library be installed as well? - -As of Arduino IDE 1.8.10 and Arduino CLI 0.7.0, you can specify the dependencies of a library in the `depends` field of library.properties. Those libraries can be installed automatically when someone installs that library via Library Manager. - -For more information, see the [`library.properties` file format documentation](https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format). - -### Can I install multiple versions of one library and use the proper one in my sketches? - -Library Manager installs libraries into your sketchbook's `libraries` folder. Since you cannot create two folders with the same name, we can't install two versions of the same library. However, you can switch between library versions by selecting the appropriate one from the version dropdown that pops up on Library Manager when more than one version is available. - -### How can I remove a library I installed via Library Manager? - -#### Arduino IDE 2.x - -Hover the mouse pointer over the INSTALLED label on the library listing in Library Manager. It will now change to UNINSTALL, which you can click to uninstall that library. - -#### Classic Arduino IDE - -This version of the Arduino IDE does not have an integrated uninstall functionality, so you will need to remove the library manually. Open your sketchbook's `libraries` folder with your operating system's file explorer (Windows: Explorer, Mac: Finder, Linux: Nautilus, kfiles...) and delete the folder containing the library. - -#### Arduino CLI - -Libraries can be uninstalled via [the `arduino-cli lib uninstall` command](https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_lib_uninstall/). diff --git a/LICENSE.txt b/LICENSE.txt index 0e259d42c..41df76a65 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,121 +1,21 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. +The MIT License (MIT) + +Copyright (c) 2015 tzapu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 4fdadf91e..a3cd534e2 100644 --- a/README.md +++ b/README.md @@ -1,120 +1,5 @@ -# Arduino Library Manager list +# Config Portal 32 -This repository contains the list of libraries in the -[Arduino Library Manager](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries#using-the-library-manager) index. +With this library, the developer can create a WiFi connected device with ESP32 easily without the hard coding of the SSID/PW. -## Table of Contents - - - -- [Frequently asked questions](#frequently-asked-questions) -- [Adding a library to Library Manager](#adding-a-library-to-library-manager) - - [Instructions](#instructions) - - [If the problem is with the pull request:](#if-the-problem-is-with-the-pull-request) - - [If the problem is with the library:](#if-the-problem-is-with-the-library) -- [Changing the URL of a library already in Library Manager](#changing-the-url-of-a-library-already-in-library-manager) -- [Removing a library from Library Manager](#removing-a-library-from-library-manager) -- [Report a problem with Library Manager](#report-a-problem-with-library-manager) - - - -## Frequently asked questions - -For more information about Arduino Library Manager and how the index is maintained, please see [the FAQ](FAQ.md). - -## Adding a library to Library Manager - -If you would like to make a library available for installation via Library Manager, just submit a -[pull request](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests) -that adds the repository URL to [the list](repositories.txt). You are welcome to add multiple libraries at once. - -See the instructions below for detailed instructions on how to do this via the GitHub web interface. - -### Instructions - -1. You may want to first take a look at - [the requirements for admission into the Arduino Library Manager index](FAQ.md#submission-requirements). Each submission will be checked for - compliance before being accepted. -1. Click the following link:
- https://github.com/arduino/library-registry/fork
- The "**Create a new fork**" page will open. -1. Click the Create fork button in the "**Create a new fork**" page.
- A "**Forking arduino/library-registry**" page will open while the fork is in the process of being created. -1. Wait for the "Forking" process to finish.
- The home page of your [fork](https://docs.github.com/get-started/quickstart/fork-a-repo) of the **library-registry** repository will open. -1. Click on the file `repositories.txt` under the list of files you see in that page.
- The "**library-registry/repositories.txt**" page will open. -1. Click the pencil icon ("Edit this file") at the right side of the toolbar in the "**library-registry/repositories.txt**" page.
- The `repositories.txt` file will open in the online text editor. -1. Add the library repository's URL to the list (it doesn't matter where in the list). This should be the URL of the repository home page. For example: - `https://github.com/arduino-libraries/Servo` -1. Click the Commit changes... button located near the top right corner of the page.
- The "**Commit changes**" dialog will open. -1. Click the Commit changes button in the "**Commit changes**" dialog.
- The "**library-registry/repositories.txt**" page will open. -1. Click the "**library-registry**" link at the top of the "**library-registry/repositories.txt**" page.
- The home page of your fork of the **library-registry** repository will open. -1. You should see a banner on the page that says: - - > **This branch is 1 commit ahead of arduino:main.** - - Click the "**Contribute**" link near the right side of that banner.
- A menu will open. - -1. Click the Open pull request button in the menu.
- The "**Open a pull request**" page will open. -1. In the **"Open a pull request"** window that opens, click the Create pull request button. - -The library will be automatically checked for compliance as soon as the pull request is submitted. If no problems were -found, the pull request will be immediately merged and the library will be available for installation via Library -Manager within a day's time. - -If any problems are found, a bot will comment on the pull request to tell you what is wrong. The problem may be either -with your pull request or with the library. - -#### If the problem is with the pull request: - -Edit the file in the -[branch](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches) -you submitted the pull request from in your fork of the `arduino/library-registry` repository, then commit. - -Doing this will update the pull request and cause the automated checks to run again. - -#### If the problem is with the library: - -1. Make the necessary fix in the library repository. -1. Increment the `version` value in the library's - [library.properties file](https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata). -1. Create a - [release](https://docs.github.com/repositories/releasing-projects-on-github/managing-releases-in-a-repository) - or [tag](https://git-scm.com/docs/git-tag). The Library Manager index always uses tagged versions of the libraries, - so even if the development version of the library is compliant, it can't be accepted until the latest release or tag - is compliant. Alternatively, you can redo the existing release/tag if you prefer. -1. Comment on your pull request here in the `arduino/library-registry` repository, mentioning **@ArduinoBot** in the - comment. Doing this will cause the automated check to run again. - -## Changing the URL of a library already in Library Manager - -Submit a pull request that changes the URL as desired in [repositories.txt](repositories.txt). This can be done by -following [the instructions above](#instructions). - -Since this type of request must be reviewed by a human maintainer, please write an explanation in the pull request -description, making it clear that the URL is intentionally being changed. - -## Removing a library from Library Manager - -Submit a pull request that removes the URL from [repositories.txt](repositories.txt). This can be done by following -[the instructions above](#instructions). - -Since this type of request must be reviewed by a human maintainer, please write an explanation in the pull request -description, making it clear that the URL is intentionally being removed. - -## Report a problem with Library Manager - -First, please take a look at [the FAQ](FAQ.md). If a library release is missing from Library Manager, it is usually -because it was not compliant with all [the requirements](FAQ.md#update-requirements) listed in that document. - -This repository is not an appropriate place to request support or report problems with a library. Check the library's -own documentation for instructions or ask on the [Arduino Forum](https://forum.arduino.cc/). - -If the problem is about something else, please submit an issue report [here](https://github.com/arduino/library-registry/issues/new/choose). +This is a porting of ConfigPortal8266(https://github.com/yhur/ConfigPortal8266) to ESP32. Please refer to ConfigPortal8266 for the usage and explanation for now. diff --git a/example/data/config.json b/example/data/config.json new file mode 100644 index 000000000..f9462b0a8 --- /dev/null +++ b/example/data/config.json @@ -0,0 +1,7 @@ +{ + "meta": { + }, + "ssid": "IoT518", + "w_pw": "iot123456", + "config": "done" +} \ No newline at end of file diff --git a/example/data/postSave.html b/example/data/postSave.html new file mode 100644 index 000000000..2201f1cec --- /dev/null +++ b/example/data/postSave.html @@ -0,0 +1,4 @@ +Custom Reboot Device +
You can configure this page with the postSave.html
Click the Reboot Button
+

+

\ No newline at end of file diff --git a/example/platformio.ini b/example/platformio.ini new file mode 100644 index 000000000..c5842613f --- /dev/null +++ b/example/platformio.ini @@ -0,0 +1,28 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32doit-devkit-v1] +platform = https://github.com/platformio/platform-espressif32.git +board = esp32dev +framework = arduino +build_flags = + -D MQTT_MAX_PACKET_SIZE=512 +lib_deps = + bblanchon/ArduinoJson@^6.18.3 + knolleary/PubSubClient@^2.8 + https://github.com/yhur/IBMIOTF32.git +board_build.filesystem=littlefs +debug_tool = esp-prog +debug_init_break = tbreak setup +monitor_port = /dev/cu.usbserial-019ABF2B +monitor_speed = 115200 +upload_speed = 921000 +upload_port = /dev/cu.usbserial-019ABF2B +upload_protocol = esptool diff --git a/example/src/main.cpp b/example/src/main.cpp new file mode 100644 index 000000000..402aa70d0 --- /dev/null +++ b/example/src/main.cpp @@ -0,0 +1,47 @@ +#include +//#include +#include +#include + +char* ssid_pfix = (char*)"CaptivePortal"; +String user_config_html = ""; +/* + * ConfigPortal library to extend and implement the WiFi connected IOT device + * + * Yoonseok Hur + * + * Usage Scenario: + * 0. copy the example template in the README.md + * 1. Modify the ssid_pfix to help distinquish your Captive Portal SSID + * char ssid_pfix[]; + * 2. Modify user_config_html to guide and get the user config data through the Captive Portal + * String user_config_html; + * 2. declare the user config variable before setup + * 3. In the setup(), read the cfg["meta"]["your field"] and assign to your config variable + * + */ + +void setup() { + Serial.begin(115200); + + loadConfig(); + // *** If no "config" is found or "config" is not "done", run configDevice *** + if(!cfg.containsKey("config") || strcmp((const char*)cfg["config"], "done")) { + configDevice(); + } + WiFi.mode(WIFI_STA); + WiFi.begin((const char*)cfg["ssid"], (const char*)cfg["w_pw"]); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + // main setup + Serial.printf("\nIP address : "); Serial.println(WiFi.localIP()); + + if (MDNS.begin("miniwifi")) { + Serial.println("MDNS responder started"); + } +} + +void loop() { +} \ No newline at end of file diff --git a/library.properties b/library.properties new file mode 100644 index 000000000..da55a4e77 --- /dev/null +++ b/library.properties @@ -0,0 +1,9 @@ +name=ConfigPortal32 +version=0.1.0 +author=yhur +maintainer=yhur +sentence=Configuration Web Portal for ESP32 +paragraph=Configuration Web Portal for ESP32 +category=Communication +url=https://github.com/yhur/ConfigPortal32 +architectures=esp32 \ No newline at end of file diff --git a/repositories.txt b/repositories.txt index bda6f9fc0..853ea88af 100644 --- a/repositories.txt +++ b/repositories.txt @@ -6577,3 +6577,4 @@ https://github.com/PU2REO/PU2REO_AD9851 https://github.com/pk17r/PushButtonTaps https://github.com/PaulNTU/Wizibot_VescMotorController https://github.com/alekseizarubin/CD22M3494EZ +https://github.com/yhur/ConfigPortal32 \ No newline at end of file diff --git a/src/ConfigPortal32.h b/src/ConfigPortal32.h new file mode 100644 index 000000000..f78a48d96 --- /dev/null +++ b/src/ConfigPortal32.h @@ -0,0 +1,208 @@ +/* + * ConfigPortal library to extend and implement the WiFi connected IOT device + * + * Yoonseok Hur + * + * Usage Scenario: + * 0. copy the example template in the README.md + * 1. Modify the ssid_pfix to help distinquish your Captive Portal SSID + * char ssid_pfix[]; + * 2. Modify user_config_html to guide and get the user config data through the Captive Portal + * String user_config_html; + * 2. declare the user config variable before setup + * 3. In the setup(), read the cfg["meta"]["your field"] and assign to your config variable + * + */ +#include +#include +#include +#include +#include + +#define JSON_BUFFER_LENGTH 3072 +#define JSON_CHAR_LENGTH 1024 +StaticJsonDocument cfg; + +WebServer webServer(80); +const int RESET_PIN = 0; + +char cfgFile[] = "/config.json"; + +extern String user_config_html; +extern char *ssid_pfix; + +String html_begin = "" + "IOT Device Setup" + "

Device Setup Page

" + "" + "
" + "

" + "

"; + +String html_end = "" + "

" + "

" + "
"; + +String postSave_html_default = "" + "Reboot Device" + "
Device Configuration Finished
Click the Reboot Button
" + "

" + "

"; + +String redirect_html = "" + "" + "

Redirecting"; + +String postSave_html; + +void (*userConfigLoop)() = NULL; + +void byte2buff(char* msg, byte* payload, unsigned int len) { + unsigned int i, j; + for (i=j=0; i < len ;) { + msg[j++] = payload[i++]; + } + msg[j] = '\0'; +} + +void save_config_json(){ + File f = LittleFS.open(cfgFile, "w"); + serializeJson(cfg, f); + f.close(); +} + +void reset_config() { + deserializeJson(cfg, "{meta:{}}"); + save_config_json(); +} + +void maskConfig(char* buff) { + DynamicJsonDocument temp_cfg = cfg; + if(cfg.containsKey("w_pw")) temp_cfg["w_pw"] = "********"; + if(cfg.containsKey("token")) temp_cfg["token"] = "********"; + serializeJson(temp_cfg, buff, JSON_CHAR_LENGTH); +} + +IRAM_ATTR void reboot() { + WiFi.disconnect(); + ESP.restart(); +} + +void loadConfig() { + // check Factory Reset Request and reset if requested or load the config + if(!LittleFS.begin()) { LittleFS.format(); } // before the reset_config and reading + + pinMode(RESET_PIN, INPUT_PULLUP); + if( digitalRead(RESET_PIN) == 0 ) { + unsigned long t1 = millis(); + while(digitalRead(RESET_PIN) == 0) { + delay(500); + Serial.print("."); + } + if (millis() - t1 > 5000) { + reset_config(); // Factory Reset + } + } + attachInterrupt(RESET_PIN, reboot, FALLING); + + if (LittleFS.exists(cfgFile)) { + String buff; + File f = LittleFS.open(cfgFile, "r"); + DeserializationError error = deserializeJson(cfg, f.readString()); + f.close(); + + if (error) { + deserializeJson(cfg, "{meta:{}}"); + } else { + Serial.println("CONFIG JSON Successfully loaded"); + char maskBuffer[JSON_CHAR_LENGTH]; + maskConfig(maskBuffer); + Serial.println(String(maskBuffer)); + } + } else { + deserializeJson(cfg, "{meta:{}}"); + } +} + +void saveEnv() { + int args = webServer.args(); + for (int i = 0; i < args ; i++){ + if (webServer.argName(i).indexOf(String("meta.")) == 0 ) { + String temp = webServer.arg(i); + temp.trim(); + cfg["meta"][webServer.argName(i).substring(5)] = temp; + } else { + String temp = webServer.arg(i); + temp.trim(); + cfg[webServer.argName(i)] = temp; + } + } + cfg["config"] = "done"; + save_config_json(); + // redirect uri augmentation here + // + webServer.send(200, "text/html", redirect_html); +} + +void pre_reboot() { + int args = webServer.args(); + for (int i = 0; i < args ; i++){ + Serial.printf("%s -> %s\n", webServer.argName(i).c_str(), webServer.arg(i).c_str()); + } + webServer.send(200, "text/html", postSave_html); +} + +bool getHTML(String* html, char* fname) { + if (LittleFS.exists(fname)) { + String buff; + File f = LittleFS.open(fname, "r"); + buff = f.readString(); + buff.trim(); + f.close(); + *html = buff; + return true; + } else { + return false; + } +} + +void configDevice() { + DNSServer dnsServer; + const byte DNS_PORT = 53; + IPAddress apIP(192, 168, 1, 1); + WiFi.mode(WIFI_AP); + WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); + char ap_name[100]; + sprintf(ap_name, "%s_%08X", ssid_pfix, (unsigned int)ESP.getEfuseMac()); + WiFi.softAP(ap_name); + dnsServer.start(DNS_PORT, "*", apIP); + + if (getHTML(&postSave_html, (char*)"/postSave.html")) { + // argument redirection + } else { + postSave_html = postSave_html_default; + } + + webServer.on("/save", saveEnv); + webServer.on("/reboot", reboot); + webServer.on("/pre_boot", pre_reboot); + + webServer.onNotFound([]() { + webServer.send(200, "text/html", html_begin + user_config_html + html_end); + }); + webServer.begin(); + Serial.println("starting the config"); + while(1) { + yield(); + dnsServer.processNextRequest(); + webServer.handleClient(); + if(userConfigLoop != NULL) { + (*userConfigLoop)(); + } + } +} \ No newline at end of file