mirror of https://github.com/arendst/Tasmota.git
parent
54c2eb283a
commit
d85278f1b2
|
@ -4,31 +4,61 @@ about: Create a report to help us improve
|
|||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
<GUIDE>
|
||||
|
||||
<This BUG issue template is meant to REPORT Tasmota software BUGS ONLY>
|
||||
|
||||
<Please DO NOT OPEN AN ISSUE:>
|
||||
<If your Tasmota version is not the latest, please update before posting. Your issue might be already solved. Latest precompiled bins of Tasmota can be downloaded from http://thehackbox.org/tasmota/>
|
||||
<If your issue is a flashing issue, please address that to the Tasmota Support Chat>
|
||||
<If your issue is compilation problem, please address that to the Tasmota Support Chat>
|
||||
<If your issue has been addresed before (duplicated issue), please ask in the original issue>
|
||||
<If your issue is wifi problem or mqtt problem, please try first the steps provided in troubleshooting of the wiki>
|
||||
|
||||
### BUG DESCRIPTION
|
||||
_A clear and concise description of what the bug is._
|
||||
|
||||
|
||||
_Also, make sure these boxes are checked [x] before submitting your issue - Thank you!_
|
||||
- [ ] _Searched the problem in issues and in the wiki_
|
||||
- [ ] _Hardware used_ :
|
||||
- [ ] _Provide the output of command_``status 0`` :
|
||||
### REQUESTED INFORMATION
|
||||
_Make sure these boxes are checked before submitting your issue. Thank you_
|
||||
|
||||
**FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED**
|
||||
|
||||
- [ ] Read the [Contributing Guide and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) and [the Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md)
|
||||
- [ ] Searched the problem in issues (https://github.com/arendst/Sonoff-Tasmota/issues)
|
||||
- [ ] Searched the problem in the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting)
|
||||
- [ ] Searched the problem in the forum (https://groups.google.com/d/forum/sonoffusers)
|
||||
- [ ] Searched the problem in the chat (https://discord.gg/Ks2Kzd4)
|
||||
- [ ] Device used (i.e. Sonoff Basic) : _____
|
||||
- [ ] Tasmota binary firmware version number used : ____ / (pre-compiled or self-compiled ?)
|
||||
- [ ] Development IDE - Compiler / Upload tools used : ____ / ____
|
||||
- [ ] Provide the output of command ``status 0`` :
|
||||
```
|
||||
STATUS 0 OUTPUT HERE
|
||||
STATUS 0 OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
- [ ] Provide the output of console when you experience your issue if apply :
|
||||
_(Please use_ ``weblog 4`` _for more debug information)_
|
||||
```
|
||||
CONSOLE OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
|
||||
**To Reproduce**
|
||||
### TO REPRODUCE
|
||||
_Steps to reproduce the behavior:_
|
||||
|
||||
|
||||
**Expected behavior**
|
||||
### EXPECTED BEHAVIOUR
|
||||
_A clear and concise description of what you expected to happen._
|
||||
|
||||
|
||||
**Screenshots**
|
||||
### SCREENSHOTS
|
||||
_If applicable, add screenshots to help explain your problem._
|
||||
|
||||
|
||||
**Additional context**
|
||||
### ADDITIONAL CONTEXT
|
||||
_Add any other context about the problem here._
|
||||
|
||||
|
||||
|
|
|
@ -4,16 +4,47 @@ about: Users Troubleshooting Help
|
|||
|
||||
---
|
||||
|
||||
Make sure these boxes are checked [x] before submitting your issue - Thank you!
|
||||
<GUIDE>
|
||||
|
||||
<This troubleshooting issue template is meant to help Tasmota users with difficult problems. It is aimed to be opened if using the wiki and the support chat could not solve the issue. The Github Issue tracker is NOT a general discussion forum>
|
||||
|
||||
<Please DO NOT OPEN AN ISSUE:>
|
||||
<If you have general questions or you need help on Tasmota usage, go to the Tasmota support chat>
|
||||
<If your Tasmota version is not the latest, please update before posting. Your issue might be already solved. Latest precompiled bins of Tasmota can be downloaded from http://thehackbox.org/tasmota/>
|
||||
<If your issue is a new device, please use the Tasmota Template Feature. See wiki for that>
|
||||
<If your issue is a flashing issue, please address that to the Tasmota Support Chat>
|
||||
<If your issue is compilation problem, please address that to the Tasmota Support Chat>
|
||||
<If your issue has been addresed before (duplicated issue), please ask in the original issue>
|
||||
<If your issue is wifi problem or mqtt problem, please try first the steps provided in troubleshooting of the wiki>
|
||||
|
||||
### ISSUE DESCRIPTION - TROUBLESHOOTING
|
||||
_A clear description of what the issue is and be as extensive as possible_
|
||||
|
||||
|
||||
### REQUESTED INFORMATION
|
||||
_Make sure these boxes are checked before submitting your issue. Thank you_
|
||||
|
||||
**FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED**
|
||||
|
||||
- [ ] Read the [Contributing Guide and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) and [the Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md)
|
||||
- [ ] Searched the problem in issues (https://github.com/arendst/Sonoff-Tasmota/issues)
|
||||
- [ ] Searched the problem in the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting)
|
||||
- [ ] Searched the problem in the forum (https://groups.google.com/d/forum/sonoffusers)
|
||||
- [ ] Searched the problem in the chat (https://discord.gg/Ks2Kzd4)
|
||||
- [ ] Hardware used :
|
||||
- [ ] Device used (i.e. Sonoff Basic) : _____
|
||||
- [ ] Tasmota binary firmware version number used : ____ / (pre-compiled or self-compiled ?)
|
||||
- [ ] Development IDE - Compiler / Upload tools used : ____ / ____
|
||||
- [ ] Provide the output of command ``status 0`` :
|
||||
```
|
||||
STATUS 0 OUTPUT HERE
|
||||
```
|
||||
STATUS 0 OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
- [ ] Provide the output of console when you experience your issue if apply :
|
||||
_(Please use_ ``weblog 4`` _for more debug information)_
|
||||
```
|
||||
CONSOLE OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
**(Please, remember to close the issue when the problem has been addressed)**
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
## Description:
|
||||
|
||||
**Related issue (if applicable):** fixes #<Sonoff-Tasmota issue number goes here>
|
||||
|
||||
## Checklist:
|
||||
- [ ] The pull request is done against the dev branch
|
||||
- [ ] Only relevant files were touched (Also beware if your editor has auto-formatting feature enabled)
|
||||
- [ ] Only one feature/fix was added per PR.
|
||||
- [ ] The code change is tested and works.
|
||||
- [ ] The code change pass travis tests. **Your PR cannot be merged unless tests pass**
|
|
@ -1,9 +1,9 @@
|
|||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 45
|
||||
daysUntilStale: 25
|
||||
|
||||
# Number of days of inactivity before a stale Issue or Pull Request is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 15
|
||||
daysUntilClose: 5
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
|
@ -37,4 +37,4 @@ closeComment: >
|
|||
limitPerRun: 30
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
#only: issues
|
||||
|
|
2
API.md
2
API.md
|
@ -23,6 +23,8 @@ FUNC_JSON_APPEND | | | | x | | Extend tele
|
|||
FUNC_WEB_APPEND | | | | x | | Extend webgui ajax info
|
||||
FUNC_SAVE_BEFORE_RESTART | | | | x | | Just before a planned restart
|
||||
FUNC_COMMAND | x | | x | x | | When a command is not recognized
|
||||
FUNC_COMMAND_DRIVER | x | 6.4.1.21 | x | | | When command Driver\<id\> is executed
|
||||
FUNC_COMMAND_SENSOR | x | 6.4.1.21 | | x | | When command Sensor\<id\> is executed
|
||||
FUNC_MQTT_SUBSCRIBE | | 5.12.0k | x | | | At end of MQTT subscriptions
|
||||
FUNC_MQTT_INIT | | 5.12.0k | x | | | Once at end of MQTT connection
|
||||
FUNC_MQTT_DATA | x | 5.12.0k | x | | | Before decoding command
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at https://sidweb.nl/cms3/en/contact. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
|
@ -0,0 +1,63 @@
|
|||
# Contributing to Sonoff-Tasmota
|
||||
|
||||
**Any contribution helps our team and makes Tasmota better for the entire community!**
|
||||
|
||||
Everybody is welcome and invited to contribute to Sonoff-Tasmota Project by:
|
||||
|
||||
* Testing newly released features and reporting issues.
|
||||
* Providing Pull Requests (Features, Proof of Concepts, Language files or Fixes)
|
||||
* Contributing missing documentation for features and devices on our [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Contributing)
|
||||
|
||||
This document describes rules that are in effect for this repository, meant for handling issues by contributors in the issue tracker and PRs.
|
||||
|
||||
## Opening New Issues
|
||||
|
||||
**Issue tracker is NOT a general discussion forum!**
|
||||
1. Opening an issue means that a problem exists in the code and should be addressed by the project contributors.
|
||||
2. When opening an issue, it is required to fill out the presented template. The requested information is important! If the template is ignored or insufficient info about the issue is provided, the issue may be closed.
|
||||
3. Questions of type "How do I..." or "Can you please help me with..." or "Can Tasmota do..." WILL NOT be handled here. Such questions should be directed at a discussion forum or to the Tasmota Support Chat. All issues of this type will be closed with a simple reference to this contributing policy.
|
||||
4. Issues about topics already handled in the documentation will be closed in a similar manner.
|
||||
5. Issues for unmerged PRs will be closed. If there is an issue with a PR, the explanation should be added to the PR itself.
|
||||
6. Issues with accompanied investigation that shows the root of the problem should be given priority.
|
||||
7. Duplicate issues will be closed.
|
||||
|
||||
## Triaging of Issues/PR's
|
||||
|
||||
1. Any contributor to the project can participate in the triaging process, if he/she chooses to do so.
|
||||
2. An issue that needs to be closed, either due to not complying with this policy, or for other reasons, should be closed by a contributor.
|
||||
3. Issues that are accepted should be marked with appropriate labels.
|
||||
4. Issues that could impact functionality for many users should be considered severe.
|
||||
5. Issues caused by the SDK or chip should not be marked severe, as there usually isn’t much to be done. Common sense should be applied when deciding. Such issues should be documented in the Wiki, for reference by users.
|
||||
6. Issues with feature requests should be discussed for viability/desirability.
|
||||
7. Feature requests or changes that are meant to address a very specific/limited use case, especially if at the expense of increased code complexity, may be denied, or may be required to be redesigned, generalized, or simplified.
|
||||
8. Feature requests that are not accompanied by a PR:
|
||||
* could be closed immediately (denied).
|
||||
* could be closed after some predetermined period of time (left as candidate for somebody to pick up).
|
||||
9. In some cases, feedback may be requested from the issue reporter, either as additional info for clarification, additional testing, or other. If no feedback is provided, the issue may be closed by a contributor or after 30 days by the STALE bot.
|
||||
|
||||
## Pull requests
|
||||
|
||||
A Pull Request (PR) is the process where code modifications are managed in GitHub.
|
||||
|
||||
The process is straight-forward.
|
||||
|
||||
- Read [How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews) by Kubernetes (but skip step 0)
|
||||
- Fork the Sonoff-Tasmota Repository [git repository](https://github.com/arendst/Sonoff-Tasmota).
|
||||
- Write/Change the code in your Fork for a new feature, bug fix, new sensor, optimization, etc.
|
||||
- Ensure tests work.
|
||||
- Create a Pull Request against the [**dev**](https://github.com/arendst/Sonoff-Tasmota/tree/dev) branch of Sonoff-Tasmota.
|
||||
|
||||
1. All pull requests must be done against the dev branch.
|
||||
2. Only relevant files should be touched (Also beware if your editor has auto-formatting feature enabled).
|
||||
3. Only one feature/fix should be added per PR.
|
||||
4. If adding a new functionality (new hardware, new library support) not related to an existing component move it to it's own modules (.ino file).
|
||||
5. PRs that don't compile (break Travis) or cause coding errors will not be merged. Please fix the issue. Same goes for PRs that are raised against older commit in dev - you might need to rebase and resolve conflicts.
|
||||
6. All pull requests should undergo peer review by at least one contributor other than the creator, excepts for the owner.
|
||||
7. All pull requests should consider updates to the documentation.
|
||||
8. Pull requests that address an outstanding issue, particularly an issue deemed to be severe, should be given priority.
|
||||
9. If a PR is accepted, then it should undergo review and updated based on the feedback provided, then merged.
|
||||
10. Pull requests that don't meet the above will be denied and closed.
|
||||
|
||||
<Other>
|
||||
<A table should be maintained for relating maintainers and components. When triaging, this is essential to figure out if someone in particular should be consulted about specific changes.>
|
||||
<A stable release cadence should be established, e.g.: every month.>
|
11
README.md
11
README.md
|
@ -1,6 +1,6 @@
|
|||
## Sonoff-Tasmota
|
||||
|
||||
Alternative firmware for _ESP8266 based devices_ like [iTead](https://www.itead.cc/) _**Sonoff**_ with **web**, **timers**, 'Over The Air' (**OTA**) firmware updates and **sensors support**, allowing control under **Serial**, **HTTP**, **MQTT** and **KNX**, so as to be used on **Smart Home Systems**. Written for Arduino IDE and PlatformIO.
|
||||
Alternative firmware for _ESP8266 based devices_ like [iTead](https://www.itead.cc/) _**Sonoff**_ with **web UI, rules and timers, OTA updates, custome device templates and sensors support**. Allows control over **MQTT**, **HTTP**, **Serial** and **KNX** for integrations with smart home systems. Written for Arduino IDE and PlatformIO.
|
||||
|
||||
[![GitHub version](https://img.shields.io/github/release/arendst/Sonoff-Tasmota.svg)](https://github.com/arendst/Sonoff-Tasmota/releases/latest)
|
||||
[![GitHub download](https://img.shields.io/github/downloads/arendst/Sonoff-Tasmota/total.svg)](https://github.com/arendst/Sonoff-Tasmota/releases/latest)
|
||||
|
@ -24,6 +24,9 @@ A Sonoff device is not a toy. It uses Mains AC so there is a danger of electrocu
|
|||
|
||||
We don't take any responsibility nor liability for using this software nor for the installation or any tips, advice, videos, etc. given by any member of this site or any related site.
|
||||
|
||||
### Note
|
||||
Please do not ask to add devices where you can't provide a basic working configuration (other than sonoff). Since there are thousands of them..
|
||||
|
||||
### Quick Install
|
||||
Download one of the released binaries from https://github.com/arendst/Sonoff-Tasmota/releases and flash it to your hardware as documented in the wiki.
|
||||
|
||||
|
@ -101,6 +104,7 @@ You can contribute to Sonoff-Tasmota by
|
|||
- providing Pull Requests (Features, Proof of Concepts, Language files or Fixes)
|
||||
- testing new released features and report issues
|
||||
- donating to acquire hardware for testing and implementing or out of gratitude
|
||||
- contributing missing documentation for features and devices on our [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki)
|
||||
|
||||
[![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://paypal.me/tasmota)
|
||||
|
||||
|
@ -121,9 +125,11 @@ Libraries used with Sonoff-Tasmota are:
|
|||
- [C2 Programmer](http://app.cear.ufpb.br/~lucas.hartmann/tag/efm8bb1/)
|
||||
- [esp-epaper-29-ws-20171230-gemu](https://github.com/gemu2015/Sonoff-Tasmota/tree/displays/lib)
|
||||
- [esp-knx-ip](https://github.com/envy/esp-knx-ip)
|
||||
- FrogmoreScd30
|
||||
- [I2Cdevlib](https://github.com/jrowberg/i2cdevlib)
|
||||
- [IRremoteEsp8266](https://github.com/markszabo/IRremoteESP8266)
|
||||
- [JobaTsl2561](https://github.com/joba-1/Joba_Tsl2561)
|
||||
- [LinkedList](https://github.com/ivanseidel/LinkedList)
|
||||
- [Liquid Cristal](https://github.com/marcoschwartz/LiquidCrystal_I2C)
|
||||
- [MultiChannelGasSensor](http://wiki.seeedstudio.com/Grove-Multichannel_Gas_Sensor/)
|
||||
- [NeoPixelBus](https://github.com/Makuna/NeoPixelBus)
|
||||
|
@ -157,7 +163,8 @@ People helping to keep the show on the road:
|
|||
- Andre Thomas for providing [thehackbox](http://thehackbox.org/tasmota/) OTA support and daily development builds
|
||||
- Joel Stein and digiblur for their Tuya research and driver
|
||||
- Frogmore42 and Jason2866 for providing many issue answers
|
||||
- Many more providing Tips, Pocs or PRs
|
||||
- Blakadder for editing the wiki and providing template management
|
||||
- Many more providing Tips, Wips, Pocs or PRs
|
||||
|
||||
### License
|
||||
|
||||
|
|
|
@ -82,6 +82,15 @@ Module | Description
|
|||
58 PS-16-DZ | PS-16-DZ Wifi dimmer for Incandescent Lights and Led
|
||||
59 Teckin US | Teckin US and ZooZee SA102 Wifi Smart Switch with Energy Monitoring
|
||||
60 Manzoku strip | Manzoku Wifi Smart Power Strip with four Relays
|
||||
61 OBI Socket 2 | OBI 2 Wifi Smart Socket
|
||||
62 YTF IR Bridge | YTF Infra Red Wifi Bridge
|
||||
63 Digoo DG-SP202 | Digoo DG-SP202 Dual Wifi Smart Switch with Energy Monitoring
|
||||
64 KA10 | Smanergy KA10 Wifi Smart Wall Switch with Energy Monitoring
|
||||
65 Luminea ZX2820 | Luminea ZX2820 Wifi Smart Switch with Energy Monitoring
|
||||
66 Mi Desk Lamp | Mi Desk Lamp with rotary switch and Wifi
|
||||
67 SP10 | Tuya SP10 Wifi Smart Switch with Energy Monitoring
|
||||
68 WAGA CHCZ02MB | WAGA life CHCZ02MB Wifi Smart Switch with Energy Monitoring
|
||||
69 SYF05 | Sunyesmart SYF05 RGBWW Wifi Led Bulb
|
||||
|
||||
## Provided Binary Downloads
|
||||
The following binary downloads have been compiled with ESP8266/Arduino library core version **2.4.2** patched with the Alexa fix.
|
||||
|
@ -98,9 +107,6 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
|
||||
| Feature or Sensor | minimal | basic | classic | sonoff | knx | sensors | Remarks
|
||||
|--------------------------------|---------|-------|---------|--------|------|---------|--------
|
||||
| ESP/Arduino lib v2.3.0 | 346k | 429k | 482k | 504k | 522k | 535k |
|
||||
| ESP/Arduino lib v2.4.2 | 366k | 446k | 496k | 522k | 538k | 551k | No wifi sleep
|
||||
| | | | | | | |
|
||||
| MY_LANGUAGE en-GB | x | x | x | x | x | x |
|
||||
| MQTT_LIBRARY_TYPE PUBSUBCLIENT | x | x | x | x | x | x |
|
||||
| USE_WPS | - | - | x | - | - | - | WPS
|
||||
|
@ -150,6 +156,8 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
| USE_MPU6050 | - | - | - | - | - | - |
|
||||
| USE_DS3231 | - | - | - | - | - | - |
|
||||
| USE_MGC3130 | - | - | - | - | - | - |
|
||||
| USE_MAX44009 | - | - | - | - | - | - |
|
||||
| USE_SCD30 | - | - | - | - | - | - |
|
||||
| | | | | | | |
|
||||
| Feature or Sensor | minimal | basic | classic | sonoff | knx | sensors |
|
||||
| USE_SPI | - | - | - | - | - | - |
|
||||
|
@ -169,6 +177,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
| USE_ARMTRONIX_DIMMERS | - | x | - | x | x | x |
|
||||
| USE_PS_16_DZ | - | x | - | x | x | x |
|
||||
| USE_AZ7798 | - | - | - | - | - | - |
|
||||
| USE_PN532_HSU | - | - | - | - | - | - |
|
||||
| USE_IR_REMOTE | - | - | - | x | x | x |
|
||||
| USE_IR_HVAC | - | - | - | - | - | x |
|
||||
| USE_IR_RECEIVE | - | - | - | x | x | x |
|
||||
|
@ -182,80 +191,10 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
| USE_TX20_WIND_SENSOR | - | - | - | x | x | x |
|
||||
| USE_RC_SWITCH | - | - | - | x | x | x |
|
||||
| USE_RF_SENSOR | - | - | - | - | - | x | AlectoV2 only
|
||||
| USE_SM16716 | - | x | x | x | x | x |
|
||||
| USE_DISPLAY | - | - | - | - | - | - |
|
||||
|
||||
## Changelog
|
||||
Version 6.4.1 20181225
|
||||
* Change RAM usage BMP/BME I2C sensors
|
||||
* Change FallbackTopic from cmnd/\<mqttclient\>/ to cmnd/\<mqttclient\>_fb/ to discriminate from Topic (#1528)
|
||||
* Change FallbackTopic detection (#4706)
|
||||
* Change Hass discovery to short MQTT messages as used by Hass 0.81 and up (#4711)
|
||||
* Change MQTT GUI password handling (#4723)
|
||||
* Fix possible dtostrf buffer overflows by increasing buffers
|
||||
* Fix wifi strongest signal detection (#4704)
|
||||
* Fix Alexa "this value is outside the range of the device". Needs power cycle and Alexa deletion/discovery cycle. (#3159, #4712)
|
||||
* Add Slovak language file (#4663)
|
||||
* Add support for AZ-Instrument 7798 CO2 meter/datalogger (#4672)
|
||||
* Add define WIFI_SOFT_AP_CHANNEL in my_user_config.h to set Soft Access Point Channel number between 1 and 13 as used by Wifi Manager web GUI (#4673)
|
||||
* Add define USE_MQTT_TLS_CA_CERT for checking MQTT TLS against root ca using Let's Encrypt cert from sonoff_letsencrypt.h - not supported with core 2.3.0 (#4703)
|
||||
Version 6.5.0 20190315
|
||||
|
||||
Version 6.4.0 20181217
|
||||
* Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40%.
|
||||
In case of web page errors clear your browser cache or do Page Reload (F5 or Ctrl+R)
|
||||
* Change enforcing flashmode dout but it is still mandatory
|
||||
* Change bootcount update (being first) flash write to 10 seconds after restart
|
||||
* Change display and epaper drivers
|
||||
* Change command WebSend Host header field from IP address to hostname (#4331)
|
||||
* Change log buffer size from 512 to 520 to accommodate http sensor data (#4354)
|
||||
* Change default WIFI_CONFIG_TOOL from WIFI_WAIT to WIFI_RETRY in my_user_config.h (#4400)
|
||||
* Change webgui refresh time delay for Save Settings and local OTA Upload (#4423)
|
||||
* Change SR-04 driver to use NewPing library (#4488)
|
||||
* Change MCP230xx driver to support interrupt retention over teleperiod (#4547)
|
||||
* Change support for MPU6050 using DMP (#4581)
|
||||
* Fix unintended function overload of WifiState
|
||||
* Fix wifi connection errors using wifi disconnect and ESP.reset instead of ESP.restart
|
||||
* Fix Sonoff Pow R2 and Sonoff S31 Serial interface hang caused by Sonoff Basic R2 driver delay implementation (and possibly core bug)
|
||||
* Fix MQTT connection error after restart
|
||||
* Fix wifi re-scan connection baseline
|
||||
* Fix possible strncat buffer overflows
|
||||
* Fix intermittent Pzem sensor energy overflow calculation error
|
||||
* Fix shelly2 ghost switching caused by lack of pull-up inputs (#4255)
|
||||
* Fix hardware serial pin configuration. To keep using hardware serial swap current Rx/Tx pin configuration only (#4280)
|
||||
* Fix MqttRetry values above 255 seconds (#4424)
|
||||
* Fix WifiManager functionality on initial installation (#4433)
|
||||
* Fix ArduinoOTA for Core 2.5.0 (#4620)
|
||||
* Add minutes to commands Timezone to allow all possible world timezones
|
||||
* Add more strict checks for GPIO selections
|
||||
* Add code image and optional commit number to version
|
||||
* Add dynamic delay to main loop providing time for wifi background tasks
|
||||
* Add additional start-up delay during initial wifi connection
|
||||
* Add support for decoding Theo V2 sensors as documented on https://sidweb.nl using 434MHz RF sensor receiver
|
||||
* Add support for decoding Alecto V2 sensors like ACH2010, WS3000 and DKW2012 weather stations using 868MHz RF sensor receiver
|
||||
* Add user definition of defines WIFI_RSSI_THRESHOLD (default 10) and WIFI_RESCAN_MINUTES (default 44)
|
||||
* Add command SetOption58 0/1 to enable IR raw data info in JSON message (#2116)
|
||||
* Add command IRSend \<frequency\>|0,\<rawdata1\>,\<rawdata2\>,.. to allow raw data transmission (#2116)
|
||||
* Add command SetOption56 0/1 to enable wifi network scan and select highest RSSI (#3173)
|
||||
* Add command SetOption57 0/1 to enable wifi network re-scan every 44 minutes with a rssi threshold of 10 to select highest RSSI (#3173)
|
||||
* Add support for SDM220 (#3610)
|
||||
* Add default sleep 1 to sonoff-basic to lower energy consumption (#4217)
|
||||
* Add wifi status to Tuya (#4221)
|
||||
* Add delays to reduce CPU usage at boot time (#4233)
|
||||
* Add command SetOption24 0/1 to select pressure unit as hPa or mmHg (#4241)
|
||||
* Add optional hardware serial when GPIO13(Rx) and GPIO15(Tx) are selected removing hardware serial from GPIO01(Tx) and GPIO03(Rx) (#4288)
|
||||
* Add support for Gosund SP1 v2.3 Power Socket with Energy Monitoring (#4297)
|
||||
* Add support for Armtronix dimmers. See wiki for info (#4321)
|
||||
* Add to command WebSend option to send a direct path when command starts with a slash (#4329)
|
||||
* Add support for LG HVac and IrRemote (#4377)
|
||||
* Add initial support for Hass sensor discovery (#4380)
|
||||
* Add support for Fujitsu HVac and IrRemote (#4387)
|
||||
* Add support for I2C MGC3130 Electric Field Effect sensor by Christian Baars (#3774, #4404)
|
||||
* Add command CalcRes to set number of decimals (0 - 7) used in commands ADD, SUB, MULT and SCALE (#4420)
|
||||
* Add CPU average load to state message (#4431)
|
||||
* Add command SetOption59 0/1 to change state topic from tele/STATE to stat/RESULT (#4450)
|
||||
* Add support for SM Smart Wifi Dimmer PS-16-DZ (#4465)
|
||||
* Add support for Teckin US Power Socket with Energy Monitoring (#4481)
|
||||
* Add command SetOption60 0/1 to select dynamic sleep (0) or sleep (1) (#4497)
|
||||
* Add support for iFan02 Fanspeed in Domoticz using a selector (#4517)
|
||||
* Add support for GPIO02 for newer Sonoff Basic (#4518)
|
||||
* Add Announce Switches to MQTT Discovery (#4531)
|
||||
* Add support for Manzoku Power Strip (#4590)
|
||||
* Tbd
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# Sonoff-Tasmota Support
|
||||
|
||||
If you're looking for support on **Sonoff-Tasmota** there are some options available:
|
||||
|
||||
### Documentation:
|
||||
|
||||
* [Wiki Pages](https://github.com/arendst/Sonoff-Tasmota/wiki): For information on how to Flash Tasmota, configure and use it.
|
||||
* [Troubleshooting Information](https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting): For information on common problems and solutions.
|
||||
* [Commands Information](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands): For information on all the commands supported by Tasmota.
|
||||
|
||||
### Support's Community:
|
||||
|
||||
* [Tasmota Forum](https://groups.google.com/d/forum/sonoffusers): For usage and discussions.
|
||||
* [Tasmota Support Chat](https://discord.gg/Ks2Kzd4): For support, troubleshooting and general questions. You have better chances to get fast answers from members of the Tasmota Community.
|
||||
* [Search in Issues](https://github.com/arendst/Sonoff-Tasmota/issues): You might find an answer to your question by searching current or closed issues.
|
||||
|
||||
### Developers' Community:
|
||||
|
||||
* [Bug Report](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Bug_report.md): For reporting Bugs of Tasmota Software.
|
||||
* [Feature Request](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Feature_request.md): For requesting features/functions to Tasmota Software.
|
||||
* [Troubleshooting](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Custom.md): As a last resort, you can open new *Troubleshooting* issue on GitHub if the solution could not be found using the other channels. Just remember: the more info you provide the more chances you'll have to get an accurate answer.
|
||||
* [Issue a question](https://github.com/arendst/Sonoff-Tasmota/issues/new/choose): As a last resort, you can open new *Question* issue on GitHub if the answer could not be found using the other channels. Just remember: the more info you provide the more chances you'll have to get an accurate answer.
|
|
@ -0,0 +1,86 @@
|
|||
## Sonoff-Tasmota template information
|
||||
Sonoff-Tasmota uses Device or Module information to control peripherals connected to GPIOs. This information is stored in the ``sonoff_template.h`` file as a device specific template. The template contains information about what GPIO should be connected to what peripheral and what GPIO may be configured online using the ``GPIO`` command or GUI Configure Module menu. In addition a device may need specific coding to process the data from these peripherals. The module number as provided by the ``Modules`` command is used to select this coding.
|
||||
|
||||
Starting with version 6.4.1.16 Sonoff-Tasmota Modules can be extended by users online using a template. To provide easy processing by Sonoff-Tasmota a user template is written as JSON text and could look like this:
|
||||
|
||||
{"NAME":"UserModule1","GPIO":[17,148,29,149,7,255,255,255,138,255,139,255,255],"FLAG":0,"BASE":18}
|
||||
|
||||
The four properties with UPPERCASE property names have the following functionality:
|
||||
|
||||
Property name | Property value description
|
||||
--------------|-------------------------------------------------------------------------------------------------------------------
|
||||
NAME | Up to 14 characters for the Module name
|
||||
GPIO | Up to 13 decimal numbers from 0 to 255 representing GPIO0 to GPIO5, GPIO09, GPIO10 and GPIO12 to GPIO16
|
||||
FLAG | 8 bit mask flag register
|
||||
BASE | Module number of a hard-coded device to be used when device specific functionality is needed
|
||||
|
||||
The above example, based on the Generic Module does not allow ADC0 input.
|
||||
|
||||
## GPIO functionality
|
||||
The GPIO functionality numbers are the same is shown by command ``GPIOs``. In addition code 255 is added to select a GPIO as user configurable via the GUI Configure Module menu.
|
||||
|
||||
## FLAG functionality
|
||||
The FLAG value is an 8-bit mask where each bit controls a features. Add FLAG values to set multiple bits.
|
||||
|
||||
FLAG | Mask | Feature description
|
||||
-----|----------|------------------------------
|
||||
1 | xxxxxxx1 | Allowing to use Analog0 (ADC0) as input if define USE_ADC_VCC in ``my_user_config.h`` is disabled
|
||||
2 | xxxxxx1x | Enable GUI pull-up control message
|
||||
4 | xxxxx1xx | Not used
|
||||
8 | xxxx1xxx | Not used
|
||||
16 | xxx1xxxx | Not used
|
||||
32 | xx1xxxxx | Not used
|
||||
64 | x1xxxxxx | Not used
|
||||
128 | 1xxxxxxx | Not used
|
||||
|
||||
## BASE functionality
|
||||
The following table lists hard-coded device specific functionality. Notice that not all device modules need special handling.
|
||||
|
||||
BASE | Module | Description
|
||||
-----|----------------|----------------------------------------------
|
||||
4 | Sonoff Dual | Process relay and button via hardware serial interface using GPIO01 and GPIO03. Change baudrate to 19200 bps. Process buttons as single press only
|
||||
9 | Sonoff Touch | Invert ledstate 1 functionality
|
||||
10 | Sonoff LED | Set light type to 2 PWM channels disregarding SetOption15. Fix device specific LED instabilities by disabling GPIO04, GPIO5 and GPIO14
|
||||
12 | 4 Channel | See 4
|
||||
13 | Motor C/AC | Force all relays ON at Power On and disable command ``PowerOnState``
|
||||
15 | EXS Relay(s) | Enable pulse latching using even/odd numbered relay pairs
|
||||
18 | Generic | Show Wemos specific pin information in GUI
|
||||
19 | H801 | Change hardware UART Tx from GPIO01 to GPIO02
|
||||
20 | Sonoff SC | Enable and Process data via hardware serial interface using GPIO01 and GPIO03. Change baudrate to 19200 bps
|
||||
21 | Sonoff BN-SZ | Set light type to 1 PWM channel disregarding SetOption15
|
||||
22 | Sonoff 4CH Pro | Button handling disregarding SetOption13 only allowing single press to enable RF learning while holding the button
|
||||
24 | Sonoff Bridge | Enable and Process data via hardware serial interface using GPIO01 and GPIO03. Change baudrate to 19200 bps. Process 16 buttons in web GUI. Enable EFM8BB1 firmware upload
|
||||
25 | Sonoff B1 | Set light type to RGBWC using MY92x1
|
||||
26 | AiLight | Set light type to RGBW using MY92x1
|
||||
27 | Sonoff T1 1CH | See 9
|
||||
28 | Sonoff T1 2CH | See 9
|
||||
29 | Sonoff T1 3CH | See 9
|
||||
38 | Sonoff Dual R2 | Process buttons as single press only
|
||||
43 | Sonoff iFan02 | Enable command ``Fanspeed``. Disable Interlock and PulseTime. Tune status information, MQTT data and GUI. Sync with microcontroller. Process Domoticz Fan state
|
||||
47 | Xiaomi Philips | Process Color Temperature using PWM2 and Intensity using PWM1
|
||||
53 | Tuya Dimmer | Enable and Process data via software or hardware serial interface using GPIO 148 and 149 or forced GPIO01 and GPIO03. Change baudrate to 9600 bps. Process all Buttons
|
||||
55 | ARMTR Dimmer | Enable and Process data via software or hardware serial interface using GPIO 148 and 149. Change baudrate to 115200 bps.
|
||||
57 | PS-16-DZ | Enable and Process data via software or hardware serial interface using GPIO 148 and 149. Change baudrate to 19200 bps.
|
||||
61 | YTF IR Bridge | Disable serial interface to stop loopback
|
||||
65 | Mi Desk Lamp | Process rotary and Button1 data specific to this device
|
||||
|
||||
## Usage
|
||||
A user provided template can be stored in Sonoff-Tasmota using the ``Template`` command. It has the following options.
|
||||
|
||||
Command | Payload | Description
|
||||
---------|----------|---------------------------------------
|
||||
Template | | Show current user template
|
||||
Template | 0 | Copy active module template to user template
|
||||
Template | 1 .. 69 | Copy hard-coded module template to user template
|
||||
|
||||
The following command will store a complete template based on the Generic module
|
||||
``Template {"NAME":"UserModule1","GPIO":[17,148,29,149,7,255,255,255,138,255,139,255,255],"FLAG":0,"BASE":18}``
|
||||
|
||||
The following command will update the name of a stored template
|
||||
``Template {"NAME":"UserModule2"}``
|
||||
|
||||
The following command will update the flag of a stored template
|
||||
``Template {"FLAG":1}``
|
||||
|
||||
The following command will update the base of a stored template to Generic
|
||||
``Template {"BASE":0}``
|
|
@ -54,12 +54,12 @@ generic.menu.vt.heap=Heap
|
|||
generic.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
generic.menu.vt.iram=IRAM
|
||||
generic.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
generic.menu.exception.enabled=Enabled
|
||||
generic.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
generic.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
generic.menu.exception.disabled=Disabled
|
||||
generic.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
generic.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
generic.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
generic.menu.exception.enabled=Enabled
|
||||
generic.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
generic.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
generic.menu.ResetMethod.ck=ck
|
||||
generic.menu.ResetMethod.ck.upload.resetmethod=ck
|
||||
generic.menu.ResetMethod.nodemcu=nodemcu
|
||||
|
@ -75,14 +75,18 @@ generic.menu.FlashFreq.40=40MHz
|
|||
generic.menu.FlashFreq.40.build.flash_freq=40
|
||||
generic.menu.FlashFreq.80=80MHz
|
||||
generic.menu.FlashFreq.80.build.flash_freq=80
|
||||
generic.menu.FlashMode.qio=QIO
|
||||
generic.menu.FlashMode.qio.build.flash_mode=qio
|
||||
generic.menu.FlashMode.qout=QOUT
|
||||
generic.menu.FlashMode.qout.build.flash_mode=qout
|
||||
generic.menu.FlashMode.dout=DOUT (compatible)
|
||||
generic.menu.FlashMode.dout.build.flash_mode=dout
|
||||
generic.menu.FlashMode.dout.build.flash_flags=-DFLASHMODE_DOUT
|
||||
generic.menu.FlashMode.dio=DIO
|
||||
generic.menu.FlashMode.dio.build.flash_mode=dio
|
||||
generic.menu.FlashMode.dout=DOUT
|
||||
generic.menu.FlashMode.dout.build.flash_mode=dout
|
||||
generic.menu.FlashMode.dio.build.flash_flags=-DFLASHMODE_DIO
|
||||
generic.menu.FlashMode.qout=QOUT
|
||||
generic.menu.FlashMode.qout.build.flash_mode=qout
|
||||
generic.menu.FlashMode.qout.build.flash_flags=-DFLASHMODE_QOUT
|
||||
generic.menu.FlashMode.qio=QIO (fast)
|
||||
generic.menu.FlashMode.qio.build.flash_mode=qio
|
||||
generic.menu.FlashMode.qio.build.flash_flags=-DFLASHMODE_QIO
|
||||
generic.menu.eesz.512K=512K (no SPIFFS)
|
||||
generic.menu.eesz.512K.build.flash_size=512K
|
||||
generic.menu.eesz.512K.build.flash_size_bytes=0x80000
|
||||
|
@ -490,12 +494,12 @@ esp8285.menu.vt.heap=Heap
|
|||
esp8285.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
esp8285.menu.vt.iram=IRAM
|
||||
esp8285.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
esp8285.menu.exception.enabled=Enabled
|
||||
esp8285.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
esp8285.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
esp8285.menu.exception.disabled=Disabled
|
||||
esp8285.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
esp8285.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
esp8285.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
esp8285.menu.exception.enabled=Enabled
|
||||
esp8285.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
esp8285.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
esp8285.menu.ResetMethod.ck=ck
|
||||
esp8285.menu.ResetMethod.ck.upload.resetmethod=ck
|
||||
esp8285.menu.ResetMethod.nodemcu=nodemcu
|
||||
|
@ -508,6 +512,7 @@ esp8285.menu.CrystalFreq.26=26 MHz
|
|||
esp8285.menu.CrystalFreq.40=40 MHz
|
||||
esp8285.menu.CrystalFreq.40.build.extra_flags=-DF_CRYSTAL=40000000 -DESP8266
|
||||
esp8285.build.flash_mode=dout
|
||||
esp8285.build.flash_flags=-DFLASHMODE_DOUT
|
||||
esp8285.build.flash_freq=40
|
||||
esp8285.menu.eesz.1M=1M (no SPIFFS)
|
||||
esp8285.menu.eesz.1M.build.flash_size=1M
|
||||
|
@ -764,13 +769,14 @@ espduino.menu.vt.heap=Heap
|
|||
espduino.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
espduino.menu.vt.iram=IRAM
|
||||
espduino.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
espduino.menu.exception.enabled=Enabled
|
||||
espduino.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espduino.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
espduino.menu.exception.disabled=Disabled
|
||||
espduino.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
espduino.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
espduino.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
espduino.menu.exception.enabled=Enabled
|
||||
espduino.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espduino.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
espduino.build.flash_mode=dio
|
||||
espduino.build.flash_flags=-DFLASHMODE_DIO
|
||||
espduino.build.flash_freq=40
|
||||
espduino.menu.eesz.4M=4M (no SPIFFS)
|
||||
espduino.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -946,14 +952,15 @@ huzzah.menu.vt.heap=Heap
|
|||
huzzah.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
huzzah.menu.vt.iram=IRAM
|
||||
huzzah.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
huzzah.menu.exception.enabled=Enabled
|
||||
huzzah.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
huzzah.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
huzzah.menu.exception.disabled=Disabled
|
||||
huzzah.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
huzzah.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
huzzah.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
huzzah.menu.exception.enabled=Enabled
|
||||
huzzah.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
huzzah.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
huzzah.upload.resetmethod=nodemcu
|
||||
huzzah.build.flash_mode=qio
|
||||
huzzah.build.flash_flags=-DFLASHMODE_QIO
|
||||
huzzah.build.flash_freq=40
|
||||
huzzah.menu.eesz.4M=4M (no SPIFFS)
|
||||
huzzah.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -1129,14 +1136,15 @@ inventone.menu.vt.heap=Heap
|
|||
inventone.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
inventone.menu.vt.iram=IRAM
|
||||
inventone.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
inventone.menu.exception.enabled=Enabled
|
||||
inventone.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
inventone.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
inventone.menu.exception.disabled=Disabled
|
||||
inventone.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
inventone.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
inventone.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
inventone.menu.exception.enabled=Enabled
|
||||
inventone.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
inventone.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
inventone.upload.resetmethod=nodemcu
|
||||
inventone.build.flash_mode=dio
|
||||
inventone.build.flash_flags=-DFLASHMODE_DIO
|
||||
inventone.build.flash_freq=40
|
||||
inventone.menu.eesz.4M=4M (no SPIFFS)
|
||||
inventone.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -1312,17 +1320,18 @@ cw01.menu.vt.heap=Heap
|
|||
cw01.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
cw01.menu.vt.iram=IRAM
|
||||
cw01.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
cw01.menu.exception.enabled=Enabled
|
||||
cw01.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
cw01.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
cw01.menu.exception.disabled=Disabled
|
||||
cw01.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
cw01.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
cw01.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
cw01.menu.exception.enabled=Enabled
|
||||
cw01.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
cw01.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
cw01.upload.resetmethod=nodemcu
|
||||
cw01.menu.CrystalFreq.26=26 MHz
|
||||
cw01.menu.CrystalFreq.40=40 MHz
|
||||
cw01.menu.CrystalFreq.40.build.extra_flags=-DF_CRYSTAL=40000000 -DESP8266
|
||||
cw01.build.flash_mode=qio
|
||||
cw01.build.flash_mode=dio
|
||||
cw01.build.flash_flags=-DFLASHMODE_DIO
|
||||
cw01.build.flash_freq=40
|
||||
cw01.menu.eesz.4M=4M (no SPIFFS)
|
||||
cw01.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -1498,13 +1507,14 @@ espresso_lite_v1.menu.vt.heap=Heap
|
|||
espresso_lite_v1.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
espresso_lite_v1.menu.vt.iram=IRAM
|
||||
espresso_lite_v1.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
espresso_lite_v1.menu.exception.enabled=Enabled
|
||||
espresso_lite_v1.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espresso_lite_v1.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
espresso_lite_v1.menu.exception.disabled=Disabled
|
||||
espresso_lite_v1.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
espresso_lite_v1.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
espresso_lite_v1.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
espresso_lite_v1.menu.exception.enabled=Enabled
|
||||
espresso_lite_v1.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espresso_lite_v1.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
espresso_lite_v1.build.flash_mode=dio
|
||||
espresso_lite_v1.build.flash_flags=-DFLASHMODE_DIO
|
||||
espresso_lite_v1.build.flash_freq=40
|
||||
espresso_lite_v1.menu.eesz.4M=4M (no SPIFFS)
|
||||
espresso_lite_v1.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -1684,13 +1694,14 @@ espresso_lite_v2.menu.vt.heap=Heap
|
|||
espresso_lite_v2.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
espresso_lite_v2.menu.vt.iram=IRAM
|
||||
espresso_lite_v2.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
espresso_lite_v2.menu.exception.enabled=Enabled
|
||||
espresso_lite_v2.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espresso_lite_v2.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
espresso_lite_v2.menu.exception.disabled=Disabled
|
||||
espresso_lite_v2.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
espresso_lite_v2.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
espresso_lite_v2.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
espresso_lite_v2.menu.exception.enabled=Enabled
|
||||
espresso_lite_v2.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espresso_lite_v2.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
espresso_lite_v2.build.flash_mode=dio
|
||||
espresso_lite_v2.build.flash_flags=-DFLASHMODE_DIO
|
||||
espresso_lite_v2.build.flash_freq=40
|
||||
espresso_lite_v2.menu.eesz.4M=4M (no SPIFFS)
|
||||
espresso_lite_v2.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -1870,13 +1881,14 @@ phoenix_v1.menu.vt.heap=Heap
|
|||
phoenix_v1.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
phoenix_v1.menu.vt.iram=IRAM
|
||||
phoenix_v1.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
phoenix_v1.menu.exception.enabled=Enabled
|
||||
phoenix_v1.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
phoenix_v1.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
phoenix_v1.menu.exception.disabled=Disabled
|
||||
phoenix_v1.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
phoenix_v1.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
phoenix_v1.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
phoenix_v1.menu.exception.enabled=Enabled
|
||||
phoenix_v1.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
phoenix_v1.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
phoenix_v1.build.flash_mode=dio
|
||||
phoenix_v1.build.flash_flags=-DFLASHMODE_DIO
|
||||
phoenix_v1.build.flash_freq=40
|
||||
phoenix_v1.menu.eesz.4M=4M (no SPIFFS)
|
||||
phoenix_v1.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -2056,13 +2068,14 @@ phoenix_v2.menu.vt.heap=Heap
|
|||
phoenix_v2.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
phoenix_v2.menu.vt.iram=IRAM
|
||||
phoenix_v2.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
phoenix_v2.menu.exception.enabled=Enabled
|
||||
phoenix_v2.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
phoenix_v2.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
phoenix_v2.menu.exception.disabled=Disabled
|
||||
phoenix_v2.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
phoenix_v2.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
phoenix_v2.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
phoenix_v2.menu.exception.enabled=Enabled
|
||||
phoenix_v2.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
phoenix_v2.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
phoenix_v2.build.flash_mode=dio
|
||||
phoenix_v2.build.flash_flags=-DFLASHMODE_DIO
|
||||
phoenix_v2.build.flash_freq=40
|
||||
phoenix_v2.menu.eesz.4M=4M (no SPIFFS)
|
||||
phoenix_v2.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -2242,14 +2255,15 @@ nodemcu.menu.vt.heap=Heap
|
|||
nodemcu.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
nodemcu.menu.vt.iram=IRAM
|
||||
nodemcu.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
nodemcu.menu.exception.enabled=Enabled
|
||||
nodemcu.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
nodemcu.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
nodemcu.menu.exception.disabled=Disabled
|
||||
nodemcu.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
nodemcu.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
nodemcu.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
nodemcu.menu.exception.enabled=Enabled
|
||||
nodemcu.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
nodemcu.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
nodemcu.upload.resetmethod=nodemcu
|
||||
nodemcu.build.flash_mode=qio
|
||||
nodemcu.build.flash_flags=-DFLASHMODE_QIO
|
||||
nodemcu.build.flash_freq=40
|
||||
nodemcu.menu.eesz.4M=4M (no SPIFFS)
|
||||
nodemcu.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -2425,14 +2439,15 @@ nodemcuv2.menu.vt.heap=Heap
|
|||
nodemcuv2.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
nodemcuv2.menu.vt.iram=IRAM
|
||||
nodemcuv2.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
nodemcuv2.menu.exception.enabled=Enabled
|
||||
nodemcuv2.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
nodemcuv2.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
nodemcuv2.menu.exception.disabled=Disabled
|
||||
nodemcuv2.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
nodemcuv2.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
nodemcuv2.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
nodemcuv2.menu.exception.enabled=Enabled
|
||||
nodemcuv2.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
nodemcuv2.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
nodemcuv2.upload.resetmethod=nodemcu
|
||||
nodemcuv2.build.flash_mode=dio
|
||||
nodemcuv2.build.flash_flags=-DFLASHMODE_DIO
|
||||
nodemcuv2.build.flash_freq=40
|
||||
nodemcuv2.menu.eesz.4M=4M (no SPIFFS)
|
||||
nodemcuv2.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -2608,14 +2623,15 @@ modwifi.menu.vt.heap=Heap
|
|||
modwifi.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
modwifi.menu.vt.iram=IRAM
|
||||
modwifi.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
modwifi.menu.exception.enabled=Enabled
|
||||
modwifi.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
modwifi.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
modwifi.menu.exception.disabled=Disabled
|
||||
modwifi.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
modwifi.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
modwifi.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
modwifi.menu.exception.enabled=Enabled
|
||||
modwifi.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
modwifi.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
modwifi.upload.resetmethod=ck
|
||||
modwifi.build.flash_mode=qio
|
||||
modwifi.build.flash_flags=-DFLASHMODE_QIO
|
||||
modwifi.build.flash_freq=40
|
||||
modwifi.menu.eesz.2M=2M (no SPIFFS)
|
||||
modwifi.menu.eesz.2M.build.flash_size=2M
|
||||
|
@ -2801,14 +2817,15 @@ thing.menu.vt.heap=Heap
|
|||
thing.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
thing.menu.vt.iram=IRAM
|
||||
thing.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
thing.menu.exception.enabled=Enabled
|
||||
thing.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
thing.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
thing.menu.exception.disabled=Disabled
|
||||
thing.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
thing.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
thing.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
thing.menu.exception.enabled=Enabled
|
||||
thing.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
thing.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
thing.upload.resetmethod=ck
|
||||
thing.build.flash_mode=qio
|
||||
thing.build.flash_flags=-DFLASHMODE_QIO
|
||||
thing.build.flash_freq=40
|
||||
thing.menu.eesz.512K=512K (no SPIFFS)
|
||||
thing.menu.eesz.512K.build.flash_size=512K
|
||||
|
@ -2984,14 +3001,15 @@ thingdev.menu.vt.heap=Heap
|
|||
thingdev.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
thingdev.menu.vt.iram=IRAM
|
||||
thingdev.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
thingdev.menu.exception.enabled=Enabled
|
||||
thingdev.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
thingdev.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
thingdev.menu.exception.disabled=Disabled
|
||||
thingdev.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
thingdev.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
thingdev.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
thingdev.menu.exception.enabled=Enabled
|
||||
thingdev.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
thingdev.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
thingdev.upload.resetmethod=nodemcu
|
||||
thingdev.build.flash_mode=dio
|
||||
thingdev.build.flash_flags=-DFLASHMODE_DIO
|
||||
thingdev.build.flash_freq=40
|
||||
thingdev.menu.eesz.512K=512K (no SPIFFS)
|
||||
thingdev.menu.eesz.512K.build.flash_size=512K
|
||||
|
@ -3167,14 +3185,15 @@ esp210.menu.vt.heap=Heap
|
|||
esp210.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
esp210.menu.vt.iram=IRAM
|
||||
esp210.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
esp210.menu.exception.enabled=Enabled
|
||||
esp210.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
esp210.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
esp210.menu.exception.disabled=Disabled
|
||||
esp210.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
esp210.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
esp210.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
esp210.menu.exception.enabled=Enabled
|
||||
esp210.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
esp210.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
esp210.upload.resetmethod=ck
|
||||
esp210.build.flash_mode=qio
|
||||
esp210.build.flash_flags=-DFLASHMODE_QIO
|
||||
esp210.build.flash_freq=40
|
||||
esp210.menu.eesz.4M=4M (no SPIFFS)
|
||||
esp210.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -3350,14 +3369,15 @@ d1_mini.menu.vt.heap=Heap
|
|||
d1_mini.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
d1_mini.menu.vt.iram=IRAM
|
||||
d1_mini.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
d1_mini.menu.exception.enabled=Enabled
|
||||
d1_mini.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1_mini.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
d1_mini.menu.exception.disabled=Disabled
|
||||
d1_mini.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
d1_mini.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
d1_mini.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
d1_mini.menu.exception.enabled=Enabled
|
||||
d1_mini.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1_mini.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
d1_mini.upload.resetmethod=nodemcu
|
||||
d1_mini.build.flash_mode=dio
|
||||
d1_mini.build.flash_flags=-DFLASHMODE_DIO
|
||||
d1_mini.build.flash_freq=40
|
||||
d1_mini.menu.eesz.4M=4M (no SPIFFS)
|
||||
d1_mini.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -3533,14 +3553,15 @@ d1_mini_pro.menu.vt.heap=Heap
|
|||
d1_mini_pro.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
d1_mini_pro.menu.vt.iram=IRAM
|
||||
d1_mini_pro.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
d1_mini_pro.menu.exception.enabled=Enabled
|
||||
d1_mini_pro.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1_mini_pro.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
d1_mini_pro.menu.exception.disabled=Disabled
|
||||
d1_mini_pro.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
d1_mini_pro.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
d1_mini_pro.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
d1_mini_pro.menu.exception.enabled=Enabled
|
||||
d1_mini_pro.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1_mini_pro.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
d1_mini_pro.upload.resetmethod=nodemcu
|
||||
d1_mini_pro.build.flash_mode=dio
|
||||
d1_mini_pro.build.flash_flags=-DFLASHMODE_DIO
|
||||
d1_mini_pro.build.flash_freq=40
|
||||
d1_mini_pro.menu.eesz.16M14M=16M (14M SPIFFS)
|
||||
d1_mini_pro.menu.eesz.16M14M.build.flash_size=16M
|
||||
|
@ -3699,14 +3720,15 @@ d1_mini_lite.menu.vt.heap=Heap
|
|||
d1_mini_lite.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
d1_mini_lite.menu.vt.iram=IRAM
|
||||
d1_mini_lite.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
d1_mini_lite.menu.exception.enabled=Enabled
|
||||
d1_mini_lite.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1_mini_lite.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
d1_mini_lite.menu.exception.disabled=Disabled
|
||||
d1_mini_lite.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
d1_mini_lite.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
d1_mini_lite.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
d1_mini_lite.menu.exception.enabled=Enabled
|
||||
d1_mini_lite.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1_mini_lite.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
d1_mini_lite.upload.resetmethod=nodemcu
|
||||
d1_mini_lite.build.flash_mode=dout
|
||||
d1_mini_lite.build.flash_flags=-DFLASHMODE_DOUT
|
||||
d1_mini_lite.build.flash_freq=40
|
||||
d1_mini_lite.menu.eesz.1M=1M (no SPIFFS)
|
||||
d1_mini_lite.menu.eesz.1M.build.flash_size=1M
|
||||
|
@ -3922,14 +3944,15 @@ d1.menu.vt.heap=Heap
|
|||
d1.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
d1.menu.vt.iram=IRAM
|
||||
d1.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
d1.menu.exception.enabled=Enabled
|
||||
d1.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
d1.menu.exception.disabled=Disabled
|
||||
d1.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
d1.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
d1.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
d1.menu.exception.enabled=Enabled
|
||||
d1.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
d1.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
d1.upload.resetmethod=nodemcu
|
||||
d1.build.flash_mode=dio
|
||||
d1.build.flash_flags=-DFLASHMODE_DIO
|
||||
d1.build.flash_freq=40
|
||||
d1.menu.eesz.4M=4M (no SPIFFS)
|
||||
d1.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -4105,17 +4128,18 @@ espino.menu.vt.heap=Heap
|
|||
espino.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
espino.menu.vt.iram=IRAM
|
||||
espino.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
espino.menu.exception.enabled=Enabled
|
||||
espino.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espino.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
espino.menu.exception.disabled=Disabled
|
||||
espino.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
espino.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
espino.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
espino.menu.exception.enabled=Enabled
|
||||
espino.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espino.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
espino.menu.ResetMethod.ck=ck
|
||||
espino.menu.ResetMethod.ck.upload.resetmethod=ck
|
||||
espino.menu.ResetMethod.nodemcu=nodemcu
|
||||
espino.menu.ResetMethod.nodemcu.upload.resetmethod=nodemcu
|
||||
espino.build.flash_mode=qio
|
||||
espino.build.flash_flags=-DFLASHMODE_QIO
|
||||
espino.build.flash_freq=40
|
||||
espino.menu.eesz.4M=4M (no SPIFFS)
|
||||
espino.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -4291,14 +4315,15 @@ espinotee.menu.vt.heap=Heap
|
|||
espinotee.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
espinotee.menu.vt.iram=IRAM
|
||||
espinotee.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
espinotee.menu.exception.enabled=Enabled
|
||||
espinotee.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espinotee.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
espinotee.menu.exception.disabled=Disabled
|
||||
espinotee.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
espinotee.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
espinotee.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
espinotee.menu.exception.enabled=Enabled
|
||||
espinotee.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espinotee.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
espinotee.upload.resetmethod=nodemcu
|
||||
espinotee.build.flash_mode=qio
|
||||
espinotee.build.flash_flags=-DFLASHMODE_QIO
|
||||
espinotee.build.flash_freq=40
|
||||
espinotee.menu.eesz.4M=4M (no SPIFFS)
|
||||
espinotee.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -4491,14 +4516,15 @@ wifinfo.menu.vt.heap=Heap
|
|||
wifinfo.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
wifinfo.menu.vt.iram=IRAM
|
||||
wifinfo.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
wifinfo.menu.exception.enabled=Enabled
|
||||
wifinfo.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wifinfo.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
wifinfo.menu.exception.disabled=Disabled
|
||||
wifinfo.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
wifinfo.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
wifinfo.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
wifinfo.menu.exception.enabled=Enabled
|
||||
wifinfo.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wifinfo.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
wifinfo.upload.resetmethod=nodemcu
|
||||
wifinfo.build.flash_mode=qio
|
||||
wifinfo.build.flash_flags=-DFLASHMODE_QIO
|
||||
wifinfo.menu.FlashFreq.40=40MHz
|
||||
wifinfo.menu.FlashFreq.40.build.flash_freq=40
|
||||
wifinfo.menu.FlashFreq.80=80MHz
|
||||
|
@ -4729,14 +4755,15 @@ arduino-esp8266.menu.vt.heap=Heap
|
|||
arduino-esp8266.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
arduino-esp8266.menu.vt.iram=IRAM
|
||||
arduino-esp8266.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
arduino-esp8266.menu.exception.enabled=Enabled
|
||||
arduino-esp8266.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
arduino-esp8266.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
arduino-esp8266.menu.exception.disabled=Disabled
|
||||
arduino-esp8266.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
arduino-esp8266.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
arduino-esp8266.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
arduino-esp8266.menu.exception.enabled=Enabled
|
||||
arduino-esp8266.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
arduino-esp8266.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
arduino-esp8266.upload.resetmethod=ck
|
||||
arduino-esp8266.build.flash_mode=qio
|
||||
arduino-esp8266.build.flash_flags=-DFLASHMODE_QIO
|
||||
arduino-esp8266.build.flash_freq=40
|
||||
arduino-esp8266.menu.eesz.4M=4M (no SPIFFS)
|
||||
arduino-esp8266.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -4913,14 +4940,15 @@ gen4iod.menu.vt.heap=Heap
|
|||
gen4iod.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
gen4iod.menu.vt.iram=IRAM
|
||||
gen4iod.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
gen4iod.menu.exception.enabled=Enabled
|
||||
gen4iod.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
gen4iod.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
gen4iod.menu.exception.disabled=Disabled
|
||||
gen4iod.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
gen4iod.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
gen4iod.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
gen4iod.menu.exception.enabled=Enabled
|
||||
gen4iod.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
gen4iod.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
gen4iod.upload.resetmethod=nodemcu
|
||||
gen4iod.build.flash_mode=dio
|
||||
gen4iod.build.flash_flags=-DFLASHMODE_DIO
|
||||
gen4iod.build.flash_freq=80
|
||||
gen4iod.menu.eesz.512K=512K (no SPIFFS)
|
||||
gen4iod.menu.eesz.512K.build.flash_size=512K
|
||||
|
@ -5097,14 +5125,15 @@ oak.menu.vt.heap=Heap
|
|||
oak.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
oak.menu.vt.iram=IRAM
|
||||
oak.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
oak.menu.exception.enabled=Enabled
|
||||
oak.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
oak.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
oak.menu.exception.disabled=Disabled
|
||||
oak.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
oak.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
oak.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
oak.menu.exception.enabled=Enabled
|
||||
oak.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
oak.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
oak.upload.resetmethod=none
|
||||
oak.build.flash_mode=dio
|
||||
oak.build.flash_flags=-DFLASHMODE_DIO
|
||||
oak.build.flash_freq=40
|
||||
oak.menu.eesz.4M=4M (no SPIFFS)
|
||||
oak.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -5280,14 +5309,15 @@ wifiduino.menu.vt.heap=Heap
|
|||
wifiduino.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
wifiduino.menu.vt.iram=IRAM
|
||||
wifiduino.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
wifiduino.menu.exception.enabled=Enabled
|
||||
wifiduino.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wifiduino.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
wifiduino.menu.exception.disabled=Disabled
|
||||
wifiduino.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
wifiduino.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
wifiduino.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
wifiduino.menu.exception.enabled=Enabled
|
||||
wifiduino.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wifiduino.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
wifiduino.upload.resetmethod=nodemcu
|
||||
wifiduino.build.flash_mode=dio
|
||||
wifiduino.build.flash_flags=-DFLASHMODE_DIO
|
||||
wifiduino.build.flash_freq=40
|
||||
wifiduino.menu.eesz.4M=4M (no SPIFFS)
|
||||
wifiduino.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -5463,25 +5493,29 @@ wifi_slot.menu.vt.heap=Heap
|
|||
wifi_slot.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
wifi_slot.menu.vt.iram=IRAM
|
||||
wifi_slot.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
wifi_slot.menu.exception.enabled=Enabled
|
||||
wifi_slot.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wifi_slot.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
wifi_slot.menu.exception.disabled=Disabled
|
||||
wifi_slot.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
wifi_slot.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
wifi_slot.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
wifi_slot.menu.exception.enabled=Enabled
|
||||
wifi_slot.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wifi_slot.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
wifi_slot.upload.resetmethod=nodemcu
|
||||
wifi_slot.menu.FlashFreq.40=40MHz
|
||||
wifi_slot.menu.FlashFreq.40.build.flash_freq=40
|
||||
wifi_slot.menu.FlashFreq.80=80MHz
|
||||
wifi_slot.menu.FlashFreq.80.build.flash_freq=80
|
||||
wifi_slot.menu.FlashMode.qio=QIO
|
||||
wifi_slot.menu.FlashMode.qio.build.flash_mode=qio
|
||||
wifi_slot.menu.FlashMode.qout=QOUT
|
||||
wifi_slot.menu.FlashMode.qout.build.flash_mode=qout
|
||||
wifi_slot.menu.FlashMode.dout=DOUT (compatible)
|
||||
wifi_slot.menu.FlashMode.dout.build.flash_mode=dout
|
||||
wifi_slot.menu.FlashMode.dout.build.flash_flags=-DFLASHMODE_DOUT
|
||||
wifi_slot.menu.FlashMode.dio=DIO
|
||||
wifi_slot.menu.FlashMode.dio.build.flash_mode=dio
|
||||
wifi_slot.menu.FlashMode.dout=DOUT
|
||||
wifi_slot.menu.FlashMode.dout.build.flash_mode=dout
|
||||
wifi_slot.menu.FlashMode.dio.build.flash_flags=-DFLASHMODE_DIO
|
||||
wifi_slot.menu.FlashMode.qout=QOUT
|
||||
wifi_slot.menu.FlashMode.qout.build.flash_mode=qout
|
||||
wifi_slot.menu.FlashMode.qout.build.flash_flags=-DFLASHMODE_QOUT
|
||||
wifi_slot.menu.FlashMode.qio=QIO (fast)
|
||||
wifi_slot.menu.FlashMode.qio.build.flash_mode=qio
|
||||
wifi_slot.menu.FlashMode.qio.build.flash_flags=-DFLASHMODE_QIO
|
||||
wifi_slot.menu.eesz.1M=1M (no SPIFFS)
|
||||
wifi_slot.menu.eesz.1M.build.flash_size=1M
|
||||
wifi_slot.menu.eesz.1M.build.flash_size_bytes=0x100000
|
||||
|
@ -5743,14 +5777,15 @@ wiolink.menu.vt.heap=Heap
|
|||
wiolink.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
wiolink.menu.vt.iram=IRAM
|
||||
wiolink.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
wiolink.menu.exception.enabled=Enabled
|
||||
wiolink.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wiolink.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
wiolink.menu.exception.disabled=Disabled
|
||||
wiolink.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
wiolink.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
wiolink.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
wiolink.menu.exception.enabled=Enabled
|
||||
wiolink.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
wiolink.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
wiolink.upload.resetmethod=nodemcu
|
||||
wiolink.build.flash_mode=qio
|
||||
wiolink.build.flash_flags=-DFLASHMODE_QIO
|
||||
wiolink.build.flash_freq=40
|
||||
wiolink.menu.eesz.4M=4M (no SPIFFS)
|
||||
wiolink.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -5926,14 +5961,15 @@ espectro.menu.vt.heap=Heap
|
|||
espectro.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM
|
||||
espectro.menu.vt.iram=IRAM
|
||||
espectro.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM
|
||||
espectro.menu.exception.enabled=Enabled
|
||||
espectro.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espectro.menu.exception.enabled.build.stdcpp_lib=-lstdc++
|
||||
espectro.menu.exception.disabled=Disabled
|
||||
espectro.menu.exception.disabled.build.exception_flags=-fno-exceptions
|
||||
espectro.menu.exception.disabled.build.stdcpp_lib=-lstdc++-nox
|
||||
espectro.menu.exception.disabled.build.stdcpp_lib=-lstdc++
|
||||
espectro.menu.exception.enabled=Enabled
|
||||
espectro.menu.exception.enabled.build.exception_flags=-fexceptions
|
||||
espectro.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc
|
||||
espectro.upload.resetmethod=nodemcu
|
||||
espectro.build.flash_mode=dio
|
||||
espectro.build.flash_flags=-DFLASHMODE_DIO
|
||||
espectro.build.flash_freq=40
|
||||
espectro.menu.eesz.4M=4M (no SPIFFS)
|
||||
espectro.menu.eesz.4M.build.flash_size=4M
|
||||
|
@ -6083,4 +6119,3 @@ espectro.menu.baud.512000.windows=512000
|
|||
espectro.menu.baud.512000.upload.speed=512000
|
||||
espectro.menu.baud.921600=921600
|
||||
espectro.menu.baud.921600.upload.speed=921600
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=ESP8266 Boards (2.5.0-beta2)
|
||||
version=2.5.0-beta2
|
||||
|
||||
|
||||
name=ESP8266 Boards (2.5.0)
|
||||
version=2.5.0
|
||||
|
||||
runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/tools/xtensa-lx106-elf
|
||||
runtime.tools.esptool.path={runtime.platform.path}/tools/esptool
|
||||
runtime.tools.signing={runtime.platform.path}/tools/signing.py
|
||||
|
||||
compiler.warning_flags=-w
|
||||
|
@ -24,10 +24,8 @@ build.lwip_flags=-DLWIP_OPEN_SRC
|
|||
|
||||
build.vtable_flags=-DVTABLES_IN_FLASH
|
||||
|
||||
#build.exception_flags=-fexceptions
|
||||
build.exception_flags=-fno-exceptions
|
||||
#build.stdcpp_lib=-lstdc++
|
||||
build.stdcpp_lib=-lstdc++-nox
|
||||
build.stdcpp_lib=-lstdc++
|
||||
|
||||
#build.float=-u _printf_float -u _scanf_float
|
||||
build.float=
|
||||
|
@ -39,7 +37,7 @@ compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
|
|||
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/{build.lwip_include}" "-I{compiler.libc.path}/include" "-I{build.path}/core"
|
||||
|
||||
compiler.c.cmd=xtensa-lx106-elf-gcc
|
||||
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 {build.exception_flags} -ffunction-sections -fdata-sections {build.exception_flags}
|
||||
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections {build.exception_flags}
|
||||
|
||||
compiler.S.cmd=xtensa-lx106-elf-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
|
||||
|
@ -80,31 +78,31 @@ compiler.elf2hex.extra_flags=
|
|||
## generate file with git version number
|
||||
## needs bash, git, and echo
|
||||
recipe.hooks.core.prebuild.1.pattern=python "{runtime.tools.signing}" --mode header --publickey "{build.source.path}/public.key" --out "{build.path}/core/Updater_Signing.h"
|
||||
|
||||
|
||||
recipe.hooks.core.prebuild.2.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_VER 0x`git --git-dir {runtime.platform.path}/.git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff` >{build.path}/core/core_version.h"
|
||||
recipe.hooks.core.prebuild.3.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_DESC `cd "{runtime.platform.path}"; git describe --tags 2>/dev/null || echo unix-{version}` >>{build.path}/core/core_version.h"
|
||||
|
||||
## windows-compatible version without git
|
||||
recipe.hooks.core.prebuild.1.pattern.windows=cmd.exe /c rem cannot sign on windows
|
||||
|
||||
|
||||
recipe.hooks.core.prebuild.2.pattern.windows=cmd.exe /c mkdir {build.path}\core & (echo #define ARDUINO_ESP8266_GIT_VER 0x00000000 & echo #define ARDUINO_ESP8266_GIT_DESC win-{version} ) > {build.path}\core\core_version.h
|
||||
recipe.hooks.core.prebuild.3.pattern.windows=cmd.exe /c if exist {build.source.path}\public.key echo #error Cannot automatically build signed binaries on Windows > {build.path}\core\Updater_Signing.h
|
||||
|
||||
## Build the app.ld linker file
|
||||
recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.cmd}" -CC -E -P {build.vtable_flags} "{runtime.platform.path}/tools/sdk/ld/eagle.app.v6.common.ld.h" -o "{build.path}/local.eagle.app.v6.common.ld"
|
||||
|
||||
## Compile c files
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -Wl,-Map "-Wl,{build.path}/{build.project_name}.map" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{archive_file_path}" {compiler.c.elf.libs} -Wl,--end-group "-L{build.path}"
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {build.exception_flags} -Wl,-Map "-Wl,{build.path}/{build.project_name}.map" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{archive_file_path}" {compiler.c.elf.libs} -Wl,--end-group "-L{build.path}"
|
||||
|
||||
## Create eeprom
|
||||
recipe.objcopy.eep.pattern=
|
||||
|
@ -154,3 +152,4 @@ tools.espupload.upload.protocol=espupload
|
|||
tools.espupload.upload.params.verbose=
|
||||
tools.espupload.upload.params.quiet=
|
||||
tools.espupload.upload.pattern="{cmd}" "{path}/espupload.py" -f "{build.path}/{build.project_name}.bin"
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#include "src/ArduinoJson.h"
|
|
@ -1,130 +0,0 @@
|
|||
[![Build status](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/master?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/master) [![Build Status](https://travis-ci.org/bblanchon/ArduinoJson.svg?branch=master)](https://travis-ci.org/bblanchon/ArduinoJson) [![Coverage Status](https://img.shields.io/coveralls/bblanchon/ArduinoJson.svg)](https://coveralls.io/r/bblanchon/ArduinoJson?branch=master) [![Star this project](http://githubbadges.com/star.svg?user=bblanchon&repo=ArduinoJson&style=flat&color=fff&background=007ec6)](https://github.com/bblanchon/ArduinoJson)
|
||||
|
||||
![ArduinoJson's logo](banner.svg)
|
||||
|
||||
ArduinoJson - C++ JSON library for IoT
|
||||
====================
|
||||
|
||||
*An elegant and efficient JSON library for embedded systems.*
|
||||
|
||||
It's designed to have the most intuitive API, the smallest footprint and is able to work without any allocation on the heap (no malloc).
|
||||
|
||||
It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project.
|
||||
For instance, it supports Aduino's `String` and `Stream`, but also `std::string`, `std::istream` and `std::ostream`.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* JSON decoding (comments are supported)
|
||||
* JSON encoding (with optional indentation)
|
||||
* Elegant API, very easy to use
|
||||
* Fixed memory allocation (zero malloc)
|
||||
* No data duplication (zero copy)
|
||||
* Portable (written in C++98)
|
||||
* Self-contained (no external dependency)
|
||||
* Small footprint
|
||||
* Header-only library
|
||||
* MIT License
|
||||
|
||||
Works on
|
||||
--------
|
||||
|
||||
* Arduino boards: Uno, Due, Mini, Micro, Yun...
|
||||
* ESP8266, ESP32
|
||||
* Teensy
|
||||
* RedBearLab boards (BLE Nano...)
|
||||
* Intel Edison and Galileo
|
||||
* WeMos boards: D1...
|
||||
* Computers: Windows, Linux, OSX...
|
||||
* PlatformIO
|
||||
* Particle
|
||||
* Energia
|
||||
|
||||
Quick start
|
||||
-----------
|
||||
|
||||
#### Decoding / Parsing
|
||||
|
||||
```c++
|
||||
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
||||
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
JsonObject& root = jsonBuffer.parseObject(json);
|
||||
|
||||
const char* sensor = root["sensor"];
|
||||
long time = root["time"];
|
||||
double latitude = root["data"][0];
|
||||
double longitude = root["data"][1];
|
||||
```
|
||||
|
||||
[See JsonParserExample.ino](examples/JsonParserExample/JsonParserExample.ino)
|
||||
|
||||
Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size.
|
||||
|
||||
#### Encoding / Generating
|
||||
|
||||
```c++
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
root["sensor"] = "gps";
|
||||
root["time"] = 1351824120;
|
||||
|
||||
JsonArray& data = root.createNestedArray("data");
|
||||
data.add(48.756080);
|
||||
data.add(2.302038);
|
||||
|
||||
root.printTo(Serial);
|
||||
// This prints:
|
||||
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||
```
|
||||
|
||||
[See JsonGeneratorExample.ino](examples/JsonGeneratorExample/JsonGeneratorExample.ino)
|
||||
|
||||
Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size.
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
The documentation is available online in the [ArduinoJson Website](https://bblanchon.github.io/ArduinoJson/).
|
||||
|
||||
The [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) helps you get started with the library.
|
||||
|
||||
|
||||
Donators
|
||||
--------
|
||||
|
||||
Special thanks to the following persons and companies who made generous donations to the library author:
|
||||
|
||||
* Robert Murphy <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Surge Communications <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Alex Scott <img alt='United Kingdom' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1ec-1f1e7.svg' width='18' height='18'>
|
||||
* Firepick Services LLC <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* A B Doodkorte <img alt='Netherlands' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f3-1f1f1.svg' width='18' height='18'>
|
||||
* Scott Smith <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Johann Stieger <img alt='Austria' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1e6-1f1f9.svg' width='18' height='18'>
|
||||
* Gustavo Donizeti Gini <img alt='Brazil' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1e7-1f1f7.svg' width='18' height='18'>
|
||||
* Charles-Henri Hallard <img alt='France' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1eb-1f1f7.svg' width='18' height='18'>
|
||||
* Martijn van den Burg <img alt='Netherlands' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f3-1f1f1.svg' width='18' height='18'>
|
||||
* Nick Koumaris <img alt='Greece' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1ec-1f1f7.svg' width='18' height='18'>
|
||||
* Jon Williams <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Kestutis Liaugminas <img alt='Lithuania' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f1-1f1f9.svg' width='18' height='18'>
|
||||
* Darlington Adibe <img alt='Nigeria' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f3-1f1ec.svg' width='18' height='18'>
|
||||
* Yoeri Kroon <img alt='Netherlands' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f3-1f1f1.svg' width='18' height='18'>
|
||||
* Andrew Melvin <img alt='United Kingdom' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1ec-1f1e7.svg' width='18' height='18'>
|
||||
* Doanh Luong <img alt ='Vietnam' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fb-1f1f3.svg' width='18' height='18'>
|
||||
* Christoph Schmidt <img alt='Germany' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1e9-1f1ea.svg' width='18' height='18'>
|
||||
* OpenEVSE LLC <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Prokhoryatov Alexey <img alt='Russia' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f7-1f1fa.svg' width='18' height='18'>
|
||||
* Google Inc. <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Charles Haynes <img alt='Australia' src='https://d1j8pt39hxlh3d.cloudfront.net/development/emojione/2.2/989/2546.svg' width='18' height='18'>
|
||||
* Charles Walker <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Günther Jehle <img alt='Liechtenstein' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f1-1f1ee.svg' width='18' height='18'>
|
||||
* Patrick Elliott
|
||||
|
||||
|
||||
---
|
||||
|
||||
Found this library useful? Please star this project or [help me back with a donation!](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donate%40benoitblanchon%2efr&lc=GB&item_name=Benoit%20Blanchon&item_number=Arduino%20JSON¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) :smile:
|
|
@ -1,184 +0,0 @@
|
|||
// Sample Arduino Json Web Client
|
||||
// Downloads and parse http://jsonplaceholder.typicode.com/users/1
|
||||
//
|
||||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
EthernetClient client;
|
||||
|
||||
const char* server = "jsonplaceholder.typicode.com"; // server's address
|
||||
const char* resource = "/users/1"; // http resource
|
||||
const unsigned long BAUD_RATE = 9600; // serial connection speed
|
||||
const unsigned long HTTP_TIMEOUT = 10000; // max respone time from server
|
||||
const size_t MAX_CONTENT_SIZE = 512; // max size of the HTTP response
|
||||
|
||||
// The type of data that we want to extract from the page
|
||||
struct UserData {
|
||||
char name[32];
|
||||
char company[32];
|
||||
};
|
||||
|
||||
// ARDUINO entry point #1: runs once when you press reset or power the board
|
||||
void setup() {
|
||||
initSerial();
|
||||
initEthernet();
|
||||
}
|
||||
|
||||
// ARDUINO entry point #2: runs over and over again forever
|
||||
void loop() {
|
||||
if (connect(server)) {
|
||||
if (sendRequest(server, resource) && skipResponseHeaders()) {
|
||||
UserData userData;
|
||||
if (readReponseContent(&userData)) {
|
||||
printUserData(&userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
wait();
|
||||
}
|
||||
|
||||
// Initialize Serial port
|
||||
void initSerial() {
|
||||
Serial.begin(BAUD_RATE);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to initialize
|
||||
}
|
||||
Serial.println("Serial ready");
|
||||
}
|
||||
|
||||
// Initialize Ethernet library
|
||||
void initEthernet() {
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
if (!Ethernet.begin(mac)) {
|
||||
Serial.println("Failed to configure Ethernet");
|
||||
return;
|
||||
}
|
||||
Serial.println("Ethernet ready");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// Open connection to the HTTP server
|
||||
bool connect(const char* hostName) {
|
||||
Serial.print("Connect to ");
|
||||
Serial.println(hostName);
|
||||
|
||||
bool ok = client.connect(hostName, 80);
|
||||
|
||||
Serial.println(ok ? "Connected" : "Connection Failed!");
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Send the HTTP GET request to the server
|
||||
bool sendRequest(const char* host, const char* resource) {
|
||||
Serial.print("GET ");
|
||||
Serial.println(resource);
|
||||
|
||||
client.print("GET ");
|
||||
client.print(resource);
|
||||
client.println(" HTTP/1.0");
|
||||
client.print("Host: ");
|
||||
client.println(host);
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip HTTP headers so that we are at the beginning of the response's body
|
||||
bool skipResponseHeaders() {
|
||||
// HTTP headers end with an empty line
|
||||
char endOfHeaders[] = "\r\n\r\n";
|
||||
|
||||
client.setTimeout(HTTP_TIMEOUT);
|
||||
bool ok = client.find(endOfHeaders);
|
||||
|
||||
if (!ok) {
|
||||
Serial.println("No response or invalid response!");
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Parse the JSON from the input string and extract the interesting values
|
||||
// Here is the JSON we need to parse
|
||||
// {
|
||||
// "id": 1,
|
||||
// "name": "Leanne Graham",
|
||||
// "username": "Bret",
|
||||
// "email": "Sincere@april.biz",
|
||||
// "address": {
|
||||
// "street": "Kulas Light",
|
||||
// "suite": "Apt. 556",
|
||||
// "city": "Gwenborough",
|
||||
// "zipcode": "92998-3874",
|
||||
// "geo": {
|
||||
// "lat": "-37.3159",
|
||||
// "lng": "81.1496"
|
||||
// }
|
||||
// },
|
||||
// "phone": "1-770-736-8031 x56442",
|
||||
// "website": "hildegard.org",
|
||||
// "company": {
|
||||
// "name": "Romaguera-Crona",
|
||||
// "catchPhrase": "Multi-layered client-server neural-net",
|
||||
// "bs": "harness real-time e-markets"
|
||||
// }
|
||||
// }
|
||||
bool readReponseContent(struct UserData* userData) {
|
||||
// Compute optimal size of the JSON buffer according to what we need to parse.
|
||||
// See https://bblanchon.github.io/ArduinoJson/assistant/
|
||||
const size_t BUFFER_SIZE =
|
||||
JSON_OBJECT_SIZE(8) // the root object has 8 elements
|
||||
+ JSON_OBJECT_SIZE(5) // the "address" object has 5 elements
|
||||
+ JSON_OBJECT_SIZE(2) // the "geo" object has 2 elements
|
||||
+ JSON_OBJECT_SIZE(3) // the "company" object has 3 elements
|
||||
+ MAX_CONTENT_SIZE; // additional space for strings
|
||||
|
||||
// Allocate a temporary memory pool
|
||||
DynamicJsonBuffer jsonBuffer(BUFFER_SIZE);
|
||||
|
||||
JsonObject& root = jsonBuffer.parseObject(client);
|
||||
|
||||
if (!root.success()) {
|
||||
Serial.println("JSON parsing failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Here were copy the strings we're interested in
|
||||
strcpy(userData->name, root["name"]);
|
||||
strcpy(userData->company, root["company"]["name"]);
|
||||
// It's not mandatory to make a copy, you could just use the pointers
|
||||
// Since, they are pointing inside the "content" buffer, so you need to make
|
||||
// sure it's still in memory when you read the string
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Print the data extracted from the JSON
|
||||
void printUserData(const struct UserData* userData) {
|
||||
Serial.print("Name = ");
|
||||
Serial.println(userData->name);
|
||||
Serial.print("Company = ");
|
||||
Serial.println(userData->company);
|
||||
}
|
||||
|
||||
// Close the connection with the HTTP server
|
||||
void disconnect() {
|
||||
Serial.println("Disconnect");
|
||||
client.stop();
|
||||
}
|
||||
|
||||
// Pause for a 1 minute
|
||||
void wait() {
|
||||
Serial.println("Wait 60 seconds");
|
||||
delay(60000);
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
// Sample Arduino Json Web Server
|
||||
// Created by Benoit Blanchon.
|
||||
// Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
IPAddress ip(192, 168, 0, 177);
|
||||
EthernetServer server(80);
|
||||
|
||||
bool readRequest(EthernetClient& client) {
|
||||
bool currentLineIsBlank = true;
|
||||
while (client.connected()) {
|
||||
if (client.available()) {
|
||||
char c = client.read();
|
||||
if (c == '\n' && currentLineIsBlank) {
|
||||
return true;
|
||||
} else if (c == '\n') {
|
||||
currentLineIsBlank = true;
|
||||
} else if (c != '\r') {
|
||||
currentLineIsBlank = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
JsonArray& analogValues = root.createNestedArray("analog");
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
int value = analogRead(pin);
|
||||
analogValues.add(value);
|
||||
}
|
||||
|
||||
JsonArray& digitalValues = root.createNestedArray("digital");
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
int value = digitalRead(pin);
|
||||
digitalValues.add(value);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
void writeResponse(EthernetClient& client, JsonObject& json) {
|
||||
client.println("HTTP/1.1 200 OK");
|
||||
client.println("Content-Type: application/json");
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
|
||||
json.prettyPrintTo(client);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Ethernet.begin(mac, ip);
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EthernetClient client = server.available();
|
||||
if (client) {
|
||||
bool success = readRequest(client);
|
||||
if (success) {
|
||||
// Use https://bblanchon.github.io/ArduinoJson/assistant/ to
|
||||
// compute the right size for the buffer
|
||||
StaticJsonBuffer<500> jsonBuffer;
|
||||
JsonObject& json = prepareResponse(jsonBuffer);
|
||||
writeResponse(client, json);
|
||||
}
|
||||
delay(1);
|
||||
client.stop();
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
// Send a JSON object on UDP at regular interval
|
||||
//
|
||||
// You can easily test this program with netcat:
|
||||
// $ nc -ulp 8888
|
||||
//
|
||||
// by Benoit Blanchon, MIT License 2015-2017
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
IPAddress localIp(192, 168, 0, 177);
|
||||
IPAddress remoteIp(192, 168, 0, 109);
|
||||
unsigned int remotePort = 8888;
|
||||
unsigned localPort = 8888;
|
||||
EthernetUDP udp;
|
||||
|
||||
JsonObject& buildJson(JsonBuffer& jsonBuffer) {
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
JsonArray& analogValues = root.createNestedArray("analog");
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
int value = analogRead(pin);
|
||||
analogValues.add(value);
|
||||
}
|
||||
|
||||
JsonArray& digitalValues = root.createNestedArray("digital");
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
int value = digitalRead(pin);
|
||||
digitalValues.add(value);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
void sendJson(JsonObject& json) {
|
||||
udp.beginPacket(remoteIp, remotePort);
|
||||
json.printTo(udp);
|
||||
udp.println();
|
||||
udp.endPacket();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Ethernet.begin(mac, localIp);
|
||||
udp.begin(localPort);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
delay(1000);
|
||||
|
||||
// Use https://bblanchon.github.io/ArduinoJson/assistant/ to
|
||||
// compute the right size for the buffer
|
||||
StaticJsonBuffer<300> jsonBuffer;
|
||||
JsonObject& json = buildJson(jsonBuffer);
|
||||
sendJson(json);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
name=ArduinoJson
|
||||
version=5.11.2
|
||||
author=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
sentence=An efficient and elegant JSON library for Arduino.
|
||||
paragraph=Like this project? Please star it on GitHub!
|
||||
category=Data Processing
|
||||
url=https://bblanchon.github.io/ArduinoJson/
|
||||
architectures=*
|
|
@ -1,12 +0,0 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ArduinoJson.hpp"
|
||||
|
||||
using namespace ArduinoJson;
|
|
@ -1,51 +0,0 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../JsonBuffer.hpp"
|
||||
#include "../JsonVariant.hpp"
|
||||
#include "../StringTraits/StringTraits.hpp"
|
||||
#include "../TypeTraits/EnableIf.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
template <typename TSourceRef, typename Enable = void>
|
||||
struct ValueSetter {
|
||||
template <typename TDestination>
|
||||
static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) {
|
||||
destination = source;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TSourceRef>
|
||||
struct ValueSetter<TSourceRef, typename TypeTraits::EnableIf<StringTraits<
|
||||
TSourceRef>::should_duplicate>::type> {
|
||||
template <typename TDestination>
|
||||
static bool set(JsonBuffer* buffer, TDestination& destination,
|
||||
TSourceRef source) {
|
||||
const char* copy = buffer->strdup(source);
|
||||
if (!copy) return false;
|
||||
destination = copy;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TSourceRef>
|
||||
struct ValueSetter<TSourceRef, typename TypeTraits::EnableIf<!StringTraits<
|
||||
TSourceRef>::should_duplicate>::type> {
|
||||
template <typename TDestination>
|
||||
static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) {
|
||||
// unsigned char* -> char*
|
||||
destination = reinterpret_cast<const char*>(source);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "./ctype.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
|
||||
inline bool isInteger(const char* s) {
|
||||
if (!s) return false;
|
||||
if (issign(*s)) s++;
|
||||
while (isdigit(*s)) s++;
|
||||
return *s == '\0';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// A special type of data that can be used to insert pregenerated JSON portions.
|
||||
class RawJson {
|
||||
public:
|
||||
explicit RawJson(const char* str) : _str(str) {}
|
||||
operator const char*() const {
|
||||
return _str;
|
||||
}
|
||||
|
||||
private:
|
||||
const char* _str;
|
||||
};
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Configuration.hpp"
|
||||
#include "IsSame.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace TypeTraits {
|
||||
|
||||
// A meta-function that returns true if T is an integral type.
|
||||
template <typename T>
|
||||
struct IsSignedIntegral {
|
||||
static const bool value = TypeTraits::IsSame<T, signed char>::value ||
|
||||
TypeTraits::IsSame<T, signed short>::value ||
|
||||
TypeTraits::IsSame<T, signed int>::value ||
|
||||
TypeTraits::IsSame<T, signed long>::value ||
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
TypeTraits::IsSame<T, signed long long>::value ||
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_USE_INT64
|
||||
TypeTraits::IsSame<T, signed __int64>::value ||
|
||||
#endif
|
||||
false;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Configuration.hpp"
|
||||
#include "IsSame.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace TypeTraits {
|
||||
|
||||
// A meta-function that returns true if T is an integral type.
|
||||
template <typename T>
|
||||
struct IsUnsignedIntegral {
|
||||
static const bool value = TypeTraits::IsSame<T, unsigned char>::value ||
|
||||
TypeTraits::IsSame<T, unsigned short>::value ||
|
||||
TypeTraits::IsSame<T, unsigned int>::value ||
|
||||
TypeTraits::IsSame<T, unsigned long>::value ||
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
TypeTraits::IsSame<T, unsigned long long>::value ||
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_USE_INT64
|
||||
TypeTraits::IsSame<T, unsigned __int64>::value ||
|
||||
#endif
|
||||
false;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#include "src/ArduinoJson.h"
|
|
@ -1,6 +1,78 @@
|
|||
ArduinoJson: change log
|
||||
=======================
|
||||
|
||||
v5.13.4
|
||||
-------
|
||||
|
||||
* Removed spurious files in the Particle library
|
||||
|
||||
v5.13.3
|
||||
-------
|
||||
|
||||
* Improved float serialization when `-fsingle-precision-constant` is used
|
||||
* Fixed `JsonVariant::is<int>()` that returned true for empty strings
|
||||
* Fixed `JsonVariant::is<String>()` (closes #763)
|
||||
|
||||
v5.13.2
|
||||
-------
|
||||
|
||||
* Fixed `JsonBuffer::parse()` not respecting nesting limit correctly (issue #693)
|
||||
* Fixed inconsistencies in nesting level counting (PR #695 from Zhenyu Wu)
|
||||
* Fixed null values that could be pass to `strcmp()` (PR #745 from Mike Karlesky)
|
||||
* Added macros `ARDUINOJSON_VERSION`, `ARDUINOJSON_VERSION_MAJOR`...
|
||||
|
||||
v5.13.1
|
||||
-------
|
||||
|
||||
* Fixed `JsonVariant::operator|(int)` that returned the default value if the variant contained a double (issue #675)
|
||||
* Allowed non-quoted key to contain underscores (issue #665)
|
||||
|
||||
v5.13.0
|
||||
-------
|
||||
|
||||
* Changed the rules of string duplication (issue #658)
|
||||
* `RawJson()` accepts any kind of string and obeys to the same rules for duplication
|
||||
* Changed the return type of `strdup()` to `const char*` to prevent double duplication
|
||||
* Marked `strdup()` as deprecated
|
||||
|
||||
> ### New rules for string duplication
|
||||
>
|
||||
> | type | duplication |
|
||||
> |:---------------------------|:------------|
|
||||
> | const char* | no |
|
||||
> | char* | ~~no~~ yes |
|
||||
> | String | yes |
|
||||
> | std::string | yes |
|
||||
> | const __FlashStringHelper* | yes |
|
||||
>
|
||||
> These new rules make `JsonBuffer::strdup()` useless.
|
||||
|
||||
v5.12.0
|
||||
-------
|
||||
|
||||
* Added `JsonVariant::operator|` to return a default value (see below)
|
||||
* Added a clear error message when compiled as C instead of C++ (issue #629)
|
||||
* Added detection of MPLAB XC compiler (issue #629)
|
||||
* Added detection of Keil ARM Compiler (issue #629)
|
||||
* Added an example that shows how to save and load a configuration file
|
||||
* Reworked all other examples
|
||||
|
||||
> ### How to use the new feature?
|
||||
>
|
||||
> If you have a block like this:
|
||||
>
|
||||
> ```c++
|
||||
> const char* ssid = root["ssid"];
|
||||
> if (!ssid)
|
||||
> ssid = "default ssid";
|
||||
> ```
|
||||
>
|
||||
> You can simplify like that:
|
||||
>
|
||||
> ```c++
|
||||
> const char* ssid = root["ssid"] | "default ssid";
|
||||
> ```
|
||||
|
||||
v5.11.2
|
||||
-------
|
||||
|
||||
|
@ -42,27 +114,26 @@ v5.10.0
|
|||
* Fixed error `IsBaseOf is not a member of ArduinoJson::TypeTraits` (issue #495)
|
||||
* Fixed error `forming reference to reference` (issue #495)
|
||||
|
||||
### BREAKING CHANGES :warning:
|
||||
|
||||
| Old syntax | New syntax |
|
||||
|---------------------------------|---------------------|
|
||||
| `double_with_n_digits(3.14, 2)` | `3.14` |
|
||||
| `float_with_n_digits(3.14, 2)` | `3.14f` |
|
||||
| `obj.set("key", 3.14, 2)` | `obj["key"] = 3.14` |
|
||||
| `arr.add(3.14, 2)` | `arr.add(3.14)` |
|
||||
|
||||
| Input | Old output | New output |
|
||||
|-----------|------------|------------|
|
||||
| `3.14159` | `3.14` | `3.14159` |
|
||||
| `42.0` | `42.00` | `42` |
|
||||
| `0.0` | `0.00` | `0` |
|
||||
|
||||
| Expression | Old result | New result |
|
||||
|--------------------------------|------------|------------|
|
||||
| `JsonVariant(42).is<int>()` | `true` | `true` |
|
||||
| `JsonVariant(42).is<float>()` | `false` | `true` |
|
||||
| `JsonVariant(42).is<double>()` | `false` | `true` |
|
||||
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> | Old syntax | New syntax |
|
||||
> |:--------------------------------|:--------------------|
|
||||
> | `double_with_n_digits(3.14, 2)` | `3.14` |
|
||||
> | `float_with_n_digits(3.14, 2)` | `3.14f` |
|
||||
> | `obj.set("key", 3.14, 2)` | `obj["key"] = 3.14` |
|
||||
> | `arr.add(3.14, 2)` | `arr.add(3.14)` |
|
||||
>
|
||||
> | Input | Old output | New output |
|
||||
> |:----------|:-----------|:-----------|
|
||||
> | `3.14159` | `3.14` | `3.14159` |
|
||||
> | `42.0` | `42.00` | `42` |
|
||||
> | `0.0` | `0.00` | `0` |
|
||||
>
|
||||
> | Expression | Old result | New result |
|
||||
> |:-------------------------------|:-----------|:-----------|
|
||||
> | `JsonVariant(42).is<int>()` | `true` | `true` |
|
||||
> | `JsonVariant(42).is<float>()` | `false` | `true` |
|
||||
> | `JsonVariant(42).is<double>()` | `false` | `true` |
|
||||
|
||||
v5.9.0
|
||||
------
|
||||
|
@ -116,24 +187,23 @@ v5.8.0
|
|||
* Added support for `Stream` (issue #300)
|
||||
* Reduced memory consumption by not duplicating spaces and comments
|
||||
|
||||
### BREAKING CHANGES :warning:
|
||||
|
||||
`JsonBuffer::parseObject()` and `JsonBuffer::parseArray()` have been pulled down to the derived classes `DynamicJsonBuffer` and `StaticJsonBufferBase`.
|
||||
|
||||
This means that if you have code like:
|
||||
|
||||
```c++
|
||||
void myFunction(JsonBuffer& jsonBuffer);
|
||||
```
|
||||
|
||||
you need to replace it with one of the following:
|
||||
|
||||
```c++
|
||||
void myFunction(DynamicJsonBuffer& jsonBuffer);
|
||||
void myFunction(StaticJsonBufferBase& jsonBuffer);
|
||||
template<typename TJsonBuffer> void myFunction(TJsonBuffer& jsonBuffer);
|
||||
```
|
||||
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> `JsonBuffer::parseObject()` and `JsonBuffer::parseArray()` have been pulled down to the derived classes `DynamicJsonBuffer` and `StaticJsonBufferBase`.
|
||||
>
|
||||
> This means that if you have code like:
|
||||
>
|
||||
> ```c++
|
||||
> void myFunction(JsonBuffer& jsonBuffer);
|
||||
> ```
|
||||
>
|
||||
> you need to replace it with one of the following:
|
||||
>
|
||||
> ```c++
|
||||
> void myFunction(DynamicJsonBuffer& jsonBuffer);
|
||||
> void myFunction(StaticJsonBufferBase& jsonBuffer);
|
||||
> template<typename TJsonBuffer> void myFunction(TJsonBuffer& jsonBuffer);
|
||||
> ```
|
||||
|
||||
v5.7.3
|
||||
------
|
||||
|
@ -166,27 +236,26 @@ v5.7.0
|
|||
* Added example `StringExample.ino` to show where `String` can be used
|
||||
* Increased default nesting limit to 50 when compiled for a computer (issue #349)
|
||||
|
||||
### BREAKING CHANGES :warning:
|
||||
|
||||
The non-template functions `JsonObject::get()` and `JsonArray.get()` have been removed. This means that you need to explicitely tell the type you expect in return.
|
||||
|
||||
Old code:
|
||||
|
||||
```c++
|
||||
#define ARDUINOJSON_USE_ARDUINO_STRING 0
|
||||
JsonVariant value1 = myObject.get("myKey");
|
||||
JsonVariant value2 = myArray.get(0);
|
||||
```
|
||||
|
||||
New code:
|
||||
|
||||
```c++
|
||||
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0
|
||||
#define ARDUINOJSON_ENABLE_STD_STRING 1
|
||||
JsonVariant value1 = myObject.get<JsonVariant>("myKey");
|
||||
JsonVariant value2 = myArray.get<JsonVariant>(0);
|
||||
```
|
||||
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> The non-template functions `JsonObject::get()` and `JsonArray.get()` have been removed. This means that you need to explicitely tell the type you expect in return.
|
||||
>
|
||||
> Old code:
|
||||
>
|
||||
> ```c++
|
||||
> #define ARDUINOJSON_USE_ARDUINO_STRING 0
|
||||
> JsonVariant value1 = myObject.get("myKey");
|
||||
> JsonVariant value2 = myArray.get(0);
|
||||
> ```
|
||||
>
|
||||
> New code:
|
||||
>
|
||||
> ```c++
|
||||
> #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0
|
||||
> #define ARDUINOJSON_ENABLE_STD_STRING 1
|
||||
> JsonVariant value1 = myObject.get<JsonVariant>("myKey");
|
||||
> JsonVariant value2 = myArray.get<JsonVariant>(0);
|
||||
> ```
|
||||
|
||||
v5.6.7
|
||||
------
|
||||
|
@ -278,8 +347,9 @@ v5.1.0
|
|||
* Added support of `long long` (issue #171)
|
||||
* Moved all build settings to `ArduinoJson/Configuration.hpp`
|
||||
|
||||
**BREAKING CHANGE**:
|
||||
If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`.
|
||||
> ### BREAKING CHANGE :warning:
|
||||
>
|
||||
> If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`.
|
||||
|
||||
v5.0.8
|
||||
------
|
||||
|
@ -293,10 +363,10 @@ v5.0.7
|
|||
* Made library easier to use from a CMake project: simply `add_subdirectory(ArduinoJson/src)`
|
||||
* Changed `String` to be a `typedef` of `std::string` (issues #142 and #161)
|
||||
|
||||
### BREAKING CHANGES :warning:
|
||||
|
||||
- `JsonVariant(true).as<String>()` now returns `"true"` instead of `"1"`
|
||||
- `JsonVariant(false).as<String>()` now returns `"false"` instead of `"0"`
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> - `JsonVariant(true).as<String>()` now returns `"true"` instead of `"1"`
|
||||
> - `JsonVariant(false).as<String>()` now returns `"false"` instead of `"0"`
|
||||
|
||||
v5.0.6
|
||||
------
|
||||
|
@ -350,11 +420,11 @@ v5.0.0
|
|||
* Redesigned `JsonVariant` to leverage converting constructors instead of assignment operators (issue #66)
|
||||
* Switched to new the library layout (requires Arduino 1.0.6 or above)
|
||||
|
||||
### BREAKING CHANGES :warning:
|
||||
|
||||
- `JsonObject::add()` was renamed to `set()`
|
||||
- `JsonArray::at()` and `JsonObject::at()` were renamed to `get()`
|
||||
- Number of digits of floating point value are now set with `double_with_n_digits()`
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> - `JsonObject::add()` was renamed to `set()`
|
||||
> - `JsonArray::at()` and `JsonObject::at()` were renamed to `get()`
|
||||
> - Number of digits of floating point value are now set with `double_with_n_digits()`
|
||||
|
||||
**Personal note about the `String` class**:
|
||||
Support of the `String` class has been added to the library because many people use it in their programs.
|
||||
|
@ -407,106 +477,7 @@ v4.0
|
|||
* Unified parser and generator API (issue #23)
|
||||
* Updated library layout, now requires Arduino 1.0.6 or newer
|
||||
|
||||
**BREAKING CHANGE**: API changed significantly, see [Migrating code to the new API](https://github.com/bblanchon/ArduinoJson/wiki/Migrating-code-to-the-new-API).
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> API changed significantly since v3, see [Migrating code to the new API](https://arduinojson.org/doc/migration/).
|
||||
|
||||
|
||||
v3.4
|
||||
----
|
||||
|
||||
* Fixed escaped char parsing (issue #16)
|
||||
|
||||
|
||||
v3.3
|
||||
----
|
||||
|
||||
* Added indented output for the JSON generator (issue #11), see example bellow.
|
||||
* Added `IndentedPrint`, a decorator for `Print` to allow indented output
|
||||
|
||||
Example:
|
||||
|
||||
JsonOject<2> json;
|
||||
json["key"] = "value";
|
||||
json.prettyPrintTo(Serial);
|
||||
|
||||
v3.2
|
||||
----
|
||||
|
||||
* Fixed a bug when adding nested object in `JsonArray` (bug introduced in v3.1).
|
||||
|
||||
v3.1
|
||||
----
|
||||
|
||||
* Calling `Generator::JsonObject::add()` twice with the same `key` now replaces the `value`
|
||||
* Added `Generator::JsonObject::operator[]`, see bellow the new API
|
||||
* Added `Generator::JsonObject::remove()` (issue #9)
|
||||
|
||||
Old generator API:
|
||||
|
||||
JsonObject<3> root;
|
||||
root.add("sensor", "gps");
|
||||
root.add("time", 1351824120);
|
||||
root.add("data", array);
|
||||
|
||||
New generator API:
|
||||
|
||||
JsonObject<3> root;
|
||||
root["sensor"] = "gps";
|
||||
root["time"] = 1351824120;
|
||||
root["data"] = array;
|
||||
|
||||
v3.0
|
||||
----
|
||||
|
||||
* New parser API, see bellow
|
||||
* Renamed `JsonHashTable` into `JsonObject`
|
||||
* Added iterators for `JsonArray` and `JsonObject` (issue #4)
|
||||
|
||||
Old parser API:
|
||||
|
||||
JsonHashTable root = parser.parseHashTable(json);
|
||||
|
||||
char* sensor = root.getString("sensor");
|
||||
long time = root.getLong("time");
|
||||
double latitude = root.getArray("data").getDouble(0);
|
||||
double longitude = root.getArray("data").getDouble(1);
|
||||
|
||||
New parser API:
|
||||
|
||||
JsonObject root = parser.parse(json);
|
||||
|
||||
char* sensor = root["sensor"];
|
||||
long time = root["time"];
|
||||
double latitude = root["data"][0];
|
||||
double longitude = root["data"][1];
|
||||
|
||||
v2.1
|
||||
----
|
||||
|
||||
* Fixed case `#include "jsmn.cpp"` which caused an error in Linux (issue #6)
|
||||
* Fixed a buffer overrun in JSON Parser (issue #5)
|
||||
|
||||
v2.0
|
||||
----
|
||||
|
||||
* Added JSON encoding (issue #2)
|
||||
* Renamed the library `ArduinoJsonParser` becomes `ArduinoJson`
|
||||
|
||||
**Breaking change**: you need to add the following line at the top of your program.
|
||||
|
||||
using namespace ArduinoJson::Parser;
|
||||
|
||||
v1.2
|
||||
----
|
||||
|
||||
* Fixed error in JSON parser example (issue #1)
|
||||
|
||||
v1.1
|
||||
----
|
||||
|
||||
* Example: changed `char* json` into `char[] json` so that the bytes are not write protected
|
||||
* Fixed parsing bug when the JSON contains multi-dimensional arrays
|
||||
|
||||
v1.0
|
||||
----
|
||||
|
||||
Initial release
|
|
@ -1,7 +1,7 @@
|
|||
The MIT License (MIT)
|
||||
---------------------
|
||||
|
||||
Copyright © 2014-2017 Benoit BLANCHON
|
||||
Copyright © 2014-2018 Benoit BLANCHON
|
||||
|
||||
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:
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
![ArduinoJson](banner.svg)
|
||||
|
||||
---
|
||||
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/master?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/master) [![Build Status](https://travis-ci.org/bblanchon/ArduinoJson.svg?branch=master)](https://travis-ci.org/bblanchon/ArduinoJson) [![Coverage Status](https://img.shields.io/coveralls/bblanchon/ArduinoJson.svg)](https://coveralls.io/r/bblanchon/ArduinoJson?branch=master) [![Star this project](http://githubbadges.com/star.svg?user=bblanchon&repo=ArduinoJson&style=flat&color=fff&background=007ec6)](https://github.com/bblanchon/ArduinoJson)
|
||||
|
||||
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
|
||||
|
||||
## Features
|
||||
|
||||
* JSON decoding (comments are supported)
|
||||
* JSON encoding (with optional indentation)
|
||||
* Elegant API, easy to use
|
||||
* Fixed memory allocation (zero malloc)
|
||||
* No data duplication (zero copy)
|
||||
* Portable (written in C++98, can be used in any C++ project)
|
||||
* Self-contained (no external dependency)
|
||||
* Small footprint
|
||||
* Input and output streams
|
||||
* [100% code coverage](https://coveralls.io/github/bblanchon/ArduinoJson)
|
||||
* [Header-only library](https://en.wikipedia.org/wiki/Header-only)
|
||||
* [MIT License](https://en.wikipedia.org/wiki/MIT_License)
|
||||
* [Comprehensive documentation](https://arduinojson.org?utm_source=github&utm_medium=readme)
|
||||
|
||||
## Compatibility
|
||||
|
||||
ArduinoJson works on the following hardware:
|
||||
|
||||
* <img src="https://www.arduino.cc/favicon.ico" height="16" width="16"> Arduino boards: [Uno](https://www.arduino.cc/en/Main/ArduinoBoardUno), [Due](https://www.arduino.cc/en/Main/ArduinoBoardDue), [Mini](https://www.arduino.cc/en/Main/ArduinoBoardMini), [Micro](https://www.arduino.cc/en/Main/ArduinoBoardMicro), [Yun](https://www.arduino.cc/en/Main/ArduinoBoardYun)...
|
||||
* <img src="http://espressif.com/sites/all/themes/espressif/favicon.ico" height="16" width="16"> Espressif chips: [ESP8266](https://en.wikipedia.org/wiki/ESP8266), [ESP32](https://en.wikipedia.org/wiki/ESP32)
|
||||
* <img src="https://www.wemos.cc/themes/martin-materialize-parallax/assets/favicon.ico" height="16" width="16"> WeMos boards: [D1](https://wiki.wemos.cc/products:d1:d1), [D1 mini](https://wiki.wemos.cc/products:d1:d1_mini), ...
|
||||
* <img src="http://redbearlab.com/favicon.ico" height="16" width="16"> RedBearLab boards: [BLE Nano](http://redbearlab.com/blenano/), [BLE Mini](http://redbearlab.com/blemini/), [WiFi Micro](https://redbear.cc/product/wifi/wifi-micro.html), [LOLIN32](https://wiki.wemos.cc/products:lolin32:lolin32)...
|
||||
* <img src="https://www.pjrc.com/favicon.ico" height="16" width="16"> [Teensy](https://www.pjrc.com/teensy/) boards
|
||||
* <img src="https://software.intel.com/sites/all/themes/zero/favicon.ico" height="16" width="16"> Intel boards: Edison, Galileo...
|
||||
* <img src="https://www-assets.particle.io/images/favicon.png" height="16" width="16"> Particle boards: [Photon](https://www.particle.io/products/hardware/photon-wifi-dev-kit), [Electron](https://www.particle.io/products/hardware/electron-cellular-dev-kit)...
|
||||
* <img src="http://www.ti.com/favicon.ico" height="16" width="16"> Texas Instruments boards: [MSP430](http://www.ti.com/microcontrollers/msp430-ultra-low-power-mcus/overview/overview.html)...
|
||||
|
||||
ArduinoJson compiles with zero warning on the following compilers, IDEs, and platforms:
|
||||
|
||||
* <img src="https://www.arduino.cc/favicon.ico" height="16" width="16"> [Arduino IDE](https://www.arduino.cc/en/Main/Software)
|
||||
* <img src="http://cdn.platformio.org/favicon.ico" height="16" width="16"> [PlatformIO](http://platformio.org/)
|
||||
* <img src="http://energia.nu/img/favicon.ico" height="16" width="16"> [Energia](http://energia.nu/)
|
||||
* <img src="http://www.visualmicro.com/pics/arduino-visual-studio-ld.png" height="16" width="16"> [Visual Micro](http://www.visualmicro.com/)
|
||||
* <img src="http://www.atmel.com/Images/favicon.ico" height="16" width="16"> [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/)
|
||||
* <img src="https://www.iar.com/favicon.ico" height="16" width="16"> [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/)
|
||||
* <img src="http://www.st.com/etc/clientlibs/st-site/media/app/images/favicon.png" height="16" width="16"> [Atollic TrueSTUDIO](https://atollic.com/truestudio/)
|
||||
* <img src="http://www.keil.com/favicon.ico" height="16" width="16"> [Keil uVision](http://www.keil.com/)
|
||||
* <img src="http://www.microchip.com/favicon.ico" height="16" width="16"> [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide)
|
||||
* <img src="https://gcc.gnu.org/favicon.ico" height="16" width="16"> [GCC](https://gcc.gnu.org/)
|
||||
* <img src="https://clang.llvm.org/favicon.ico" height="16" width="16"> [Clang](https://clang.llvm.org/)
|
||||
* <img src="https://www.visualstudio.com/favicon.ico" height="16" width="16"> [Visual Studio](https://www.visualstudio.com/)
|
||||
|
||||
## Quickstart
|
||||
|
||||
### Deserialization
|
||||
|
||||
Here is a program that parses a JSON document with ArduinoJson.
|
||||
|
||||
```c++
|
||||
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
||||
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
JsonObject& root = jsonBuffer.parseObject(json);
|
||||
|
||||
const char* sensor = root["sensor"];
|
||||
long time = root["time"];
|
||||
double latitude = root["data"][0];
|
||||
double longitude = root["data"][1];
|
||||
```
|
||||
|
||||
See the [tutorial on arduinojson.org](https://arduinojson.org/doc/decoding/?utm_source=github&utm_medium=readme)
|
||||
|
||||
### Serialization
|
||||
|
||||
Here is a program that generates a JSON document with ArduinoJson:
|
||||
|
||||
```c++
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
root["sensor"] = "gps";
|
||||
root["time"] = 1351824120;
|
||||
|
||||
JsonArray& data = root.createNestedArray("data");
|
||||
data.add(48.756080);
|
||||
data.add(2.302038);
|
||||
|
||||
root.printTo(Serial);
|
||||
// This prints:
|
||||
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||
```
|
||||
|
||||
See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme)
|
||||
|
||||
## Documentation
|
||||
|
||||
The documentation is available on [arduinojson.org](https://arduinojson.org/?utm_source=github&utm_medium=readme), here are some shortcuts:
|
||||
|
||||
* The [Examples](https://arduinojson.org/example/?utm_source=github&utm_medium=readme) show how to use the library in various situations.
|
||||
* The [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=readme) contains the description of each class and function.
|
||||
* The [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=readme) has the answer to virtually every question.
|
||||
* The [ArduinoJson Assistant](https://arduinojson.org/assistant/?utm_source=github&utm_medium=readme) writes programs for you!
|
||||
|
||||
---
|
||||
|
||||
Do you like this library? Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)!
|
||||
|
||||
What? You don't like it but you *love* it?
|
||||
We don't take donations anymore, but [we sell a book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme), so you can help and learn at the same time!
|
|
@ -0,0 +1,144 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows how to store your project configuration in a file.
|
||||
// It uses the SD library but can be easily modified for any other file-system.
|
||||
//
|
||||
// The file contains a JSON document with the following content:
|
||||
// {
|
||||
// "hostname": "examples.com",
|
||||
// "port": 2731
|
||||
// }
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <SD.h>
|
||||
#include <SPI.h>
|
||||
|
||||
// Configuration that we'll store on disk
|
||||
struct Config {
|
||||
char hostname[64];
|
||||
int port;
|
||||
};
|
||||
|
||||
const char *filename = "/config.txt"; // <- SD library uses 8.3 filenames
|
||||
Config config; // <- global configuration object
|
||||
|
||||
// Loads the configuration from a file
|
||||
void loadConfiguration(const char *filename, Config &config) {
|
||||
// Open file for reading
|
||||
File file = SD.open(filename);
|
||||
|
||||
// Allocate the memory pool on the stack.
|
||||
// Don't forget to change the capacity to match your JSON document.
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<512> jsonBuffer;
|
||||
|
||||
// Parse the root object
|
||||
JsonObject &root = jsonBuffer.parseObject(file);
|
||||
|
||||
if (!root.success())
|
||||
Serial.println(F("Failed to read file, using default configuration"));
|
||||
|
||||
// Copy values from the JsonObject to the Config
|
||||
config.port = root["port"] | 2731;
|
||||
strlcpy(config.hostname, // <- destination
|
||||
root["hostname"] | "example.com", // <- source
|
||||
sizeof(config.hostname)); // <- destination's capacity
|
||||
|
||||
// Close the file (File's destructor doesn't close the file)
|
||||
file.close();
|
||||
}
|
||||
|
||||
// Saves the configuration to a file
|
||||
void saveConfiguration(const char *filename, const Config &config) {
|
||||
// Delete existing file, otherwise the configuration is appended to the file
|
||||
SD.remove(filename);
|
||||
|
||||
// Open file for writing
|
||||
File file = SD.open(filename, FILE_WRITE);
|
||||
if (!file) {
|
||||
Serial.println(F("Failed to create file"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate the memory pool on the stack
|
||||
// Don't forget to change the capacity to match your JSON document.
|
||||
// Use https://arduinojson.org/assistant/ to compute the capacity.
|
||||
StaticJsonBuffer<256> jsonBuffer;
|
||||
|
||||
// Parse the root object
|
||||
JsonObject &root = jsonBuffer.createObject();
|
||||
|
||||
// Set the values
|
||||
root["hostname"] = config.hostname;
|
||||
root["port"] = config.port;
|
||||
|
||||
// Serialize JSON to file
|
||||
if (root.printTo(file) == 0) {
|
||||
Serial.println(F("Failed to write to file"));
|
||||
}
|
||||
|
||||
// Close the file (File's destructor doesn't close the file)
|
||||
file.close();
|
||||
}
|
||||
|
||||
// Prints the content of a file to the Serial
|
||||
void printFile(const char *filename) {
|
||||
// Open file for reading
|
||||
File file = SD.open(filename);
|
||||
if (!file) {
|
||||
Serial.println(F("Failed to read file"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract each characters by one by one
|
||||
while (file.available()) {
|
||||
Serial.print((char)file.read());
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
// Close the file (File's destructor doesn't close the file)
|
||||
file.close();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// Initialize SD library
|
||||
while (!SD.begin()) {
|
||||
Serial.println(F("Failed to initialize SD library"));
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// Should load default config if run for the first time
|
||||
Serial.println(F("Loading configuration..."));
|
||||
loadConfiguration(filename, config);
|
||||
|
||||
// Create configuration file
|
||||
Serial.println(F("Saving configuration..."));
|
||||
saveConfiguration(filename, config);
|
||||
|
||||
// Dump config file
|
||||
Serial.println(F("Print config file..."));
|
||||
printFile(filename);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization or deserialization problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a case study of a project that has
|
||||
// a complex configuration with nested members.
|
||||
// Contrary to this example, the project in the book uses the SPIFFS filesystem.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -1,23 +1,21 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
// This example shows how to generate a JSON document with ArduinoJson.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void setup() {
|
||||
// Initialize Serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
// wait serial port initialization
|
||||
}
|
||||
while (!Serial) continue;
|
||||
|
||||
// Memory pool for JSON object tree.
|
||||
//
|
||||
// Inside the brackets, 200 is the size of the pool in bytes.
|
||||
// If the JSON object is more complex, you need to increase that value.
|
||||
// See https://bblanchon.github.io/ArduinoJson/assistant/
|
||||
// Don't forget to change this value to match your JSON document.
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
// StaticJsonBuffer allocates memory on the stack, it can be
|
||||
|
@ -68,3 +66,16 @@ void setup() {
|
|||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
|
||||
// It begins with a simple example, like the one above, and then adds more
|
||||
// features like serializing directly to a file or an HTTP request.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -0,0 +1,112 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows how to parse a JSON document in an HTTP response.
|
||||
// It uses the Ethernet library, but can be easily adapted for Wifi.
|
||||
//
|
||||
// It performs a GET resquest on arduinojson.org/example.json
|
||||
// Here is the expected response:
|
||||
// {
|
||||
// "sensor": "gps",
|
||||
// "time": 1351824120,
|
||||
// "data": [
|
||||
// 48.756080,
|
||||
// 2.302038
|
||||
// ]
|
||||
// }
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
void setup() {
|
||||
// Initialize Serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// Initialize Ethernet library
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
if (!Ethernet.begin(mac)) {
|
||||
Serial.println(F("Failed to configure Ethernet"));
|
||||
return;
|
||||
}
|
||||
delay(1000);
|
||||
|
||||
Serial.println(F("Connecting..."));
|
||||
|
||||
// Connect to HTTP server
|
||||
EthernetClient client;
|
||||
client.setTimeout(10000);
|
||||
if (!client.connect("arduinojson.org", 80)) {
|
||||
Serial.println(F("Connection failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println(F("Connected!"));
|
||||
|
||||
// Send HTTP request
|
||||
client.println(F("GET /example.json HTTP/1.0"));
|
||||
client.println(F("Host: arduinojson.org"));
|
||||
client.println(F("Connection: close"));
|
||||
if (client.println() == 0) {
|
||||
Serial.println(F("Failed to send request"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check HTTP status
|
||||
char status[32] = {0};
|
||||
client.readBytesUntil('\r', status, sizeof(status));
|
||||
if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
|
||||
Serial.print(F("Unexpected response: "));
|
||||
Serial.println(status);
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip HTTP headers
|
||||
char endOfHeaders[] = "\r\n\r\n";
|
||||
if (!client.find(endOfHeaders)) {
|
||||
Serial.println(F("Invalid response"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate JsonBuffer
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;
|
||||
DynamicJsonBuffer jsonBuffer(capacity);
|
||||
|
||||
// Parse JSON object
|
||||
JsonObject& root = jsonBuffer.parseObject(client);
|
||||
if (!root.success()) {
|
||||
Serial.println(F("Parsing failed!"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract values
|
||||
Serial.println(F("Response:"));
|
||||
Serial.println(root["sensor"].as<char*>());
|
||||
Serial.println(root["time"].as<char*>());
|
||||
Serial.println(root["data"][0].as<char*>());
|
||||
Serial.println(root["data"][1].as<char*>());
|
||||
|
||||
// Disconnect
|
||||
client.stop();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on deserialization
|
||||
// showing how to parse the response from Yahoo Weather. In the last chapter,
|
||||
// it shows how to parse the huge documents from OpenWeatherMap
|
||||
// and Weather Underground.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -1,23 +1,21 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
// This example shows how to deserialize a JSON document with ArduinoJson.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void setup() {
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
// wait serial port initialization
|
||||
}
|
||||
while (!Serial) continue;
|
||||
|
||||
// Memory pool for JSON object tree.
|
||||
//
|
||||
// Inside the brackets, 200 is the size of the pool in bytes,
|
||||
// If the JSON object is more complex, you need to increase that value.
|
||||
// See https://bblanchon.github.io/ArduinoJson/assistant/
|
||||
// Inside the brackets, 200 is the size of the pool in bytes.
|
||||
// Don't forget to change this value to match your JSON document.
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
// StaticJsonBuffer allocates memory on the stack, it can be
|
||||
|
@ -65,3 +63,16 @@ void setup() {
|
|||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// deserialization problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on deserialization.
|
||||
// It begins with a simple example, like the one above, and then adds more
|
||||
// features like deserializing directly from a file or an HTTP request.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -0,0 +1,109 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows how to implement an HTTP server that sends JSON document
|
||||
// in the responses.
|
||||
// It uses the Ethernet library but can be easily adapted for Wifi.
|
||||
//
|
||||
// It sends the value of the analog and digital pins.
|
||||
// The JSON document looks like the following:
|
||||
// {
|
||||
// "analog": [ 0, 1, 2, 3, 4, 5 ],
|
||||
// "digital": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
|
||||
// }
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
EthernetServer server(80);
|
||||
|
||||
void setup() {
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// Initialize Ethernet libary
|
||||
if (!Ethernet.begin(mac)) {
|
||||
Serial.println(F("Failed to initialize Ethernet library"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Start to listen
|
||||
server.begin();
|
||||
|
||||
Serial.println(F("Server is ready."));
|
||||
Serial.print(F("Please connect to http://"));
|
||||
Serial.println(Ethernet.localIP());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Wait for an incomming connection
|
||||
EthernetClient client = server.available();
|
||||
|
||||
// Do we have a client?
|
||||
if (!client) return;
|
||||
|
||||
Serial.println(F("New client"));
|
||||
|
||||
// Read the request (we ignore the content in this example)
|
||||
while (client.available()) client.read();
|
||||
|
||||
// Allocate JsonBuffer
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<500> jsonBuffer;
|
||||
|
||||
// Create the root object
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
// Create the "analog" array
|
||||
JsonArray& analogValues = root.createNestedArray("analog");
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
// Read the analog input
|
||||
int value = analogRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
analogValues.add(value);
|
||||
}
|
||||
|
||||
// Create the "digital" array
|
||||
JsonArray& digitalValues = root.createNestedArray("digital");
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
// Read the digital input
|
||||
int value = digitalRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
digitalValues.add(value);
|
||||
}
|
||||
|
||||
Serial.print(F("Sending: "));
|
||||
root.printTo(Serial);
|
||||
Serial.println();
|
||||
|
||||
// Write response headers
|
||||
client.println("HTTP/1.0 200 OK");
|
||||
client.println("Content-Type: application/json");
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
|
||||
// Write JSON document
|
||||
root.prettyPrintTo(client);
|
||||
|
||||
// Disconnect
|
||||
client.stop();
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
|
||||
// It begins with a simple example, then adds more features like serializing
|
||||
// directly to a file or an HTTP client.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -0,0 +1,101 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows how to send a JSON document to a UDP socket.
|
||||
// At regular interval, it sends a UDP packet that contains the status of
|
||||
// analog and digital pins.
|
||||
// The JSON document looks like the following:
|
||||
// {
|
||||
// "analog": [ 0, 1, 2, 3, 4, 5 ],
|
||||
// "digital": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
|
||||
// }
|
||||
//
|
||||
// If you want to test this program, you need to be able to receive the UDP
|
||||
// packets.
|
||||
// For example, you can run netcat on your computer
|
||||
// $ ncat -ulp 8888
|
||||
// See https://nmap.org/ncat/
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
IPAddress remoteIp(192, 168, 0, 108); // <- EDIT!!!!
|
||||
unsigned short remotePort = 8888;
|
||||
unsigned short localPort = 8888;
|
||||
EthernetUDP udp;
|
||||
|
||||
void setup() {
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// Initialize Ethernet libary
|
||||
if (!Ethernet.begin(mac)) {
|
||||
Serial.println(F("Failed to initialize Ethernet library"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable UDP
|
||||
udp.begin(localPort);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Allocate JsonBuffer
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<500> jsonBuffer;
|
||||
|
||||
// Create the root object
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
// Create the "analog" array
|
||||
JsonArray& analogValues = root.createNestedArray("analog");
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
// Read the analog input
|
||||
int value = analogRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
analogValues.add(value);
|
||||
}
|
||||
|
||||
// Create the "digital" array
|
||||
JsonArray& digitalValues = root.createNestedArray("digital");
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
// Read the digital input
|
||||
int value = digitalRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
digitalValues.add(value);
|
||||
}
|
||||
|
||||
// Log
|
||||
Serial.print(F("Sending to "));
|
||||
Serial.print(remoteIp);
|
||||
Serial.print(F(" on port "));
|
||||
Serial.println(remotePort);
|
||||
root.printTo(Serial);
|
||||
|
||||
// Send UDP packet
|
||||
udp.beginPacket(remoteIp, remotePort);
|
||||
root.printTo(udp);
|
||||
udp.println();
|
||||
udp.endPacket();
|
||||
|
||||
// Wait
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
|
||||
// It begins with a simple example, then adds more features like serializing
|
||||
// directly to a file or any stream.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -1,21 +1,19 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
// This example shows the different ways you can use Flash strings with
|
||||
// ArduinoJson.
|
||||
//
|
||||
// Use Flash strings sparingly, because ArduinoJson duplicates them in the
|
||||
// JsonBuffer. Prefer plain old char*, as they are more efficient in term of
|
||||
// code size, speed, and memory usage.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
// About
|
||||
// -----
|
||||
// This example shows the different ways you can use PROGMEM with ArduinoJson.
|
||||
// Please don't see this as an invitation to use PROGMEM.
|
||||
// On the contrary, you should always use char[] when possible, it's much more
|
||||
// efficient in term of code size, speed and memory usage.
|
||||
|
||||
void setup() {
|
||||
#ifdef PROGMEM
|
||||
#ifdef PROGMEM // <- check that Flash strings are supported
|
||||
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
|
||||
// You can use a Flash String as your JSON input.
|
||||
|
@ -39,6 +37,9 @@ void setup() {
|
|||
// JsonBuffer.
|
||||
root["sensor"] = F("gps");
|
||||
|
||||
// It works with RawJson too:
|
||||
root["sensor"] = RawJson(F("\"gps\""));
|
||||
|
||||
// You can compare the content of a JsonVariant to a Flash String
|
||||
if (root["sensor"] == F("gps")) {
|
||||
// ...
|
||||
|
@ -54,3 +55,16 @@ void setup() {
|
|||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any memory
|
||||
// problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a quick C++ course that explains
|
||||
// how your microcontroller stores strings in memory. It also tells why you
|
||||
// should not abuse Flash strings with ArduinoJson.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -1,19 +1,15 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
// This example shows the different ways you can use String with ArduinoJson.
|
||||
//
|
||||
// Use String objects sparingly, because ArduinoJson duplicates them in the
|
||||
// JsonBuffer. Prefer plain old char[], as they are more efficient in term of
|
||||
// code size, speed, and memory usage.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
// About
|
||||
// -----
|
||||
// This example shows the different ways you can use String with ArduinoJson.
|
||||
// Please don't see this as an invitation to use String.
|
||||
// On the contrary, you should always use char[] when possible, it's much more
|
||||
// efficient in term of code size, speed and memory usage.
|
||||
|
||||
void setup() {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
|
||||
|
@ -44,6 +40,9 @@ void setup() {
|
|||
// WARNING: the content of the String will be duplicated in the JsonBuffer.
|
||||
root["sensor"] = sensor;
|
||||
|
||||
// It works with RawJson too:
|
||||
root["sensor"] = RawJson(sensor);
|
||||
|
||||
// You can also concatenate strings
|
||||
// WARNING: the content of the String will be duplicated in the JsonBuffer.
|
||||
root[String("sen") + "sor"] = String("gp") + "s";
|
||||
|
@ -61,3 +60,15 @@ void setup() {
|
|||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// https://arduinojson.org/ contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any problem.
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a quick C++ course that explains
|
||||
// how your microcontroller stores strings in memory. On several occasions, it
|
||||
// shows how you can avoid String in your program.
|
||||
// Learn more at https://arduinojson.org/book/
|
||||
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
|
|
@ -0,0 +1,11 @@
|
|||
name=ArduinoJson
|
||||
version=5.13.4
|
||||
author=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
sentence=An efficient and elegant JSON library for Arduino.
|
||||
paragraph=ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ fixed allocation, ✔ zero-copy, ✔ streams, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation.
|
||||
category=Data Processing
|
||||
url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties
|
||||
architectures=*
|
||||
repository=https://github.com/bblanchon/ArduinoJson.git
|
||||
license=MIT
|
|
@ -0,0 +1,17 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "ArduinoJson.hpp"
|
||||
|
||||
using namespace ArduinoJson;
|
||||
|
||||
#else
|
||||
|
||||
#error ArduinoJson requires a C++ compiler, please change file extension to .cc or .cpp
|
||||
|
||||
#endif
|
|
@ -1,12 +1,11 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ArduinoJson/version.hpp"
|
||||
|
||||
#include "ArduinoJson/DynamicJsonBuffer.hpp"
|
||||
#include "ArduinoJson/JsonArray.hpp"
|
||||
#include "ArduinoJson/JsonObject.hpp"
|
|
@ -1,15 +1,13 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
// Small or big machine?
|
||||
#ifndef ARDUINOJSON_EMBEDDED_MODE
|
||||
#if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__)
|
||||
#if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) || defined(__XC) || \
|
||||
defined(__ARMCC_VERSION)
|
||||
#define ARDUINOJSON_EMBEDDED_MODE 1
|
||||
#else
|
||||
#define ARDUINOJSON_EMBEDDED_MODE 0
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../JsonBuffer.hpp"
|
||||
#include "../JsonVariant.hpp"
|
||||
#include "../StringTraits/StringTraits.hpp"
|
||||
#include "../TypeTraits/EnableIf.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
template <typename Source, typename Enable = void>
|
||||
struct ValueSaver {
|
||||
template <typename Destination>
|
||||
static bool save(JsonBuffer*, Destination& destination, Source source) {
|
||||
destination = source;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Source>
|
||||
struct ValueSaver<
|
||||
Source, typename EnableIf<StringTraits<Source>::should_duplicate>::type> {
|
||||
template <typename Destination>
|
||||
static bool save(JsonBuffer* buffer, Destination& dest, Source source) {
|
||||
if (!StringTraits<Source>::is_null(source)) {
|
||||
typename StringTraits<Source>::duplicate_t dup =
|
||||
StringTraits<Source>::duplicate(source, buffer);
|
||||
if (!dup) return false;
|
||||
dest = dup;
|
||||
} else {
|
||||
dest = reinterpret_cast<const char*>(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// const char*, const signed char*, const unsigned char*
|
||||
template <typename Char>
|
||||
struct ValueSaver<
|
||||
Char*, typename EnableIf<!StringTraits<Char*>::should_duplicate>::type> {
|
||||
template <typename Destination>
|
||||
static bool save(JsonBuffer*, Destination& dest, Char* source) {
|
||||
dest = reinterpret_cast<const char*>(source);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -47,19 +44,18 @@ class JsonParser {
|
|||
|
||||
const char *parseString();
|
||||
bool parseAnythingTo(JsonVariant *destination);
|
||||
FORCE_INLINE bool parseAnythingToUnsafe(JsonVariant *destination);
|
||||
|
||||
inline bool parseArrayTo(JsonVariant *destination);
|
||||
inline bool parseObjectTo(JsonVariant *destination);
|
||||
inline bool parseStringTo(JsonVariant *destination);
|
||||
|
||||
static inline bool isInRange(char c, char min, char max) {
|
||||
static inline bool isBetween(char c, char min, char max) {
|
||||
return min <= c && c <= max;
|
||||
}
|
||||
|
||||
static inline bool isLetterOrNumber(char c) {
|
||||
return isInRange(c, '0', '9') || isInRange(c, 'a', 'z') ||
|
||||
isInRange(c, 'A', 'Z') || c == '+' || c == '-' || c == '.';
|
||||
static inline bool canBeInNonQuotedString(char c) {
|
||||
return isBetween(c, '0', '9') || isBetween(c, '_', 'z') ||
|
||||
isBetween(c, 'A', 'Z') || c == '+' || c == '-' || c == '.';
|
||||
}
|
||||
|
||||
static inline bool isQuote(char c) {
|
||||
|
@ -74,7 +70,7 @@ class JsonParser {
|
|||
|
||||
template <typename TJsonBuffer, typename TString, typename Enable = void>
|
||||
struct JsonParserBuilder {
|
||||
typedef typename Internals::StringTraits<TString>::Reader InputReader;
|
||||
typedef typename StringTraits<TString>::Reader InputReader;
|
||||
typedef JsonParser<InputReader, TJsonBuffer &> TParser;
|
||||
|
||||
static TParser makeParser(TJsonBuffer *buffer, TString &json,
|
||||
|
@ -84,10 +80,9 @@ struct JsonParserBuilder {
|
|||
};
|
||||
|
||||
template <typename TJsonBuffer, typename TChar>
|
||||
struct JsonParserBuilder<
|
||||
TJsonBuffer, TChar *,
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsConst<TChar>::value>::type> {
|
||||
typedef typename Internals::StringTraits<TChar *>::Reader TReader;
|
||||
struct JsonParserBuilder<TJsonBuffer, TChar *,
|
||||
typename EnableIf<!IsConst<TChar>::value>::type> {
|
||||
typedef typename StringTraits<TChar *>::Reader TReader;
|
||||
typedef StringWriter<TChar> TWriter;
|
||||
typedef JsonParser<TReader, TWriter> TParser;
|
||||
|
||||
|
@ -103,5 +98,5 @@ inline typename JsonParserBuilder<TJsonBuffer, TString>::TParser makeParser(
|
|||
return JsonParserBuilder<TJsonBuffer, TString>::makeParser(buffer, json,
|
||||
nestingLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Internals
|
||||
} // namespace ArduinoJson
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -20,18 +17,9 @@ inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::eat(
|
|||
}
|
||||
|
||||
template <typename TReader, typename TWriter>
|
||||
inline bool ArduinoJson::Internals::JsonParser<
|
||||
TReader, TWriter>::parseAnythingTo(JsonVariant *destination) {
|
||||
if (_nestingLimit == 0) return false;
|
||||
_nestingLimit--;
|
||||
bool success = parseAnythingToUnsafe(destination);
|
||||
_nestingLimit++;
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename TReader, typename TWriter>
|
||||
inline bool ArduinoJson::Internals::JsonParser<
|
||||
TReader, TWriter>::parseAnythingToUnsafe(JsonVariant *destination) {
|
||||
inline bool
|
||||
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseAnythingTo(
|
||||
JsonVariant *destination) {
|
||||
skipSpacesAndComments(_reader);
|
||||
|
||||
switch (_reader.current()) {
|
||||
|
@ -49,6 +37,9 @@ inline bool ArduinoJson::Internals::JsonParser<
|
|||
template <typename TReader, typename TWriter>
|
||||
inline ArduinoJson::JsonArray &
|
||||
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArray() {
|
||||
if (_nestingLimit == 0) return JsonArray::invalid();
|
||||
_nestingLimit--;
|
||||
|
||||
// Create an empty array
|
||||
JsonArray &array = _buffer->createArray();
|
||||
|
||||
|
@ -70,6 +61,7 @@ ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArray() {
|
|||
|
||||
SUCCESS_EMPTY_ARRAY:
|
||||
SUCCES_NON_EMPTY_ARRAY:
|
||||
_nestingLimit++;
|
||||
return array;
|
||||
|
||||
ERROR_INVALID_VALUE:
|
||||
|
@ -92,6 +84,9 @@ inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArrayTo(
|
|||
template <typename TReader, typename TWriter>
|
||||
inline ArduinoJson::JsonObject &
|
||||
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObject() {
|
||||
if (_nestingLimit == 0) return JsonObject::invalid();
|
||||
_nestingLimit--;
|
||||
|
||||
// Create an empty object
|
||||
JsonObject &object = _buffer->createObject();
|
||||
|
||||
|
@ -118,6 +113,7 @@ ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObject() {
|
|||
|
||||
SUCCESS_EMPTY_OBJECT:
|
||||
SUCCESS_NON_EMPTY_OBJECT:
|
||||
_nestingLimit++;
|
||||
return object;
|
||||
|
||||
ERROR_INVALID_KEY:
|
||||
|
@ -142,8 +138,7 @@ inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObjectTo(
|
|||
template <typename TReader, typename TWriter>
|
||||
inline const char *
|
||||
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseString() {
|
||||
typename TypeTraits::RemoveReference<TWriter>::type::String str =
|
||||
_writer.startString();
|
||||
typename RemoveReference<TWriter>::type::String str = _writer.startString();
|
||||
|
||||
skipSpacesAndComments(_reader);
|
||||
char c = _reader.current();
|
||||
|
@ -169,7 +164,7 @@ ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseString() {
|
|||
}
|
||||
} else { // no quotes
|
||||
for (;;) {
|
||||
if (!isLetterOrNumber(c)) break;
|
||||
if (!canBeInNonQuotedString(c)) break;
|
||||
_reader.move();
|
||||
str.append(c);
|
||||
c = _reader.current();
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -22,6 +19,7 @@
|
|||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
class DefaultAllocator {
|
||||
public:
|
||||
void* allocate(size_t size) {
|
||||
|
@ -154,6 +152,7 @@ class DynamicJsonBufferBase
|
|||
Block* _head;
|
||||
size_t _nextBlockCapacity;
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
|
@ -166,5 +165,6 @@ class DynamicJsonBufferBase
|
|||
// Implements a JsonBuffer with dynamic memory allocation.
|
||||
// You are strongly encouraged to consider using StaticJsonBuffer which is much
|
||||
// more suitable for embedded systems.
|
||||
typedef DynamicJsonBufferBase<DefaultAllocator> DynamicJsonBuffer;
|
||||
typedef Internals::DynamicJsonBufferBase<Internals::DefaultAllocator>
|
||||
DynamicJsonBuffer;
|
||||
}
|
|
@ -1,16 +1,13 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Data/JsonBufferAllocated.hpp"
|
||||
#include "Data/List.hpp"
|
||||
#include "Data/ReferenceType.hpp"
|
||||
#include "Data/ValueSetter.hpp"
|
||||
#include "Data/ValueSaver.hpp"
|
||||
#include "JsonVariant.hpp"
|
||||
#include "Serialization/JsonPrintable.hpp"
|
||||
#include "StringTraits/StringTraits.hpp"
|
||||
|
@ -29,7 +26,9 @@ namespace ArduinoJson {
|
|||
// Forward declarations
|
||||
class JsonObject;
|
||||
class JsonBuffer;
|
||||
namespace Internals {
|
||||
class JsonArraySubscript;
|
||||
}
|
||||
|
||||
// An array of JsonVariant.
|
||||
//
|
||||
|
@ -50,28 +49,26 @@ class JsonArray : public Internals::JsonPrintable<JsonArray>,
|
|||
: Internals::List<JsonVariant>(buffer) {}
|
||||
|
||||
// Gets the value at the specified index
|
||||
const JsonArraySubscript operator[](size_t index) const;
|
||||
const Internals::JsonArraySubscript operator[](size_t index) const;
|
||||
|
||||
// Gets or sets the value at specified index
|
||||
JsonArraySubscript operator[](size_t index);
|
||||
Internals::JsonArraySubscript operator[](size_t index);
|
||||
|
||||
// Adds the specified value at the end of the array.
|
||||
//
|
||||
// bool add(TValue);
|
||||
// TValue = bool, long, int, short, float, double, RawJson, JsonVariant,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<T>::value, bool>::type add(
|
||||
const T &value) {
|
||||
bool add(const T &value) {
|
||||
return add_impl<const T &>(value);
|
||||
}
|
||||
//
|
||||
// bool add(TValue);
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename T>
|
||||
bool add(const T *value) {
|
||||
return add_impl<const T *>(value);
|
||||
bool add(T *value) {
|
||||
return add_impl<T *>(value);
|
||||
}
|
||||
//
|
||||
// bool add(TValue value, uint8_t decimals);
|
||||
|
@ -84,28 +81,25 @@ class JsonArray : public Internals::JsonPrintable<JsonArray>,
|
|||
|
||||
// Sets the value at specified index.
|
||||
//
|
||||
// bool add(size_t index, TValue);
|
||||
// bool add(size_t index, const TValue&);
|
||||
// TValue = bool, long, int, short, float, double, RawJson, JsonVariant,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<T>::value, bool>::type set(
|
||||
size_t index, const T &value) {
|
||||
bool set(size_t index, const T &value) {
|
||||
return set_impl<const T &>(index, value);
|
||||
}
|
||||
//
|
||||
// bool add(size_t index, TValue);
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename T>
|
||||
bool set(size_t index, const T *value) {
|
||||
return set_impl<const T *>(index, value);
|
||||
bool set(size_t index, T *value) {
|
||||
return set_impl<T *>(index, value);
|
||||
}
|
||||
//
|
||||
// bool set(size_t index, TValue value, uint8_t decimals);
|
||||
// TValue = float, double
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value,
|
||||
bool>::type
|
||||
typename Internals::EnableIf<Internals::IsFloatingPoint<T>::value, bool>::type
|
||||
set(size_t index, T value, uint8_t decimals) {
|
||||
return set_impl<const JsonVariant &>(index, JsonVariant(value, decimals));
|
||||
}
|
||||
|
@ -211,14 +205,14 @@ class JsonArray : public Internals::JsonPrintable<JsonArray>,
|
|||
bool set_impl(size_t index, TValueRef value) {
|
||||
iterator it = begin() += index;
|
||||
if (it == end()) return false;
|
||||
return Internals::ValueSetter<TValueRef>::set(_buffer, *it, value);
|
||||
return Internals::ValueSaver<TValueRef>::save(_buffer, *it, value);
|
||||
}
|
||||
|
||||
template <typename TValueRef>
|
||||
bool add_impl(TValueRef value) {
|
||||
iterator it = Internals::List<JsonVariant>::add();
|
||||
if (it == end()) return false;
|
||||
return Internals::ValueSetter<TValueRef>::set(_buffer, *it, value);
|
||||
return Internals::ValueSaver<TValueRef>::save(_buffer, *it, value);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -16,6 +13,7 @@
|
|||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
|
||||
public:
|
||||
FORCE_INLINE JsonArraySubscript(JsonArray& array, size_t index)
|
||||
|
@ -28,10 +26,9 @@ class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
|
|||
|
||||
// Replaces the value
|
||||
//
|
||||
// operator=(TValue)
|
||||
// operator=(const TValue&)
|
||||
// TValue = bool, long, int, short, float, double, RawJson, JsonVariant,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename T>
|
||||
FORCE_INLINE JsonArraySubscript& operator=(const T& src) {
|
||||
_array.set(_index, src);
|
||||
|
@ -39,9 +36,9 @@ class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
|
|||
}
|
||||
//
|
||||
// operator=(TValue)
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename T>
|
||||
FORCE_INLINE JsonArraySubscript& operator=(const T* src) {
|
||||
FORCE_INLINE JsonArraySubscript& operator=(T* src) {
|
||||
_array.set(_index, src);
|
||||
return *this;
|
||||
}
|
||||
|
@ -51,7 +48,7 @@ class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
FORCE_INLINE typename Internals::JsonVariantAs<T>::type as() const {
|
||||
FORCE_INLINE typename JsonVariantAs<T>::type as() const {
|
||||
return _array.get<T>(_index);
|
||||
}
|
||||
|
||||
|
@ -62,19 +59,18 @@ class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
|
|||
|
||||
// Replaces the value
|
||||
//
|
||||
// bool set(TValue)
|
||||
// bool set(const TValue&)
|
||||
// TValue = bool, long, int, short, float, double, RawJson, JsonVariant,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue>
|
||||
FORCE_INLINE bool set(const TValue& value) {
|
||||
return _array.set(_index, value);
|
||||
}
|
||||
//
|
||||
// bool set(TValue)
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename TValue>
|
||||
FORCE_INLINE bool set(const TValue* value) {
|
||||
FORCE_INLINE bool set(TValue* value) {
|
||||
return _array.set(_index, value);
|
||||
}
|
||||
//
|
||||
|
@ -91,21 +87,6 @@ class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
|
|||
const size_t _index;
|
||||
};
|
||||
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
||||
inline std::ostream& operator<<(std::ostream& os,
|
||||
const JsonArraySubscript& source) {
|
||||
return source.printTo(os);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline JsonArraySubscript JsonArray::operator[](size_t index) {
|
||||
return JsonArraySubscript(*this, index);
|
||||
}
|
||||
|
||||
inline const JsonArraySubscript JsonArray::operator[](size_t index) const {
|
||||
return JsonArraySubscript(*const_cast<JsonArray*>(this), index);
|
||||
}
|
||||
|
||||
template <typename TImpl>
|
||||
inline JsonArraySubscript JsonVariantSubscripts<TImpl>::operator[](
|
||||
size_t index) {
|
||||
|
@ -118,7 +99,23 @@ inline const JsonArraySubscript JsonVariantSubscripts<TImpl>::operator[](
|
|||
return impl()->template as<JsonArray>()[index];
|
||||
}
|
||||
|
||||
} // namespace ArduinoJson
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
||||
inline std::ostream& operator<<(std::ostream& os,
|
||||
const JsonArraySubscript& source) {
|
||||
return source.printTo(os);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline Internals::JsonArraySubscript JsonArray::operator[](size_t index) {
|
||||
return Internals::JsonArraySubscript(*this, index);
|
||||
}
|
||||
|
||||
inline const Internals::JsonArraySubscript JsonArray::operator[](
|
||||
size_t index) const {
|
||||
return Internals::JsonArraySubscript(*const_cast<JsonArray*>(this), index);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -41,20 +38,21 @@ class JsonBuffer : Internals::NonCopyable {
|
|||
|
||||
// Duplicates a string
|
||||
//
|
||||
// char* strdup(TValue);
|
||||
// const char* strdup(TValue);
|
||||
// TValue = const std::string&, const String&,
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
char *>::type
|
||||
strdup(const TString &src) {
|
||||
DEPRECATED("char* are duplicated, you don't need strdup() anymore")
|
||||
typename Internals::EnableIf<!Internals::IsArray<TString>::value,
|
||||
const char *>::type strdup(const TString &src) {
|
||||
return Internals::StringTraits<TString>::duplicate(src, this);
|
||||
}
|
||||
//
|
||||
// char* strdup(TValue);
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// const char* strdup(TValue);
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename TString>
|
||||
char *strdup(const TString *src) {
|
||||
return Internals::StringTraits<const TString *>::duplicate(src, this);
|
||||
DEPRECATED("char* are duplicated, you don't need strdup() anymore")
|
||||
const char *strdup(TString *src) {
|
||||
return Internals::StringTraits<TString *>::duplicate(src, this);
|
||||
}
|
||||
|
||||
// Allocates n bytes in the JsonBuffer.
|
|
@ -1,15 +1,13 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Deserialization/JsonParser.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
template <typename TDerived>
|
||||
class JsonBufferBase : public JsonBuffer {
|
||||
public:
|
||||
|
@ -28,8 +26,8 @@ class JsonBufferBase : public JsonBuffer {
|
|||
// JsonArray& parseArray(TString);
|
||||
// TString = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
JsonArray &>::type
|
||||
typename Internals::EnableIf<!Internals::IsArray<TString>::value,
|
||||
JsonArray &>::type
|
||||
parseArray(const TString &json,
|
||||
uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
|
||||
return Internals::makeParser(that(), json, nestingLimit).parseArray();
|
||||
|
@ -65,8 +63,8 @@ class JsonBufferBase : public JsonBuffer {
|
|||
// JsonObject& parseObject(TString);
|
||||
// TString = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
JsonObject &>::type
|
||||
typename Internals::EnableIf<!Internals::IsArray<TString>::value,
|
||||
JsonObject &>::type
|
||||
parseObject(const TString &json,
|
||||
uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
|
||||
return Internals::makeParser(that(), json, nestingLimit).parseObject();
|
||||
|
@ -94,8 +92,8 @@ class JsonBufferBase : public JsonBuffer {
|
|||
// JsonVariant parse(TString);
|
||||
// TString = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
JsonVariant>::type
|
||||
typename Internals::EnableIf<!Internals::IsArray<TString>::value,
|
||||
JsonVariant>::type
|
||||
parse(const TString &json,
|
||||
uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
|
||||
return Internals::makeParser(that(), json, nestingLimit).parseVariant();
|
||||
|
@ -126,3 +124,4 @@ class JsonBufferBase : public JsonBuffer {
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,16 +1,13 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Data/JsonBufferAllocated.hpp"
|
||||
#include "Data/List.hpp"
|
||||
#include "Data/ReferenceType.hpp"
|
||||
#include "Data/ValueSetter.hpp"
|
||||
#include "Data/ValueSaver.hpp"
|
||||
#include "JsonPair.hpp"
|
||||
#include "Serialization/JsonPrintable.hpp"
|
||||
#include "StringTraits/StringTraits.hpp"
|
||||
|
@ -29,6 +26,10 @@ namespace ArduinoJson {
|
|||
// Forward declarations
|
||||
class JsonArray;
|
||||
class JsonBuffer;
|
||||
namespace Internals {
|
||||
template <typename>
|
||||
class JsonObjectSubscript;
|
||||
}
|
||||
|
||||
// A dictionary of JsonVariant indexed by string (char*)
|
||||
//
|
||||
|
@ -45,25 +46,24 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// Create an empty JsonArray attached to the specified JsonBuffer.
|
||||
// You should not use this constructor directly.
|
||||
// Instead, use JsonBuffer::createObject() or JsonBuffer.parseObject().
|
||||
explicit JsonObject(JsonBuffer* buffer) throw()
|
||||
: Internals::List<JsonPair>(buffer) {}
|
||||
explicit JsonObject(JsonBuffer* buffer) throw()
|
||||
: Internals::List<JsonPair>(buffer) {}
|
||||
|
||||
// Gets or sets the value associated with the specified key.
|
||||
//
|
||||
// JsonObjectSubscript operator[](TKey)
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
JsonObjectSubscript<const TString&> >::type
|
||||
operator[](const TString& key) {
|
||||
return JsonObjectSubscript<const TString&>(*this, key);
|
||||
Internals::JsonObjectSubscript<const TString&> operator[](
|
||||
const TString& key) {
|
||||
return Internals::JsonObjectSubscript<const TString&>(*this, key);
|
||||
}
|
||||
//
|
||||
// JsonObjectSubscript operator[](TKey)
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, char[], const char[N], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
JsonObjectSubscript<const TString*> operator[](const TString* key) {
|
||||
return JsonObjectSubscript<const TString*>(*this, key);
|
||||
Internals::JsonObjectSubscript<TString*> operator[](TString* key) {
|
||||
return Internals::JsonObjectSubscript<TString*>(*this, key);
|
||||
}
|
||||
|
||||
// Gets the value associated with the specified key.
|
||||
|
@ -71,21 +71,19 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// const JsonObjectSubscript operator[](TKey) const;
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<
|
||||
!TypeTraits::IsArray<TString>::value,
|
||||
const JsonObjectSubscript<const TString&> >::type
|
||||
operator[](const TString& key) const {
|
||||
return JsonObjectSubscript<const TString&>(*const_cast<JsonObject*>(this),
|
||||
key);
|
||||
const Internals::JsonObjectSubscript<const TString&> operator[](
|
||||
const TString& key) const {
|
||||
return Internals::JsonObjectSubscript<const TString&>(
|
||||
*const_cast<JsonObject*>(this), key);
|
||||
}
|
||||
//
|
||||
// const JsonObjectSubscript operator[](TKey) const;
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
const JsonObjectSubscript<const TString*> operator[](
|
||||
const TString* key) const {
|
||||
return JsonObjectSubscript<const TString*>(*const_cast<JsonObject*>(this),
|
||||
key);
|
||||
const Internals::JsonObjectSubscript<TString*> operator[](
|
||||
TString* key) const {
|
||||
return Internals::JsonObjectSubscript<TString*>(
|
||||
*const_cast<JsonObject*>(this), key);
|
||||
}
|
||||
|
||||
// Sets the specified key with the specified value.
|
||||
|
@ -93,43 +91,35 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// bool set(TKey, TValue);
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = bool, long, int, short, float, double, RawJson, JsonVariant,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value &&
|
||||
!TypeTraits::IsArray<TValue>::value,
|
||||
bool>::type
|
||||
set(const TString& key, const TValue& value) {
|
||||
bool set(const TString& key, const TValue& value) {
|
||||
return set_impl<const TString&, const TValue&>(key, value);
|
||||
}
|
||||
//
|
||||
// bool set(TKey, TValue);
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename TValue, typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
bool>::type
|
||||
set(const TString& key, const TValue* value) {
|
||||
return set_impl<const TString&, const TValue*>(key, value);
|
||||
bool set(const TString& key, TValue* value) {
|
||||
return set_impl<const TString&, TValue*>(key, value);
|
||||
}
|
||||
//
|
||||
// bool set(TKey, TValue);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// bool set(TKey, const TValue&);
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = bool, long, int, short, float, double, RawJson, JsonVariant,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TValue>::value, bool>::type
|
||||
set(const TString* key, const TValue& value) {
|
||||
return set_impl<const TString*, const TValue&>(key, value);
|
||||
bool set(TString* key, const TValue& value) {
|
||||
return set_impl<TString*, const TValue&>(key, value);
|
||||
}
|
||||
//
|
||||
// bool set(TKey, TValue);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename TValue, typename TString>
|
||||
bool set(const TString* key, const TValue* value) {
|
||||
return set_impl<const TString*, const TValue*>(key, value);
|
||||
bool set(TString* key, TValue* value) {
|
||||
return set_impl<TString*, TValue*>(key, value);
|
||||
}
|
||||
//
|
||||
// bool set(TKey, TValue, uint8_t decimals);
|
||||
|
@ -137,50 +127,43 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// TValue = float, double
|
||||
template <typename TValue, typename TString>
|
||||
DEPRECATED("Second argument is not supported anymore")
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<TValue>::value &&
|
||||
!TypeTraits::IsArray<TString>::value,
|
||||
bool>::type
|
||||
typename Internals::EnableIf<Internals::IsFloatingPoint<TValue>::value,
|
||||
bool>::type
|
||||
set(const TString& key, TValue value, uint8_t) {
|
||||
return set_impl<const TString&, const JsonVariant&>(key,
|
||||
JsonVariant(value));
|
||||
}
|
||||
//
|
||||
// bool set(TKey, TValue, uint8_t decimals);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = float, double
|
||||
template <typename TValue, typename TString>
|
||||
DEPRECATED("Second argument is not supported anymore")
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<TValue>::value,
|
||||
bool>::type
|
||||
set(const TString* key, TValue value, uint8_t) {
|
||||
return set_impl<const TString*, const JsonVariant&>(key,
|
||||
JsonVariant(value));
|
||||
typename Internals::EnableIf<Internals::IsFloatingPoint<TValue>::value,
|
||||
bool>::type
|
||||
set(TString* key, TValue value, uint8_t) {
|
||||
return set_impl<TString*, const JsonVariant&>(key, JsonVariant(value));
|
||||
}
|
||||
|
||||
// Gets the value associated with the specified key.
|
||||
//
|
||||
// TValue get<TValue>(TKey);
|
||||
// TValue get<TValue>(TKey) const;
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TString>
|
||||
typename TypeTraits::EnableIf<
|
||||
!TypeTraits::IsArray<TString>::value,
|
||||
typename Internals::JsonVariantAs<TValue>::type>::type
|
||||
get(const TString& key) const {
|
||||
typename Internals::JsonVariantAs<TValue>::type get(
|
||||
const TString& key) const {
|
||||
return get_impl<const TString&, TValue>(key);
|
||||
}
|
||||
//
|
||||
// TValue get<TValue>(TKey);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue get<TValue>(TKey) const;
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TString>
|
||||
typename Internals::JsonVariantAs<TValue>::type get(
|
||||
const TString* key) const {
|
||||
return get_impl<const TString*, TValue>(key);
|
||||
typename Internals::JsonVariantAs<TValue>::type get(TString* key) const {
|
||||
return get_impl<TString*, TValue>(key);
|
||||
}
|
||||
|
||||
// Checks the type of the value associated with the specified key.
|
||||
|
@ -189,23 +172,19 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// bool is<TValue>(TKey) const;
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
bool>::type
|
||||
is(const TString& key) const {
|
||||
bool is(const TString& key) const {
|
||||
return is_impl<const TString&, TValue>(key);
|
||||
}
|
||||
//
|
||||
// bool is<TValue>(TKey) const;
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TString>
|
||||
bool is(const TString* key) const {
|
||||
return is_impl<const TString*, TValue>(key);
|
||||
bool is(TString* key) const {
|
||||
return is_impl<TString*, TValue>(key);
|
||||
}
|
||||
|
||||
// Creates and adds a JsonArray.
|
||||
|
@ -213,16 +192,14 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// JsonArray& createNestedArray(TKey);
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
JsonArray&>::type
|
||||
createNestedArray(const TString& key) {
|
||||
JsonArray& createNestedArray(const TString& key) {
|
||||
return createNestedArray_impl<const TString&>(key);
|
||||
}
|
||||
// JsonArray& createNestedArray(TKey);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, char[], const char[], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
JsonArray& createNestedArray(const TString* key) {
|
||||
return createNestedArray_impl<const TString*>(key);
|
||||
JsonArray& createNestedArray(TString* key) {
|
||||
return createNestedArray_impl<TString*>(key);
|
||||
}
|
||||
|
||||
// Creates and adds a JsonObject.
|
||||
|
@ -230,17 +207,15 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// JsonObject& createNestedObject(TKey);
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
JsonObject&>::type
|
||||
createNestedObject(const TString& key) {
|
||||
JsonObject& createNestedObject(const TString& key) {
|
||||
return createNestedObject_impl<const TString&>(key);
|
||||
}
|
||||
//
|
||||
// JsonObject& createNestedObject(TKey);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, char[], const char[], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
JsonObject& createNestedObject(const TString* key) {
|
||||
return createNestedObject_impl<const TString*>(key);
|
||||
JsonObject& createNestedObject(TString* key) {
|
||||
return createNestedObject_impl<TString*>(key);
|
||||
}
|
||||
|
||||
// Tells weither the specified key is present and associated with a value.
|
||||
|
@ -248,17 +223,15 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// bool containsKey(TKey);
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
bool>::type
|
||||
containsKey(const TString& key) const {
|
||||
bool containsKey(const TString& key) const {
|
||||
return findKey<const TString&>(key) != end();
|
||||
}
|
||||
//
|
||||
// bool containsKey(TKey);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, char[], const char[], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
bool containsKey(const TString* key) const {
|
||||
return findKey<const TString*>(key) != end();
|
||||
bool containsKey(TString* key) const {
|
||||
return findKey<TString*>(key) != end();
|
||||
}
|
||||
|
||||
// Removes the specified key and the associated value.
|
||||
|
@ -266,17 +239,15 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
// void remove(TKey);
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value,
|
||||
void>::type
|
||||
remove(const TString& key) {
|
||||
void remove(const TString& key) {
|
||||
remove(findKey<const TString&>(key));
|
||||
}
|
||||
//
|
||||
// void remove(TKey);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
// TKey = char*, const char*, char[], const char[], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
void remove(const TString* key) {
|
||||
remove(findKey<const TString*>(key));
|
||||
void remove(TString* key) {
|
||||
remove(findKey<TString*>(key));
|
||||
}
|
||||
//
|
||||
// void remove(iterator)
|
||||
|
@ -315,16 +286,22 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
|||
|
||||
template <typename TStringRef, typename TValueRef>
|
||||
bool set_impl(TStringRef key, TValueRef value) {
|
||||
// ignore null key
|
||||
if (Internals::StringTraits<TStringRef>::is_null(key)) return false;
|
||||
|
||||
// search a matching key
|
||||
iterator it = findKey<TStringRef>(key);
|
||||
if (it == end()) {
|
||||
// add the key
|
||||
it = Internals::List<JsonPair>::add();
|
||||
if (it == end()) return false;
|
||||
|
||||
bool key_ok =
|
||||
Internals::ValueSetter<TStringRef>::set(_buffer, it->key, key);
|
||||
Internals::ValueSaver<TStringRef>::save(_buffer, it->key, key);
|
||||
if (!key_ok) return false;
|
||||
}
|
||||
return Internals::ValueSetter<TValueRef>::set(_buffer, it->value, value);
|
||||
|
||||
// save the value
|
||||
return Internals::ValueSaver<TValueRef>::save(_buffer, it->value, value);
|
||||
}
|
||||
|
||||
template <typename TStringRef, typename TValue>
|
||||
|
@ -347,5 +324,5 @@ struct JsonVariantDefault<JsonObject> {
|
|||
return JsonObject::invalid();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace Internals
|
||||
} // namespace ArduinoJson
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -17,6 +14,7 @@
|
|||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
template <typename TStringRef>
|
||||
class JsonObjectSubscript
|
||||
|
@ -34,23 +32,20 @@ class JsonObjectSubscript
|
|||
|
||||
// Set the specified value
|
||||
//
|
||||
// operator=(TValue);
|
||||
// operator=(const TValue&);
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue>
|
||||
FORCE_INLINE
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TValue>::value,
|
||||
this_type&>::type
|
||||
operator=(const TValue& src) {
|
||||
FORCE_INLINE typename EnableIf<!IsArray<TValue>::value, this_type&>::type
|
||||
operator=(const TValue& src) {
|
||||
_object.set(_key, src);
|
||||
return *this;
|
||||
}
|
||||
//
|
||||
// operator=(TValue);
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename TValue>
|
||||
FORCE_INLINE this_type& operator=(const TValue* src) {
|
||||
FORCE_INLINE this_type& operator=(TValue* src) {
|
||||
_object.set(_key, src);
|
||||
return *this;
|
||||
}
|
||||
|
@ -60,7 +55,7 @@ class JsonObjectSubscript
|
|||
}
|
||||
|
||||
template <typename TValue>
|
||||
FORCE_INLINE typename Internals::JsonVariantAs<TValue>::type as() const {
|
||||
FORCE_INLINE typename JsonVariantAs<TValue>::type as() const {
|
||||
return _object.get<TValue>(_key);
|
||||
}
|
||||
|
||||
|
@ -71,20 +66,17 @@ class JsonObjectSubscript
|
|||
|
||||
// Sets the specified value.
|
||||
//
|
||||
// bool set(TValue);
|
||||
// bool set(const TValue&);
|
||||
// TValue = bool, char, long, int, short, float, double, RawJson, JsonVariant,
|
||||
// const std::string&, const String&,
|
||||
// const JsonArray&, const JsonObject&
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue>
|
||||
FORCE_INLINE
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TValue>::value,
|
||||
bool>::type
|
||||
set(const TValue& value) {
|
||||
FORCE_INLINE typename EnableIf<!IsArray<TValue>::value, bool>::type set(
|
||||
const TValue& value) {
|
||||
return _object.set(_key, value);
|
||||
}
|
||||
//
|
||||
// bool set(TValue);
|
||||
// TValue = const char*, const char[N], const FlashStringHelper*
|
||||
// TValue = char*, const char, const FlashStringHelper*
|
||||
template <typename TValue>
|
||||
FORCE_INLINE bool set(const TValue* value) {
|
||||
return _object.set(_key, value);
|
||||
|
@ -110,7 +102,8 @@ inline std::ostream& operator<<(std::ostream& os,
|
|||
return source.printTo(os);
|
||||
}
|
||||
#endif
|
||||
} // namespace ArduinoJson
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -39,7 +36,7 @@ class JsonObject;
|
|||
// - a char, short, int or a long (signed or unsigned)
|
||||
// - a string (const char*)
|
||||
// - a reference to a JsonArray or JsonObject
|
||||
class JsonVariant : public JsonVariantBase<JsonVariant> {
|
||||
class JsonVariant : public Internals::JsonVariantBase<JsonVariant> {
|
||||
template <typename Print>
|
||||
friend class Internals::JsonSerializer;
|
||||
|
||||
|
@ -59,8 +56,8 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// JsonVariant(double value);
|
||||
// JsonVariant(float value);
|
||||
template <typename T>
|
||||
JsonVariant(T value, typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
|
||||
JsonVariant(T value, typename Internals::EnableIf<
|
||||
Internals::IsFloatingPoint<T>::value>::type * = 0) {
|
||||
using namespace Internals;
|
||||
_type = JSON_FLOAT;
|
||||
_content.asFloat = static_cast<JsonFloat>(value);
|
||||
|
@ -68,8 +65,8 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
template <typename T>
|
||||
DEPRECATED("Second argument is not supported anymore")
|
||||
JsonVariant(T value, uint8_t,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsFloatingPoint<T>::value>::type * = 0) {
|
||||
using namespace Internals;
|
||||
_type = JSON_FLOAT;
|
||||
_content.asFloat = static_cast<JsonFloat>(value);
|
||||
|
@ -82,9 +79,11 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// JsonVariant(signed long)
|
||||
// JsonVariant(signed char)
|
||||
template <typename T>
|
||||
JsonVariant(T value, typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSignedIntegral<T>::value ||
|
||||
TypeTraits::IsSame<T, char>::value>::type * = 0) {
|
||||
JsonVariant(
|
||||
T value,
|
||||
typename Internals::EnableIf<Internals::IsSignedIntegral<T>::value ||
|
||||
Internals::IsSame<T, char>::value>::type * =
|
||||
0) {
|
||||
using namespace Internals;
|
||||
if (value >= 0) {
|
||||
_type = JSON_POSITIVE_INTEGER;
|
||||
|
@ -99,8 +98,8 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// JsonVariant(unsigned long)
|
||||
template <typename T>
|
||||
JsonVariant(T value,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsUnsignedIntegral<T>::value>::type * = 0) {
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsUnsignedIntegral<T>::value>::type * = 0) {
|
||||
using namespace Internals;
|
||||
_type = JSON_POSITIVE_INTEGER;
|
||||
_content.asInteger = static_cast<JsonUInt>(value);
|
||||
|
@ -113,14 +112,14 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
template <typename TChar>
|
||||
JsonVariant(
|
||||
const TChar *value,
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsChar<TChar>::value>::type * =
|
||||
typename Internals::EnableIf<Internals::IsChar<TChar>::value>::type * =
|
||||
0) {
|
||||
_type = Internals::JSON_STRING;
|
||||
_content.asString = reinterpret_cast<const char *>(value);
|
||||
}
|
||||
|
||||
// Create a JsonVariant containing an unparsed string
|
||||
JsonVariant(RawJson value) {
|
||||
JsonVariant(Internals::RawJsonString<const char *> value) {
|
||||
_type = Internals::JSON_UNPARSED;
|
||||
_content.asString = value;
|
||||
}
|
||||
|
@ -147,14 +146,13 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// unsigned int as<unsigned int>() const;
|
||||
// unsigned long as<unsigned long>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsIntegral<T>::value, T>::type
|
||||
const typename Internals::EnableIf<Internals::IsIntegral<T>::value, T>::type
|
||||
as() const {
|
||||
return variantAsInteger<T>();
|
||||
}
|
||||
// bool as<bool>() const
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value,
|
||||
T>::type
|
||||
const typename Internals::EnableIf<Internals::IsSame<T, bool>::value, T>::type
|
||||
as() const {
|
||||
return variantAsInteger<int>() != 0;
|
||||
}
|
||||
|
@ -162,8 +160,8 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// double as<double>() const;
|
||||
// float as<float>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value,
|
||||
T>::type
|
||||
const typename Internals::EnableIf<Internals::IsFloatingPoint<T>::value,
|
||||
T>::type
|
||||
as() const {
|
||||
return variantAsFloat<T>();
|
||||
}
|
||||
|
@ -171,9 +169,9 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// const char* as<const char*>() const;
|
||||
// const char* as<char*>() const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsSame<T, const char *>::value ||
|
||||
TypeTraits::IsSame<T, char *>::value,
|
||||
const char *>::type
|
||||
typename Internals::EnableIf<Internals::IsSame<T, const char *>::value ||
|
||||
Internals::IsSame<T, char *>::value,
|
||||
const char *>::type
|
||||
as() const {
|
||||
return variantAsString();
|
||||
}
|
||||
|
@ -181,7 +179,7 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// std::string as<std::string>() const;
|
||||
// String as<String>() const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<Internals::StringTraits<T>::has_append, T>::type
|
||||
typename Internals::EnableIf<Internals::StringTraits<T>::has_append, T>::type
|
||||
as() const {
|
||||
const char *cstr = variantAsString();
|
||||
if (cstr) return T(cstr);
|
||||
|
@ -193,9 +191,9 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// JsonArray& as<JsonArray> const;
|
||||
// JsonArray& as<JsonArray&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
JsonArray>::value,
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsSame<typename Internals::RemoveReference<T>::type,
|
||||
JsonArray>::value,
|
||||
JsonArray &>::type
|
||||
as() const {
|
||||
return variantAsArray();
|
||||
|
@ -203,9 +201,9 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
//
|
||||
// const JsonArray& as<const JsonArray&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
const JsonArray>::value,
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsSame<typename Internals::RemoveReference<T>::type,
|
||||
const JsonArray>::value,
|
||||
const JsonArray &>::type
|
||||
as() const {
|
||||
return variantAsArray();
|
||||
|
@ -214,9 +212,9 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// JsonObject& as<JsonObject> const;
|
||||
// JsonObject& as<JsonObject&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
JsonObject>::value,
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsSame<typename Internals::RemoveReference<T>::type,
|
||||
JsonObject>::value,
|
||||
JsonObject &>::type
|
||||
as() const {
|
||||
return variantAsObject();
|
||||
|
@ -225,9 +223,9 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// JsonObject& as<const JsonObject> const;
|
||||
// JsonObject& as<const JsonObject&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
const JsonObject>::value,
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsSame<typename Internals::RemoveReference<T>::type,
|
||||
const JsonObject>::value,
|
||||
const JsonObject &>::type
|
||||
as() const {
|
||||
return variantAsObject();
|
||||
|
@ -235,8 +233,8 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
//
|
||||
// JsonVariant as<JsonVariant> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsSame<T, JsonVariant>::value,
|
||||
T>::type
|
||||
typename Internals::EnableIf<Internals::IsSame<T, JsonVariant>::value,
|
||||
T>::type
|
||||
as() const {
|
||||
return *this;
|
||||
}
|
||||
|
@ -254,33 +252,34 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// bool is<unsigned int>() const;
|
||||
// bool is<unsigned long>() const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsIntegral<T>::value, bool>::type
|
||||
is() const {
|
||||
typename Internals::EnableIf<Internals::IsIntegral<T>::value, bool>::type is()
|
||||
const {
|
||||
return variantIsInteger();
|
||||
}
|
||||
//
|
||||
// bool is<double>() const;
|
||||
// bool is<float>() const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value,
|
||||
bool>::type
|
||||
typename Internals::EnableIf<Internals::IsFloatingPoint<T>::value, bool>::type
|
||||
is() const {
|
||||
return variantIsFloat();
|
||||
}
|
||||
//
|
||||
// bool is<bool>() const
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value, bool>::type
|
||||
typename Internals::EnableIf<Internals::IsSame<T, bool>::value, bool>::type
|
||||
is() const {
|
||||
return variantIsBoolean();
|
||||
}
|
||||
//
|
||||
// bool is<const char*>() const;
|
||||
// bool is<char*>() const;
|
||||
// bool is<std::string>() const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsSame<T, const char *>::value ||
|
||||
TypeTraits::IsSame<T, char *>::value,
|
||||
bool>::type
|
||||
typename Internals::EnableIf<Internals::IsSame<T, const char *>::value ||
|
||||
Internals::IsSame<T, char *>::value ||
|
||||
Internals::StringTraits<T>::has_append,
|
||||
bool>::type
|
||||
is() const {
|
||||
return variantIsString();
|
||||
}
|
||||
|
@ -289,11 +288,10 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// bool is<JsonArray&> const;
|
||||
// bool is<const JsonArray&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<
|
||||
typename TypeTraits::RemoveConst<
|
||||
typename TypeTraits::RemoveReference<T>::type>::type,
|
||||
JsonArray>::value,
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsSame<typename Internals::RemoveConst<
|
||||
typename Internals::RemoveReference<T>::type>::type,
|
||||
JsonArray>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return variantIsArray();
|
||||
|
@ -303,11 +301,10 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
|
|||
// bool is<JsonObject&> const;
|
||||
// bool is<const JsonObject&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<
|
||||
typename TypeTraits::RemoveConst<
|
||||
typename TypeTraits::RemoveReference<T>::type>::type,
|
||||
JsonObject>::value,
|
||||
typename Internals::EnableIf<
|
||||
Internals::IsSame<typename Internals::RemoveConst<
|
||||
typename Internals::RemoveReference<T>::type>::type,
|
||||
JsonObject>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return variantIsObject();
|
||||
|
@ -357,4 +354,4 @@ DEPRECATED("Decimal places are ignored, use the double value instead")
|
|||
inline JsonVariant double_with_n_digits(double value, uint8_t) {
|
||||
return JsonVariant(value);
|
||||
}
|
||||
}
|
||||
} // namespace ArduinoJson
|
|
@ -1,23 +1,24 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JsonVariantCasts.hpp"
|
||||
#include "JsonVariantComparisons.hpp"
|
||||
#include "JsonVariantOr.hpp"
|
||||
#include "JsonVariantSubscripts.hpp"
|
||||
#include "Serialization/JsonPrintable.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
template <typename TImpl>
|
||||
class JsonVariantBase : public Internals::JsonPrintable<TImpl>,
|
||||
class JsonVariantBase : public JsonPrintable<TImpl>,
|
||||
public JsonVariantCasts<TImpl>,
|
||||
public JsonVariantComparisons<TImpl>,
|
||||
public JsonVariantOr<TImpl>,
|
||||
public JsonVariantSubscripts<TImpl>,
|
||||
public TypeTraits::JsonVariantTag {};
|
||||
public JsonVariantTag {};
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -11,6 +8,7 @@
|
|||
#include "Polyfills/attributes.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
template <typename TImpl>
|
||||
class JsonVariantCasts {
|
||||
|
@ -58,3 +56,4 @@ class JsonVariantCasts {
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -12,6 +9,7 @@
|
|||
#include "TypeTraits/IsVariant.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
template <typename TImpl>
|
||||
class JsonVariantComparisons {
|
||||
|
@ -23,10 +21,8 @@ class JsonVariantComparisons {
|
|||
}
|
||||
|
||||
template <typename TComparand>
|
||||
friend
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsVariant<TComparand>::value,
|
||||
bool>::type
|
||||
operator==(TComparand comparand, const JsonVariantComparisons &variant) {
|
||||
friend typename EnableIf<!IsVariant<TComparand>::value, bool>::type
|
||||
operator==(TComparand comparand, const JsonVariantComparisons &variant) {
|
||||
return variant.equals(comparand);
|
||||
}
|
||||
|
||||
|
@ -37,10 +33,8 @@ class JsonVariantComparisons {
|
|||
}
|
||||
|
||||
template <typename TComparand>
|
||||
friend
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsVariant<TComparand>::value,
|
||||
bool>::type
|
||||
operator!=(TComparand comparand, const JsonVariantComparisons &variant) {
|
||||
friend typename EnableIf<!IsVariant<TComparand>::value, bool>::type
|
||||
operator!=(TComparand comparand, const JsonVariantComparisons &variant) {
|
||||
return !variant.equals(comparand);
|
||||
}
|
||||
|
||||
|
@ -97,7 +91,7 @@ class JsonVariantComparisons {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
const typename Internals::JsonVariantAs<T>::type as() const {
|
||||
const typename JsonVariantAs<T>::type as() const {
|
||||
return impl()->template as<T>();
|
||||
}
|
||||
|
||||
|
@ -107,17 +101,16 @@ class JsonVariantComparisons {
|
|||
}
|
||||
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsString<TString>::value,
|
||||
bool>::type
|
||||
equals(const TString &comparand) const {
|
||||
typename EnableIf<StringTraits<TString>::has_equals, bool>::type equals(
|
||||
const TString &comparand) const {
|
||||
const char *value = as<const char *>();
|
||||
return Internals::StringTraits<TString>::equals(comparand, value);
|
||||
return StringTraits<TString>::equals(comparand, value);
|
||||
}
|
||||
|
||||
template <typename TComparand>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsVariant<TComparand>::value &&
|
||||
!TypeTraits::IsString<TComparand>::value,
|
||||
bool>::type
|
||||
typename EnableIf<!IsVariant<TComparand>::value &&
|
||||
!StringTraits<TComparand>::has_equals,
|
||||
bool>::type
|
||||
equals(const TComparand &comparand) const {
|
||||
return as<TComparand>() == comparand;
|
||||
}
|
||||
|
@ -136,9 +129,11 @@ class JsonVariantComparisons {
|
|||
if (is<JsonObject>() && right.template is<JsonObject>())
|
||||
return as<JsonObject>() == right.template as<JsonObject>();
|
||||
if (is<char *>() && right.template is<char *>())
|
||||
return strcmp(as<char *>(), right.template as<char *>()) == 0;
|
||||
return StringTraits<const char *>::equals(as<char *>(),
|
||||
right.template as<char *>());
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace Internals
|
||||
} // namespace ArduinoJson
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -61,7 +58,7 @@ inline T JsonVariant::variantAsInteger() const {
|
|||
return T(~_content.asInteger + 1);
|
||||
case JSON_STRING:
|
||||
case JSON_UNPARSED:
|
||||
return Polyfills::parseInteger<T>(_content.asString);
|
||||
return parseInteger<T>(_content.asString);
|
||||
default:
|
||||
return T(_content.asFloat);
|
||||
}
|
||||
|
@ -89,7 +86,7 @@ inline T JsonVariant::variantAsFloat() const {
|
|||
return -static_cast<T>(_content.asInteger);
|
||||
case JSON_STRING:
|
||||
case JSON_UNPARSED:
|
||||
return Polyfills::parseFloat<T>(_content.asString);
|
||||
return parseFloat<T>(_content.asString);
|
||||
default:
|
||||
return static_cast<T>(_content.asFloat);
|
||||
}
|
||||
|
@ -109,7 +106,7 @@ inline bool JsonVariant::variantIsInteger() const {
|
|||
using namespace Internals;
|
||||
|
||||
return _type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER ||
|
||||
(_type == JSON_UNPARSED && Polyfills::isInteger(_content.asString));
|
||||
(_type == JSON_UNPARSED && isInteger(_content.asString));
|
||||
}
|
||||
|
||||
inline bool JsonVariant::variantIsFloat() const {
|
||||
|
@ -117,7 +114,7 @@ inline bool JsonVariant::variantIsFloat() const {
|
|||
|
||||
return _type == JSON_FLOAT || _type == JSON_POSITIVE_INTEGER ||
|
||||
_type == JSON_NEGATIVE_INTEGER ||
|
||||
(_type == JSON_UNPARSED && Polyfills::isFloat(_content.asString));
|
||||
(_type == JSON_UNPARSED && isFloat(_content.asString));
|
||||
}
|
||||
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
|
@ -0,0 +1,52 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Data/JsonVariantAs.hpp"
|
||||
#include "Polyfills/attributes.hpp"
|
||||
#include "TypeTraits/EnableIf.hpp"
|
||||
#include "TypeTraits/IsIntegral.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
template <typename TImpl>
|
||||
class JsonVariantOr {
|
||||
public:
|
||||
// Returns the default value if the JsonVariant is undefined of incompatible
|
||||
template <typename T>
|
||||
typename EnableIf<!IsIntegral<T>::value, T>::type operator|(
|
||||
const T &defaultValue) const {
|
||||
if (impl()->template is<T>())
|
||||
return impl()->template as<T>();
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// Returns the default value if the JsonVariant is undefined of incompatible
|
||||
// Special case for string: null is treated as undefined
|
||||
const char *operator|(const char *defaultValue) const {
|
||||
const char *value = impl()->template as<const char *>();
|
||||
return value ? value : defaultValue;
|
||||
}
|
||||
|
||||
// Returns the default value if the JsonVariant is undefined of incompatible
|
||||
// Special case for integers: we also accept double
|
||||
template <typename Integer>
|
||||
typename EnableIf<IsIntegral<Integer>::value, Integer>::type operator|(
|
||||
const Integer &defaultValue) const {
|
||||
if (impl()->template is<double>())
|
||||
return impl()->template as<Integer>();
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private:
|
||||
const TImpl *impl() const {
|
||||
return static_cast<const TImpl *>(this);
|
||||
}
|
||||
};
|
||||
} // namespace Internals
|
||||
} // namespace ArduinoJson
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -13,6 +10,7 @@
|
|||
#include "TypeTraits/EnableIf.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// Forward declarations.
|
||||
class JsonArraySubscript;
|
||||
|
@ -44,19 +42,18 @@ class JsonVariantSubscripts {
|
|||
// const JsonObjectSubscript operator[](TKey) const;
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename TypeTraits::EnableIf<
|
||||
Internals::StringTraits<TString>::has_equals,
|
||||
const JsonObjectSubscript<const TString &> >::type
|
||||
operator[](const TString &key) const {
|
||||
FORCE_INLINE
|
||||
typename EnableIf<StringTraits<TString>::has_equals,
|
||||
const JsonObjectSubscript<const TString &> >::type
|
||||
operator[](const TString &key) const {
|
||||
return impl()->template as<JsonObject>()[key];
|
||||
}
|
||||
//
|
||||
// const JsonObjectSubscript operator[](TKey) const;
|
||||
// TKey = const std::string&, const String&
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename TypeTraits::EnableIf<
|
||||
Internals::StringTraits<TString>::has_equals,
|
||||
JsonObjectSubscript<const TString &> >::type
|
||||
FORCE_INLINE typename EnableIf<StringTraits<TString>::has_equals,
|
||||
JsonObjectSubscript<const TString &> >::type
|
||||
operator[](const TString &key) {
|
||||
return impl()->template as<JsonObject>()[key];
|
||||
}
|
||||
|
@ -64,9 +61,8 @@ class JsonVariantSubscripts {
|
|||
// JsonObjectSubscript operator[](TKey);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename TypeTraits::EnableIf<
|
||||
Internals::StringTraits<const TString *>::has_equals,
|
||||
JsonObjectSubscript<const TString *> >::type
|
||||
FORCE_INLINE typename EnableIf<StringTraits<const TString *>::has_equals,
|
||||
JsonObjectSubscript<const TString *> >::type
|
||||
operator[](const TString *key) {
|
||||
return impl()->template as<JsonObject>()[key];
|
||||
}
|
||||
|
@ -74,10 +70,10 @@ class JsonVariantSubscripts {
|
|||
// JsonObjectSubscript operator[](TKey);
|
||||
// TKey = const char*, const char[N], const FlashStringHelper*
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename TypeTraits::EnableIf<
|
||||
Internals::StringTraits<TString *>::has_equals,
|
||||
const JsonObjectSubscript<const TString *> >::type
|
||||
operator[](const TString *key) const {
|
||||
FORCE_INLINE
|
||||
typename EnableIf<StringTraits<TString *>::has_equals,
|
||||
const JsonObjectSubscript<const TString *> >::type
|
||||
operator[](const TString *key) const {
|
||||
return impl()->template as<JsonObject>()[key];
|
||||
}
|
||||
|
||||
|
@ -87,3 +83,4 @@ class JsonVariantSubscripts {
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,15 +1,12 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER // Visual Studio
|
||||
|
||||
#define FORCE_INLINE __forceinline
|
||||
#define FORCE_INLINE // __forceinline causes C4714 when returning std::string
|
||||
#define NO_INLINE __declspec(noinline)
|
||||
#define DEPRECATED(msg) __declspec(deprecated(msg))
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
namespace Internals {
|
||||
|
||||
inline bool isdigit(char c) {
|
||||
return '0' <= c && c <= '9';
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -11,7 +8,7 @@
|
|||
#include "./ctype.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
namespace Internals {
|
||||
|
||||
inline bool isFloat(const char* s) {
|
||||
if (!s) return false;
|
|
@ -0,0 +1,19 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "./ctype.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
inline bool isInteger(const char* s) {
|
||||
if (!s || !*s) return false;
|
||||
if (issign(*s)) s++;
|
||||
while (isdigit(*s)) s++;
|
||||
return *s == '\0';
|
||||
}
|
||||
} // namespace Internals
|
||||
} // namespace ArduinoJson
|
|
@ -1,14 +1,11 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
namespace Internals {
|
||||
template <typename T>
|
||||
bool isNaN(T x) {
|
||||
return x != x;
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -12,11 +9,11 @@
|
|||
#include "./math.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
namespace Internals {
|
||||
|
||||
template <typename T>
|
||||
inline T parseFloat(const char* s) {
|
||||
typedef TypeTraits::FloatTraits<T> traits;
|
||||
typedef FloatTraits<T> traits;
|
||||
typedef typename traits::mantissa_type mantissa_t;
|
||||
typedef typename traits::exponent_type exponent_t;
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -13,7 +10,7 @@
|
|||
#include "./ctype.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
namespace Internals {
|
||||
template <typename T>
|
||||
T parseInteger(const char *s) {
|
||||
if (!s) return 0; // NULL
|
|
@ -0,0 +1,46 @@
|
|||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
namespace Internals {
|
||||
// A special type of data that can be used to insert pregenerated JSON portions.
|
||||
template <typename T>
|
||||
class RawJsonString {
|
||||
public:
|
||||
explicit RawJsonString(T str) : _str(str) {}
|
||||
operator T() const {
|
||||
return _str;
|
||||
}
|
||||
|
||||
private:
|
||||
T _str;
|
||||
};
|
||||
|
||||
template <typename String>
|
||||
struct StringTraits<RawJsonString<String>, void> {
|
||||
static bool is_null(RawJsonString<String> source) {
|
||||
return StringTraits<String>::is_null(static_cast<String>(source));
|
||||
}
|
||||
|
||||
typedef RawJsonString<const char*> duplicate_t;
|
||||
|
||||
template <typename Buffer>
|
||||
static duplicate_t duplicate(RawJsonString<String> source, Buffer* buffer) {
|
||||
return duplicate_t(StringTraits<String>::duplicate(source, buffer));
|
||||
}
|
||||
|
||||
static const bool has_append = false;
|
||||
static const bool has_equals = false;
|
||||
static const bool should_duplicate = StringTraits<String>::should_duplicate;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Internals::RawJsonString<T> RawJson(T str) {
|
||||
return Internals::RawJsonString<T>(str);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -59,7 +56,7 @@ struct FloatParts {
|
|||
}
|
||||
|
||||
static int16_t normalize(TFloat& value) {
|
||||
typedef TypeTraits::FloatTraits<TFloat> traits;
|
||||
typedef FloatTraits<TFloat> traits;
|
||||
int16_t powersOf10 = 0;
|
||||
|
||||
int8_t index = sizeof(TFloat) == 8 ? 8 : 5;
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -32,9 +29,8 @@ template <typename T>
|
|||
class JsonPrintable {
|
||||
public:
|
||||
template <typename Print>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsString<Print>::value,
|
||||
size_t>::type
|
||||
printTo(Print &print) const {
|
||||
typename EnableIf<!StringTraits<Print>::has_append, size_t>::type printTo(
|
||||
Print &print) const {
|
||||
JsonWriter<Print> writer(print);
|
||||
JsonSerializer<JsonWriter<Print> >::serialize(downcast(), writer);
|
||||
return writer.bytesWritten();
|
||||
|
@ -59,8 +55,8 @@ class JsonPrintable {
|
|||
}
|
||||
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<StringTraits<TString>::has_append, size_t>::type
|
||||
printTo(TString &str) const {
|
||||
typename EnableIf<StringTraits<TString>::has_append, size_t>::type printTo(
|
||||
TString &str) const {
|
||||
DynamicStringBuilder<TString> sb(str);
|
||||
return printTo(sb);
|
||||
}
|
||||
|
@ -82,15 +78,14 @@ class JsonPrintable {
|
|||
}
|
||||
|
||||
template <typename Print>
|
||||
typename TypeTraits::EnableIf<!TypeTraits::IsString<Print>::value,
|
||||
size_t>::type
|
||||
typename EnableIf<!StringTraits<Print>::has_append, size_t>::type
|
||||
prettyPrintTo(Print &print) const {
|
||||
IndentedPrint<Print> indentedPrint(print);
|
||||
return prettyPrintTo(indentedPrint);
|
||||
}
|
||||
|
||||
template <typename TString>
|
||||
typename TypeTraits::EnableIf<StringTraits<TString>::has_append, size_t>::type
|
||||
typename EnableIf<StringTraits<TString>::has_append, size_t>::type
|
||||
prettyPrintTo(TString &str) const {
|
||||
DynamicStringBuilder<TString> sb(str);
|
||||
return prettyPrintTo(sb);
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -12,14 +9,15 @@
|
|||
namespace ArduinoJson {
|
||||
|
||||
class JsonArray;
|
||||
class JsonArraySubscript;
|
||||
class JsonObject;
|
||||
template <typename TKey>
|
||||
class JsonObjectSubscript;
|
||||
class JsonVariant;
|
||||
|
||||
namespace Internals {
|
||||
|
||||
class JsonArraySubscript;
|
||||
template <typename TKey>
|
||||
class JsonObjectSubscript;
|
||||
|
||||
template <typename Writer>
|
||||
class JsonSerializer {
|
||||
public:
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -82,14 +79,14 @@ class JsonWriter {
|
|||
|
||||
template <typename TFloat>
|
||||
void writeFloat(TFloat value) {
|
||||
if (Polyfills::isNaN(value)) return writeRaw("NaN");
|
||||
if (isNaN(value)) return writeRaw("NaN");
|
||||
|
||||
if (value < 0.0) {
|
||||
writeRaw('-');
|
||||
value = -value;
|
||||
}
|
||||
|
||||
if (Polyfills::isInfinity(value)) return writeRaw("Infinity");
|
||||
if (isInfinity(value)) return writeRaw("Infinity");
|
||||
|
||||
FloatParts<TFloat> parts(value);
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JsonBufferBase.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
class StaticJsonBufferBase : public JsonBufferBase<StaticJsonBufferBase> {
|
||||
public:
|
||||
|
@ -93,6 +91,7 @@ class StaticJsonBufferBase : public JsonBufferBase<StaticJsonBufferBase> {
|
|||
size_t _capacity;
|
||||
size_t _size;
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
|
@ -108,9 +107,10 @@ class StaticJsonBufferBase : public JsonBufferBase<StaticJsonBufferBase> {
|
|||
// The template paramenter CAPACITY specifies the capacity of the buffer in
|
||||
// bytes.
|
||||
template <size_t CAPACITY>
|
||||
class StaticJsonBuffer : public StaticJsonBufferBase {
|
||||
class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
|
||||
public:
|
||||
explicit StaticJsonBuffer() : StaticJsonBufferBase(_buffer, CAPACITY) {}
|
||||
explicit StaticJsonBuffer()
|
||||
: Internals::StaticJsonBufferBase(_buffer, CAPACITY) {}
|
||||
|
||||
private:
|
||||
char _buffer[CAPACITY];
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright Benoit Blanchon 2014-2017
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -46,14 +43,17 @@ struct ArduinoStreamTraits {
|
|||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
static const bool has_append = false;
|
||||
static const bool has_equals = false;
|
||||
};
|
||||
|
||||
template <typename TStream>
|
||||
struct StringTraits<TStream,
|
||||
// match any type that is derived from Stream:
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsBaseOf<
|
||||
Stream, typename TypeTraits::RemoveReference<
|
||||
TStream>::type>::value>::type>
|
||||
struct StringTraits<
|
||||
TStream,
|
||||
// match any type that is derived from Stream:
|
||||
typename EnableIf<
|
||||
IsBaseOf<Stream, typename RemoveReference<TStream>::type>::value>::type>
|
||||
: ArduinoStreamTraits {};
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue