Compare commits

..
Author SHA1 Message Date
ESPEasy release bot e060c83cf8 automatically updated release notes for mega-20180719 2018-07-19 04:00:14 +02:00
Gijs NoorlanderandGitHub 5480af2d5d Merge pull request #1587 from TD-er/feature/sunrise_sunset_offset
[sunrise/sunset] Allow offset from sunrise/sunset
2018-07-19 01:07:39 +02:00
TD-er ff28605d39 [sunrise/sunset] Allow offset from sunrise/sunset
`%sunrise%` and `%sunset%` were already available.
Now it is also possible to get some time before or after those times.
For example `%sunrise+10m%` or `%sunset-1h%`
The offset must be an integer (including + or -) and can have a postfix of "m" or "h".
Default is "s", for seconds.
2018-07-19 01:06:06 +02:00
Gijs NoorlanderandGitHub fe0ca9b9a3 Merge pull request #1584 from denisfrench/enable_clientid_is_name_without_unit
When clientid = %sysname%, only add %unit% if non-zero (#1155)
2018-07-18 21:17:06 +02:00
Gijs NoorlanderandGitHub 54ef70aee9 Merge pull request #1586 from beigenmann/mega
lib_archive already exists & Implicit dependency not found
2018-07-18 21:16:03 +02:00
Gijs NoorlanderandGitHub e24d077061 Merge pull request #1583 from clumsy-stefan/P077_fix
Fix for P077 crashes
2018-07-18 21:15:44 +02:00
Benno Eigenmann 7ebf29d857 lib_archive already exists & Implicit dependency not found 2018-07-18 14:02:01 +02:00
denisfrench 33c6925376 When clientid = %sysname%, only add %unit% if non-zero 2018-07-17 19:35:17 +10:00
stefan 0b383a1f3b Fix for P077 crashes
some code rearrangements and improvements:
- fix a rare buffer overflow
- only update variables when new (correct) values are received
- little speed-up
- correct code indentations...
2018-07-16 13:39:51 +02:00
stefan 70d1b0807c Merge remote-tracking branch 'origin/mega' into mega 2018-07-16 07:22:31 +02:00
ESPEasy release bot 8e1f4d628b automatically updated release notes for mega-20180716 2018-07-16 04:00:09 +02:00
Gijs NoorlanderandGitHub ef29603f05 Merge pull request #1581 from TD-er/feature/ESP32_partitiontable
[ESP32] Show partition table on sysinfo page
2018-07-16 00:59:50 +02:00
Gijs NoorlanderandGitHub 71b27d95fa Merge pull request #1562 from TD-er/bugfix/wifi_reset_empty_IP
[WiFi] Reset wifi when IP is set to 0.0.0.0
2018-07-16 00:58:31 +02:00
Gijs NoorlanderandGitHub 787c1c6c39 Merge pull request #1579 from TD-er/bugfix/scheduler_rewrite
[Scheduler] Complete rewrite of time based scheduling
2018-07-16 00:58:02 +02:00
Gijs NoorlanderandGitHub 74e4848edc Merge pull request #1578 from TD-er/bugfix/JSON_device_info
[JSON] Fixed broken JSON output on /json URL
2018-07-16 00:57:41 +02:00
TD-er 9a7690473a [ESP32] Show partition table on sysinfo page
Graphical display of partition table.
2018-07-16 00:49:30 +02:00
TD-er 3fc1ba27e5 [JSON] Fixed broken JSON output on /json URL
This bug also broke the auto update of the sensor values on the device tab.
2018-07-15 20:23:11 +02:00
TD-er b2212d2edb [Scheduler] Complete rewrite of time based scheduling
All scheduled operations are now handled by a time scheduler.
Also the CPU load is now based entirely on the idle time found by this scheduler.
2018-07-15 20:21:37 +02:00
stefan 76f7dc82fc Merge branch 'bugfix/wifi_reset_empty_IP' into mega 2018-07-15 11:07:47 +02:00
ESPEasy release bot 86233b65bc automatically updated release notes for mega-20180714 2018-07-14 04:00:13 +02:00
Gijs NoorlanderandGitHub 984cfe23a0 Merge pull request #1569 from letscontrolit/bugfix/1567_uservarcheck
[#1567] Only check values set before sending
2018-07-13 10:35:25 +02:00
Gijs NoorlanderandGitHub 621087d48f [#1567] Only check values set before sending
Fix suggested by @s0170071 [here](https://github.com/letscontrolit/ESPEasy/issues/1567#issuecomment-404746920)
2018-07-13 09:21:42 +02:00
ESPEasy release bot 9336697f1a automatically updated release notes for mega-20180712 2018-07-12 04:00:12 +02:00
TD-er ad06cbc835 [WiFi] Reset wifi when IP is set to 0.0.0.0
As being described a few times and a screenshot shown here: https://github.com/letscontrolit/ESPEasy/issues/1302#issuecomment-393631572
It looks like a DHCP request may fail resulting in a cleared IP setup. The web server then still replies to requests, but no new connections can be made then.

This patch should detect such a situation and then reset the wifi and make a new connection.
2018-07-12 00:20:55 +02:00
Gijs NoorlanderandGitHub f5b026e678 Merge pull request #1561 from TD-er/bugfix/1542_domoticz_IDX
[#1542] Fix  Domoticz IDX more than 4 characters
2018-07-11 22:27:05 +02:00
TD-er e29eb2eb3c [#1542] Fix Domoticz IDX more than 4 characters
Looks like Domoticz uses an unsigned int, so it could be up-to 32 bits.
Just to be sure, I limited it now to 1 bln.
2018-07-11 22:26:05 +02:00
Gijs NoorlanderandGitHub 10329f4351 Merge pull request #1560 from TD-er/bugfix/send_to_controller
[#1555] Fix TSL2591 values are not transferred to controller
2018-07-11 22:08:13 +02:00
TD-er ab4750d5fa [#1555] Fix TSL2591 values are not transferred to controller
Also checked other plugins to see if they had the same issue and fixed a few other obvious switch-statement bugs.
2018-07-11 22:04:11 +02:00
ESPEasy release bot b9f3f68335 automatically updated release notes for mega-20180710 2018-07-10 04:00:12 +02:00
GrovkillenandGitHub 777485077c P077: changed category to "energy" 2018-07-09 07:11:15 +02:00
ESPEasy release bot 3e3ef4253f automatically updated release notes for mega-20180708 2018-07-08 04:00:08 +02:00
Gijs NoorlanderandGitHub 0e78b1f8c4 Merge pull request #1554 from TD-er/bugfix/preprocessor_issues
[PIO build] Build issues caused by incorrect precompile processing
2018-07-08 00:43:41 +02:00
TD-er e7764ca7e6 [PIO build] Build issues caused by incorrect precompile processing
It looks like `ESP32` is not defined anymore, which leads to various issues when building.
2018-07-08 00:29:11 +02:00
ESPEasy release bot 89578058b6 automatically updated release notes for mega-20180705 2018-07-05 04:00:18 +02:00
Gijs NoorlanderandGitHub 34beb07120 Merge pull request #1548 from TD-er/bugfix/low_loop_count
Statistics routines to test performance and some stability fixes
2018-07-05 02:26:19 +02:00
Gijs NoorlanderandGitHub c98ae55f23 Merge pull request #1541 from tempura-san/webui_fixes
Minor WebUI fixes
2018-07-05 02:25:43 +02:00
Gijs NoorlanderandGitHub 6b08009fdd Merge pull request #1546 from uzi18/patch-1
Update _C005.ino
2018-07-05 02:25:17 +02:00
TD-er f3a8e503ac [info] Display ESP32 partition table
And added some HEX formatting functions to reduce code duplication and allow for more uniform formatting.
2018-07-05 02:14:43 +02:00
TD-er 856afe9ec5 [PlatformIO] Update to Espressif32@1.1.1 2018-07-05 02:12:52 +02:00
TD-er c4803b4136 [Stability] Use functions to get Webserver Arguments from POST messages.
These functions check values before attempting to convert to int for example.
2018-07-04 01:19:15 +02:00
TD-er 9de29b8d9c [Stability] Add check for string length to isNumerical() 2018-07-04 01:17:19 +02:00
TD-er 5a2b4146e5 [PIO build] Use newer flag syntax for Travis 2018-07-04 01:16:38 +02:00
TD-er 0a8050312c [ESP32] Upgrade to new ESpressif32 version
Known issue:
Crash when trying to load the devices page.
2018-07-03 00:48:27 +02:00
TD-er 2ffa52c7ee [Timing stats] Allow computing timing to estimate performance. 2018-07-03 00:47:29 +02:00
TD-er 6a984ad750 [BMx280] Do not wait for measurements, collect async
This plugin did wait for 1000 msec for new samples.
Such delays will disturb time critical tasks.
2018-07-03 00:46:07 +02:00
Bartłomiej ZimońandGitHub f0c1b10f46 Update _C005.ino
unification like on C002.ino
2018-07-02 20:59:54 +02:00
Tempura San da6ab075a5 [WebUI] removed stray </div> 2018-06-29 13:37:47 +02:00
Tempura San fb7ffe0731 [WebUI] font-family set to monospace for TEXTAREA 2018-06-29 13:37:47 +02:00
TD-er 1d3bafc982 [loop times] New timer statistics class to monitor performance 2018-06-28 02:19:57 +02:00
TD-er 2fde3d28a8 [CPU usage] Increase loop count
Attempting to find a plugin ID based on a task number was done a lot and also rather brute force.
Now a cache is added to lessen the load.
2018-06-27 01:25:43 +02:00
ESPEasy release bot 4c1b3a8abf automatically updated release notes for mega-20180625 2018-06-25 04:00:08 +02:00
Gijs NoorlanderandGitHub 988f269954 Merge pull request #1533 from TD-er/bugfix/ArduinoIDE_build
Bugfix/arduino ide build
2018-06-24 12:20:02 +02:00
TD-er 808b571814 [PIO update] platform to espressif8266@1.7.3 2018-06-24 12:18:41 +02:00
TD-er a4f8068fcd [Arduino IDE] Fix build include path ESPEasy-Globals.h
As mentioned by @clumsy-stefan See [here](https://github.com/letscontrolit/ESPEasy/commit/8c9b9b1700efacbf281dd9bcc94684726cd034b1#commitcomment-29475286)
2018-06-24 12:17:52 +02:00
ESPEasy release bot 025e346cb1 automatically updated release notes for mega-20180624 2018-06-24 04:00:29 +02:00
Gijs NoorlanderandGitHub 3481dd9868 Merge pull request #1532 from TD-er/bugfix/RAM_usage_command_executor
Bugfix/ram usage command executor
2018-06-24 02:52:31 +02:00
TD-er fd596c14b2 [Cmd Exec] Use switch statement instead of lookup map
The lookup of a function call based on a command string is known at compile time, so no need to keep track of this in memory.
This saves about 2200 bytes of RAM.

The strings alone account for close to 800 bytes (not using F() macro) and they are also being stored in the map.
So that's about 1600 bytes.
The extra 400 bytes are probably the pointers being stored in the map.
2018-06-24 02:48:55 +02:00
TD-er 8c9b9b1700 [Cmd Exec] Add #ifndef #def statements to prevent multiple includes
For .h files, it is common practice to add #ifndef #def statements around the implementation to prevent compiler issues when a file might be included twice.
2018-06-24 02:44:47 +02:00
Gijs NoorlanderandGitHub e0b00a23cf Merge pull request #1522 from workgroupengineering/feature/CommandsManger
Feature commands manger
2018-06-23 22:40:16 +02:00
Gijs NoorlanderandGitHub 685c975bab Merge pull request #1531 from TD-er/bugfix/build_newer_platformio
Bugfix/build newer platformio
2018-06-23 22:39:09 +02:00
TD-er d01ca5209e [web log] Disable excessive web log about RAM usage 2018-06-23 22:38:43 +02:00
TD-er d5a05a1ac5 [PlatformIO.ini] VScode needs monitor_speed and update ESP8266 platform
VScode + PlatformIO needs the monitor_speed setting to be able to monitor the connected node. (default 9600 baud)
Also set the ESP8266 code base to 1.7.2
2018-06-23 22:11:58 +02:00
TD-er c670520788 [SDS011] Set SDS011 Dust plugin to normal from testing
This plugin works on my test setup for more than 6 months and is by far the most stable node. (system uptimes of > 110 days)
So this may be considered stable.
2018-06-23 22:09:29 +02:00
TD-er 859b67e34d [ArduinoJson] Update external library ArduinoJson.
Is needed to compile new ESP32 code.
2018-06-23 22:06:22 +02:00
TD-er d325f7c1fd [JavaScript] Device measurement value update may sometimes fail
The Json data has more items at the level of `data.Sensors[c]` thus must check if it is a TaskValues item.
Otherwise the values shown on Device page will not be updated.
2018-06-23 22:04:51 +02:00
TD-er c2998b081f [AM2320] Explicit use boolean in Wire.endTransmission
Newer ESP32 environment also has endTransmission with an int as parameter.
2018-06-23 22:01:55 +02:00
Saverio Cisternino c3c2a0b6bd Migration core command 2018-06-21 15:05:44 +02:00
Saverio Cisternino 9e00623677 Implement CommandsManager 2018-06-21 15:05:44 +02:00
ESPEasy release bot 6be032b350 automatically updated release notes for mega-20180621 2018-06-21 04:00:14 +02:00
Gijs NoorlanderandGitHub 96367a9422 Merge pull request #1520 from workgroupengineering/HotFix/Issue_1489
Fixed Issue #1489
2018-06-20 15:56:54 +02:00
Gijs NoorlanderandGitHub 543ac49eaf Merge pull request #1521 from workgroupengineering/feature/show_device_port_in_hex
Show in devices list port number in hex
2018-06-20 15:55:02 +02:00
Saverio Cisternino 3e0362d52a Show in devices list port number in hex 2018-06-20 13:48:03 +02:00
Saverio Cisternino 15118d372e Fixed Issue #1489 2018-06-20 13:36:12 +02:00
ESPEasy release bot c8ee7976cc automatically updated release notes for mega-20180619 2018-06-19 04:00:10 +02:00
Gijs NoorlanderandGitHub b750e875bd Merge pull request #1515 from TD-er/bugfix/esp8285_build
[ESP8285] PlatformIO set max upload size limit
2018-06-18 23:52:36 +02:00
TD-er 5ad43348b4 [ESP8285] PlatformIO set max upload size limit
With the newer Platform IO versions, builds failed because of wrong size set in board definition of ESP8285 board.
The PlatformIO settings labels have changed.
2018-06-18 23:23:27 +02:00
Gijs NoorlanderandGitHub 08b2259924 Merge pull request #1514 from TD-er/bigfix/build_flash_ESP32
[ESP32] Allow flashing to ESP32 again from PlatformIO
2018-06-18 21:46:27 +02:00
TD-er f268b40291 [OTA] Output proper port number when ARDUINO_FEATURE_OTA is set
No functional change, only proper log entry and a bit of code cleanup.
2018-06-18 21:44:45 +02:00
TD-er 52d747dd49 [ESP32] Set build to @0.12.0
@1.0.2 does build, but ESP32 device hangs when booting.
2018-06-18 21:43:14 +02:00
TD-er e5653d1817 [ESP32] Allow flashing to ESP32 again from PlatformIO
See [this thread](https://community.platformio.org/t/esp32-esptool-error-too-few-arguments/4230/44)
2018-06-18 20:26:54 +02:00
ESPEasy release bot 6b2257063b automatically updated release notes for mega-20180618 2018-06-18 04:00:12 +02:00
Gijs NoorlanderandGitHub b9a4af54c9 Merge pull request #1509 from TD-er/bugfix/disable_ping
[#1494] Disabled ping to check if host is reachable
2018-06-18 00:11:16 +02:00
TD-er 26634f7ba9 [#1494] Disabled ping to check if host is reachable
A failing ping may also halt the ESP node and some services may not return a ping, or ICMP packets may be filtered out on some connections.
See issue #1494.
2018-06-18 00:09:31 +02:00
Gijs NoorlanderandGitHub 9beda98009 Merge pull request #1501 from clumsy-stefan/mega
Ammended central I2C fuctions (#1417)
2018-06-17 22:33:33 +02:00
Gijs NoorlanderandGitHub c7c46d28b1 Merge pull request #1507 from stelas/mega
Add sunset and sunrise variables...
2018-06-17 22:31:48 +02:00
Steffen Lange c51b78bfbf Add %sunrise% and %sunset% variables 2018-06-17 17:06:28 +02:00
Steffen Lange df5c22529f Add GPS coordinates to Advanced Settings 2018-06-17 16:51:12 +02:00
ESPEasy release bot 808ab85afb automatically updated release notes for mega-20180615 2018-06-15 04:00:11 +02:00
Gijs NoorlanderandGitHub ad1cbf5ddf Merge pull request #1504 from TD-er/feature/warn_OTA_1M
[1M flash warning] Warn for OTA when 1M flash present
2018-06-14 23:27:29 +02:00
TD-er 4aff834f76 [1M flash warning] Warn for OTA when 1M flash present 2018-06-14 20:04:01 +02:00
ESPEasy release bot f8405690c5 automatically updated release notes for mega-20180614 2018-06-14 04:00:11 +02:00
Gijs NoorlanderandGitHub 3edf12913d [#1503] Use proper timeout on BME280/BMP280 2018-06-13 23:18:59 +02:00
Gijs NoorlanderandGitHub f0aa9c50f6 [#1502] Change wait-to-connect timeout to 12 sec. 2018-06-13 22:51:31 +02:00
stefan 80f87b6c53 Ammended central I2C fuctions (#1417)
Ammended central I2C functions with 16bit write and 32 bit read.
also added "false" parameter to wire.endTransmission before wire.request form

all as discussed in #1417
2018-06-13 13:55:16 +02:00
ESPEasy release bot f41f0969f0 automatically updated release notes for mega-20180613 2018-06-13 04:00:15 +02:00
Gijs NoorlanderandGitHub 14e2f4c697 [BMx280] Correct nr values for special sensor type
`SENSOR_TYPE_TEMP_EMPTY_BARO` outputs values 1 and 3, so must consider them as 3-valued sensor.
2018-06-13 00:54:18 +02:00
Gijs NoorlanderandGitHub b9f5535b48 Merge pull request #1500 from TD-er/bugfix/bme280_change_type_for_BMP280
[BMx280] Send data from BMP280 as temp_baro, not temp_hum_baro
2018-06-13 00:43:16 +02:00
TD-er 81022e4605 [BMx280] Send data from BMP280 as temp_baro, not temp_hum_baro
The plugin BMx280 can handle BMP280 and BME280.
The BMP version has no humidity sensor.
For Domoticz you have to send the data formatted differently.

Now the same plugin can be used for both BME280 and BMP280 and the settings in Domoticz can be set accordingly.
2018-06-13 00:39:23 +02:00
Gijs NoorlanderandGitHub 616898514b Merge pull request #1499 from TD-er/feature/log_reset_reason
[Diag] Log Reset Reason at boot for ESP8266 and ESP32
2018-06-12 23:57:54 +02:00
TD-er 020aec0541 [Diag] Log Reset Reason at boot for ESP8266 and ESP32
To get a better idea of the cause with reported issues.
2018-06-12 23:24:59 +02:00
ESPEasy release bot 1e39a314f5 automatically updated release notes for mega-20180611 2018-06-11 04:00:21 +02:00
Gijs NoorlanderandGitHub 4d369927fd Merge pull request #1491 from TD-er/bugfix/ultrasonic_multi_device
Bugfix/ultrasonic multi device
2018-06-11 00:49:08 +02:00
Gijs NoorlanderandGitHub c1465831bb Merge pull request #1481 from tempura-san/mega
[MQTT Import] system variables support for topics
2018-06-11 00:48:50 +02:00
Gijs NoorlanderandGitHub 3ec1d29c19 Merge pull request #1473 from workgroupengineering/HotFix/PCA9685_Instance_Command
Fixed issue when there is more PCA9685
2018-06-11 00:48:23 +02:00
Gijs NoorlanderandGitHub 22b430c669 Merge pull request #1461 from TD-er/feature/central_i2c_code
[#1417] Move I2C functions to a separate file
2018-06-11 00:47:58 +02:00
TD-er 2f7560cc90 [BME/BMP280] Improve temperature/humidity readout
Previously the I2C registers containing measurement data was read per address at once.
Now all are read in one I2C command and then processed.

Also changed the source to be able to support multiple instances of the same task.
2018-06-11 00:08:30 +02:00
TD-er 4f97db87f7 [PlatformIO] Added libraries to be able to use std::map 2018-06-09 23:21:42 +02:00
TD-er dcf8e86db7 [#1484] Multiple instances of ultrasonic sensors
This should also fix #1381.

There is something strange about the handling of micros() timers in `NewPingESP8266`.
For this reason I added also a timeout based on `millis()`.
2018-06-09 23:20:29 +02:00
ESPEasy release bot 06914e72b1 automatically updated release notes for mega-20180606 2018-06-06 04:00:17 +02:00
Gijs NoorlanderandGitHub fca56ac311 Merge pull request #1485 from letscontrolit/bugfix/Gpio_command
[GPIO command] work-around as long as gpio command is still performed in P001
2018-06-05 20:38:44 +02:00
Gijs NoorlanderandGitHub 2bacc5a1b2 [GPIO command] work-around as long as gpio command is still performed in P001_switch.
As discussed in #1477
2018-06-05 20:02:00 +02:00
TD-er a487bd132d [I2C] Disable calls to wire.begin() from libraries 2018-06-05 19:56:23 +02:00
Tempura San 3f441b11ee [MQTT Import] system variables support for topics 2018-06-04 23:45:30 +02:00
Saverio Cisternino 40d5780600 Fixed issue when there is more PCA9685 2018-05-30 10:07:06 +02:00
TD-er 9822c4bac0 [I2Cdev] Add I2Cdevlib library
Adding an existing and proven I2C library.
Will need to test if this is working fine on ESP32 too and try to move I2C functionality to use these functions.
2018-05-27 01:32:40 +02:00
ESPEasy release bot 0fc3a28875 automatically updated release notes for mega-20180524 2018-05-24 04:00:14 +02:00
TD-er 0aac28b15e [#1417] Move I2C functions to a separate file
As discussed in #1417.
2018-05-24 00:41:18 +02:00
Gijs NoorlanderandGitHub 810927f32b Merge pull request #1244 from susisstrolch/git-hooks
GIT hooks: post-merge, post-commit, post-checkout
2018-05-23 22:28:00 +02:00
Gijs NoorlanderandGitHub c3d8d0a2fe Merge branch 'mega' into git-hooks 2018-05-23 22:27:41 +02:00
Gijs NoorlanderandGitHub 0c9e27a180 Merge pull request #1369 from workgroupengineering/feature/mqtt_enhanced_customization
[Feature]mqtt enhanced customization
2018-05-23 22:25:28 +02:00
Gijs NoorlanderandGitHub a5f44a1811 Merge pull request #1460 from TD-er/bugfix/CI-build-errors
[CI build] Small fix to prevent Travis CI build errors.
2018-05-23 22:15:46 +02:00
TD-er 66f386f3fc [CI build] Small fix to prevent Travis CI build errors. 2018-05-23 22:14:14 +02:00
Gijs NoorlanderandGitHub e74cc14dfb Merge pull request #1448 from workgroupengineering/feature/PCA9685_enhanced
PCA9685 enhanced
2018-05-23 22:00:38 +02:00
Gijs NoorlanderandGitHub ad1907eef4 Merge pull request #1387 from workgroupengineering/feature/Multi_OLED
Implement Issue #1377
2018-05-23 21:31:07 +02:00
Saverio Cisternino 7640132828 PCA9685: Add support at command [TaskName].gpio all,1 | 0 which allows you to turn on (1) or turn off (0) all gpio of expander. 2018-05-22 15:25:49 +02:00
Saverio Cisternino fecf740121 PCA9685: Add named istance pulse command. Es: Extend.pulse 0,1,50,auto gnenerate pulse on gpio 0 with duration of 50 ms an autorestart after 50 ms 2018-05-22 15:25:49 +02:00
Saverio Cisternino 7d9628c6d1 PCA9685: Add support at commad gpio on name instance call 2018-05-22 15:25:49 +02:00
Saverio Cisternino 7d5a0db6fa PCA9685: Allow use frq alias when call instance command es: Extender.frq 100 2018-05-22 15:25:49 +02:00
Saverio Cisternino 49fc761657 PCA9685: Add pcafrq arg validation 2018-05-22 15:25:48 +02:00
Saverio Cisternino 98d1a9cec4 PCA9685: Allow use pwm alias when call instance command es: Extender.pwm 1, 1000 2018-05-22 15:25:07 +02:00
Saverio Cisternino ae010e25fb PCA9685: show address in hex. 2018-05-22 15:25:06 +02:00
Saverio Cisternino 3013c8e468 PCA9685: Add Pin e PWM validation 2018-05-22 15:25:06 +02:00
Saverio Cisternino ade5f83819 PCA9685: Allow named istance commands for execute command on specific task when there is more PCA9685 task. 2018-05-22 15:25:05 +02:00
Saverio Cisternino caf487e04e PCA9685: Allow select address. 2018-05-22 15:25:05 +02:00
Saverio Cisternino d8100a2b9d ExecuteCommand intercept Par4 and Par5 2018-05-22 15:24:24 +02:00
Saverio Cisternino 18f38b3019 EventStruct copy ctor 2018-05-22 15:24:23 +02:00
Saverio Cisternino 952c532542 -Arminizze type of ParX of systemTimerStruct with EventStruct to prevent truncation issue
-Add setSystemTimer overload
2018-05-22 15:24:23 +02:00
Saverio Cisternino d1b15579a1 Allow PLUGIN_TIMER_IN TaskIndex 2018-05-22 15:24:23 +02:00
Saverio Cisternino 8445d8cc71 Allow escape char [ and ] for use with comannd and rule containde space es [Extra 2]#Go 2018-05-22 15:24:23 +02:00
Saverio Cisternino 7720b5bce3 Allows plugin to intercept PLUGIN_WRITE and PLUGIN_REQUEST, when there is more tasks of same plugin type but different configuration. 2018-05-22 15:24:23 +02:00
Saverio Cisternino 965046778a Allow use Unit Name as MQTT ClientId 2018-05-22 15:22:24 +02:00
Saverio Cisternino 1a8fffda28 Allow custom lwt message 2018-05-22 15:22:24 +02:00
Saverio Cisternino a5e3979be6 Allow custom mqtt lwt topic 2018-05-22 15:22:24 +02:00
ESPEasy release bot 9d2e008a5c automatically updated release notes for mega-20180522 2018-05-22 04:00:14 +02:00
Gijs NoorlanderandGitHub a031ce9b5b Merge pull request #1456 from TD-er/feature/SonoffPOW2
[P077] CSE7766 - Energy (Sonoff S31 and Sonoff Pow R2)
2018-05-22 00:10:35 +02:00
Gijs NoorlanderandGitHub c8593d5644 Merge pull request #1457 from tedenda/Inform_user_about_valid_tasknumber_for_PulseCounter
Added a note for PulseCounter
2018-05-22 00:09:44 +02:00
Daniel Tedenljung 306b2174f2 Add note for PulseCounter
I added a note if you choose PulseCounter on task 5-12.
Part of #882
2018-05-21 23:03:22 +02:00
Daniel TedenljungandGitHub 10ff688cc4 Merge pull request #3 from letscontrolit/mega
Catch up...
2018-05-21 22:45:52 +02:00
TD-er ae292921e2 [P077] CSE7766 - Energy (Sonoff S31 and Sonoff Pow R2)
Was P134 on the playground
2018-05-21 22:34:03 +02:00
Gijs NoorlanderandGitHub a1622f6066 Merge pull request #1449 from clumsy-stefan/mega
Add CSE7766 for Sonoff POW R2 to plugin_sets
2018-05-21 20:23:56 +02:00
Gijs NoorlanderandGitHub 86490d6f0b Merge pull request #1454 from giig1967g/new/commands_ip
Added 10 new commands for setup through serial port
2018-05-21 19:36:15 +02:00
Plebs 976df758d2 Added 10 new commands for serial port configuration
In order to semplify the setup of new units, I have added the following commands for modifying settings though serial port:

gateway (x.x.x.x)
dns (x.x.x.x)
subnet (x.x.x.x)
dst (0 or 1)
mqttretainflag (0 or 1)
messagedelay (ms)
ntphost (url)
timezone (minutes)
udpport (port number)
usentp (0 or 1)

work in serial and rules
2018-05-21 00:00:02 +02:00
stefan c31e50dfa0 Merge remote-tracking branch 'origin/mega' into mega 2018-05-19 10:25:05 +02:00
ESPEasy release bot 147acc6724 automatically updated release notes for mega-20180519 2018-05-19 04:00:07 +02:00
stefan bfd5ad587a Merge remote-tracking branch 'origin/mega' into mega 2018-05-19 00:19:06 +02:00
Saverio Cisternino 84791ecbd5 Allow using two oled at same time.
Suppose you have two oled task with name FrontPanel and BackPanel. If you want turn off FrontPanel and print on BackPanel "Hi" at posintion 0,0  you must use the following instructions:

frontpanel.oledcmd off
backpanel.oled 0,0,Hi

if task name have space you must surround with square brackets. es: [task with space].oledcmd off
2018-05-18 15:39:06 +02:00
Saverio Cisternino 6e4f4cb27b EventStruct copy ctor 2018-05-18 15:24:21 +02:00
Saverio Cisternino c1ee60ebca -Arminizze type of ParX of systemTimerStruct with EventStruct to prevent truncation issue
-Add setSystemTimer overload
2018-05-18 15:24:21 +02:00
Saverio Cisternino fc1f6acc61 Allow PLUGIN_TIMER_IN TaskIndex 2018-05-18 15:24:21 +02:00
Saverio Cisternino e2c82680aa Allow escape char [ and ] for use with comannd and rule containde space es [Extra 2]#Go 2018-05-18 15:23:59 +02:00
Saverio Cisternino f0eb7659b2 Allows plugin to intercept PLUGIN_WRITE and PLUGIN_REQUEST, when there is more tasks of same plugin type but different configuration. 2018-05-18 15:21:40 +02:00
GrovkillenandGitHub 966353614d [tools page] added a function for wide buttons 2018-05-18 09:58:18 +02:00
stefan 3308a47a3a Merge remote-tracking branch 'origin/mega' into mega 2018-05-18 08:19:08 +02:00
ESPEasy release bot ffad0256e9 automatically updated release notes for mega-20180518 2018-05-18 04:00:07 +02:00
GrovkillenandGitHub c531639d03 Merge pull request #1450 from Grovkillen/mega
[tools page] added 100% wide buttons + red factory reset
2018-05-18 00:42:50 +02:00
GrovkillenandGitHub a2ec2d15f1 [tools page] Center text, factory reset is red 2018-05-18 00:29:43 +02:00
GrovkillenandGitHub eaa21d0182 [tools page] wider buttons 2018-05-18 00:16:36 +02:00
GrovkillenandGitHub 5a19b08262 Merge pull request #30 from letscontrolit/mega
update from master
2018-05-18 00:14:07 +02:00
stefan 2c9964127c Add CSE7766 for Sonoff POW R2 to plugin_sets
Add USES_P134 to define_plugin_sets.h for use with Sonoff POW R2 measurments.
See also
pull request #94 on ESPEasyPlayground (https://github.com/letscontrolit/ESPEasyPluginPlayground/pull/94)
2018-05-17 20:35:22 +02:00
GrovkillenandGitHub ea20971b51 Merge pull request #1442 from Grovkillen/memory-optimization-for-JS
Memory optimization for JavaScript
2018-05-17 09:45:24 +02:00
GrovkillenandGitHub eed78f9613 [JavaScript] made static variables "const" 2018-05-17 08:51:13 +02:00
GrovkillenandGitHub fe26453927 Merge pull request #28 from letscontrolit/mega
update from master
2018-05-17 08:46:37 +02:00
GrovkillenandGitHub 70db6d65db Merge pull request #1440 from TD-er/feature/1431
[#1431] Add DataAcquisition to /json and reduce json for sensor updates
2018-05-17 08:18:55 +02:00
ESPEasy release bot 07b9d5c6f5 automatically updated release notes for mega-20180517 2018-05-17 04:00:08 +02:00
TD-er 45048ea6bc [#1431] Add DataAcquisition to /json and reduce json for sensor updates
The /json page now also supports a limited view for the device page sensor updates.

The supported URLs for the json page are:

- `/json` All information in JSON format.
- `/json?view=sensorupdate` Limited view only for auto update on Devices tab.
- `/json?tasknr=N` with N being the task number, just outputs the information for the given task number.

N.B. these parameters can be combined, like: `/json?tasknr=1&view=sensorupdate`
2018-05-16 23:41:50 +02:00
Gijs NoorlanderandGitHub c7ff6059ce Merge pull request #1438 from TD-er/bugfix/flash_strings
[Flash strings] Store more strings into flash to keep memory usage low
2018-05-16 21:39:04 +02:00
Gijs NoorlanderandGitHub 6d2cd505a8 Update WebServer.ino 2018-05-16 14:30:38 +02:00
Gijs NoorlanderandGitHub 6b05d2b02e Update _C012.ino 2018-05-16 13:45:29 +02:00
ESPEasy release bot 083310679c automatically updated release notes for mega-20180516 2018-05-16 04:00:09 +02:00
Gijs NoorlanderandGitHub 2758c80af2 Merge pull request #1437 from Grovkillen/add-current-log-level-+-legend
Add current log level + some error capture
2018-05-16 02:08:40 +02:00
TD-er 0bd1134eca [Flash strings] Store more strings into flash to keep memory usage low 2018-05-16 01:55:41 +02:00
GrovkillenandGitHub 4a75b1fa6d [web log] error capture of lower log levels
Also added the current log level as info above the log viewer...
2018-05-15 21:51:07 +02:00
GrovkillenandGitHub 21d30f0ebe Merge pull request #27 from letscontrolit/mega
update from master
2018-05-15 20:22:35 +02:00
Gijs NoorlanderandGitHub 16463dff85 Merge pull request #1432 from Grovkillen/github-copy-button
GitHub copy button
2018-05-15 20:20:08 +02:00
Gijs NoorlanderandGitHub 8e5fb85fa8 Merge pull request #1429 from giig1967g/bugfix/formats
Another small fix for #1426
2018-05-15 20:19:25 +02:00
GrovkillenandGitHub 74f059e639 Merge pull request #1434 from Grovkillen/bugfix-for-log-level-info
Bugfix for log level info
2018-05-15 20:17:53 +02:00
GrovkillenandGitHub 045c50f69f [web log] bugfix for empty logJSON stings 2018-05-15 19:49:18 +02:00
GrovkillenandGitHub a122066e36 Merge pull request #26 from letscontrolit/mega
update from master
2018-05-15 19:24:20 +02:00
GrovkillenandGitHub d3bf64fc4f Merge pull request #25 from letscontrolit/mega
Update from master
2018-05-15 15:39:13 +02:00
GrovkillenandGitHub 74decbd159 [sysinfo page] fixed layout of button 2018-05-15 15:38:03 +02:00
GrovkillenandGitHub b00020de89 [sysinfo page] Added GitHub button to TXBuffer 2018-05-15 07:03:40 +02:00
GrovkillenandGitHub d9848c1911 [sysinfo page] added CSS to GitHub copy button 2018-05-15 07:02:27 +02:00
ESPEasy release bot 648353b216 automatically updated release notes for mega-20180515 2018-05-15 04:00:11 +02:00
GrovkillenandGitHub f729012ee1 [sysinfo page] added GitHub copy 2018-05-15 00:44:10 +02:00
GrovkillenandGitHub 87176b453a Added latest nightly release badge 2018-05-14 23:18:23 +02:00
GrovkillenandGitHub a2270bebbf Merge pull request #24 from Grovkillen/mega
update
2018-05-14 23:02:50 +02:00
GrovkillenandGitHub 305d729015 Merge pull request #23 from letscontrolit/mega
update from master
2018-05-14 23:01:39 +02:00
Plebs c31fa71988 Another small fix for #1426 2018-05-14 22:38:58 +02:00
Gijs NoorlanderandGitHub fba4331213 Merge pull request #1423 from Grovkillen/optimize-log-script
Optimize log script
2018-05-14 20:51:55 +02:00
Gijs NoorlanderandGitHub 972d24118a Merge pull request #1424 from Grovkillen/fix-corrupted-bin-files
Fix corrupted bin files
2018-05-14 20:51:34 +02:00
Gijs NoorlanderandGitHub a885cf1f90 Merge pull request #1427 from giig1967g/bugfix/formats
fix for #1426
2018-05-14 20:50:35 +02:00
Plebs 56d85814b1 fix for #1426 2018-05-14 19:09:35 +02:00
GrovkillenandGitHub c760174c78 [fix for crc2.py] truncation corrupted bin file 2018-05-14 12:20:13 +02:00
GrovkillenandGitHub 2c43094a87 [web log] added warning if IE11 or older is used 2018-05-14 10:59:23 +02:00
GrovkillenandGitHub ee99e9e6f4 [web log] added the reRunCout to the function 2018-05-14 10:09:08 +02:00
GrovkillenandGitHub 864e402cc2 [web log] Added declaring of reRunCount 2018-05-14 09:29:55 +02:00
GrovkillenandGitHub dff51ba54d [web log] Chunk transfer instead of line transfer 2018-05-14 09:27:18 +02:00
GrovkillenandGitHub 0eea67d176 Merge pull request #22 from Grovkillen/mega
update
2018-05-14 08:10:10 +02:00
GrovkillenandGitHub 9139baa6cb Merge pull request #21 from letscontrolit/mega
update from master
2018-05-14 08:09:06 +02:00
ESPEasy release bot fdf8a40acf automatically updated release notes for mega-20180514 2018-05-14 04:00:09 +02:00
Gijs NoorlanderandGitHub 547f3643ff Merge pull request #1421 from TD-er/bugfix_issue#1411
Memory optimizations
2018-05-13 23:46:12 +02:00
TD-er 83d0980248 [ESP32] ESP.getResetReason() is unknown to ESP32 2018-05-13 23:25:08 +02:00
TD-er 0b1f9a81b5 [memory corruption] LWIP data corrupts log buffer
Not sure how, but the headers of new JSON message can corrupt the buffer in the web log buffer.
In this attempt the log buffer lines are now moved to heap instead of stack. 
Also the streaming webserver is given a bit more time to handle requests.

Steps to reproduce:
Set web log level to maximum and open web log viewer.
Then wait a few seconds to minutes to let the JSON stream stop and look at the last sent Json message. This will contain some typical Json web headers and thus no valid Json anymore.

Also added a quick fix for #1419
2018-05-13 23:12:02 +02:00
TD-er 0e8b333f48 [issue #1380] Prevent memory leaks in WiFiClient
See described work-around in https://github.com/esp8266/Arduino/issues/4497#issuecomment-373023864
2018-05-13 23:04:45 +02:00
TD-er 67098c2539 [memory] use "-DNDEBUG" to disable ASSERT macros
See https://github.com/esp8266/Arduino/issues/3978
2018-05-13 22:58:10 +02:00
Gijs NoorlanderandGitHub 700b14b8ff Merge pull request #1420 from ZericE/mega
[#1404] Change email notify protocol to better comply with RFC2821. Rewrite line breaks for content-type: text/html
2018-05-13 19:05:03 +02:00
ZericE 9175cd3a17 use reference to free up mem. 2018-05-13 09:23:23 -07:00
ZericE c16f27af1b remove unneeded use of bMesg to free up mem. 2018-05-13 08:45:43 -07:00
Gijs NoorlanderandGitHub cc60b8a05d Merge pull request #1382 from flexiti/mega
ESP32 OTA amendments
2018-05-13 11:42:33 +02:00
Gijs NoorlanderandGitHub d7b46b3395 Merge pull request #1416 from giig1967g/new/formats
Added more #formats transformations
2018-05-13 11:41:12 +02:00
ESPEasy release bot 701677274f automatically updated release notes for mega-20180513 2018-05-13 04:00:08 +02:00
ZericE ebfffb8d43 updated comment 2018-05-12 18:08:47 -07:00
ZericE f5fd624739 remove debug lines in email notify 2018-05-12 18:06:00 -07:00
ZericE abdf011a2d undo unnecessary changes in email body
Previously I thought the body wasn't working correctly in email, however it was, with the exception of line breaks for text/html that have to be rewritten.
2018-05-12 18:03:59 -07:00
ZericE 4ece42bdc9 Merge branch 'mega' of https://github.com/ZericE/ESPEasy into mega 2018-05-12 16:48:17 -07:00
ZericE b0961c15a3 [#1404] Fix email notification for RFC2821, fix so msg body included.
In communicating with the server, the sender and receiver needed to be surrounded by <> to be RFC2821 compliant.
The message body was coming out blank as an empty string was being sent instead of the correct string.
2018-05-12 16:43:30 -07:00
Plebs 70a422bdfd Added more #formats transformations
New Transformations:
#H: Hot/Cold
#A: Man/Auto
#a: M/A

New Justifications:
#Lx: Left (x=number of chars)
#Rx: Right (x=number of chars)
#Ux.y: Substring (x=first char; y=number of chars)
2018-05-12 23:57:58 +02:00
Gijs NoorlanderandGitHub 5449d82639 [PR #1304] Rename file before running crc2.py
Quick patch of PR #1304
2018-05-12 22:57:17 +02:00
ZericEandGitHub 7e5577b30b Merge pull request #1 from letscontrolit/mega
update latest changes from main repository
2018-05-12 13:14:39 -07:00
Gijs NoorlanderandGitHub 0d95fd12fe Fix debug code (commented) in _P045_MPU6050.ino
Original PR was https://github.com/letscontrolit/ESPEasy/pull/1389
Found by @maartenpaauw
2018-05-12 22:10:33 +02:00
flexitiandGitHub b7df21a1d5 Merge pull request #4 from letscontrolit/mega
Sat May 12 04:00:06 CEST 2018
2018-05-12 11:00:14 +02:00
ESPEasy release bot 431b94c587 automatically updated release notes for mega-20180512 2018-05-12 04:00:06 +02:00
GrovkillenandGitHub 53241f2afc Added Github logo (for button) 2018-05-12 00:46:10 +02:00
GrovkillenandGitHub 076c2c04f1 Merge pull request #20 from letscontrolit/mega
update from master
2018-05-12 00:43:00 +02:00
GrovkillenandGitHub 10e912f46f Merge pull request #1413 from Grovkillen/optimized-log-a-tiny-bit-(feels-good)
Optimized log a tiny bit (feels good)
2018-05-12 00:25:26 +02:00
GrovkillenandGitHub c90174712b [web log] safety net not needed anymore 2018-05-12 00:14:54 +02:00
GrovkillenandGitHub 1d71d362b9 Merge pull request #19 from letscontrolit/mega
update from master
2018-05-12 00:06:39 +02:00
Gijs NoorlanderandGitHub 73fbe04981 Merge pull request #1410 from TD-er/bugfix/nightlybuilds
[build] Do builds twice on the nightly builds
2018-05-11 22:11:08 +02:00
flexitiandGitHub 469735b5fd Merge pull request #3 from letscontrolit/mega
Commits on May 10, 2018
2018-05-11 17:42:10 +02:00
TD-er cf13024175 [#1411] Add SensorTypeNone to indicate no sensor values for Domoticz
Some plugins which do not output any values had this setting set to "Switch" or "single".
2018-05-11 17:20:32 +02:00
Gijs NoorlanderandGitHub eaf6488b0c Merge pull request #1409 from Grovkillen/device-page]-added-max-request
[Device page] added max request
2018-05-11 14:44:32 +02:00
GrovkillenandGitHub 4d067f010f [device page] added dynamic length to loop 2018-05-11 14:41:01 +02:00
GrovkillenandGitHub e6db005dba [web log] also taking care of disconnects 2018-05-11 14:19:16 +02:00
GrovkillenandGitHub 7a03802c15 [device page] added max request here too 2018-05-11 14:00:17 +02:00
GrovkillenandGitHub 1e2e750b3b Merge pull request #18 from letscontrolit/mega
update from master
2018-05-11 13:59:23 +02:00
Gijs NoorlanderandGitHub 50a19692b5 Merge pull request #1408 from Grovkillen/fix-request-issue
[web log] Fix request issue
2018-05-11 13:46:52 +02:00
TD-er b6284f2701 [build] Do builds twice on the nightly builds
And added build for ESP32 and Sonoff POW
2018-05-11 13:42:41 +02:00
GrovkillenandGitHub b3db6621e2 [web log] fixed wait on requests 2018-05-11 13:33:28 +02:00
GrovkillenandGitHub 2d32fe3e32 Merge pull request #17 from letscontrolit/mega
update from master
2018-05-11 11:33:28 +02:00
GrovkillenandGitHub 241f21b87c Merge pull request #1407 from Grovkillen/fix-for-sub-second-timers
[web log] Fix for sub second timers
2018-05-11 10:58:45 +02:00
GrovkillenandGitHub 4f18f81522 [web log] fixed overflow when set to "debug dev" 2018-05-11 10:50:47 +02:00
GrovkillenandGitHub b860f79e77 Merge pull request #16 from letscontrolit/mega
update from master
2018-05-11 10:44:17 +02:00
Gijs NoorlanderandGitHub 8966e1680b Merge pull request #1403 from Grovkillen/fix-timer-in-javascript
Fix timer in javascript
2018-05-11 10:03:34 +02:00
GrovkillenandGitHub 01436201a3 Added ";" 2018-05-11 09:59:31 +02:00
GrovkillenandGitHub 1ac94bf6db Merge pull request #15 from letscontrolit/mega
Update from master
2018-05-11 09:44:20 +02:00
GrovkillenandGitHub ed66a98e08 Fix for decimals on auto update device page 2018-05-11 09:43:07 +02:00
Gijs NoorlanderandGitHub 5a0c2e2353 Merge pull request #1405 from TD-er/bugfix/json_nr_decimals
[JSON] Add number of decimals to the JSON output
2018-05-11 09:42:01 +02:00
TD-er 06bc63e385 [JSON] Add number of decimals to the JSON output 2018-05-11 09:40:32 +02:00
GrovkillenandGitHub d3ebe3ec46 Fixed scrolling issue when fetch <450mSec 2018-05-11 09:32:23 +02:00
GrovkillenandGitHub 2282288030 Added check to stop flooding 2018-05-11 09:17:17 +02:00
GrovkillenandGitHub e5766bee46 Fixed some small syntax missing 2018-05-11 08:31:04 +02:00
flexitiandGitHub c5bbfd1b4c Merge pull request #2 from letscontrolit/mega
Fri May 11 04:00:08 CEST 2018
2018-05-11 08:18:27 +02:00
ESPEasy release bot 652ce2f809 automatically updated release notes for mega-20180511 2018-05-11 04:00:08 +02:00
GrovkillenandGitHub f3fd3900e5 Removed a timer reset... 2018-05-11 00:44:49 +02:00
GrovkillenandGitHub 07b726d4b1 Preparation for fixed decimals... 2018-05-11 00:30:58 +02:00
GrovkillenandGitHub 648d960bf5 Fixed format (I like tabs, Platformio like spaces) 2018-05-10 23:25:45 +02:00
GrovkillenandGitHub 1829a35df2 Fixed the timers for log + devices 2018-05-10 23:23:06 +02:00
GrovkillenandGitHub c5bb6700d9 Merge pull request #14 from letscontrolit/mega
update from master
2018-05-10 22:45:00 +02:00
Gijs NoorlanderandGitHub 3b2dd86280 Merge pull request #1402 from TD-er/feature/ImproveWebserver
[Web] Improve serving large blobs directly from flash
2018-05-10 22:27:38 +02:00
TD-er 11563469d0 [Web] Improve serving large blobs directly from flash
Serve PROGMEM data directly from flash.
This makes it easier to add Javascript code to the source and it will be served directly from flash
2018-05-10 22:13:56 +02:00
Gijs NoorlanderandGitHub fcea12b515 Merge pull request #1400 from TD-er/bugfix/JSONoutput
Format user values + Legend for log JSON
2018-05-10 18:48:33 +02:00
TD-er 2b72ad2088 [log JSON] Add log level legend to the logjson output
To be shown on the  web log viewer as legend
2018-05-10 18:10:40 +02:00
TD-er 30acf569e7 [cleanup] Simplify formatting user variables and allow checking
Extended the way a user variable is formatted to allow checking the value.
Also made clear when values are actually checked.
2018-05-10 18:05:14 +02:00
GrovkillenandGitHub cb71f73b56 Merge pull request #13 from letscontrolit/mega
update from master
2018-05-10 13:11:14 +02:00
flexitiandGitHub 521ca465e5 Merge pull request #1 from letscontrolit/mega
Thu May 10 04:00:13 CEST 2018
2018-05-10 10:51:44 +02:00
ESPEasy release bot ca10c834cc automatically updated release notes for mega-20180510 2018-05-10 04:00:13 +02:00
Gijs NoorlanderandGitHub ef90c84506 Merge pull request #1393 from Grovkillen/color-scheme-for-web-log
Color scheme for web log
2018-05-09 23:34:47 +02:00
Gijs NoorlanderandGitHub 3c2f539ec3 Merge pull request #1390 from workgroupengineering/HotFix/Device_Plugin_ID
Fix plugin_id visualization
2018-05-09 23:34:22 +02:00
Gijs NoorlanderandGitHub 30419c9932 Merge pull request #1378 from TD-er/feature/Ventus_W266_build_selection
[build] Special build config for Ventus W266
2018-05-09 23:33:44 +02:00
Gijs NoorlanderandGitHub a340b4dedc Merge pull request #1385 from Grovkillen/auto-update-values
Auto update values on device page
2018-05-09 23:32:58 +02:00
Gijs NoorlanderandGitHub 69e4d1ec7a Merge pull request #1384 from ZericE/mega
[#1368] Remove call to Plugin_041_update in _P041_NeoClock that caused a hard crash.
2018-05-09 23:29:55 +02:00
GrovkillenandGitHub 91570e9df5 Fixed copy to clipboard (handle HTML tags) 2018-05-09 20:48:03 +02:00
GrovkillenandGitHub 53e9a8f4a3 Fixed the log level colors 2018-05-09 19:51:21 +02:00
GrovkillenandGitHub 71c9b772fe Removed auto update of values... wrong branch 2018-05-09 19:34:40 +02:00
Saverio Cisternino 3ff96a5bec Fix plugin_id visualization on devices view that afflict Development build 2018-05-09 18:54:00 +02:00
GrovkillenandGitHub 32f8edb1ce Added div to web log (color scheme)
Need to add clean up to copy button.
2018-05-09 16:04:40 +02:00
GrovkillenandGitHub 977611b39c Wrap up for the PR 2018-05-08 00:09:22 +02:00
GrovkillenandGitHub 52979cafba Values are updated (1-4 values per task) 2018-05-07 23:47:36 +02:00
ZericE b0a1b95f64 Merge remote-tracking branch 'upstream/mega' into mega 2018-05-07 12:58:07 -07:00
ZericE 04f323b902 [#1368] Remove call to Plugin_041_update causing a hard crash.
Plugin_041_update was being called before the plugin has been initialized, this resulted in an exception 28 type crash. Plugin_041_update clears the display and isn't required at the time of webform save.
2018-05-07 12:34:38 -07:00
GrovkillenandGitHub c20656fe77 First draft of auto update of task/device values 2018-05-07 20:41:55 +02:00
GrovkillenandGitHub 6d3b2d1b18 Merge pull request #12 from letscontrolit/mega
update from master
2018-05-07 12:52:02 +02:00
flexitiandGitHub 388b8f4feb ESP32 OTA port setting 2018-05-07 11:57:32 +02:00
flexitiandGitHub 7b6b72b912 ESP32 OTA port is set to 3232 2018-05-07 11:53:06 +02:00
flexitiandGitHub 5e9ad087b9 OTA check box
if Arduino OTA is not compiled, a button to choose  it is not available
2018-05-07 11:50:03 +02:00
flexitiandGitHub ca5a1bdba1 Improvement in the file platformio.ini 2018-05-07 11:46:50 +02:00
ESPEasy release bot 98522d7cfc automatically updated release notes for mega-20180507 2018-05-07 04:00:08 +02:00
GrovkillenandGitHub 30ab8aef9e [issue template] extra reminder to self compilers 2018-05-06 23:35:59 +02:00
TD-er 22593d7116 [Ventus W266] Fix signed/unsigned warning 2018-05-06 22:52:04 +02:00
TD-er a8f3ad1be2 [build] Special build config for Ventus W266 2018-05-06 22:29:25 +02:00
ESPEasy release bot d54a01a3e6 automatically updated release notes for mega-20180506 2018-05-06 04:00:08 +02:00
Gijs NoorlanderandGitHub 226b3f3d54 Merge pull request #1344 from giig1967g/bugfix/960
fix for #960: new command: TaskValueSetAndRun
2018-05-05 23:47:52 +02:00
Gijs NoorlanderandGitHub 1e4a0858c1 Merge branch 'mega' into bugfix/960 2018-05-05 23:34:02 +02:00
Gijs NoorlanderandGitHub 379c4fccd1 Merge pull request #1347 from Grovkillen/Infinitive-web-log
This one is not yet complete, way more features and improvements are coming. 
But for now it is already much much better than the old log viewer :)
So I'll merge it now and we'll see what it will become.
2018-05-05 23:30:41 +02:00
Gijs NoorlanderandGitHub 886d46fd4c Merge pull request #1370 from ZericE/mega
[#1356] Remove redundant call to MQTTCheck
2018-05-05 22:47:35 +02:00
Gijs NoorlanderandGitHub 5184cba646 Merge pull request #1374 from giig1967g/new/logentry
new command: logentry #1183
2018-05-05 22:46:57 +02:00
Gijs NoorlanderandGitHub b8c4215a27 Merge pull request #1373 from TD-er/feature/optimize_json_pages
Feature/optimize json pages
2018-05-05 22:46:24 +02:00
TD-er d1b017b287 [JSON] Fix for single task view of json output. 2018-05-05 22:26:56 +02:00
TD-er a5421e816c [JSON] Add TTL, task interval and task enabled
TTL = The shortest interval per enabled task (with output values) in msec.
2018-05-05 22:14:42 +02:00
GrovkillenandGitHub d6ca15671d Forgot the auto-scroll function... now added 2018-05-05 21:14:51 +02:00
GrovkillenandGitHub 24231cdc56 Updated to compile with TD-er's update on JSON 2018-05-05 21:05:31 +02:00
TD-er 30e192f041 [JSON] Sanitize JSON value strings
May not contain newline nor "
2018-05-05 17:15:46 +02:00
Plebs 38472a3d6b new command logentry
Command:
usage: logentry,anything (including system variables, task#values with formatting, text, etc.)

Example:
logentry,S=[task#value] T=[task1#value]:

Log output:
ACT  : logentry,S=24 T=23.1
Command: logentry
2018-05-05 16:58:58 +02:00
TD-er d54af04a79 [JSON] Make proper log JSON output for log viewer 2018-05-05 16:52:55 +02:00
TD-er 056e7a7a40 [JSON] Use streaming webserver for serving JSON page
Reduces memory and load times.
2018-05-05 13:31:02 +02:00
ESPEasy release bot f69e476174 automatically updated release notes for mega-20180505 2018-05-05 04:00:07 +02:00
Gijs NoorlanderandGitHub b368252db8 Merge pull request #1371 from TD-er/bugfix/wifi_scan_hidden
[#1337]  Include hidden SSID in wifi scans
2018-05-05 00:55:55 +02:00
TD-er ea3389f792 [#1337] WiFi.isHidden() is unknown to ESP32 2018-05-05 00:55:19 +02:00
TD-er 33b8570c33 [#1337] Include hidden SSID in wifi scans
When found, they appear with "#Hidden#" in the list.
2018-05-04 23:38:48 +02:00
ZericE 76ff83e3f4 [#1356] Remove redundant call to MQTTCheck
A redundant call to MQTTcheck in runEach30Seconds was adding to the blocking issue when attempting to connect to unavailable broker.
2018-05-04 10:00:20 -07:00
mvdbro 92680c5542 Fix corruption of task settings 2018-05-04 15:43:24 +02:00
ESPEasy release bot e568bbed7c automatically updated release notes for mega-20180504 2018-05-04 04:00:10 +02:00
Gijs NoorlanderandGitHub 82bfadd77a Merge pull request #1367 from TD-er/bugfix/20180503
Bugfix/20180503
2018-05-04 00:49:02 +02:00
TD-er b636959cc7 [LWIP2] Change LWIP1.4 => LWIP2 Low Memory
Please make sure to restart PlatformIO after loading this changed ini file and do a clean build (twice???)
2018-05-04 00:42:07 +02:00
TD-er 2a1f6eebe7 [Settings] Add checks to investigate issues with overlap in settings
See #1361
2018-05-04 00:40:44 +02:00
Gijs NoorlanderandGitHub b7b8ceebcf Merge pull request #1366 from Grovkillen/fix-dropdown-a-bit
Fix dropdown a bit
2018-05-04 00:30:12 +02:00
GrovkillenandGitHub 9f6f39053e Added a break under the hamburger
to have a bit of a buffer zone. Or else you'll accidently click the "main" button....
2018-05-04 00:01:33 +02:00
GrovkillenandGitHub 8eed47393f Merge pull request #11 from letscontrolit/mega
update from master
2018-05-03 23:54:15 +02:00
TD-er cc0c2c0f8b [rules timer] revert treating the rules timer as periodical timer
May have unexpected effects, so if a more accurate timer is needed, a new timer type should be used, not setting an interval in the rules.
2018-05-03 23:13:21 +02:00
Gijs NoorlanderandGitHub 0450d8a106 Merge pull request #1352 from Grovkillen/Menu-for-phone
Dropdown menu for phone
2018-05-03 21:36:30 +02:00
Gijs NoorlanderandGitHub e96de4a988 Merge branch 'mega' into Menu-for-phone 2018-05-03 21:36:14 +02:00
Gijs NoorlanderandGitHub 28bdc37d24 Merge pull request #1364 from Grovkillen/fix-checkboxe
Fix checkboxes (#1363)
2018-05-03 21:19:05 +02:00
GrovkillenandGitHub b7ccba979c [#1363] fixed overlapping checkboxes 2018-05-03 20:35:34 +02:00
GrovkillenandGitHub 5132a318af Merge pull request #10 from letscontrolit/mega
Update from master
2018-05-03 09:45:16 +02:00
ESPEasy release bot cfd27b4918 automatically updated release notes for mega-20180503 2018-05-03 04:00:12 +02:00
Gijs NoorlanderandGitHub feba82188a Merge pull request #1359 from TD-er/bugfix/timers
Bugfix/timers
2018-05-03 00:34:25 +02:00
TD-er 1a3274d2c2 [#1353] Remove Domoticz HTTP as default controller 2018-05-03 00:32:18 +02:00
TD-er 0f04456ae6 [timers] Make rules timers more constant and MQTT reconnect less aggressive
See #1356
And #1223
2018-05-02 23:49:50 +02:00
Gijs NoorlanderandGitHub 6016e1b1d3 Merge pull request #1358 from TD-er/bugfix/issue1351_rules
[rules] Make rules start working again.
2018-05-02 23:30:07 +02:00
TD-er 39e391ca0e [rules] Make rules start working again.
See #1351
Whenever a plugin_write returns success = true, the execute command will no longer be called.
It doesn't matter whether the plugin is enabled or present.
It should only return success = true when the command was actually meant for this plugin.
2018-05-02 23:23:19 +02:00
GrovkillenandGitHub 8088ed4ed8 Added some "-" 2018-05-02 23:08:55 +02:00
GrovkillenandGitHub 13bd7ba26b Forgot extra \ for escape in code 2018-05-02 23:06:12 +02:00
GrovkillenandGitHub 3cb90939c4 BR should be \n, now fixed 2018-05-02 23:01:12 +02:00
GrovkillenandGitHub 76cddb7c71 Added break... 2018-05-02 22:56:24 +02:00
GrovkillenandGitHub 3d0f871600 If error make log show this more clear 2018-05-02 22:54:34 +02:00
GrovkillenandGitHub ffb3ee4039 Spelling correction 2018-05-02 22:33:43 +02:00
GrovkillenandGitHub 456796a87d Added dropdown for phones 2018-05-02 15:09:37 +02:00
GrovkillenandGitHub bf512f9da0 Merge pull request #9 from letscontrolit/mega
Update from master
2018-05-02 13:11:04 +02:00
GrovkillenandGitHub d5b8a36acb Web log now inside a textarea 2018-05-02 09:43:40 +02:00
GrovkillenandGitHub f09642101f Merge pull request #8 from letscontrolit/mega
Update from master
2018-05-02 08:23:46 +02:00
ESPEasy release bot cb16773128 automaticly updated release notes for mega-20180502 2018-05-02 04:00:16 +02:00
Gijs NoorlanderandGitHub 2e55b6304c Merge pull request #1348 from TD-er/bugfix/improvetimers
Bugfix/improvetimers
2018-05-02 01:33:40 +02:00
TD-er f61586ebbc [web log] Read all items from the log buffer
This is a very sub optimal implementation. Eventually it should use the streaming web TXBuffer we made. It now uses quite some memory, when called.
2018-05-02 01:19:44 +02:00
TD-er 7f385fc74a [wifi] Make retry intervals to connect increase at each attempt.
There is still an issue when the node is trying to reconnect very hard, it will not react to commands given via the serial port.
2018-05-02 01:18:05 +02:00
TD-er a579c906d5 [timers] Make timers more accurate
Previously the moment a timed function was called, the new timer was set. That would make the timer interval to be the minimum interval, with quite some margin of error.
Now the timers are at a more strict interval, unless the device cannot keep up.
2018-05-02 01:16:39 +02:00
GrovkillenandGitHub a80f3a5f0b Added div to not copy "Fetching log entries...."
Clipboard should not have the fetch info text
2018-05-01 23:27:03 +02:00
GrovkillenandGitHub 7e10fda7e5 Added javascript to handle the log entries 2018-05-01 22:57:03 +02:00
GrovkillenandGitHub 16a6135f53 Merge pull request #7 from letscontrolit/mega
update from master
2018-05-01 22:55:13 +02:00
Gijs NoorlanderandGitHub 343ea459ab Merge pull request #1343 from giig1967g/bugfix/1142
fix for #1142
2018-05-01 22:46:55 +02:00
Gijs NoorlanderandGitHub 0ddcee1f07 Merge pull request #1323 from workgroupengineering/Optimize_setSystemTimer
Optimize setSystemTimer
2018-05-01 22:39:25 +02:00
Gijs NoorlanderandGitHub 07ac4cf8cf Merge pull request #1345 from giig1967g/new/strings
Added 2 system variables
2018-05-01 22:29:23 +02:00
Gijs NoorlanderandGitHub a864aeab1e Merge pull request #1339 from Grovkillen/new-weblog
New web log
2018-05-01 22:25:39 +02:00
Gijs NoorlanderandGitHub 35a7ab94df Merge pull request #1346 from TD-er/bugfix/change_to_LWIP_140
[LWIP 1.4.0] Change to LWIP 1.4.0, to allow large http POST messages
2018-05-01 22:18:07 +02:00
TD-er 44755e83b9 [LWIP] fix ESP32 build 2018-05-01 22:04:29 +02:00
Gijs NoorlanderandGitHub f93b38624d Merge pull request #1342 from giig1967g/bugfix/1170
fix for #1170
2018-05-01 21:10:11 +02:00
TD-er c1cb7d873c [LWIP 1.4.0] Change to LWIP 1.4.0, to allow large http POST messages
See #1296
Rules got truncated when trying to save rules > 1520 Bytes.

Also added a bit more log information and some details about the used libraries in the sysinfo page and json output.
2018-05-01 21:05:50 +02:00
Plebs 62d81325b2 Added 2 system variables
Added 2 system variables

%SP% = space
%ip4% = 4th IP octet
2018-05-01 20:58:13 +02:00
Plebs 5bc2af0e4c deleted comments
deleted comments and moved success outside of the if clause.
2018-05-01 20:52:00 +02:00
Plebs bc5bf7f3f1 fix for #960
Added a new global command: TaskValueSetAndRun.

It changes the value of a task and runs it, so new value is pubished on MQTT and rules are executed.
2018-05-01 19:56:49 +02:00
Plebs 0b4013b33c fix for #1142 2018-05-01 19:51:26 +02:00
Plebs 3c3a11d77b fix for #1170
The reason is that inside PLUGIN_WRITE the variable [event->BaseVarIndex] is not set and is always = 0.
So actually this PR modifies the 1st value of task 1 and not the encoder counter.
Line 183 of P059_Encoder.ino should be removed:
UserVar[event->BaseVarIndex] = (float) event->Par1;
2018-05-01 19:46:51 +02:00
ESPEasy release bot 5876fb84af automaticly updated release notes for mega-20180501 2018-05-01 04:00:17 +02:00
GrovkillenandGitHub 25ab07a9ba Merge pull request #6 from letscontrolit/mega
update from master
2018-04-30 21:41:41 +02:00
GrovkillenandGitHub e6044bdbf8 Added log JSON 2018-04-30 21:40:35 +02:00
mvdbro 572f8bcde7 Fix broken Mini Dashboard feature 2018-04-30 14:28:25 +02:00
Saverio Cisternino c010640aa5 Optimize setSystemTimer; Removed the second "for" cycle for checking the availability of timers 2018-04-30 09:29:50 +02:00
ESPEasy release bot e60c0dc5f0 automaticly updated release notes for mega-20180430 2018-04-30 04:00:08 +02:00
Gijs NoorlanderandGitHub 4e6e31fdae Merge pull request #1335 from TD-er/bugfix/mqtt_timout
Bugfix/mqtt timout
2018-04-29 17:49:01 +02:00
TD-er 77deb3d8b3 [MQTT] Set default timeout to 10 sec, equal to default Mosquito timeout
See https://github.com/knolleary/pubsubclient/issues/239
2018-04-29 17:41:00 +02:00
TD-er 3530027864 [rules] Add log indicating POST request for update rules
There is something strange going on, POST variables may be empty.
2018-04-29 17:40:07 +02:00
Gijs NoorlanderandGitHub 07bfec4234 Merge pull request #1334 from TD-er/bugfix/wifi_connected_check
[wifi] Use internal ESPeasy state to check connected status
2018-04-29 14:59:28 +02:00
TD-er 3476792c58 [wifi] Use internal ESPeasy state to check connected status 2018-04-29 14:58:50 +02:00
Gijs NoorlanderandGitHub 45afaf8d3f Merge pull request #1333 from TD-er/bugfix/displayNamesInLog
[wifi] Do not rely on WiFi.status() and better log of status
2018-04-29 13:45:58 +02:00
TD-er 9084a5542b [wifi] Do not rely on WiFi.status() and better log of status
`WiFi.status() == WL_CONNECTED` may not always be correct.
For ESP82xx check the SDK status.
2018-04-29 13:27:32 +02:00
mvdbro 4ac330ebf6 Changed plugin call debug timers 2018-04-29 11:51:46 +02:00
ESPEasy release bot 49a0476487 automaticly updated release notes for mega-20180429 2018-04-29 04:00:07 +02:00
Gijs NoorlanderandGitHub f606d2c55d Merge pull request #1331 from TD-er/bugfix/ChangeReconnect
[wifi] Force wifi reconnect at lots of MQTT failed connects.
2018-04-29 00:53:27 +02:00
TD-er 4f9a383d93 [wifi] Force wifi reconnect at lots of MQTT failed connects. 2018-04-29 00:52:41 +02:00
Gijs NoorlanderandGitHub d4d0ee3b30 Merge pull request #1328 from TD-er/bugfix/set_static_IP_after_reconnect
[wifi] Setup static IP config after connecting to wifi.
2018-04-28 23:57:42 +02:00
TD-er 9705702f4c [wifi] Added connectionCheckHandler() to force reconnect when needed
Example taken from [this issue discussion](https://github.com/esp8266/Arduino/issues/4445)
2018-04-28 23:42:34 +02:00
TD-er c3e015342c [wifi] ESP32 does not know wifi_station_get_connect_status() 2018-04-28 23:10:24 +02:00
TD-er 209484554e [wifi] Add wifi status log (Debug More) and DHCP/Static config to info page 2018-04-28 23:06:16 +02:00
TD-er 27377ab3ed [wifi] Show number of reconnects in the sysinfo 2018-04-28 19:08:07 +02:00
TD-er 7055d24693 [wifi] Set static IP config before and after connect
Apparently static IP needs to have IP config set before and after connection has been made.
The beginning is needed to make sure no DHCP client is started.
The second one is needed to make sure the wifi status is correct in the core library.
2018-04-28 17:39:47 +02:00
TD-er 62e6317a23 [wifi] Setup static IP config after connecting to wifi. 2018-04-28 15:45:59 +02:00
ESPEasy release bot 29f89b687d automaticly updated release notes for mega-20180428 2018-04-28 04:00:15 +02:00
Gijs NoorlanderandGitHub 697d20a028 Merge pull request #1325 from TD-er/bugfix/wifi_stability
Known issue:   With NTP enabled, it may be possible the connection is not fully operational.
2018-04-28 00:50:52 +02:00
TD-er e9df0e75b9 [Wifi] Avoid doing network communications when not connected.
This may disrupt the network stack.
2018-04-28 00:10:01 +02:00
TD-er f23f49931b [wifi] Just disconnect when DNS lookup is not possible
This may prevent issues with hostname resolving to 0.0.0.0.
2018-04-27 23:45:31 +02:00
TD-er 4af29c405b [PlatformIO] Updated core to 2.4.1
```
[core_2_4_1]
platform         = espressif8266@1.7.0

[common]
build_flags      = -D BUILD_GIT='"${env.TRAVIS_TAG}"'  ; ${compiler_warnings.build_flags}
                   -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
```
2018-04-27 21:45:30 +02:00
ESPEasy release bot d780f1a07f automaticly updated release notes for mega-20180426 2018-04-26 04:00:14 +02:00
TD-er f9be283cb7 [wifi] Attempt to make event based wifi simpler
With static IP, the connection is lost frequently.
2018-04-26 02:04:18 +02:00
Gijs NoorlanderandGitHub 3f1cda7b81 Change use of core 2_4_0 to 2_3_0 2018-04-25 16:05:05 +02:00
ESPEasy release bot 2fd226d6bd automaticly updated release notes for mega-20180425 2018-04-25 04:00:08 +02:00
Gijs NoorlanderandGitHub 3d1edcf33e Merge pull request #1311 from TD-er/bugfix/more_active_reconnect
[wifi] More active reconnect to wifi when disconnected
2018-04-25 00:44:30 +02:00
TD-er cc740b46f1 [wifi] More active reconnect to wifi when disconnected
And also set ESP32 to a fixed version, since latest versions may cause lots of reboots/bootloops.
2018-04-25 00:43:05 +02:00
Gijs NoorlanderandGitHub e829058c92 Merge pull request #1310 from giig1967g/mega
Fix another bug in LCD plugin
2018-04-25 00:06:03 +02:00
Plebs 685438c35d Fix another bug in LCD plugin
There was another part in the WRITE section where was trying to read the Settings. Fixed with a global variable.
2018-04-24 23:52:22 +02:00
Gijs NoorlanderandGitHub f8a4ef389f Merge pull request #1309 from giig1967g/mega
Adding 3 new http commands: taskrun, taskvalueset and rules
2018-04-24 23:09:43 +02:00
Gijs NoorlanderandGitHub 7e9c31131c Merge pull request #1308 from TD-er/merge/modbus_1128
[Modbus] PR #1128 made by @s0170071
2018-04-24 22:41:07 +02:00
Plebs 99150c4214 Adding 3 new http commands: taskrun, taskvalueset and rules
Usage:
control?cmd=taskrun,n
control?cmd=taskvalueset,t,v,n
control?cmd=rules,n (0 or 1 to activate or deactivate rules
2018-04-24 22:28:18 +02:00
TD-er ec7e6f80b0 [Modbus] PR #1128 made by @s0170071
Was long overdue to merge, a simple re-do to include the Modbus.ino to allow development of Modbus plugins.
2018-04-24 22:21:50 +02:00
Gijs NoorlanderandGitHub dada682ed6 Merge pull request #1307 from giig1967g/mega
Fix for #1300
2018-04-24 21:40:52 +02:00
GrovkillenandGitHub ab31b33a2c Merge pull request #1305 from Grovkillen/added-"addcopybutton"
Added "addcopybutton"
2018-04-24 12:13:32 +02:00
GrovkillenandGitHub 621585901f Added new lines if BR + delimiter if wanted 2018-04-24 11:09:51 +02:00
ESPEasy release bot eaaf1fe888 automaticly updated release notes for mega-20180424 2018-04-24 04:00:13 +02:00
GrovkillenandGitHub 41e4705198 Merge pull request #5 from Grovkillen/mega
Added copy to clipboard on log page
2018-04-23 21:28:35 +02:00
GrovkillenandGitHub c35fe3d500 Added copy to clipboard on log page
The <br> will work as new lines if pasted into issue template but we might add a conversion within the javascript code. I leave as is for now.
2018-04-23 21:27:36 +02:00
GrovkillenandGitHub e2da8ecbb9 Made copy to clipboard JavaScript based instead 2018-04-23 21:15:20 +02:00
Plebs 3dad26a58a Fix for #1300
LCD 1602 and 2004 fixed.
2018-04-23 19:19:08 +02:00
GrovkillenandGitHub ae930a1d36 Added a void addCopyButton
For general use...
2018-04-23 15:47:02 +02:00
GrovkillenandGitHub 45e980beda Merge pull request #4 from letscontrolit/mega
Update from master
2018-04-23 09:23:52 +02:00
GrovkillenandGitHub 8723e177df Added note to self compilers
Many self compilers are reporting stuff, it's near to impossible to also support these since the different environments are so hard to set up for us developers to test.
2018-04-23 08:34:14 +02:00
ESPEasy release bot 8454994023 automaticly updated release notes for mega-20180423 2018-04-23 04:00:10 +02:00
Gijs NoorlanderandGitHub 50732aed8a Merge pull request #1295 from TD-er/bugfix/delay_between_connection_attempts
[wifi] Add delay between connection attempts
2018-04-22 12:28:09 +02:00
TD-er f2888951dc [wifi] Add delay between connection attempts
Accesspoints cannot handle lots of (immediate) reconnect attempts.
Added a delay of up-to a second between new attempts.
2018-04-22 12:27:24 +02:00
Gijs NoorlanderandGitHub 56ac640986 Merge pull request #1294 from giig1967g/mega
Fixing #1289 for backwards compatibility
2018-04-22 11:52:53 +02:00
Plebs df2d7be30b Fixing #1289 for backwards compatibility
I noticed that my latest commit introduced a small issue with Transformations:
The previous transformations were right justified. The new ones are left justified.
To maintain backwards compatibility I have modified the code.
2018-04-22 11:49:51 +02:00
ESPEasy release bot 9e06cf4dc7 automaticly updated release notes for mega-20180422 2018-04-22 04:00:09 +02:00
Gijs NoorlanderandGitHub cd27339b8e Merge pull request #1293 from TD-er/bugfix/remove_crc_from_config_file
[issue #1292] Remove CRC from settings, init settings and wifi fixes
2018-04-22 02:02:23 +02:00
TD-er ec38ba1fb7 [issue #1292] Remove CRC from settings, init settings and wifi fixes
- Reset wifi when DNS lookup returns *.0.0.0 (NTP lookup sometimes returns like these)
- Accept Wifi events out of order.
- Remove CRC from settings struct
- Patch settings with last few added items initialized
- Changed red question mark to white questionmark, for links to wiki.
2018-04-22 02:01:10 +02:00
Gijs NoorlanderandGitHub b8fa42925f Merge pull request #1289 from giig1967g/mega
Syntax: [task#value#transformation#justification]
2018-04-21 14:21:05 +02:00
Plebs 4169ca0ee8 Code changed as per TD-er suggestions 2018-04-21 09:53:19 +02:00
ESPEasy release bot 578477bf6d automaticly updated release notes for mega-20180421 2018-04-21 04:00:08 +02:00
Gijs NoorlanderandGitHub 0803e946b0 Merge pull request #1290 from TD-er/feature/P076_SonoffPOW
[Sonoff Pow] P076 - Add support for HLW8012 by @papperone
2018-04-21 01:42:38 +02:00
TD-er 06001bbc94 [Sonoff POW] Set some proper defaults for the Sonoff POW
I2C pins may conflict with the used energy sensor.
Also the status LED is set to a non standard pin.
2018-04-21 01:24:48 +02:00
TD-er f171d5b211 [Sonoff POW] Change Plugin ID to 76
Nextion was added as P075
2018-04-21 00:18:05 +02:00
TD-er 360b552424 [Sonoff Pow] Add support for HLW8012 2018-04-21 00:17:52 +02:00
Unknown d9597febf8 Merge remote-tracking branch 'papperone/mega' into merge/papperone
Remove edits on P073 to separate PRs
2018-04-21 00:17:43 +02:00
TD-er 6aa21ea6f8 [Sonoff Pow] Add support for HLW8012 2018-04-21 00:17:33 +02:00
Unknown b1de652b62 Merge remote-tracking branch 'papperone/mega' into merge/papperone
Remove edits on P073 to separate PRs
2018-04-21 00:17:22 +02:00
Plebs 5c3bf9e894 Syntax: [task#value#transformation#justification]
Transformations:
Special:
!: negate (only for 0 or 1)
R: RIGHT JUSTIFY

V: value
O: ON/OFF
C: OPEN/CLOSE
U: UP/DOWN
u: U/D
Y: YES/NO
y: Y/N
X: O/X
I: IN/OUT
Z: 0/1
1: 1 decimal
2: 2 decimals
3: 3 decimals
Dx.y: x digits + y decimals
F: floor
E: ceiling

Justification:
P: prefix spaces
S: suffix spaces
2018-04-20 23:21:17 +02:00
Gijs NoorlanderandGitHub 0acd7b0e70 Merge pull request #1288 from TD-er/bugfix/InitStaticIP_before_connect
[WiFi] Init static IP before connect to wifi
2018-04-20 22:08:22 +02:00
TD-er 8bbaffdeb0 [info] Add more build related info to the log and wifi info link to wiki
Add core information to the log and info page
Add "more info" button to main page
Add question mark link button to sysinfo section describing wifi. This links to the wifi page on the wiki.
2018-04-20 21:54:40 +02:00
TD-er 19e86e7df3 [Toast message] Change "Settings saved" to "Submitted"
Message is sent to provide feedback on pressing the 'submit' button.
At that moment, it is not yet clear the data will be saved successful.
To prevent "Settings Saved" and "Error writing to..." to show on the same page, this text was changed.
2018-04-20 20:55:17 +02:00
TD-er 311d6f01df [WiFi] Init static IP before connect to wifi
As suggested by @Feuerreiter  [here](https://github.com/letscontrolit/ESPEasy/issues/1255#issuecomment-383094333)
2018-04-20 20:37:38 +02:00
Gijs NoorlanderandGitHub 61f47d5ffc Merge pull request #1287 from workgroupengineering/feature/elseif
[Feature] Allow elseif
2018-04-20 20:25:16 +02:00
Gijs NoorlanderandGitHub 72f0f95471 Merge pull request #1285 from Grovkillen/toast-mes
Toast message added
2018-04-20 20:24:56 +02:00
Gijs NoorlanderandGitHub 4e33472d81 Merge pull request #1246 from workgroupengineering/feature/timer_pause_resume
[Feature] Timers Pause and Resume
2018-04-20 20:24:33 +02:00
Saverio Cisternino 69c4f970a9 Add debug info 2018-04-20 16:46:04 +02:00
GrovkillenandGitHub 28866bd08c Removed fade in of body added toast message! 2018-04-20 13:01:14 +02:00
GrovkillenandGitHub 0f93e3ed3c Merge pull request #3 from letscontrolit/mega
Update
2018-04-20 12:59:38 +02:00
Saverio Cisternino 59a82ee17f Add support at elseif statment 2018-04-20 11:36:12 +02:00
Saverio Cisternino e8af00f99f Add Trigger Rules#TimerPause= and Rules#TimerResume= 2018-04-20 11:33:05 +02:00
Saverio Cisternino ad4b0f8008 Add Commands timerpause and timerresume 2018-04-20 11:33:05 +02:00
ESPEasy release bot ae2a0b5208 automaticly updated release notes for mega-20180420 2018-04-20 04:00:09 +02:00
Gijs NoorlanderandGitHub 785266bd39 Merge pull request #1283 from TD-er/bugfix/webserver_restart_connection_change
Bugfix/webserver restart connection change
2018-04-20 00:38:10 +02:00
TD-er 2e63e764b2 [wifi] Create event 'gotIP' after processing 'connected' event
And stop webserver when trying to reconnect to WiFi
2018-04-20 00:35:09 +02:00
TD-er f7eaecf5d4 [log] Make web log 30 lines for ESP32 2018-04-20 00:01:52 +02:00
TD-er 1bee80d0ec [wifi] Restart webserver when connection changes. 2018-04-19 23:43:30 +02:00
GrovkillenandGitHub 504a9aa295 Added extra breaks below "back to setup" button 2018-04-19 15:21:24 +02:00
GrovkillenandGitHub 059530a6b7 Merge pull request #1277 from Grovkillen/Update-GUI
Update GUI a bit more
2018-04-19 11:53:22 +02:00
Gijs NoorlanderandGitHub 5b83c634e9 Merge pull request #1278 from TD-er/bugfix/set_static_at_change_mode
[Static IP] Make sure static mode is set correct always
2018-04-19 11:08:09 +02:00
TD-er ff7ab3837e [Static IP] Make sure static mode is set correct always
Also when changing settings from static to DHCP and vice verse.
2018-04-19 11:07:29 +02:00
GrovkillenandGitHub badad651de "bodymenu" was accidentally copied to all body 2018-04-19 11:01:02 +02:00
GrovkillenandGitHub 8a767b77e8 Added small fade in (0.5s)
To make user understand that submit have been clicked (web interface is so fast now).
2018-04-19 10:38:41 +02:00
GrovkillenandGitHub 072a1a4080 Merge pull request #2 from letscontrolit/mega
update
2018-04-19 10:37:20 +02:00
ESPEasy release bot 394e4b095d automaticly updated release notes for mega-20180419 2018-04-19 04:00:17 +02:00
Gijs NoorlanderandGitHub ae1e62c8c6 Merge pull request #1276 from TD-er/bugfix/pr_1257
Bugfix/pr 1257
2018-04-19 01:25:45 +02:00
TD-er 0efb7823d7 [ESP32] Add Generic info plugin 2018-04-19 01:24:40 +02:00
TD-er 3ee7d4d04e [PR #1257] Make it compile again 2018-04-19 01:24:14 +02:00
stefanandTD-er f2d3a5d222 Changes for use of plugin sets
Remove ifdefs for PLUGIN_BUILD_TESTING to make use of USES_ defines and define_plugin_defs.h
2018-04-19 00:42:56 +02:00
Gijs NoorlanderandGitHub 904a5cc612 Merge pull request #1267 from sentinel073/plugin_template_issue_1211
Issue #1211: Plugin template file and hints on writing new plugins
2018-04-19 00:40:37 +02:00
Gijs NoorlanderandGitHub 5241f93f5f Merge pull request #1268 from hansrune/mega
Implemented syslog facilities and levels
2018-04-19 00:38:37 +02:00
Gijs NoorlanderandGitHub 6d33d21f70 Merge pull request #1266 from Grovkillen/CSS-the-reset-of-the-gui
CSS the rest of the GUI
2018-04-19 00:37:56 +02:00
Gijs NoorlanderandGitHub 045e2ef9f4 Merge pull request #1275 from TD-er/bugfix/Static_ip
[Static IP] Work-around for set _use_static_ip
2018-04-19 00:37:32 +02:00
TD-er 527267de62 [Static IP] Work-around for set _use_static_ip
See [this bug report](https://github.com/esp8266/Arduino/issues/4114), which is not fixed in 2.4.0.

This work-around will make sure no dhcp-client will be started when connecting to a network.
The active DHCP client could result in IP conflicts, difficulty in reconnect and other strange issues.
2018-04-19 00:13:53 +02:00
sentinel073 29c01eeb38 Issue #1211: Plugin template file and hints on writing new plugins
Added review comments
2018-04-18 13:01:49 +03:00
GrovkillenandGitHub 1c5a1d3656 Removed unused row on hardware settings page 2018-04-17 17:31:28 +02:00
GrovkillenandGitHub d6fe76750a Added CSS radio buttons to WiFi setup wizard 2018-04-17 17:18:28 +02:00
Hans-Rune Bue 1889c0f9e5 Implemented syslog facilities and levels
Sending LOG_LEVEL_ERROR as syslog error, LOG_LEVEL_INFO as syslog notice, and everything else as syslog deug
Also added Settings.Syslogfacility setting to be able to choose kernel (still default), user, daemon, message and local0-local7
2018-04-17 12:43:52 +02:00
sentinel073 ebc16044e2 Issue #1211: Plugin template file and hints on writing new plugins 2018-04-17 11:57:37 +03:00
GrovkillenandGitHub 5695ea8fa8 Updated the input, select, textareas with CSS 2018-04-17 10:50:52 +02:00
GrovkillenandGitHub 16cc9aaa6b Merge pull request #1 from letscontrolit/mega
Updated from main
2018-04-17 10:48:37 +02:00
ESPEasy release bot 7f393af2a0 automaticly updated release notes for mega-20180417 2018-04-17 04:00:09 +02:00
Gijs NoorlanderandGitHub 3e22607276 Merge pull request #1264 from TD-er/feature/nextion_port_from_playground
Feature/nextion port from playground
2018-04-17 01:35:06 +02:00
TD-er 4de720382d [wifi] Fix build error for ESP32
Shared function was declared within #ifdef scope.
2018-04-17 01:34:07 +02:00
TD-er a718572688 [P075] Nextion plugin (testing)
Added Nextion plugin for testing from the Playground.
It is not yet tested on real hardware, but it has been in development for a while on the forum and playground.
Also requested in issue #1256 and by several others.
2018-04-17 01:29:31 +02:00
Unknown 2d66c9fefa [Nextion] Initial support for Nextion displays
Code taken from playground P117 and added minimal changes.
Still need some work to check and test with real display.
Not tested yet, myself.
2018-04-16 23:47:12 +02:00
Gijs NoorlanderandGitHub de51a130b3 Merge pull request #1262 from TD-er/bugfix/json_oled
[issue #1260] parentheses error on the json page
2018-04-16 23:28:53 +02:00
TD-er a8020c9011 [issue #1260] parentheses error on the json page 2018-04-16 23:28:02 +02:00
Gijs NoorlanderandGitHub a2cbc6d474 Merge pull request #1261 from TD-er/bugfix/fix_disconnects_static_ip
[wifi] Fix wifi reconnects with static IP
2018-04-16 23:03:05 +02:00
TD-er ea5c99431c [NTP] Add more information in the log when connecting to NTP server fail 2018-04-16 22:49:07 +02:00
TD-er 6f68d87f50 [wifi] Fix wifi reconnects with static IP
When a fixed IP setting is used, there will be no "Got IP" event, which will lead to a timeout and thus reconnect.
As a fix, the "Connected" event will also act like when a "Got IP" event was received when configured to use static IP.
2018-04-16 22:48:23 +02:00
Gijs NoorlanderandGitHub 4aa9c5e0ba Merge pull request #1259 from Grovkillen/Updating-gui
Updating gui (max width etc)
2018-04-16 20:49:07 +02:00
GrovkillenandGitHub 7e4666afed "Ctr (IDX)" was accidentally removed, now added 2018-04-16 17:23:37 +02:00
GrovkillenandGitHub 7651a07efc Added max widths for inputs 2018-04-16 17:02:31 +02:00
GrovkillenandGitHub f961a9f331 Made IDX column wider (device list) 2018-04-16 16:37:39 +02:00
GrovkillenandGitHub bb49cbdc89 Added number input to CSS (width 100px) 2018-04-16 16:34:00 +02:00
GrovkillenandGitHub 7fe1b41ea5 Made input type password part of "wide" 2018-04-16 16:26:18 +02:00
GrovkillenandGitHub 358e9f1e24 Change enable "off" to a nicer X 2018-04-16 16:20:14 +02:00
GrovkillenandGitHub 8f77ffc871 Made controller symbols a bit bigger (1)(2)(3) 2018-04-16 16:09:14 +02:00
GrovkillenandGitHub 60faa58894 Moved help button on hardware page
Moved it up (from right of the submit button which wasn't a good place for it)
2018-04-16 14:40:52 +02:00
GrovkillenandGitHub aba095b25d Moved help button for sleep 2018-04-16 14:00:17 +02:00
GrovkillenandGitHub 617ebe96de Re-arranged Rules page
Button moved down
Edit text removed
2018-04-16 13:45:57 +02:00
GrovkillenandGitHub a1bf42dde1 Put borders around checkboxes
Suggested here: #1253
2018-04-16 13:20:04 +02:00
ESPEasy release bot b0b83543eb automaticly updated release notes for mega-20180416 2018-04-16 04:00:09 +02:00
Gijs NoorlanderandGitHub b97be9c718 Merge pull request #1250 from TD-er/bugfix/wifi_start_ap_mode
[wifi] Prevent starting AP+STA mode with correct settings
2018-04-16 00:51:04 +02:00
TD-er 33831b072b [info] Added FW information to help diagnose issues
A lot of issue reports do not include information about the used version of the core libraries and 'normal', 'dev', etc. 
Since this information helps narrowing down the possible causes of the reported issues, it is best to add them in the general log.
2018-04-16 00:49:17 +02:00
TD-er a5f94298d8 [wifi] Proper log of static IP configuration 2018-04-15 14:41:41 +02:00
TD-er d0dc959d31 [Wifi] force STA mode at boot
I finally have one node acting as described by others and this one reported a disconnect before a connect attempt was made.

Now forcing the wifi in STA mode, should resolve this issue.
2018-04-15 14:10:02 +02:00
TD-er 644aa2f65e [wifi] Prevent starting AP+STA mode with correct settings
WiFi persistent settings were disabled after initialisation of the event handler.
This allowed the firmware to start WiFi connection with settings stored in the flash (not our settings, the settings kept by the core library). If these fail, then a connection failed event would occur before a connect attempt was started from ESPeasy, which would lead to strange results on some nodes while others work just fine.
2018-04-15 12:05:07 +02:00
ESPEasy release bot e457fe7597 automaticly updated release notes for mega-20180415 2018-04-15 04:00:08 +02:00
Gijs NoorlanderandGitHub dcd409e9d9 Merge pull request #1249 from TD-er/bugfix/Webserver_appendingStrings
A lot of functions in Webserver.ino were just appending to a ever increasing string. These strings were eventually sent to TXBuffer of the Webinterface.
So why not directly send them to the streaming buffer and thus reduce memory usage and gain speed.
2018-04-15 02:06:34 +02:00
TD-er c227c13ba2 [Merge] Easier to merge, rebased on Mega branch. 2018-04-15 01:55:22 +02:00
TD-er c64566ce49 [PR #1248] Fixed textarea sizes
See #1248
2018-04-15 01:45:52 +02:00
TD-er a9366c8f23 [PR #1247 ] Merged PR into the refactoring of Webserver 2018-04-15 01:45:52 +02:00
TD-er bbf470c61d [WebServer] Cleanup of all functions appending to a big string
A lot of functions in Webserver.ino were just appending to a ever increasing string. These strings were eventually sent to TXBuffer of the Webinterface.
So why not directly send them to the streaming buffer and thus reduce memory usage and gain speed.
2018-04-15 01:45:30 +02:00
GrovkillenandGitHub 1c1211c4f3 Bumped delay timer for MQTT pub 10mSec
Tests showed that instead of publishing "now" a 10mSec delay made the unit respond better and publish faster.
2018-04-15 00:50:30 +02:00
Gijs NoorlanderandGitHub 7da0bc4a44 Merge pull request #1247 from Grovkillen/Fix-some-html
Fix some html
2018-04-14 21:19:52 +02:00
GrovkillenandGitHub 91a0c51ff8 Made addFormSeparator function a lot cleaner
Thanks to da man @TD-er
2018-04-14 21:15:33 +02:00
GrovkillenandGitHub 0aa523a329 Updated some more stuff
Made the call for the function work without the extra (not used) "extra text"... it's still in the base function for future use.
2018-04-14 20:55:52 +02:00
Gijs NoorlanderandGitHub cac7275eb9 Merge pull request #1245 from susisstrolch/ds18b20
ignore power-on reset value (85.0 °C)
2018-04-14 17:29:50 +02:00
Susis Strolch c705fdfff0 add missing &amp; around value 2018-04-14 15:51:09 +02:00
Susis Strolch 1fc876cfea add missing &amp; around value, add README 2018-04-14 15:44:20 +02:00
Susis Strolch 109eaf7d25 DS_readTemp: handle power-on reset value
return false if DS_readTemp is power-on reset value
(0xaa for DS1820|DS18B20, 0x550 for DS18B20|DS1825|DS1822)
2018-04-14 15:38:11 +02:00
GrovkillenandGitHub 9ba15f2c19 Added column width for separator...
Now variable
2018-04-14 13:51:06 +02:00
GrovkillenandGitHub 1c07d787c5 Fixed missed update. 2018-04-14 13:45:13 +02:00
GrovkillenandGitHub b7ae2ea5fe Made checkmarks CSS
The &nbsp; is made to be able to have text after the custom checkbox... the text itself is not yet styled since we're not using labels like that yet.
2018-04-14 13:40:49 +02:00
Gijs NoorlanderandGitHub b75bb204e3 Merge pull request #1209 from nunofgs/enhancement/replace-ultrasonic-plugin-with-newping-lib
Replace ultrasonic plugin with NewPing lib
2018-04-14 13:11:14 +02:00
Gijs NoorlanderandGitHub bfc8006205 Merge pull request #1242 from susisstrolch/stringConverter
system variables %sysheap%, %syssec_d
2018-04-14 13:08:28 +02:00
Gijs NoorlanderandGitHub aab2e4a442 Added C013 2018-04-14 12:56:41 +02:00
Gijs NoorlanderandGitHub abfdfe014e Merge pull request #1243 from susisstrolch/defineUses
add missing USES_XXX to _C*.ino, _N*.ino
2018-04-14 12:53:42 +02:00
Susis Strolch f82040d2ef ignore power-on reset value (85.0 °C) 2018-04-14 12:31:17 +02:00
Susis Strolch 56f2cf3121 system variables %sysheap%, %syssec_d
- %sysheap%: free heap memory
- %syssec_d%: seconds since midnight
2018-04-14 12:03:23 +02:00
Susis Strolch 21011c548e GIT hooks: post-merge, post-commit, post-checkout
scripts intended as local git hooks.
post-merge:
- create symlink ESPEasy - if necessary
- add "#define BUILD_GIT <git revision>" to Custom.h
- add "#define USE_CUSTOM_H" to src/ESPEasy-Globals.h

post-commit:
- add "#define BUILD_GIT <git revision>" to Custom.h

post-checkout:
- on branch checkout also add "#define BUILD_GIT <git revision>"
2018-04-14 11:28:05 +02:00
Susis Strolch 6349f07d1a add missing USES_XXX to _C*.ino, _N*.ino 2018-04-14 10:44:25 +02:00
GrovkillenandGitHub 1b44559d3e Merge pull request #2 from letscontrolit/mega
Update source from MAIN
2018-04-14 08:57:26 +02:00
ESPEasy release bot a151e60755 automaticly updated release notes for mega-20180414 2018-04-14 04:00:08 +02:00
Gijs NoorlanderandGitHub ce11c84e74 Merge pull request #1186 from linuxnico/mega
add ds1822 definition to ds_read_temp function
2018-04-14 00:13:39 +02:00
Gijs NoorlanderandGitHub 9808bf86c4 Merge pull request #1078 from GHolli/mega
Sensor MH-Z19: Fixing offsets for the detection range setting command
2018-04-14 00:13:04 +02:00
Gijs NoorlanderandGitHub cfae636e55 Merge pull request #1240 from TD-er/feature/bssid_channel_variables
[issue #1239] %bssid% and %wi_ch% added as variables
2018-04-14 00:09:23 +02:00
Gijs NoorlanderandGitHub ebaaf50df6 Merge pull request #1230 from Grovkillen/Fix-nomenclature-for-delay/interval
Renamed delay to interval/time for better understanding
2018-04-14 00:09:09 +02:00
Gijs NoorlanderandGitHub 5c0be9e89f Merge pull request #1193 from clumsy-stefan/patch-1
_P015_TSL2561 added Broadband and IR Values
2018-04-14 00:07:32 +02:00
Gijs NoorlanderandGitHub 36468663f7 Merge pull request #1210 from giig1967g/mega
Fixes for #1208 and partial #1196
2018-04-14 00:05:36 +02:00
TD-er fba32608ee [issue #1239] %bssid% and %wi_ch% added as variables
See #1239
2018-04-13 23:47:08 +02:00
GrovkillenandGitHub 06848e50c3 Fixed main page!
Table was messed up... also update other tables
2018-04-13 23:46:45 +02:00
GrovkillenandGitHub 879d0d4916 Added better(?) format for tables
Fixed "normal" and "multirow" table css and made some column widths fixed.
2018-04-13 15:47:13 +02:00
ESPEasy release bot d083a58cd7 automaticly updated release notes for mega-20180413 2018-04-13 04:00:09 +02:00
Gijs NoorlanderandGitHub b1e9ff9fdc Merge pull request #1234 from TD-er/bugfix/Wifi_connection_issues
[wifi] Event based wifi, fix set AP and crash on start
2018-04-13 01:51:45 +02:00
TD-er 304280f415 [wifi] Event based wifi, fix set AP and crash on start
The settings had 2 new values which would be overwriten by the checksum and there was still some issue about when to save the settings.

Also added a check to only save changed settings.

Known issue: 
Sometimes after initial setup of wifi credentials, it is best to perform a reset.
2018-04-13 01:48:22 +02:00
GrovkillenandGitHub 2c8ca1421f Removed the serial print "done." 2018-04-12 09:55:11 +02:00
GrovkillenandGitHub 3ce0fb9f75 Merge branch 'mega' into Fix-nomenclature-for-delay/interval 2018-04-12 09:28:48 +02:00
ESPEasy release bot 8a71d2abd6 automaticly updated release notes for mega-20180412 2018-04-12 04:00:14 +02:00
Gijs NoorlanderandGitHub 1b174f4eac Merge pull request #1224 from flexiti/mega
ESP32 cpu speed and Id
2018-04-12 01:25:45 +02:00
Gijs NoorlanderandGitHub f1d18c7b41 Merge pull request #1220 from TD-er/bugfix/SoftAP_event_based_wifi
[issue #1215] Cannot login to accesspoint on new install
2018-04-12 01:22:46 +02:00
TD-er 204d4607ba Merge remote-tracking branch 'upstream/mega' into bugfix/SoftAP_event_based_wifi 2018-04-12 01:12:28 +02:00
TD-er 51f7ce0cb6 [wifi] Event based wifi, improve scan information. 2018-04-12 01:07:39 +02:00
Nuno Sousa 8f73deb133 Replace ultrasonic plugin with NewPing lib 2018-04-11 23:26:58 +01:00
Gijs NoorlanderandGitHub 1d4147309c [MQTT] Process MQTT loop on publish
As [discussed here](https://github.com/letscontrolit/ESPEasy/issues/1228#issuecomment-380420609).
2018-04-11 15:29:49 +02:00
mvdbro a68e4c1456 Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into mega 2018-04-11 14:57:22 +02:00
mvdbro 2ee51363dd Reboot/Reset pin, build 20101 patch 2018-04-11 14:57:12 +02:00
TD-er 172eb37b5b [wifi] Fix wifi AP setup mode for ESP32. 2018-04-11 01:24:34 +02:00
GrovkillenandGitHub 68e1d8ea69 Added RSSI, BSSID, Channel to WifiScan/Setup
And also delay is now renamed interval.
2018-04-10 15:47:59 +02:00
GrovkillenandGitHub ac8e8db0e7 Merge pull request #1 from letscontrolit/mega
Update
2018-04-10 14:24:17 +02:00
ESPEasy release bot d72bf9b76c automaticly updated release notes for mega-20180410 2018-04-10 04:00:21 +02:00
GeraldandGitHub 6d3f535d16 Merge pull request #3 from letscontrolit/mega
Downstream updates from head fork.
2018-04-09 21:39:15 +02:00
GrovkillenandGitHub 0709763f3a Update issue_template.md
`YOUR TEXT GOES HERE` added
2018-04-09 13:09:59 +02:00
GrovkillenandGitHub 538d843643 Update issue_template.md
Rearranged the topics...
2018-04-09 13:07:56 +02:00
GrovkillenandGitHub 2339ee928c Update issue_template.md
Added code format
2018-04-09 13:05:55 +02:00
GrovkillenandGitHub 9550b951d5 Update issue_template.md
Added a "Summarize" topic
2018-04-09 12:55:43 +02:00
GrovkillenandGitHub 0491af8a2f Added comments that will not show up on issues
Many users forget to "clean" the template from unnecessary text... these are now automatically hidden.
2018-04-09 12:53:05 +02:00
ESPEasy release bot 806a2757b2 automaticly updated release notes for mega-20180409 2018-04-09 04:00:13 +02:00
TD-er 3931b71d00 Merge branch 'mega' into bugfix/SoftAP_event_based_wifi 2018-04-09 00:17:48 +02:00
TD-er af0c3d5f62 [wifi] Make it work for ESP32 again 2018-04-08 23:50:07 +02:00
mvdbro c7a6ca4555 Both reset/factoryreset option 2018-04-08 17:05:59 +02:00
mvdbro 4a01e2eb49 Factory Reset (not enabled yet) 2018-04-08 08:27:25 +02:00
TD-er d6ff20b35d [WiFi] Event based wifi, now AP mode works
It appeared to be related to the core 2.3.0 version. The 2.4.0 does just work. Also changed a number of other things to improve stability.
2018-04-08 00:34:34 +02:00
ESPEasy release bot 0ada9aa105 automaticly updated release notes for mega-20180407 2018-04-07 04:00:12 +02:00
Holli 6b04539571 Disable detection range commands by default. 2018-04-06 18:40:08 +02:00
Plebs 9380ec13dc Added #I
#I: IN/OUT
2018-04-06 12:41:00 +02:00
GrovkillenandGitHub ae946c27c0 Fixed clickable link www.letscontrolit.com (#1192) 2018-04-06 10:02:36 +02:00
Plebs 86cf00759f added more formats
#X
#y
#Z
2018-04-06 08:38:26 +02:00
Plebs 0eb5f55d63 new #formats
Hi, here the new formats:
#O: ON/OFF
#C: Open/Close
#U: UP/Down
#Y: YES/NO
#D: converto to nearest integer
#F: convert to floor
#E: convert to ceiling
2018-04-05 23:39:54 +02:00
flexitiandGitHub f27d2aa7eb ESP CPU speed and ID 2018-04-05 15:09:24 +02:00
flexitiandGitHub 2d3285aaaf Merge pull request #1 from letscontrolit/mega
update
2018-04-05 15:05:25 +02:00
ESPEasy release bot 5bd2532853 automaticly updated release notes for mega-20180405 2018-04-05 04:00:10 +02:00
Plebs 765c56ccef modified float() call 2018-04-05 00:20:38 +02:00
mvdbro 4c755d83a6 ESP32 RTOS 10 per second
Run 10 per seconds call independent from main loop
2018-04-04 21:55:50 +02:00
mvdbro 1b9e1b92aa ESP32 RTOS config setting 2018-04-04 12:32:17 +02:00
Gijs NoorlanderandGitHub a4c73cc91e Merge pull request #1175 from Grovkillen/Fix-parsing-structure-for-JSON-+-upload-file-filter
Updated JSON path for sensor values and names
2018-04-04 10:06:17 +02:00
Gijs NoorlanderandGitHub 736fe2111a Merge pull request #1218 from soif/Fix/PioConfTypo
Unwanted lib_ignore now properly commented
2018-04-04 10:05:22 +02:00
Gijs NoorlanderandGitHub 767b0af733 Merge pull request #1217 from soif/Feat/JsonLoad
Shows CPU Load in JSON page
2018-04-04 10:04:59 +02:00
TD-er 02255180e9 [Wifi] Use statemachine to move between Wifi states
Still existing problems:
- Credentials are not being saved from web interface and thus connection doesn't work from setup page.
- First time connect to SoftAP takes a lot of attempts, when the wifi was searching for an existing accesspoint. This searching does prevent the SoftAP to form a stable connection to the client.

Maybe the entire wifi stack has to be reset before switching to SoftAP. Now it is near to impossible to recover from incorrect settings or a changes accesspoint.
Still under investigation.

It looks to be a problem with the
2018-04-04 03:19:03 +02:00
ESPEasy release bot c3bde94f7a automaticly updated release notes for mega-20180403 2018-04-03 04:00:14 +02:00
TD-er 886958d479 Merge remote-tracking branch 'origin/bugfix/SoftAP_event_based_wifi' into bugfix/SoftAP_event_based_wifi 2018-04-03 01:04:22 +02:00
TD-er 84cbc19f38 [issue #1215] Cannot login to accesspoint on new install
Since event based wifi, it became more apparent the ESP8266 has some issues with running AP and STA mode simultaneous.
It appears this can only work when the channel remains constant. But when trying to connect to an accesspoint that channel will change.
This means Soft AP and STA cannot be active at the same time when searching for an accesspoint to connect to. For example login to the Soft AP to correct some settings or replace an accesspoint would not be possible.

This fix deals with all of these issues and keeps the fast try/fail connection attempts offered by the event based wifi.
In short:
- 3x attempt to connect to AP1 (each attempt takes about 2.5 seconds when failing)
- 3x attempt to connect to AP2
- Enable accesspoint

When accesspoint is active, the connect attempts will be done at a slower pace and STA mode is disabled. STA mode is also disabled as soon as someone connects to the Soft AP.
When the settings are saved, a retry to connect like normal is started almost immediately. N.B. This will result in a disconnect of the connected users to the Soft AP.

So the connection time is:
- AP1 is valid: 4 - 10 seconds
- AP1 is not valid, AP2 is: 12 - 20 seconds
- AP1 and AP2 are not valid: +/- 18 seconds before activating Soft AP
2018-04-03 01:03:27 +02:00
TD-er 178ec9dfa9 [issue #1215] Cannot login to accesspoint on new install
Since event based wifi, it became more apparent the ESP8266 has some issues with running AP and STA mode simultaneous.
It appears this can only work when the channel remains constant. But when trying to connect to an accesspoint that channel will change.
This means Soft AP and STA cannot be active at the same time when searching for an accesspoint to connect to. For example login to the Soft AP to correct some settings or replace an accesspoint would not be possible.

This fix deals with all of these issues and keeps the fast try/fail connection attempts offered by the event based wifi.
In short:
- 3x attempt to connect to AP1 (each attempt takes about 2.5 seconds when failing)
- 3x attempt to connect to AP2
- Enable accesspoint

When accesspoint is active, the connect attempts will be done at a slower pace and STA mode is disabled. STA mode is also disabled as soon as someone connects to the Soft AP.
When the settings are saved, a retry to connect like normal is started almost immediately. N.B. This will result in a disconnect of the connected users to the Soft AP.

So the connection time is:
- AP1 is valid: 4 - 10 seconds
- AP1 is not valid, AP2 is: 12 - 20 seconds
- AP1 and AP2 are not valid: +/- 18 seconds before activating Soft AP
2018-04-03 00:47:06 +02:00
GrovkillenandGitHub 080be1ad0a Update _P029_Output.ino 2018-04-02 20:41:22 +02:00
GrovkillenandGitHub 232ca4f215 Update _P038_NeoPixel.ino 2018-04-02 20:40:08 +02:00
mvdbro bfa6eac538 ESP32 prep for RTOS multitasking 2018-04-02 15:59:01 +02:00
moi 0ca06782b9 unwanted lib_ignore now properly commented 2018-04-02 13:27:02 +02:00
moi 2079b0f28b Adds CPU Load LC in JSON page 2018-04-02 12:39:14 +02:00
moi 32bf45e817 Show CPU Load in JSON page 2018-04-02 12:38:30 +02:00
ESPEasy release bot 5d41bf9e73 automaticly updated release notes for mega-20180402 2018-04-02 04:00:10 +02:00
Gijs Noorlander dc5a2fd956 Revert "Merge pull request #1205 from s0170071/SerialSwap"
This reverts commit 46586e5355.
2018-04-01 10:47:50 +02:00
ESPEasy release bot b20f05305b automaticly updated release notes for mega-20180401 2018-04-01 04:00:08 +02:00
Gijs NoorlanderandGitHub 46586e5355 Merge pull request #1205 from s0170071/SerialSwap
Serial Swap function
2018-04-01 01:17:51 +02:00
Gijs NoorlanderandGitHub 7e8a751657 Merge pull request #1203 from TD-er/feature/mqtt_disconnect_event
[issue #1201] MQTT#Disconnected event and MQTT stability improvements
2018-04-01 01:14:55 +02:00
TD-er 7d61e55d34 [deepsleep] Allow for some minimum wifi connect time
In Deepsleep mode the wifi connect time is now minimum of 6 seconds.
Also the first loop after connect, the 'awake' timer will reset and start over. Without WiFi connection the set 'awake' timer starts at the moment the node boots.
2018-03-31 23:53:15 +02:00
GrovkillenandGitHub 2f663429a3 P0059 (rotary encoder) and P0063 (ttp229, keypad)
These two plugins are not in test but in normal.
2018-03-31 19:52:25 +02:00
TD-er 52e75ade78 Merge remote-tracking branch 'origin/feature/mqtt_disconnect_event' into feature/mqtt_disconnect_event 2018-03-31 01:42:19 +02:00
TD-er 525a0ba0a1 [issue #1201] MQTT#Disconnected event and MQTT stability improvements
While looking for issues regarding DeepSleep + MQTT and issue #1195, I came across a number of other issues related to high CPU load and WiFi disconnects when a MQTT controller cannot reach the MQTT broker or is set to be no longer enabled.

These fixes improve CPU load and WiFi stability and also send the following events:
- `MQTT#Connected` 
- `MQTT#Disconnected`
- `MQTTimport#Connected` 
- `MQTTimport#Disconnected`

The MQTTimport plugin still has some major issues which have to be taken care of, so #1195 is not fixed yet.
2018-03-31 01:34:50 +02:00
Plebs e774ef5751 Fixes for #1208 and partial #1196
Fixed #1208
Added dìformat commands:
#C: 1/0 = Open/Close
#U: 1/0 = Up/Down
2018-03-30 21:05:33 +02:00
s0170071 eba1fb3388 Serial Swap function
swaps Serial Pins *and* keeps track of it.
2018-03-30 08:47:55 +02:00
TD-er 3583db3e22 [issue #1201] MQTT#Disconnected event and MQTT stability improvements
While looking for issues regarding DeepSleep + MQTT and issue #1195, I came across a number of other issues related to high CPU load and WiFi disconnects when a MQTT controller cannot reach the MQTT broker or is set to be no longer enabled.

These fixes improve CPU load and WiFi stability and also send the following events:
- `MQTT#Connected` 
- `MQTT#Disconnected`
- `MQTTimport#Connected` 
- `MQTTimport#Disconnected`

The MQTTimport plugin still has some major issues which have to be taken care of, so #1195 is not fixed yet.
2018-03-30 02:48:23 +02:00
GeraldandGitHub 5d3f8bf073 Update _P049_MHZ19.ino
Clarification of pin connections.
2018-03-29 21:28:25 +02:00
GHolliandGitHub dd88db1913 Merge pull request #2 from letscontrolit/mega
Downstream updates
2018-03-29 20:10:05 +02:00
GHolliandGitHub aab00567fc Downstream updates (#1)
* Initial re-organisation of plugin sets (#1019)

* 12bit ADC values acceted up to 4095

MCP3221 is a 12bit ADC so accepted values should be up to 40195 not 1024

* automaticly updated release notes for v2.0-20180313

* - move all structs from ESPEasy.ino into header file
- add some fix for headers
- add const to rtttl notes array

* [issue #1066] Fix Webserver handle_control

There wasn't a proper start/end for the streaming webserver.
See discussion on issue #1066

* automaticly updated release notes for mega-20180314

* Custom controller GUI option

* Fixed #433

Not tested!

* #893, part 2 receiving

* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega

# Conflicts:
#	src/ESPEasy.ino

* Rules fix

* #893 part1, send messages

* Custom controller GUI option

* #893, part 2 receiving

* Rules fix

* automaticly updated release notes for mega-20180315

* - move all structs from ESPEasy.ino into header file

- add some fix for headers
- add const to rtttl notes array

* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega

# Conflicts:
#	src/ESPEasy.ino

* [v2.0 split globals] Base split on v2.0 version of ESPEasy.ino

*  MCP3221 allow values for calibration (#1073)

MCP3221 allow values for calibration

* [issue #1066] Fix Webserver handle_control (#1079)

[issue #1066] Fix Webserver handle_control

* Fixed multi instance problem on SHT3x #433 (#1081)

Fixed multi instance problem on SHT3x #433

* [issue #1057] AM PM display issue

X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`

* [issue #993] variable in MQTT subscribe topic

As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn

* [issue #951] Changed System#Initialized  => System#Wake

Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.

* [issue #1057] AM PM display issue

X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`

* [issue #993] variable in MQTT subscribe topic

As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn

* [issue #951] Changed System#Initialized  => System#Wake

Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.

* automaticly updated release notes for mega-20180316

* automaticly updated release notes for v2.0-20180316

* Add download button for current rule set

* - add encoder write #1086

* changed memory tracker to uint64_t for the ESP32

* Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up

* Keep uint. Just change the init value.

* [WiFi] Try to minimize effect of WiFi interruptions

And send event when connected to a different accesspoint.
Currently the impact on WiFi reconnects is enorm. The ESP stalls, won't react on events, etc.

* - fix success setting

* - fix P073 success setting in PLUGIN_WRITE callback

* - initialize pointer in P073

* [Relaxed WiFi] Perform WiFi initialization in steps

Doing WiFi initialization in multiple steps, will reduce boot time a lot.
For deepsleep the Setup is waiting for wifi initialization to complete, but for normal use the wifi connection is initiated during setup and checked on regular intervals to see if it is available.
The same for WiFi reconnect, which will hopefully not affect the performance of the ESP module during reconnects.

Also added a check + event when connected to another accesspoint with different BSSID (MAC address of accesspoint). Also the last used BSSID is used to reconnect to try to connect to the same device over and over, which may be useful with WiFi repeaters.

* [Travis error] Some #include test that wasn't meant to be included

... in the commit.

* [JSON] Add uint name (#1099) and WiFi information (PR #1113)

As suggested by @Grovkillen on PR #1113.

* [issue #1007] Allow user specific data in separate file

File will be ignored by git and can be simply included using `-D USE_OWN_DEFAULTS` in the build

* #ifndef instead of #ifdef

* [issue #1007] Add other defines as suggested by @uzi18

* [Memory] parseTemplate did not check if markers were found

"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.

* [issue #1097] MQTT publish after deep sleep

The MQTTConnect was only called after a while. This is a problem for deepsleep.
So now the MQTT connect is done at the first loop when deep sleep is enabled.

* Add download button for current rule set (#1102)

Add download button for current rule set

* - add encoder write command #1086 (#1103)

- add encoder write command #1086

* Changed so that running all tasks immediately with deep sleep enabled… (#1110)

Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up

* Merge pull request #1112 from uzi18/fix-p073

Fix p073 - #1111

* Merge pull request #1114 from TD-er/feature/wifi_details_json

[JSON] Add uint name (#1099) and WiFi information (PR #1113)

* Merge pull request #1113 from TD-er/feature/reduce_impact_wifi_disconnect

[Relaxed WiFi] Perform WiFi initialization in steps

* Merge pull request #1116 from TD-er/feature/allow_own_defaults

[issue #1007] Allow user specific data in separate file

* Merge pull request #1118 from TD-er/bugfix/mqtt_publish_after_deep_sleep

[issue #1097] MQTT publish after deep sleep

* [merge] MIssing #endif due to merging.

* automaticly updated release notes for mega-20180319

* automaticly updated release notes for v2.0-20180319

* Fix wiring description for SN75176 transceiver

* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"

This reverts commit 8ccbdcadf0.

* Fix wiring description for SN75176 transceiver

* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"

This reverts commit 8ccbdcadf0.

* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset

Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.

* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset

Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.

* automaticly updated release notes for mega-20180320

* automaticly updated release notes for v2.0-20180320

* [wifi] Setup with factory settings could not complete

* [wifi] Setup with factory settings could not complete

* [merge issue] Forgotten #endif in merge

* - P012 fix command interpretation

* - P023 fix command interpretation

* - P035 move strings to flash

* - P048 fetch params only when needed

* automaticly updated release notes for mega-20180321

* automaticly updated release notes for v2.0-20180321

* Serial WD crash

* [wifi] Make more robust checks and increase timeout

See #1145

* - P012 fix command interpretation

* - P023 fix command interpretation

* - P035 move strings to flash

* - P048 fetch params only when needed

* Serial WD crash

* [wifi] Make more robust checks and increase timeout

See #1145

* [Memory] parseTemplate did not check if markers were found

"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.

* [WiFi] Take much more time for initial WiFi connect during setup

Accesspoint is still active, so it may take a lot more time to make the initial connection

* [WiFi] Take much more time for initial WiFi connect during setup

Accesspoint is still active, so it may take a lot more time to make the initial connection

* automaticly updated release notes for mega-20180322

* ESP32 fix

* [Command] Parsing improvement for commands

Use more intelligent parsing of commands and switch statement to improve speed

* automaticly updated release notes for mega-20180323

* [WiFi] Reverted those temp String uses for ssid/pass

Was introduced due to misunderstanding of reported issues with WiFi.

* [issue #1131] Add %unixtime%

Show the current time as [Unix time](https://en.wikipedia.org/wiki/Unix_time) (numbers of seconds that have elapsed since midnight 1970-01-01, UTC)

* [issue #1097] Call MQTTclient.loop() during deepsleep

The `MQTTclient.loop()` function should be called quite often.
This does the actual MQTT handling.
In normal operations, this is called quite frequently, but it should also be called when deepsleep is active and right before deepsleep is activated again.

* [P1] Support for latest standard

* [wifi] Event based connect/reconnect

Now using the core WiFiEvents to act on:

- connect
- disconnect
- gotIP

This will make polling for a status no longer needed.
It also allows to get a better understanding in why diconnects happen, since the disconnect reason is given in the events.
This extra information is also present on the information panel on the webinterface and also in the JSON output.

The entire connect/disconnect/reconnect is now done completely asynchronous and thus takes much less resources from the ESP.
A disconnect will now also send an event: "WiFi#Disconnected"

For deepsleep this means there has to be a minimum awake time set and perhaps use rules to set the ESP into sleep again when done.
Typical connection times to an accesspoint are about 3 seconds + about 1 second for DHCP.

This also resolves the issues where services my try to connect while there is a WiFi connection, but not yet an IP address set.

I already noticed a lot of NTP servers from pool.ntp.org are non responsive the last few weeks, so that may still take some time, but that's another issue.

* automaticly updated release notes for mega-20180324

* [NTP] Speedup NTP again with async WiFi

Previously it would only start calling "now" when the WiFi was already setup.
And in calling `now()`, a call to an NTP server is being made. When this fails, retry again in a minute.
But now the WiFi initialization is asynchronous, so the first NTP query was already failing and thus the retry is already set to a minute.

This is fixed now and also the pool.ntp.org will pick a random one from 0...3 (.pool.ntp.org).
The DNS queries from this pool change about every minute, so if you want to retry because one of the servers is offline, you should try one from the other `N.pool.ntp.org` or else you have to wait for another minute.

* - fix for #1170 - uservar not setted on encwrite

* automaticly updated release notes for mega-20180326

* [issue #1174] Show degree sign via external writes to LCD

Fix suggested by [elmicha](https://github.com/letscontrolit/ESPEasy/issues/1174#issuecomment-376244766)

* [ESP32] Event driven WiFi for ESP32

Not tested, just got some inspiration by these files:

- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino
- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.cpp
- https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/esp32/esp_event.h

* automaticly updated release notes for mega-20180327

* Fix nesting level check

* [Build] Cleanup/split builds using defines

See PR #1034 and #1040 made by @soif

* [build] Disabled a few PlatformIO profiles for now.

There were way too many.
Just placed them in comments and Travis had already built them all to test first.

* automaticly updated release notes for mega-20180328

* [Arduino IDE] Revert changes in include paths

Were changed to be able to test the PlatformIO feature to compile only files that are actually used.
Apparently the Arduino IDE cannot find the files anymore because that IDE needs the parent directory to be named as the main project file, not "src"

* automaticly updated release notes for mega-20180329
2018-03-29 19:53:54 +02:00
clumsy-stefanandGitHub 21cb6135dd _P015_TSL2561 added Broadband and IR Values
Extended Plugin to also read Broadband and IR values from device.
2018-03-29 09:27:53 +02:00
linuxnico 07948c87aa add ds1822 definition to ds_read_temp function 2018-03-28 14:30:05 +02:00
GrovkillenandGitHub 5f4685337e Added value number as discussed. 2018-03-26 14:59:47 +02:00
GrovkillenandGitHub 08c158aa9c Moved to correct folder 2018-03-26 10:33:22 +02:00
GrovkillenandGitHub e9d71a8f35 Delete WebServer.ino
Same mistake as before, wrong folder upload
2018-03-26 10:32:58 +02:00
GrovkillenandGitHub 3e3173cbb0 Updated JSON path for sensor values and names
+file type filter on upload (not OTA since that is not part of ESP Easy core)
2018-03-26 10:31:27 +02:00
GHolliandGitHub 4543a10739 Change comma to semicolon
Same functionality, but more common.
2018-03-22 20:12:28 +01:00
GHolliandGitHub daecf2017e Update _P049_MHZ19.ino 2018-03-13 21:41:17 +01:00
Holli 37122bc619 It seems the offsets [3]..[4] for the detection range setting (command byte 0x99) are wrong in the latest online data sheet: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
According to the MH-Z19B data sheet version 1.2, valid from: 2017.03.22 (received 2018-03-07), the offset should be [6]..[7] instead.
Fixing the implementation accordingly.
2018-03-13 20:22:45 +01:00
tedenda 0d17c099e9 Merge remote-tracking branch 'origin/mega' into mega 2017-12-03 17:37:53 +01:00
tedenda 85da10ef24 Merge branch 'letscontrolit/mega' into mega 2017-10-17 20:14:00 +02:00
tedenda 7f91ec2852 Merge branch 'mega' into letscontrolit/mega 2017-10-17 20:13:20 +02:00
667 changed files with 39883 additions and 157677 deletions
+35 -9
View File
@@ -1,18 +1,44 @@
**NOTE: This is not a support forum! For questions and support go here: https://www.letscontrolit.com/forum/viewforum.php?f=1**
<!--- If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! --->
<!--- NOTE: This is not a support forum! For questions and support go here: --->
<!--- https://www.letscontrolit.com/forum/viewforum.php?f=1 --->
<!--- Remove topics that are not applicable to your feature request of issue --->
<!--- Remember to have a "to the point" TITLE --->
### Steps to reproduce
How can we trigger this problem?
Does the problem persists after powering off and on? (just resetting isn't enough sometimes)
### Summarize of the problem/feature request
<!--- Describe the problem or feature request --->
YOUR TEXT GOES HERE
### Expected behavior
Tell us what should happen?
<!--- Tell us what should happen? --->
YOUR TEXT GOES HERE
### Actual behavior
Tell us what happens instead?
<!--- Tell us what happens instead? --->
YOUR TEXT GOES HERE
### Steps to reproduce
<!--- How can we trigger this problem? --->
1.
2.
3.
<!--- Does the problem persists after powering off and on? (just resetting isn't enough sometimes) --->
<!--- Please document if you have restarted the unit and if the problem is then gone etc. etc. --->
### System configuration
<!--- Please add as much information and screenshots as possible --->
Hardware:
Software or git version:
<!--- You should also provide links to hardware pages etc where we can find more info --->
<!--- If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! --->
ESP Easy version:
<!--- In order to have a better readablity of your issue then you should place screenshots here --->
<!--- Simply drag and drop them onto this template, move the text string below the "ESP Easy settings/screenshots" topic --->
ESP Easy settings/screenshots:
### Rules or log data
<!--- place your code/rules between the two ``` rows --->
<!--- remove if not applicable! --->
```
```
+2
View File
@@ -16,3 +16,5 @@
## Project #####################
lib/readme.txt
src/Custom.h
/ESPEasy
test/output_export.cpp
+3 -1
View File
@@ -27,11 +27,13 @@ install:
script:
# - cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
# - ./memanalyzer.py ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-objdump
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
# patch platformio core libs for PUYA bug (https://github.com/letscontrolit/ESPEasy/issues/650)
- cd patches; ./check_puya_patch; cd ..
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -s --environment dev_ESP8266PUYA_1024
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -s --environment dev_ESP8266PUYA_1024
before_deploy:
+8
View File
@@ -0,0 +1,8 @@
The scripts in this directory are so called GIT hooks.
Purpose is to do automatic changes after merge, commit and checkout.
Those files are for a Linux-like environment with basic tools ln, grep, sed and bash.
Windows users can see them as template.
To use them simply copy those files into your ESPEasy/.git/hooks directory.
+4 -1
View File
@@ -1,6 +1,9 @@
# ESPEasy (development branch)
Build status: [![Build Status](https://travis-ci.org/letscontrolit/ESPEasy.svg?branch=mega)](https://travis-ci.org/letscontrolit/ESPEasy)
Badge | Info |
-------|-------|
[![Build Status](https://travis-ci.org/letscontrolit/ESPEasy.svg?branch=mega)](https://travis-ci.org/letscontrolit/ESPEasy) | build status |
[![GitHub version](https://img.shields.io/github/release/letscontrolit/ESPEasy/all.svg)](https://github.com/letscontrolit/ESPEasy/releases/latest) | latest nightly |
Introduction and wiki: https://www.letscontrolit.com/wiki/index.php/ESPEasy#Introduction
+6 -3
View File
@@ -18,13 +18,16 @@ for ENV in \
dev_ESP8266_4096\
dev_ESP8285_1024\
dev_ESP8266PUYA_1024\
dev_ESP8266PUYA_1024_VCC;\
dev_ESP8266PUYA_1024_VCC\
hard_SONOFF_POW\
esp32dev;\
do
echo
echo "### Deploying environment $ENV for version $VERSION"
BIN=.pioenvs/$ENV/firmware.bin
BIN=.pioenvs/${ENV}/ESP_Easy_${VERSION}_${ENV}.bin
cp .pioenvs/${ENV}/firmware.bin $BIN
python2 crc2.py $BIN
cp $BIN dist/"ESP_Easy_$VERSION""_$ENV.bin"
mv $BIN "dist/ESP_Easy_${VERSION}_${ENV}.bin"
done
+19 -19
View File
@@ -5,10 +5,10 @@ import struct
import md5
import os
MD5DUMMY = "MD5_MD5_MD5_MD5_BoundariesOfTheSegmentsGoHere..." #48 chars
FILENAMEDUMMY = "ThisIsTheDummyPlaceHolderForTheBinaryFilename..." #48 chars
FILENAMEDUMMY = "ThisIsTheDummyPlaceHolderForTheBinaryFilename64ByteLongFilenames" #64 chars
MemorySegmentStart,MemorySegmentEnd,MemoryContent=[],[],[]
##################################################################
# this subroutine shows the segments of a part
##################################################################
@@ -18,7 +18,7 @@ def showSegments (fileContent,offset):
herestr =""
herestr2 =""
MemorySegmentStart.append(struct.pack("I",header[0]))
MemorySegmentEnd.append(struct.pack("I",header[0]+header[1]))
MemorySegmentEnd.append(struct.pack("I",header[0]+header[1]))
MemoryContent.append(fileContent[offset+8:offset+8+header[1]])
if fileContent.find( MD5DUMMY, offset+8, offset+8+header[1]) >0 :
herestr= " <-- CRC is here."
@@ -42,7 +42,7 @@ def showParts(fileContent, offset):
return nextSegmentOffset
##################################################################
# MAIN
# MAIN
##################################################################
#if len(sys.argv) !=2 :
@@ -71,46 +71,46 @@ includeStr = "hash includes segments:"
# 4: RAM
for i in (1,2 ): # use only stable segments, must be 4 in total. We use 2.
startArray =startArray + MemorySegmentStart[i]
endArray = endArray + MemorySegmentEnd[i]
startArray =startArray + MemorySegmentStart[i]
endArray = endArray + MemorySegmentEnd[i]
hashString =hashString + MemoryContent[i]
with open(FileName+str(i), mode='wb') as file: # b is important -> binary
file.write(MemoryContent[i])
includeStr = includeStr +" "+ str(i)
print (includeStr)
# IMPORTANT: pad array with zeros if you use only 3 segments (see above)
while len(startArray) < 16 :
startArray =startArray + struct.pack("I",0)
endArray = endArray + struct.pack("I",0)
# debug print (binascii.hexlify(startArray))
# IMPORTANT: pad array with zeros if you use only 3 segments (see above)
while len(startArray) < 16 :
startArray =startArray + struct.pack("I",0)
endArray = endArray + struct.pack("I",0)
# debug print (binascii.hexlify(startArray))
# debug print (binascii.hexlify(endArray))
if (len(endArray) + len (startArray)) != 32 :
print("ERROR: please make sure you add / remove padding if you change the semgents.")
print("ERROR: please make sure you add / remove padding if you change the semgents.")
BinaryFileName = "";
if fileContent.find( FILENAMEDUMMY) < 0:
print("ERROR: FILENAMEDUMMY dummy not found in binary")
else:
BinaryFileName=os.path.basename(FileName) +"\0"
if len(BinaryFileName) >48: # check that filename is <48 chars
BinaryFileName=BinaryFileName[0:48] # truncate if necessary. 49th char in ESP is zero already
if len(BinaryFileName) >64: # check that filename is <48 chars
BinaryFileName=BinaryFileName[0:64] # truncate if necessary. 49th char in ESP is zero already
else:
BinaryFileName= BinaryFileName.ljust(48,'\0'); # pad with zeros.
BinaryFileName= BinaryFileName.ljust(64,'\0'); # pad with zeros.
if fileContent.find( MD5DUMMY) < 0:
print("ERROR: MD5 dummy not found in binary")
else:
hashString=hashString.replace (MD5DUMMY,"",1)
hashString=hashString.replace (MD5DUMMY,"",1)
m = md5.new()
m.update (hashString) #use segment 1
md5hash = m.digest()
print("MD5 hash: "+ m.hexdigest())
print("\nwriting output file:\n" + FileName)
fileContent=fileContent.replace(MD5DUMMY,md5hash+startArray+endArray)
fileContent=fileContent.replace(FILENAMEDUMMY,BinaryFileName)
with open(FileName, mode='wb') as file: # b is important -> binary
file.write(fileContent)
#k=input("press close to exit")
#k=input("press close to exit")
+1044
View File
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# purpose: GIT post-commit
# change value of BUILD_GIT macro
#
WORKDIR=src
CUSTOM_H=${WORKDIR}/Custom.h
GLOBAL_H=${WORKDIR}/ESPEasy-Globals.h
# update BUILD_GIT on branch checkout
[[ $3 == 1 && -f ${CUSTOM_H} ]] && \
sed -i.bak -e "s/\(#define BUILD_GIT\).*/\1 \"$(git log -1 --pretty=format:%h HEAD)\"/" ${CUSTOM_H}
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# purpose: GIT post-commit
# change value of BUILD_GIT macro
#
WORKDIR=src
CUSTOM_H=${WORKDIR}/Custom.h
GLOBAL_H=${WORKDIR}/ESPEasy-Globals.h
[[ -f ${CUSTOM_H} ]] && \
sed -i.bak -e "s/\(#define BUILD_GIT\).*/\1 \"$(git log -1 --pretty=format:%h HEAD)\"/" ${CUSTOM_H}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# build an include file to select plugins
#
WORKDIR=ESPEasy
CUSTOM_H=${WORKDIR}/Custom.h
GLOBAL_H=${WORKDIR}/ESPEasy-Globals.h
[[ -L ${WORKDIR} ]] || (
ln -s src ${WORKDIR}
)
# we expect that ${CUSTOM_H} always contains a "#define BUILD_GIT" macro
[[ -f ${CUSTOM_H} ]] && (
echo "post_merge: change BUILD_GIT"
sed -i.bak -e "s/\(#define BUILD_GIT\).*/\1 \"$(git log -1 --pretty=format:%h HEAD)\"/" ${CUSTOM_H}
)
# uncomment if you don't want to use the Custom.h include
grep -q "^#define USE_CUSTOM_H" ${GLOBAL_H} || (
sed -i -e "/[ \t]*#define ESPEASY_GLOBALS_H_/a #define USE_CUSTOM_H" ${GLOBAL_H}
)
+16 -16
View File
@@ -1,25 +1,25 @@
#include "AM2320.h"
#include <Wire.h>
//
//
// AM2321 Temperature & Humidity Sensor library for Arduino
// Сделана Тимофеевым Е.Н. из AM2320-master
unsigned int CRC16(byte *ptr, byte length)
{
unsigned int crc = 0xFFFF;
uint8_t s = 0x00;
unsigned int CRC16(byte *ptr, byte length)
{
unsigned int crc = 0xFFFF;
uint8_t s = 0x00;
while(length--) {
crc ^= *ptr++;
crc ^= *ptr++;
for(s = 0; s < 8; s++) {
if((crc & 0x01) != 0) {
crc >>= 1;
crc ^= 0xA001;
} else crc >>= 1;
}
}
return crc;
}
crc >>= 1;
crc ^= 0xA001;
} else crc >>= 1;
}
}
return crc;
}
AM2320::AM2320()
{
@@ -28,7 +28,7 @@ AM2320::AM2320()
int AM2320::Read()
{
byte buf[8];
for(int s = 0; s < 8; s++) buf[s] = 0x00;
for(int s = 0; s < 8; s++) buf[s] = 0x00;
Wire.beginTransmission(AM2320_address);
Wire.endTransmission();
@@ -37,10 +37,10 @@ int AM2320::Read()
Wire.write(0x03);// запрос
Wire.write(0x00); // с 0-го адреса
Wire.write(0x04); // 4 байта
if (Wire.endTransmission(1) != 0) return 1;
if (Wire.endTransmission(true) != 0) return 1;
delayMicroseconds(1600); //>1.5ms
// считываем результаты запроса
Wire.requestFrom(AM2320_address, 0x08);
Wire.requestFrom(AM2320_address, 0x08);
for (int i = 0; i < 0x08; i++) buf[i] = Wire.read();
// CRC check
+37 -37
View File
@@ -1,24 +1,24 @@
/*
This is a (Arduino) library for the BH1750FVI Digital Light Sensor.
Description:
http://www.rohm.com/web/global/products/-/product/BH1750FVI
Datasheet:
http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf
Copyright (c) 2013 Alexander Schulz. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -31,10 +31,10 @@
/**
* Constructor.
* Erlaubt die I2C-Adresse des Sensors zu ändern.
* Standardadresse: 0x23, Alternativadresse: 0x5C.
* Erlaubt die I2C-Adresse des Sensors zu ändern.
* Standardadresse: 0x23, Alternativadresse: 0x5C.
* Es sind entsprechende Konstanten definiert: BH1750_DEFAULT_I2CADDR und BH1750_SECOND_I2CADDR.
* Bei Nichtangabe wird die Standardadresse verwendet.
* Bei Nichtangabe wird die Standardadresse verwendet.
* Um die Alternativadresse zu nutzen, muss der Sensorpin 'ADR' des Chips auf VCC gelegt werden.
*/
AS_BH1750::AS_BH1750(uint8_t address) {
@@ -44,23 +44,23 @@ AS_BH1750::AS_BH1750(uint8_t address) {
/**
* Führt die anfängliche Initialisierung des Sensors.
* Mögliche Parameter:
* Mögliche Parameter:
* - Modus für die Sensorauflösung:
* -- RESOLUTION_LOW: Physische Sensormodus mit 4 lx Auflösung. Messzeit ca. 16ms. Bereich 0-54612.
* -- RESOLUTION_NORMAL: Physische Sensormodus mit 1 lx Auflösung. Messzeit ca. 120ms. Bereich 0-54612.
* -- RESOLUTION_HIGH: Physische Sensormodus mit 0,5 lx Auflösung. Messzeit ca. 120ms. Bereich 0-54612.
* (Die Messbereiche können durch Änderung des MTreg verschoben werden.)
* -- RESOLUTION_AUTO_HIGH: Die Werte im MTreg werden je nach Helligkeit automatisch so angepasst,
* -- RESOLUTION_AUTO_HIGH: Die Werte im MTreg werden je nach Helligkeit automatisch so angepasst,
* dass eine maximalmögliche Auflösung und Messbereich erziehlt werden.
* Die messbaren Werte fangen von 0,11 lx und gehen bis über 100000 lx.
* (ich weis nicht, wie genau die Werte in Grenzbereichen sind,
* (ich weis nicht, wie genau die Werte in Grenzbereichen sind,
* besonders bei hohen Werte habe ich da meine Zweifel.
* Die Werte scheinen jedoch weitgehend linear mit der steigenden Helligkeit zu wachsen.)
* Auflösung im Unteren Bereich ca. 0,13 lx, im mittleren 0,5 lx, im oberen etwa 1-2 lx.
* Die Messzeiten verlängern sich durch mehrfache Messungen und
* Die Messzeiten verlängern sich durch mehrfache Messungen und
* die Änderungen von Measurement Time (MTreg) bis max. ca. 500 ms.
*
* - AutoPowerDown: true = Der Sensor wird nach der Messung in den Stromsparmodus versetzt.
*
* - AutoPowerDown: true = Der Sensor wird nach der Messung in den Stromsparmodus versetzt.
* Das spätere Aufwecken wird ggf. automatisch vorgenommen, braucht jedoch geringfügig mehr Zeit.
*
* Defaultwerte: RESOLUTION_AUTO_HIGH, true
@@ -73,8 +73,8 @@ bool AS_BH1750::begin(sensors_resolution_t mode, bool autoPowerDown) {
#endif
_virtualMode = mode;
_autoPowerDown = autoPowerDown;
Wire.begin();
//Wire.begin(); called in ESPEasy framework
defineMTReg(BH1750_MTREG_DEFAULT); // eigentlich normalerweise unnötig, da standard
@@ -132,7 +132,7 @@ bool AS_BH1750::isPresent() {
// Check I2C Adresse
Wire.beginTransmission(_address);
if(Wire.endTransmission()!=0) {
return false;
return false;
}
// Check device: ist es ein BH1750
@@ -141,10 +141,10 @@ bool AS_BH1750::isPresent() {
//write8(BH1750_POWER_ON);
selectResolutionMode(BH1750_ONE_TIME_LOW_RES_MODE);
_hardwareMode=255;
}
}
else {
// falls einmal-modus aktiv war, muss der Sensor geweckt werden
powerOn();
powerOn();
}
// Prüfen, ob Werte auch wirklich geliefert werden (letztes Modus, ggf. wird auto-PowerDown ausgeführt)
@@ -189,9 +189,9 @@ void AS_BH1750::powerDown() {
* Sendet zum Sensor ein Befehl zum Auswahl von HardwareMode.
*
* Parameter:
* - mode: s.o.
* - mode: s.o.
* - DelayFuncPtr: delay(n) Möglichkeit, eigene Delay-Funktion mitzugeben (z.B. um sleep-Modus zu verwenden).
*
*
* Defaultwerte: delay()
*
*/
@@ -256,17 +256,17 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
return -1;
}
// ggf. PowerOn
// ggf. PowerOn
if(_autoPowerDown && _valueReaded){
powerOn();
}
// Das Automatische Modus benötigt eine Sonderbehandlung.
// Zuerst wird die Helligkeit im LowRes-Modus gelesen,
// Zuerst wird die Helligkeit im LowRes-Modus gelesen,
// je nach Bereich (dunkel, normal, sehr hell) werden die Werte von MTreg gesetzt und
// danach wird die eigentliche Messung vorgenommen.
/*
Die feste Grenzwerte verursachen möglicherweise einen 'Sprung' in der Messkurve.
Die feste Grenzwerte verursachen möglicherweise einen 'Sprung' in der Messkurve.
In diesem Fall wäre eine laufende Anpassung von MTreg in Grenzbereichen vermutlich besser.
Für meine Zwecke ist das jedoch ohne Bedeutung.
*/
@@ -282,8 +282,8 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
if(level<10) {
#if BH1750_DEBUG == 1
Serial.println("level 0: dark");
#endif
// Dunkel, Empfindlichkeit auf Maximum.
#endif
// Dunkel, Empfindlichkeit auf Maximum.
// Der Wert ist zufällig. Ab ca. 16000 wäre diese Vorgehnsweise möglich.
// Ich brauche diese Genauigkeit aber nur in den ganz dunklen Bereichen (zu erkennen, wann wirklich 'dunkel' ist).
defineMTReg(BH1750_MTREG_MAX);
@@ -294,16 +294,16 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
else if(level<32767) {
#if BH1750_DEBUG == 1
Serial.println("level 1: normal");
#endif
#endif
// Bis hierher reicht die 0,5 lx Modus. Normale Empfindlichkeit.
defineMTReg(BH1750_MTREG_DEFAULT);
selectResolutionMode(_autoPowerDown?BH1750_ONE_TIME_HIGH_RES_MODE_2:BH1750_CONTINUOUS_HIGH_RES_MODE_2, fDelayPtr);
fDelayPtr(120); // TODO: Wert prüfen
}
}
else if(level<60000) {
#if BH1750_DEBUG == 1
Serial.println("level 2: bright");
#endif
#endif
// hoher Bereich, 1 lx Modus, normale Empfindlichkeit. Der Wert von 60000 ist mehr oder weniger zufällig, es mus einfach ein hoher Wert, nah an der Grenze sein.
defineMTReg(BH1750_MTREG_DEFAULT);
selectResolutionMode(_autoPowerDown?BH1750_ONE_TIME_HIGH_RES_MODE:BH1750_CONTINUOUS_HIGH_RES_MODE, fDelayPtr);
@@ -312,29 +312,29 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
else {
#if BH1750_DEBUG == 1
Serial.println("level 3: very bright");
#endif
#endif
// sehr hoher Bereich, Empfindlichkeit verringern
defineMTReg(32); // Min+1, bei dem Minimum aus Doku spielt der Sensor (zumindest meiner) verrückt: Die Werte sind ca. 1/10 von den Erwarteten.
selectResolutionMode(_autoPowerDown?BH1750_ONE_TIME_HIGH_RES_MODE:BH1750_CONTINUOUS_HIGH_RES_MODE, fDelayPtr);
fDelayPtr(120); // TODO: Wert prüfen
}
}
}
// Hardware Wert lesen und in Lux umrechnen.
uint16_t raw = readRawLevel();
if(raw==65535) {
// Wert verdächtig hoch. Sensor prüfen.
// Wert verdächtig hoch. Sensor prüfen.
// Check I2C Adresse
Wire.beginTransmission(_address);
if(Wire.endTransmission()!=0) {
return -1;
return -1;
}
}
return convertRawValue(raw);
return convertRawValue(raw);
}
/**
* Roh-Wert der Helligkeit auslesen.
* Roh-Wert der Helligkeit auslesen.
* Wertebereich 0-65535.
*/
uint16_t AS_BH1750::readRawLevel(void) {
@@ -457,7 +457,7 @@ void AS_BH1750::defineMTReg(uint8_t val) {
* Gibt an, ob der Sensor initialisiert ist.
*/
bool AS_BH1750::isInitialized() {
return _hardwareMode!=255;
return _hardwareMode!=255;
}
/**
+1 -1
View File
@@ -20,7 +20,7 @@ Adafruit_MPR121::Adafruit_MPR121() {
}
boolean Adafruit_MPR121::begin(uint8_t i2caddr) {
Wire.begin();
//Wire.begin(); called in ESPEasy framework
_i2caddr = i2caddr;
@@ -44,7 +44,7 @@ Adafruit_MotorShield::Adafruit_MotorShield(uint8_t addr) {
void Adafruit_MotorShield::begin(uint16_t freq) {
// init PWM w/_freq
WIRE.begin();
//Wire.begin(); called in ESPEasy framework
_pwm.begin();
_freq = freq;
_pwm.setPWMFreq(_freq); // This is the maximum PWM frequency
@@ -1,17 +1,17 @@
/***************************************************
/***************************************************
This is a library for our Adafruit 16-channel PWM & Servo driver
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/815
These displays use I2C to communicate, 2 pins are required to
These displays use I2C to communicate, 2 pins are required to
interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
@@ -29,7 +29,7 @@ Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(uint8_t addr) {
}
void Adafruit_MS_PWMServoDriver::begin(void) {
WIRE.begin();
//Wire.begin(); called in ESPEasy framework
reset();
}
@@ -41,7 +41,7 @@ void Adafruit_MS_PWMServoDriver::reset(void) {
void Adafruit_MS_PWMServoDriver::setPWMFreq(float freq) {
//Serial.print("Attempting to set freq ");
//Serial.println(freq);
freq *= 0.9; // Correct for overshoot in the frequency setting (see issue #11).
float prescaleval = 25000000;
@@ -50,8 +50,8 @@ void Adafruit_MS_PWMServoDriver::setPWMFreq(float freq) {
prescaleval -= 1;
//Serial.print("Estimated pre-scale: "); Serial.println(prescaleval);
uint8_t prescale = floor(prescaleval + 0.5);
//Serial.print("Final pre-scale: "); Serial.println(prescale);
//Serial.print("Final pre-scale: "); Serial.println(prescale);
uint8_t oldmode = read8(PCA9685_MODE1);
uint8_t newmode = (oldmode&0x7F) | 0x10; // sleep
write8(PCA9685_MODE1, newmode); // go to sleep
+7 -7
View File
@@ -119,7 +119,7 @@ void Adafruit_TCS34725::enable(void)
{
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON);
delay(3);
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN);
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN);
}
/**************************************************************************/
@@ -144,7 +144,7 @@ void Adafruit_TCS34725::disable(void)
Constructor
*/
/**************************************************************************/
Adafruit_TCS34725::Adafruit_TCS34725(tcs34725IntegrationTime_t it, tcs34725Gain_t gain)
Adafruit_TCS34725::Adafruit_TCS34725(tcs34725IntegrationTime_t it, tcs34725Gain_t gain)
{
_tcs34725Initialised = false;
_tcs34725IntegrationTime = it;
@@ -161,10 +161,10 @@ Adafruit_TCS34725::Adafruit_TCS34725(tcs34725IntegrationTime_t it, tcs34725Gain_
doing anything else)
*/
/**************************************************************************/
boolean Adafruit_TCS34725::begin(void)
boolean Adafruit_TCS34725::begin(void)
{
Wire.begin();
//Wire.begin(); called in ESPEasy framework
/* Make sure we're actually connected */
uint8_t x = read8(TCS34725_ID);
if ((x != 0x44) && (x != 0x10))
@@ -182,7 +182,7 @@ boolean Adafruit_TCS34725::begin(void)
return true;
}
/**************************************************************************/
/*!
Sets the integration time for the TC34725
@@ -228,7 +228,7 @@ void Adafruit_TCS34725::getRawData (uint16_t *r, uint16_t *g, uint16_t *b, uint1
*r = read16(TCS34725_RDATAL);
*g = read16(TCS34725_GDATAL);
*b = read16(TCS34725_BDATAL);
/* Set a delay for the integration time */
switch (_tcs34725IntegrationTime)
{
+1 -1
View File
@@ -68,7 +68,7 @@ Adafruit_TSL2591::Adafruit_TSL2591(int32_t sensorID)
boolean Adafruit_TSL2591::begin(void)
{
Wire.begin();
//Wire.begin(); called in ESPEasy framework
/*
for (uint8_t i=0; i<0x20; i++)
+11 -8
View File
@@ -1,11 +1,14 @@
<!--
Thanks for using ArduinoJson :-)
Before opening an issue, please read the FAQ:
https://arduinojson.org/faq/
Before opening an issue, please make sure you've read these:
https://github.com/bblanchon/ArduinoJson/wiki/FAQ
https://github.com/bblanchon/ArduinoJson/wiki/Avoiding-pitfalls
Please provide all the relevant information:
* good title
* short description of the problem
* target platform
* compiler model and version
* MVCE (https://stackoverflow.com/help/mcve)
* compiler output
Next, make sure you provide all the relevant information: platform, code snippet, and error messages.
Please be concise!
-->
Good questions get fast answers!
-->
+3
View File
@@ -6,3 +6,6 @@
/sftp-config.json
.tags
.tags_sorted_by_file
/fuzzing/*_fuzzer
/fuzzing/*_fuzzer.options
/fuzzing/*_fuzzer_seed_corpus.zip
+6
View File
@@ -0,0 +1,6 @@
.github/
examples/
fuzzing/
scripts/
test/
third-party/
+56 -48
View File
@@ -7,111 +7,119 @@ matrix:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.4']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.4
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.5']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.5
env: SCRIPT=cmake GCC=4.4
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.6']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.6
env: SCRIPT=cmake GCC=4.6
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.7']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.7
env: SCRIPT=cmake GCC=4.7
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.8
env: SCRIPT=cmake GCC=4.8 SANITIZE=address
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.9
env: SCRIPT=cmake GCC=4.9 SANITIZE=leak
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-5
env: SCRIPT=cmake GCC=5
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6']
env: SCRIPT=cmake GCC=6
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7']
env: SCRIPT=cmake GCC=7
- compiler: clang
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++
env: SCRIPT=cmake
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5']
packages: ['clang-3.5']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.5
env: SCRIPT=cmake CLANG=3.5 SANITIZE=address
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.6']
packages: ['clang-3.6']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.6
env: SCRIPT=cmake CLANG=3.6 SANITIZE=leak
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.7']
packages: ['clang-3.7']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.7
env: SCRIPT=cmake CLANG=3.7
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8']
packages: ['clang-3.8']
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.8
env: SCRIPT=cmake CLANG=3.8 SANITIZE=undefined
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-3.9']
packages: ['clang-3.9']
env: SCRIPT=cmake CLANG=3.9
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-4.0']
packages: ['clang-4.0']
env: SCRIPT=cmake CLANG=4.0
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-5.0']
packages: ['clang-5.0']
env: SCRIPT=cmake CLANG=5.0
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
packages: ['clang-6.0']
env: SCRIPT=cmake CLANG=6.0
- compiler: gcc
env: SCRIPT=coverage
- os: osx
osx_image: beta-xcode6.1
compiler: clang
env: SCRIPT=cmake-osx
- os: osx
osx_image: beta-xcode6.2
compiler: clang
env: SCRIPT=cmake-osx
- os: osx
osx_image: beta-xcode6.3
compiler: clang
env: SCRIPT=cmake-osx
- os: osx
osx_image: xcode6.4
compiler: clang
env: SCRIPT=cmake-osx
- os: osx
osx_image: xcode7
compiler: clang
env: SCRIPT=cmake-osx
- os: osx
osx_image: xcode7.1
compiler: clang
env: SCRIPT=cmake-osx
- os: osx
osx_image: xcode7.2
compiler: clang
env: SCRIPT=cmake-osx
env: SCRIPT=cmake
- os: osx
osx_image: xcode7.3
compiler: clang
env: SCRIPT=cmake-osx
- env: SCRIPT=arduino VERSION=1.5.8 BOARD=arduino:avr:uno
env: SCRIPT=cmake SANITIZE=address
- env: SCRIPT=arduino VERSION=1.6.7 BOARD=arduino:avr:uno
- env: SCRIPT=arduino VERSION=1.6.8 BOARD=arduino:avr:uno
- env: SCRIPT=arduino VERSION=1.6.9 BOARD=arduino:avr:uno
- env: SCRIPT=arduino VERSION=1.8.2 BOARD=arduino:avr:uno
- env: SCRIPT=platformio BOARD=uno
- env: SCRIPT=platformio BOARD=due
- env: SCRIPT=platformio BOARD=esp01
- env: SCRIPT=platformio BOARD=teensy31
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
packages: ['clang-6.0','llvm-6.0']
env: SCRIPT=fuzz CLANG=6.0
cache:
directories:
- "~/.platformio"
+3 -6
View File
@@ -1,8 +1,5 @@
// Copyright Benoit Blanchon 2014-2016
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#include "include/ArduinoJson.h"
#include "src/ArduinoJson.h"
+279 -111
View File
@@ -1,6 +1,270 @@
ArduinoJson: change log
=======================
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
-------
* Fixed `DynamicJsonBuffer::clear()` not resetting allocation size (issue #561)
* Fixed incorrect rounding for float values (issue #588)
v5.11.1
-------
* Removed dependency on `PGM_P` as Particle 0.6.2 doesn't define it (issue #546)
* Fixed warning "dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]"
* Fixed warning "floating constant exceeds range of 'float' [-Woverflow]" (issue #544)
* Fixed warning "this statement may fall through" [-Wimplicit-fallthrough=] (issue #539)
* Removed `ARDUINOJSON_DOUBLE_IS_64BITS` as it became useless.
* Fixed too many decimals places in float serialization (issue #543)
v5.11.0
-------
* Made `JsonBuffer` non-copyable (PR #524 by @luisrayas3)
* Added `StaticJsonBuffer::clear()`
* Added `DynamicJsonBuffer::clear()`
v5.10.1
-------
* Fixed IntelliSense errors in Visual Micro (issue #483)
* Fixed compilation in IAR Embedded Workbench (issue #515)
* Fixed reading "true" as a float (issue #516)
* Added `ARDUINOJSON_DOUBLE_IS_64BITS`
* Added `ARDUINOJSON_EMBEDDED_MODE`
v5.10.0
-------
* Removed configurable number of decimal places (issues #288, #427 and #506)
* Changed exponentiation thresholds to `1e7` and `1e-5` (issues #288, #427 and #506)
* `JsonVariant::is<double>()` now returns `true` for integers
* 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` |
v5.9.0
------
* Added `JsonArray::remove(iterator)` (issue #479)
* Added `JsonObject::remove(iterator)`
* Renamed `JsonArray::removeAt(size_t)` into `remove(size_t)`
* Renamed folder `include/` to `src/`
* Fixed warnings `floating constant exceeds range of float`and `floating constant truncated to zero` (issue #483)
* Removed `Print` class and converted `printTo()` to a template method (issue #276)
* Removed example `IndentedPrintExample.ino`
* Now compatible with Particle 0.6.1, thanks to Jacob Nite (issue #294 and PR #461 by @foodbag)
v5.8.4
------
* Added custom implementation of `strtod()` (issue #453)
* Added custom implementation of `strtol()` (issue #465)
* `char` is now treated as an integral type (issue #337, #370)
v5.8.3
------
* Fixed an access violation in `DynamicJsonBuffer` when memory allocation fails (issue #433)
* Added operators `==` and `!=` for two `JsonVariant`s (issue #436)
* Fixed `JsonVariant::operator[const FlashStringHelper*]` (issue #441)
v5.8.2
------
* Fixed parsing of comments (issue #421)
* Fixed ignored `Stream` timeout (issue #422)
* Made sure we don't read more that necessary (issue #422)
* Fixed error when the key of a `JsonObject` is a `char[]` (issue #423)
* Reduced code size when using `const` references
* Fixed error with string of type `unsigned char*` (issue #428)
* Added `deprecated` attribute on `asArray()`, `asObject()` and `asString()` (issue #420)
v5.8.1
------
* Fixed error when assigning a `volatile int` to a `JsonVariant` (issue #415)
* Fixed errors with Variable Length Arrays (issue #416)
* Fixed error when both `ARDUINOJSON_ENABLE_STD_STREAM` and `ARDUINOJSON_ENABLE_ARDUINO_STREAM` are set to `1`
* Fixed error "Stream does not name a type" (issue #412)
v5.8.0
------
* Added operator `==` to compare `JsonVariant` and strings (issue #402)
* 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);
> ```
v5.7.3
------
* Added an `printTo(char[N])` and `prettyPrintTo(char[N])` (issue #292)
* Added ability to set a nested value like this: `root["A"]["B"] = "C"` (issue #352)
* Renamed `*.ipp` to `*Impl.hpp` because they were ignored by Arduino IDE (issue #396)
v5.7.2
------
* Made PROGMEM available on more platforms (issue #381)
* Fixed PROGMEM causing an exception on ESP8266 (issue #383)
v5.7.1
------
* Added support for PROGMEM (issue #76)
* Fixed compilation error when index is not an `int` (issue #381)
v5.7.0
------
* Templatized all functions using `String` or `std::string`
* Removed `ArduinoJson::String`
* Removed `JsonVariant::defaultValue<T>()`
* Removed non-template `JsonObject::get()` and `JsonArray.get()`
* Fixed support for `StringSumHelper` (issue #184)
* Replaced `ARDUINOJSON_USE_ARDUINO_STRING` by `ARDUINOJSON_ENABLE_STD_STRING` and `ARDUINOJSON_ENABLE_ARDUINO_STRING` (issue #378)
* 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);
> ```
v5.6.7
------
* Fixed `array[idx].as<JsonVariant>()` and `object[key].as<JsonVariant>()`
* Fixed return value of `JsonObject::set()` (issue #350)
* Fixed undefined behavior in `Prettyfier` and `Print` (issue #354)
* Fixed parser that incorrectly rejected floats containing a `+` (issue #349)
v5.6.6
------
* Fixed `-Wparentheses` warning introduced in v5.6.5 (PR #335 by @nuket)
* Added `.mbedignore` for ARM mbdeb (PR #334 by @nuket)
* Fixed `JsonVariant::success()` which didn't propagate `JsonArray::success()` nor `JsonObject::success()` (issue #342).
v5.6.5
------
* `as<char*>()` now returns `true` when input is `null` (issue #330)
v5.6.4
------
@@ -71,8 +335,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
------
@@ -86,9 +351,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**:
- `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
------
@@ -142,10 +408,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**:
- `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.
@@ -198,106 +465,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
+4 -9
View File
@@ -1,21 +1,16 @@
# Copyright Benoit Blanchon 2014-2016
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
#
# Arduino JSON library
# https://github.com/bblanchon/ArduinoJson
# If you like this project, please add a star!
cmake_minimum_required(VERSION 3.0)
project(ArduinoJson)
enable_testing()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
if(${COVERAGE})
set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
endif()
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
add_subdirectory(third-party/catch)
add_subdirectory(test)
+11
View File
@@ -0,0 +1,11 @@
# Contribution to ArduinoJson
First, thank you for taking the time to contribute to this project.
You can submit changes via GitHub Pull Requests.
Please:
1. Unit test every change in behavior
2. Use clang-format in "file" mode to format the code
3. Consider using the Continuous Integration (Travis and AppVeyor)
+1 -1
View File
@@ -1,7 +1,7 @@
The MIT License (MIT)
---------------------
Copyright © 2014-2016 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:
+59 -79
View File
@@ -1,46 +1,60 @@
Arduino JSON library
====================
![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)
*An elegant and efficient JSON library for embedded systems.*
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
It's designed to have the most intuitive API, the smallest footprint and works 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.
Features
--------
## Features
* JSON decoding (comments are supported)
* JSON encoding (with optional indentation)
* Elegant API, very easy to use
* Elegant API, easy to use
* Fixed memory allocation (zero malloc)
* No data duplication (zero copy)
* Portable (written in C++98)
* Portable (written in C++98, can be used in any C++ project)
* Self-contained (no external dependency)
* Small footprint
* Header-only library
* MIT License
* 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)
Works on
--------
## Compatibility
* All Arduino boards (Uno, Due, Mini, Micro, Yun...)
* ESP8266
* Teensy
* Intel Edison and Galileo
* PlatformIO
* Energia
* RedBearLab boards (BLE Nano...)
* Computers (Windows, Linux, OSX...)
ArduinoJson works on the following hardware:
See [FAQ: Compatibility issues](https://github.com/bblanchon/ArduinoJson/wiki/Compatibility-issues)
* <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)...
Quick start
-----------
ArduinoJson compiles with zero warning on the following compilers, IDEs, and platforms:
#### Decoding / Parsing
* <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]}";
@@ -55,7 +69,11 @@ double latitude = root["data"][0];
double longitude = root["data"][1];
```
#### Encoding / Generating
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;
@@ -65,66 +83,28 @@ root["sensor"] = "gps";
root["time"] = 1351824120;
JsonArray& data = root.createNestedArray("data");
data.add(48.756080, 6); // 6 is the number of decimals to print
data.add(2.302038, 6); // if not specified, 2 digits are printed
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
-------------
## Documentation
The documentation is available online in the [Arduino JSON wiki](https://github.com/bblanchon/ArduinoJson/wiki)
The documentation is available on [arduinojson.org](https://arduinojson.org/?utm_source=github&utm_medium=readme), here are some shortcuts:
Testimonials
------------
From Arduino's Forum user `jflaplante`:
> I tried aJson json-arduino before trying your library. I always ran into memory problem after a while.
> I have no such problem so far with your library. It is working perfectly with my web services.
From Arduino's Forum user `gbathree`:
> Thanks so much - this is an awesome library! If you want to see what we're doing with it - the project is located at www.photosynq.org.
From StackOverflow user `thegreendroid`:
> It has a really elegant, simple API and it works like a charm on embedded and Windows/Linux platforms. We recently started using this on an embedded project and I can vouch for its quality.
From GitHub user `zacsketches`:
> Thanks for a great library!!!
> I've been watching you consistently develop this library over the past six months, and I used it today for a publish and subscribe architecture designed to help hobbyists move into more advanced robotics. Your library allowed me to implement remote subscription in order to facilitate multi-processor robots.
> ArduinoJson saved me a week's worth of time!!
[From Reddit user `erm_what_`](https://www.reddit.com/r/arduino/comments/3jj6ep/announcing_arduinojson_50/cusjk8c):
> This is a great library and I wouldn't be able to do the project I'm doing without it. I completely recommend it.
[From Reddit user `makerhacks`](https://www.reddit.com/r/arduino/comments/3jj6ep/announcing_arduinojson_50/cusqg7b):
> I am just starting an ESP8266 clock project and now I can output JSON from my server script and interpret it painlessly.
[From Twitter user `@hemalchevli`](https://twitter.com/hemalchevli/status/715788439397011456):
> ArduinoJson library should be used as a benchmark/reference for making libraries. Truly elegant.
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'>
* 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!
---
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&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) :smile:
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!
+27
View File
@@ -0,0 +1,27 @@
# ArduinoJson Support
First off, thank you very much for using ArduinoJson.
We'll be very happy to help you, but first please read the following.
## Before asking for help
1. Read the [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=support)
2. Search in the [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=support)
If you did not find the answer, please create a [new issue on GitHub](https://github.com/bblanchon/ArduinoJson/issues/new).
It is OK to add a comment to a currently opened issue, but please avoid adding comments to a closed issue.
## Before hitting the Submit button
Please provide all the relevant information:
* Good title
* Short description of the problem
* Target platform
* Compiler model and version
* [MVCE](https://stackoverflow.com/help/mcve)
* Compiler output
Good questions get fast answers!
+9 -7
View File
@@ -1,13 +1,15 @@
version: 5.6.4.{build}
version: 5.13.2.{build}
environment:
matrix:
- CMAKE_GENERATOR: Visual Studio 14 2015
- CMAKE_GENERATOR: Visual Studio 12 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
CMAKE_GENERATOR: Visual Studio 12 2013
- CMAKE_GENERATOR: Visual Studio 11 2012
- CMAKE_GENERATOR: Visual Studio 10 2010
# - CMAKE_GENERATOR: MinGW Makefiles
# Note: Disabled because of unexplicated error -1073741511
# This used to work fine with GCC 4.8.2 then failed after they upgraded to GCC 4.9.3
- CMAKE_GENERATOR: MinGW Makefiles
configuration: Debug
before_build:
- set PATH=C:\MinGW\bin;%PATH:C:\Program Files\Git\usr\bin;=% # Workaround for CMake not wanting sh.exe on PATH for MinGW
@@ -15,4 +17,4 @@ before_build:
build_script:
- cmake --build . --config %CONFIGURATION%
test_script:
- ctest -V .
- ctest --output-on-failure .
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 32 KiB

@@ -1,35 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#include <ArduinoJson.h>
using namespace ArduinoJson::Internals;
void setup() {
Serial.begin(9600);
while (!Serial) {
// wait serial port initialization
}
IndentedPrint serial(Serial);
serial.setTabSize(4);
serial.println("This is at indentation 0");
serial.indent();
serial.println("This is at indentation 1");
serial.println("This is also at indentation 1");
serial.indent();
serial.println("This is at indentation 2");
serial.unindent();
serial.unindent();
serial.println("This is back at indentation 0");
}
void loop() {
// not used in this example
}
@@ -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
// --------
//
// The website 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.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
@@ -1,29 +1,27 @@
// Copyright Benoit Blanchon 2014-2016
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/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.
// 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
// replaced by DynamicJsonBuffer which allocates in the heap.
// It's simpler but less efficient.
//
// DynamicJsonBuffer jsonBuffer;
// DynamicJsonBuffer jsonBuffer(200);
// Create the root of the object tree.
//
@@ -44,8 +42,8 @@ void setup() {
// It's also possible to create the array separately and add it to the
// JsonObject but it's less efficient.
JsonArray& data = root.createNestedArray("data");
data.add(double_with_n_digits(48.756080, 6));
data.add(double_with_n_digits(2.302038, 6));
data.add(48.756080);
data.add(2.302038);
root.printTo(Serial);
// This prints:
@@ -68,3 +66,16 @@ void setup() {
void loop() {
// not used in this example
}
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
@@ -1,195 +1,112 @@
// Sample Arduino Json Web Client
// Downloads and parse http://jsonplaceholder.typicode.com/users/1
//
// Copyright Benoit Blanchon 2014-2016
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
// 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 <SPI.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();
}
// Initialize Serial port
Serial.begin(9600);
while (!Serial) continue;
// ARDUINO entry point #2: runs over and over again forever
void loop() {
if (connect(server)) {
if (sendRequest(server, resource) && skipResponseHeaders()) {
char response[MAX_CONTENT_SIZE];
readReponseContent(response, sizeof(response));
UserData userData;
if (parseUserData(response, &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() {
// Initialize Ethernet library
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
if (!Ethernet.begin(mac)) {
Serial.println("Failed to configure Ethernet");
Serial.println(F("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);
Serial.println(F("Connecting..."));
bool ok = client.connect(hostName, 80);
// Connect to HTTP server
EthernetClient client;
client.setTimeout(10000);
if (!client.connect("arduinojson.org", 80)) {
Serial.println(F("Connection failed"));
return;
}
Serial.println(ok ? "Connected" : "Connection Failed!");
return ok;
}
Serial.println(F("Connected!"));
// Send the HTTP GET request to the server
bool sendRequest(const char* host, const char* resource) {
Serial.print("GET ");
Serial.println(resource);
// 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;
}
client.print("GET ");
client.print(resource);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
// 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;
}
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
// Skip HTTP headers
char endOfHeaders[] = "\r\n\r\n";
client.setTimeout(HTTP_TIMEOUT);
bool ok = client.find(endOfHeaders);
if (!ok) {
Serial.println("No response or invalid response!");
if (!client.find(endOfHeaders)) {
Serial.println(F("Invalid response"));
return;
}
return ok;
}
// Read the body of the response from the HTTP server
void readReponseContent(char* content, size_t maxSize) {
size_t length = client.readBytes(content, maxSize);
content[length] = 0;
Serial.println(content);
}
// 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 parseUserData(char* content, struct UserData* userData) {
// Compute optimal size of the JSON buffer according to what we need to parse.
// This is only required if you use StaticJsonBuffer.
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
// Allocate a temporary memory pool on the stack
StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;
// If the memory pool is too big for the stack, use this instead:
// DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(content);
// 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("JSON parsing failed!");
return false;
Serial.println(F("Parsing failed!"));
return;
}
// 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
// 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*>());
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");
// Disconnect
client.stop();
}
// Pause for a 1 minute
void wait() {
Serial.println("Wait 60 seconds");
delay(60000);
void loop() {
// not used in this example
}
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
@@ -1,29 +1,27 @@
// Copyright Benoit Blanchon 2014-2016
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/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.
// 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
// replaced by DynamicJsonBuffer which allocates in the heap.
// It's simpler but less efficient.
//
// DynamicJsonBuffer jsonBuffer;
// DynamicJsonBuffer jsonBuffer(200);
// JSON input string.
//
@@ -65,3 +63,16 @@ void setup() {
void loop() {
// not used in this example
}
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// deserialization problem.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
@@ -1,74 +1,109 @@
// Sample Arduino Json Web Server
// Created by Benoit Blanchon.
// Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe
// 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 <SPI.h>
#include <Ethernet.h>
#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;
}
}
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;
}
return false;
// Start to listen
server.begin();
Serial.println(F("Server is ready."));
Serial.print(F("Please connect to http://"));
Serial.println(Ethernet.localIP());
}
JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
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);
}
return root;
}
Serial.print(F("Sending: "));
root.printTo(Serial);
Serial.println();
void writeResponse(EthernetClient& client, JsonObject& json) {
client.println("HTTP/1.1 200 OK");
// Write response headers
client.println("HTTP/1.0 200 OK");
client.println("Content-Type: application/json");
client.println("Connection: close");
client.println();
json.prettyPrintTo(client);
// Write JSON document
root.prettyPrintTo(client);
// Disconnect
client.stop();
}
void setup() {
Ethernet.begin(mac, ip);
server.begin();
}
void loop() {
EthernetClient client = server.available();
if (client) {
bool success = readRequest(client);
if (success) {
StaticJsonBuffer<500> jsonBuffer;
JsonObject& json = prepareResponse(jsonBuffer);
writeResponse(client, json);
}
delay(1);
client.stop();
}
}
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
@@ -1,55 +1,101 @@
// Send a JSON object on UDP at regular interval
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// You can easily test this program with netcat:
// $ nc -ulp 8888
// 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 ]
// }
//
// by Benoit Blanchon, MIT License 2015-2016
// 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 <SPI.h>
#include <Ethernet.h>
#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;
IPAddress remoteIp(192, 168, 0, 108); // <- EDIT!!!!
unsigned short remotePort = 8888;
unsigned short 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);
// 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() {
delay(1000);
// Allocate JsonBuffer
// Use arduinojson.org/assistant to compute the capacity.
StaticJsonBuffer<500> jsonBuffer;
StaticJsonBuffer<300> jsonBuffer;
JsonObject& json = buildJson(jsonBuffer);
sendJson(json);
// 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
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
@@ -0,0 +1,70 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// 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>
void setup() {
#ifdef PROGMEM // <- check that Flash strings are supported
DynamicJsonBuffer jsonBuffer;
// You can use a Flash String as your JSON input.
// WARNING: the content of the Flash String will be duplicated in the
// JsonBuffer.
JsonObject& root =
jsonBuffer.parseObject(F("{\"sensor\":\"gps\",\"time\":1351824120,"
"\"data\":[48.756080,2.302038]}"));
// You can use a Flash String to get an element of a JsonObject
// No duplication is done.
long time = root[F("time")];
// You can use a Flash String to set an element of a JsonObject
// WARNING: the content of the Flash String will be duplicated in the
// JsonBuffer.
root[F("time")] = time;
// You can set a Flash String to a JsonObject or JsonArray:
// WARNING: the content of the Flash String will be duplicated in the
// 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")) {
// ...
}
#else
#warning PROGMEM is not supported on this platform
#endif
}
void loop() {
// not used in this example
}
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any memory
// problem.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
@@ -0,0 +1,74 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// 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>
void setup() {
DynamicJsonBuffer jsonBuffer;
// You can use a String as your JSON input.
// WARNING: the content of the String will be duplicated in the JsonBuffer.
String input =
"{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
JsonObject& root = jsonBuffer.parseObject(input);
// You can use a String to get an element of a JsonObject
// No duplication is done.
long time = root[String("time")];
// You can use a String to set an element of a JsonObject
// WARNING: the content of the String will be duplicated in the JsonBuffer.
root[String("time")] = time;
// You can get a String from a JsonObject or JsonArray:
// No duplication is done, at least not in the JsonBuffer.
String sensor = root["sensor"];
// Unfortunately, the following doesn't work (issue #118):
// sensor = root["sensor"]; // <- error "ambiguous overload for 'operator='"
// As a workaround, you need to replace by:
sensor = root["sensor"].as<String>();
// You can set a String to a JsonObject or JsonArray:
// 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";
// You can compare the content of a JsonObject with a String
if (root["sensor"] == sensor) {
// ...
}
// Lastly, you can print the resulting JSON to a String
String output;
root.printTo(output);
}
void loop() {
// not used in this example
}
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any problem.
// Please check it out at: https://arduinojson.org/
//
// 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.
// Please check it out at: https://arduinojson.org/book/
+19
View File
@@ -0,0 +1,19 @@
# CAUTION: this file is invoked by https://github.com/google/oss-fuzz
CXXFLAGS += -I../src
all: \
$(OUT)/json_fuzzer \
$(OUT)/json_fuzzer_seed_corpus.zip \
$(OUT)/json_fuzzer.options
$(OUT)/json_fuzzer: fuzzer.cpp $(shell find ../src -type f)
$(CXX) $(CXXFLAGS) $< -o$@ $(LIB_FUZZING_ENGINE)
$(OUT)/json_fuzzer_seed_corpus.zip: seed_corpus/*
zip -j $@ $?
$(OUT)/json_fuzzer.options:
@echo "[libfuzzer]" > $@
@echo "max_len = 256" >> $@
@echo "timeout = 10" >> $@
+26
View File
@@ -0,0 +1,26 @@
#include <ArduinoJson.h>
class memstream : public std::istream {
struct membuf : std::streambuf {
membuf(const uint8_t *p, size_t l) {
setg((char *)p, (char *)p, (char *)p + l);
}
};
membuf _buffer;
public:
memstream(const uint8_t *p, size_t l)
: std::istream(&_buffer), _buffer(p, l) {
rdbuf(&_buffer);
}
};
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
DynamicJsonBuffer jsonBuffer;
memstream json(data, size);
JsonVariant variant = jsonBuffer.parse(json);
if (variant.success()) {
variant.as<std::string>(); // <- serialize to JSON
}
return 0;
}
@@ -0,0 +1,2 @@
*
!.gitignore
@@ -0,0 +1,10 @@
//comment
/*comment*/
[ //comment
/*comment*/"comment"/*comment*/,//comment
/*comment*/{//comment
/* comment*/"key"//comment
: //comment
"value"//comment
}/*comment*/
]//comment
@@ -0,0 +1 @@
[]
@@ -0,0 +1 @@
{}
@@ -0,0 +1 @@
[1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20,[21,[22,[23,[24,[25,[26,[27,[28,[29,[30,[31,[32,[33,[34,[35,[36,[37,[38,[39,[40,[41,[42,[43,[44,[45,[46,[47,[48,[49,[50,[51,[52,[53,[54,[55,[56,[57,[58,[59,[60,[61,[62,[63,[64,[65,[66,[67,[68,[69,[70,[71,[72,[73,[74,[75,[76,[77,[78,[79,[80,[81,[82,[83,[84,[85,[86,[87,[88,[89,[90,[91,[92,[93,[94,[95,[96,[97,[98,[99,[100,[101,[102,[103,[104,[105,[106,[107,[108,[109,[110,[111,[112,[113,[114,[115,[116,[117,[118,[119,[120]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
@@ -0,0 +1,24 @@
[
123,
-123,
123.456,
-123.456,
12e34,
12e-34,
12e+34,
12E34,
12E-34,
12E+34,
12.34e56,
12.34e-56,
12.34e+56,
12.34E56,
12.34E-56,
12.34E+56,
NaN,
-NaN,
+NaN,
Infinity,
+Infinity,
-Infinity
]
@@ -0,0 +1,53 @@
{
"coord": {
"lon": -0.13,
"lat": 51.51
},
"weather": [
{
"id": 301,
"main": "Drizzle",
"description": "drizzle",
"icon": "09n"
},
{
"id": 701,
"main": "Mist",
"description": "mist",
"icon": "50n"
},
{
"id": 741,
"main": "Fog",
"description": "fog",
"icon": "50n"
}
],
"base": "stations",
"main": {
"temp": 281.87,
"pressure": 1032,
"humidity": 100,
"temp_min": 281.15,
"temp_max": 283.15
},
"visibility": 2900,
"wind": {
"speed": 1.5
},
"clouds": {
"all": 90
},
"dt": 1483820400,
"sys": {
"type": 1,
"id": 5091,
"message": 0.0226,
"country": "GB",
"sunrise": 1483776245,
"sunset": 1483805443
},
"id": 2643743,
"name": "London",
"cod": 200
}
@@ -0,0 +1,8 @@
[
"hello",
'hello',
hello,
{"hello":"world"},
{'hello':'world'},
{hello:world}
]
@@ -0,0 +1,90 @@
{
"response": {
"version": "0.1",
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
},
"current_observation": {
"image": {
"url": "http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
"title": "Weather Underground",
"link": "http://www.wunderground.com"
},
"display_location": {
"full": "San Francisco, CA",
"city": "San Francisco",
"state": "CA",
"state_name": "California",
"country": "US",
"country_iso3166": "US",
"zip": "94101",
"latitude": "37.77500916",
"longitude": "-122.41825867",
"elevation": "47.00000000"
},
"observation_location": {
"full": "SOMA - Near Van Ness, San Francisco, California",
"city": "SOMA - Near Van Ness, San Francisco",
"state": "California",
"country": "US",
"country_iso3166": "US",
"latitude": "37.773285",
"longitude": "-122.417725",
"elevation": "49 ft"
},
"estimated": {},
"station_id": "KCASANFR58",
"observation_time": "Last Updated on June 27, 5:27 PM PDT",
"observation_time_rfc822": "Wed, 27 Jun 2012 17:27:13 -0700",
"observation_epoch": "1340843233",
"local_time_rfc822": "Wed, 27 Jun 2012 17:27:14 -0700",
"local_epoch": "1340843234",
"local_tz_short": "PDT",
"local_tz_long": "America/Los_Angeles",
"local_tz_offset": "-0700",
"weather": "Partly Cloudy",
"temperature_string": "66.3 F (19.1 C)",
"temp_f": 66.3,
"temp_c": 19.1,
"relative_humidity": "65%",
"wind_string": "From the NNW at 22.0 MPH Gusting to 28.0 MPH",
"wind_dir": "NNW",
"wind_degrees": 346,
"wind_mph": 22,
"wind_gust_mph": "28.0",
"wind_kph": 35.4,
"wind_gust_kph": "45.1",
"pressure_mb": "1013",
"pressure_in": "29.93",
"pressure_trend": "+",
"dewpoint_string": "54 F (12 C)",
"dewpoint_f": 54,
"dewpoint_c": 12,
"heat_index_string": "NA",
"heat_index_f": "NA",
"heat_index_c": "NA",
"windchill_string": "NA",
"windchill_f": "NA",
"windchill_c": "NA",
"feelslike_string": "66.3 F (19.1 C)",
"feelslike_f": "66.3",
"feelslike_c": "19.1",
"visibility_mi": "10.0",
"visibility_km": "16.1",
"solarradiation": "",
"UV": "5",
"precip_1hr_string": "0.00 in ( 0 mm)",
"precip_1hr_in": "0.00",
"precip_1hr_metric": " 0",
"precip_today_string": "0.00 in (0 mm)",
"precip_today_in": "0.00",
"precip_today_metric": "0",
"icon": "partlycloudy",
"icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
"forecast_url": "http://www.wunderground.com/US/CA/San_Francisco.html",
"history_url": "http://www.wunderground.com/history/airport/KCASANFR58/2012/6/27/DailyHistory.html",
"ob_url": "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=37.773285,-122.417725"
}
}
-9
View File
@@ -1,9 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#include "ArduinoJson.hpp"
using namespace ArduinoJson;
-21
View File
@@ -1,21 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "ArduinoJson/DynamicJsonBuffer.hpp"
#include "ArduinoJson/JsonArray.hpp"
#include "ArduinoJson/JsonObject.hpp"
#include "ArduinoJson/StaticJsonBuffer.hpp"
#include "ArduinoJson/Internals/JsonParser.ipp"
#include "ArduinoJson/JsonArray.ipp"
#include "ArduinoJson/JsonBuffer.ipp"
#include "ArduinoJson/JsonObject.ipp"
#include "ArduinoJson/JsonVariant.ipp"
using namespace ArduinoJson;
@@ -1,89 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#ifdef ARDUINO // assume this is an embedded platform
// store using float instead of double to reduce the memory usage (issue #134)
#ifndef ARDUINOJSON_USE_DOUBLE
#define ARDUINOJSON_USE_DOUBLE 0
#endif
// store using a long because it usually match the size of a float.
#ifndef ARDUINOJSON_USE_LONG_LONG
#define ARDUINOJSON_USE_LONG_LONG 0
#endif
#ifndef ARDUINOJSON_USE_INT64
#define ARDUINOJSON_USE_INT64 0
#endif
// arduino has its own implementation of String to replace std::string
#ifndef ARDUINOJSON_USE_ARDUINO_STRING
#define ARDUINOJSON_USE_ARDUINO_STRING 1
#endif
// arduino doesn't support STL stream
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
#define ARDUINOJSON_ENABLE_STD_STREAM 0
#endif
#ifndef ARDUINOJSON_ENABLE_ALIGNMENT
#ifdef ARDUINO_ARCH_AVR
// alignment isn't needed for 8-bit AVR
#define ARDUINOJSON_ENABLE_ALIGNMENT 0
#else
// but must processor needs pointer to be align on word size
#define ARDUINOJSON_ENABLE_ALIGNMENT 1
#endif
#endif
#else // assume this is a computer
// on a computer we have plenty of memory so we can use doubles
#ifndef ARDUINOJSON_USE_DOUBLE
#define ARDUINOJSON_USE_DOUBLE 1
#endif
// use long long when available
#ifndef ARDUINOJSON_USE_LONG_LONG
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
#define ARDUINOJSON_USE_LONG_LONG 1
#else
#define ARDUINOJSON_USE_LONG_LONG 0
#endif
#endif
// use _int64 on old versions of Visual Studio
#ifndef ARDUINOJSON_USE_INT64
#if defined(_MSC_VER) && _MSC_VER <= 1700
#define ARDUINOJSON_USE_INT64 1
#else
#define ARDUINOJSON_USE_INT64 0
#endif
#endif
// on a computer, we can use std::string
#ifndef ARDUINOJSON_USE_ARDUINO_STRING
#define ARDUINOJSON_USE_ARDUINO_STRING 0
#endif
// on a computer, we can assume that the STL is there
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
#define ARDUINOJSON_ENABLE_STD_STREAM 1
#endif
#ifndef ARDUINOJSON_ENABLE_ALIGNMENT
// even if not required, most cpu's are faster with aligned pointers
#define ARDUINOJSON_ENABLE_ALIGNMENT 1
#endif
#endif
#if ARDUINOJSON_USE_LONG_LONG && ARDUINOJSON_USE_INT64
#error ARDUINOJSON_USE_LONG_LONG and ARDUINOJSON_USE_INT64 cannot be set together
#endif
@@ -1,18 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Internals/BlockJsonBuffer.hpp"
namespace ArduinoJson {
// Implements a JsonBuffer with dynamic memory allocation.
// You are strongly encouraged to consider using StaticJsonBuffer which is much
// more suitable for embedded systems.
typedef Internals::BlockJsonBuffer<Internals::DefaultAllocator>
DynamicJsonBuffer;
}
@@ -1,56 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
namespace ArduinoJson {
namespace Internals {
inline const char *skipCStyleComment(const char *ptr) {
ptr += 2;
for (;;) {
if (ptr[0] == '\0') return ptr;
if (ptr[0] == '*' && ptr[1] == '/') return ptr + 2;
ptr++;
}
}
inline const char *skipCppStyleComment(const char *ptr) {
ptr += 2;
for (;;) {
if (ptr[0] == '\0' || ptr[0] == '\n') return ptr;
ptr++;
}
}
inline const char *skipSpacesAndComments(const char *ptr) {
for (;;) {
switch (ptr[0]) {
case ' ':
case '\t':
case '\r':
case '\n':
ptr++;
continue;
case '/':
switch (ptr[1]) {
case '*':
ptr = skipCStyleComment(ptr);
break;
case '/':
ptr = skipCppStyleComment(ptr);
break;
default:
return ptr;
}
break;
default:
return ptr;
}
}
}
}
}
@@ -1,21 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "../Print.hpp"
namespace ArduinoJson {
namespace Internals {
// A dummy Print implementation used in JsonPrintable::measureLength()
class DummyPrint : public Print {
public:
virtual size_t write(uint8_t) { return 1; }
};
}
}
@@ -1,33 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "../Print.hpp"
#include "../String.hpp"
namespace ArduinoJson {
namespace Internals {
// A Print implementation that allows to write in a String
class DynamicStringBuilder : public Print {
public:
DynamicStringBuilder(String &str) : _str(str) {}
virtual size_t write(uint8_t c) {
// Need to cast to char, otherwise String will print a number (issue #120)
_str += static_cast<char>(c);
return 1;
}
private:
DynamicStringBuilder &operator=(const DynamicStringBuilder &);
String &_str;
};
}
}
@@ -1,66 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "../JsonBuffer.hpp"
#include "../JsonVariant.hpp"
namespace ArduinoJson {
namespace Internals {
// Parse JSON string to create JsonArrays and JsonObjects
// This internal class is not indended to be used directly.
// Instead, use JsonBuffer.parseArray() or .parseObject()
class JsonParser {
public:
JsonParser(JsonBuffer *buffer, char *json, uint8_t nestingLimit)
: _buffer(buffer),
_readPtr(json ? json : ""),
_writePtr(json),
_nestingLimit(nestingLimit) {}
JsonArray &parseArray();
JsonObject &parseObject();
JsonVariant parseVariant() {
JsonVariant result;
parseAnythingTo(&result);
return result;
}
private:
bool skip(char charToSkip);
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) {
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 == '.';
}
static inline bool isQuote(char c) {
return c == '\'' || c == '\"';
}
JsonBuffer *_buffer;
const char *_readPtr;
char *_writePtr;
uint8_t _nestingLimit;
};
}
}
@@ -1,191 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Comments.hpp"
#include "JsonParser.hpp"
inline bool ArduinoJson::Internals::JsonParser::skip(char charToSkip) {
const char *ptr = skipSpacesAndComments(_readPtr);
if (*ptr != charToSkip) return false;
ptr++;
_readPtr = skipSpacesAndComments(ptr);
return true;
}
inline bool ArduinoJson::Internals::JsonParser::parseAnythingTo(
JsonVariant *destination) {
if (_nestingLimit == 0) return false;
_nestingLimit--;
bool success = parseAnythingToUnsafe(destination);
_nestingLimit++;
return success;
}
inline bool ArduinoJson::Internals::JsonParser::parseAnythingToUnsafe(
JsonVariant *destination) {
_readPtr = skipSpacesAndComments(_readPtr);
switch (*_readPtr) {
case '[':
return parseArrayTo(destination);
case '{':
return parseObjectTo(destination);
default:
return parseStringTo(destination);
}
}
inline ArduinoJson::JsonArray &
ArduinoJson::Internals::JsonParser::parseArray() {
// Create an empty array
JsonArray &array = _buffer->createArray();
// Check opening braket
if (!skip('[')) goto ERROR_MISSING_BRACKET;
if (skip(']')) goto SUCCESS_EMPTY_ARRAY;
// Read each value
for (;;) {
// 1 - Parse value
JsonVariant value;
if (!parseAnythingTo(&value)) goto ERROR_INVALID_VALUE;
if (!array.add(value)) goto ERROR_NO_MEMORY;
// 2 - More values?
if (skip(']')) goto SUCCES_NON_EMPTY_ARRAY;
if (!skip(',')) goto ERROR_MISSING_COMMA;
}
SUCCESS_EMPTY_ARRAY:
SUCCES_NON_EMPTY_ARRAY:
return array;
ERROR_INVALID_VALUE:
ERROR_MISSING_BRACKET:
ERROR_MISSING_COMMA:
ERROR_NO_MEMORY:
return JsonArray::invalid();
}
inline bool ArduinoJson::Internals::JsonParser::parseArrayTo(
JsonVariant *destination) {
JsonArray &array = parseArray();
if (!array.success()) return false;
*destination = array;
return true;
}
inline ArduinoJson::JsonObject &
ArduinoJson::Internals::JsonParser::parseObject() {
// Create an empty object
JsonObject &object = _buffer->createObject();
// Check opening brace
if (!skip('{')) goto ERROR_MISSING_BRACE;
if (skip('}')) goto SUCCESS_EMPTY_OBJECT;
// Read each key value pair
for (;;) {
// 1 - Parse key
const char *key = parseString();
if (!key) goto ERROR_INVALID_KEY;
if (!skip(':')) goto ERROR_MISSING_COLON;
// 2 - Parse value
JsonVariant value;
if (!parseAnythingTo(&value)) goto ERROR_INVALID_VALUE;
if (!object.set(key, value)) goto ERROR_NO_MEMORY;
// 3 - More keys/values?
if (skip('}')) goto SUCCESS_NON_EMPTY_OBJECT;
if (!skip(',')) goto ERROR_MISSING_COMMA;
}
SUCCESS_EMPTY_OBJECT:
SUCCESS_NON_EMPTY_OBJECT:
return object;
ERROR_INVALID_KEY:
ERROR_INVALID_VALUE:
ERROR_MISSING_BRACE:
ERROR_MISSING_COLON:
ERROR_MISSING_COMMA:
ERROR_NO_MEMORY:
return JsonObject::invalid();
}
inline bool ArduinoJson::Internals::JsonParser::parseObjectTo(
JsonVariant *destination) {
JsonObject &object = parseObject();
if (!object.success()) return false;
*destination = object;
return true;
}
inline const char *ArduinoJson::Internals::JsonParser::parseString() {
const char *readPtr = _readPtr;
char *writePtr = _writePtr;
char c = *readPtr;
if (isQuote(c)) { // quotes
char stopChar = c;
for (;;) {
c = *++readPtr;
if (c == '\0') break;
if (c == stopChar) {
readPtr++;
break;
}
if (c == '\\') {
// replace char
c = Encoding::unescapeChar(*++readPtr);
if (c == '\0') break;
}
*writePtr++ = c;
}
} else { // no quotes
for (;;) {
if (!isLetterOrNumber(c)) break;
*writePtr++ = c;
c = *++readPtr;
}
}
// end the string here
*writePtr++ = '\0';
const char *startPtr = _writePtr;
// update end ptr
_readPtr = readPtr;
_writePtr = writePtr;
// return pointer to unquoted string
return startPtr;
}
inline bool ArduinoJson::Internals::JsonParser::parseStringTo(
JsonVariant *destination) {
bool hasQuotes = isQuote(_readPtr[0]);
const char *value = parseString();
if (value == NULL) return false;
if (hasQuotes) {
*destination = value;
} else {
*destination = RawJson(value);
}
return true;
}
@@ -1,39 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
namespace ArduinoJson {
class JsonArray;
class JsonObject;
namespace Internals {
// Enumerated type to know the current type of a JsonVariant.
// The value determines which member of JsonVariantContent is used.
enum JsonVariantType {
JSON_UNDEFINED, // JsonVariant has not been initialized
JSON_UNPARSED, // JsonVariant contains an unparsed string
JSON_STRING, // JsonVariant stores a const char*
JSON_BOOLEAN, // JsonVariant stores a bool
JSON_POSITIVE_INTEGER, // JsonVariant stores an unsigned long
JSON_NEGATIVE_INTEGER, // JsonVariant stores an unsigned long that must be
// negated
JSON_ARRAY, // JsonVariant stores a pointer to a JsonArray
JSON_OBJECT, // JsonVariant stores a pointer to a JsonObject
// The following values are reserved for float values
// Multiple values are used for double, depending on the number of decimal
// digits that must be printed in the JSON output.
// This little trick allow to save one extra member in JsonVariant
JSON_FLOAT_0_DECIMALS
// JSON_FLOAT_1_DECIMAL
// JSON_FLOAT_2_DECIMALS
// ...
};
}
}
@@ -1,184 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "../Polyfills/attributes.hpp"
#include "../Polyfills/math.hpp"
#include "../Polyfills/normalize.hpp"
#include "../Print.hpp"
#include "Encoding.hpp"
#include "JsonFloat.hpp"
#include "JsonInteger.hpp"
namespace ArduinoJson {
namespace Internals {
// Writes the JSON tokens to a Print implementation
// This class is used by:
// - JsonArray::writeTo()
// - JsonObject::writeTo()
// - JsonVariant::writeTo()
// Its derived by PrettyJsonWriter that overrides some members to add
// indentation.
class JsonWriter {
public:
explicit JsonWriter(Print &sink) : _sink(sink), _length(0) {}
// Returns the number of bytes sent to the Print implementation.
// This is very handy for implementations of printTo() that must return the
// number of bytes written.
size_t bytesWritten() const {
return _length;
}
void beginArray() {
writeRaw('[');
}
void endArray() {
writeRaw(']');
}
void beginObject() {
writeRaw('{');
}
void endObject() {
writeRaw('}');
}
void writeColon() {
writeRaw(':');
}
void writeComma() {
writeRaw(',');
}
void writeBoolean(bool value) {
writeRaw(value ? "true" : "false");
}
void writeString(const char *value) {
if (!value) {
writeRaw("null");
} else {
writeRaw('\"');
while (*value) writeChar(*value++);
writeRaw('\"');
}
}
void writeChar(char c) {
char specialChar = Encoding::escapeChar(c);
if (specialChar) {
writeRaw('\\');
writeRaw(specialChar);
} else {
writeRaw(c);
}
}
void writeFloat(JsonFloat value, uint8_t digits = 2) {
if (Polyfills::isNaN(value)) return writeRaw("NaN");
if (value < 0.0) {
writeRaw('-');
value = -value;
}
if (Polyfills::isInfinity(value)) return writeRaw("Infinity");
short powersOf10;
if (value > 1000 || value < 0.001) {
powersOf10 = Polyfills::normalize(value);
} else {
powersOf10 = 0;
}
// Round up last digit (so that print(1.999, 2) prints as "2.00")
value += getRoundingBias(digits);
// Extract the integer part of the value and print it
JsonUInt int_part = static_cast<JsonUInt>(value);
JsonFloat remainder = value - static_cast<JsonFloat>(int_part);
writeInteger(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
writeRaw('.');
}
// Extract digits from the remainder one at a time
while (digits-- > 0) {
// Extract digit
remainder *= 10.0;
char currentDigit = char(remainder);
remainder -= static_cast<JsonFloat>(currentDigit);
// Print
writeRaw(char('0' + currentDigit));
}
if (powersOf10 < 0) {
writeRaw("e-");
writeInteger(-powersOf10);
}
if (powersOf10 > 0) {
writeRaw('e');
writeInteger(powersOf10);
}
}
void writeInteger(JsonUInt value) {
char buffer[22];
char *ptr = buffer + sizeof(buffer) - 1;
*ptr = 0;
do {
*--ptr = static_cast<char>(value % 10 + '0');
value /= 10;
} while (value);
writeRaw(ptr);
}
void writeRaw(const char *s) {
_length += _sink.print(s);
}
void writeRaw(char c) {
_length += _sink.write(c);
}
protected:
Print &_sink;
size_t _length;
private:
JsonWriter &operator=(const JsonWriter &); // cannot be assigned
static JsonFloat getLastDigit(uint8_t digits) {
// Designed as a compromise between code size and speed
switch (digits) {
case 0:
return 1e-0;
case 1:
return 1e-1;
case 2:
return 1e-2;
case 3:
return 1e-3;
default:
return getLastDigit(uint8_t(digits - 4)) * 1e-4;
}
}
FORCE_INLINE static JsonFloat getRoundingBias(uint8_t digits) {
return 0.5 * getLastDigit(digits);
}
};
}
}
@@ -1,66 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include <stdlib.h>
namespace ArduinoJson {
namespace Internals {
template <typename TFloat>
TFloat parse(const char *);
template <>
inline float parse<float>(const char *s) {
return static_cast<float>(strtod(s, NULL));
}
template <>
inline double parse<double>(const char *s) {
return strtod(s, NULL);
}
template <>
inline long parse<long>(const char *s) {
return strtol(s, NULL, 10);
}
template <>
inline unsigned long parse<unsigned long>(const char *s) {
return strtoul(s, NULL, 10);
}
template <>
inline int parse<int>(const char *s) {
return atoi(s);
}
#if ARDUINOJSON_USE_LONG_LONG
template <>
inline long long parse<long long>(const char *s) {
return strtoll(s, NULL, 10);
}
template <>
inline unsigned long long parse<unsigned long long>(const char *s) {
return strtoull(s, NULL, 10);
}
#endif
#if ARDUINOJSON_USE_INT64
template <>
inline __int64 parse<__int64>(const char *s) {
return _strtoi64(s, NULL, 10);
}
template <>
inline unsigned __int64 parse<unsigned __int64>(const char *s) {
return _strtoui64(s, NULL, 10);
}
#endif
}
}
@@ -1,35 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
namespace ArduinoJson {
namespace Internals {
// A type that is meant to be used by reference only (JsonArray and JsonObject)
class ReferenceType {
public:
bool operator==(const ReferenceType& other) const {
// two JsonArray are equal if they are the same instance
// (we don't compare the content)
return this == &other;
}
bool operator!=(const ReferenceType& other) const { return this != &other; }
protected:
ReferenceType() {}
private:
// copy constructor is private
ReferenceType(const ReferenceType&);
// copy operator is private
ReferenceType& operator=(const ReferenceType&);
};
}
}
@@ -1,37 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "../Print.hpp"
namespace ArduinoJson {
namespace Internals {
// A Print implementation that allows to write in a char[]
class StaticStringBuilder : public Print {
public:
StaticStringBuilder(char *buf, size_t size)
: buffer(buf), capacity(size - 1), length(0) {
buffer[0] = '\0';
}
virtual size_t write(uint8_t c) {
if (length >= capacity) return 0;
buffer[length++] = c;
buffer[length] = '\0';
return 1;
}
private:
char *buffer;
size_t capacity;
size_t length;
};
}
}
@@ -1,268 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Internals/JsonBufferAllocated.hpp"
#include "Internals/JsonPrintable.hpp"
#include "Internals/List.hpp"
#include "Internals/ReferenceType.hpp"
#include "JsonVariant.hpp"
#include "TypeTraits/EnableIf.hpp"
#include "TypeTraits/IsFloatingPoint.hpp"
#include "TypeTraits/IsReference.hpp"
#include "TypeTraits/IsSame.hpp"
// Returns the size (in bytes) of an array with n elements.
// Can be very handy to determine the size of a StaticJsonBuffer.
#define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \
(sizeof(JsonArray) + (NUMBER_OF_ELEMENTS) * sizeof(JsonArray::node_type))
namespace ArduinoJson {
// Forward declarations
class JsonObject;
class JsonBuffer;
class JsonArraySubscript;
// An array of JsonVariant.
//
// The constructor is private, instances must be created via
// JsonBuffer::createArray() or JsonBuffer::parseArray().
// A JsonArray can be serialized to a JSON string via JsonArray::printTo().
// It can also be deserialized from a JSON string via JsonBuffer::parseArray().
class JsonArray : public Internals::JsonPrintable<JsonArray>,
public Internals::ReferenceType,
public Internals::List<JsonVariant>,
public Internals::JsonBufferAllocated {
public:
// A meta-function that returns true if type T can be used in
// JsonArray::set()
template <typename T>
struct CanSet {
static const bool value = JsonVariant::IsConstructibleFrom<T>::value ||
TypeTraits::IsSame<T, String &>::value ||
TypeTraits::IsSame<T, const String &>::value;
};
// Create an empty JsonArray attached to the specified JsonBuffer.
// You should not call this constructor directly.
// Instead, use JsonBuffer::createArray() or JsonBuffer::parseArray().
explicit JsonArray(JsonBuffer *buffer)
: Internals::List<JsonVariant>(buffer) {}
// Gets the value at the specified index
JsonVariant operator[](size_t index) const {
return get(index);
}
// Gets or sets the value at specified index
JsonArraySubscript operator[](size_t index);
// Adds the specified value at the end of the array.
//
// bool add(bool);
// bool add(char);
// bool add(long);
// bool add(int);
// bool add(short);
// bool add(float value);
// bool add(double value);
// bool add(const char*);
template <typename T>
bool add(
T value,
typename TypeTraits::EnableIf<
CanSet<T>::value && !TypeTraits::IsReference<T>::value>::type * = 0) {
return addNode<T>(value);
}
// bool add(const String&)
// bool add(const JsonVariant&);
// bool add(JsonArray&);
// bool add(JsonObject&);
template <typename T>
bool add(const T &value,
typename TypeTraits::EnableIf<CanSet<T &>::value>::type * = 0) {
return addNode<T &>(const_cast<T &>(value));
}
// bool add(float value, uint8_t decimals);
// bool add(double value, uint8_t decimals);
template <typename T>
bool add(T value, uint8_t decimals,
typename TypeTraits::EnableIf<
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
return addNode<JsonVariant>(JsonVariant(value, decimals));
}
// Sets the value at specified index.
//
// bool set(size_t index, bool value);
// bool set(size_t index, long value);
// bool set(size_t index, int value);
// bool set(size_t index, short value);
template <typename T>
bool set(
size_t index, T value,
typename TypeTraits::EnableIf<
CanSet<T>::value && !TypeTraits::IsReference<T>::value>::type * = 0) {
return setNodeAt<T>(index, value);
}
// bool set(size_t index, const String&)
// bool set(size_t index, const JsonVariant&);
// bool set(size_t index, JsonArray&);
// bool set(size_t index, JsonObject&);
template <typename T>
bool set(size_t index, const T &value,
typename TypeTraits::EnableIf<CanSet<T &>::value>::type * = 0) {
return setNodeAt<T &>(index, const_cast<T &>(value));
}
// bool set(size_t index, float value, uint8_t decimals = 2);
// bool set(size_t index, double value, uint8_t decimals = 2);
template <typename T>
bool set(size_t index, T value, uint8_t decimals,
typename TypeTraits::EnableIf<
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
return setNodeAt<const JsonVariant &>(index, JsonVariant(value, decimals));
}
// Gets the value at the specified index.
JsonVariant get(size_t index) const {
node_type *node = getNodeAt(index);
return node ? node->content : JsonVariant();
}
// Gets the value at the specified index.
template <typename T>
typename Internals::JsonVariantAs<T>::type get(size_t index) const {
node_type *node = getNodeAt(index);
return node ? node->content.as<T>() : JsonVariant::defaultValue<T>();
}
// Check the type of the value at specified index.
template <typename T>
bool is(size_t index) const {
node_type *node = getNodeAt(index);
return node ? node->content.is<T>() : false;
}
// Creates a JsonArray and adds a reference at the end of the array.
// It's a shortcut for JsonBuffer::createArray() and JsonArray::add()
JsonArray &createNestedArray();
// Creates a JsonObject and adds a reference at the end of the array.
// It's a shortcut for JsonBuffer::createObject() and JsonArray::add()
JsonObject &createNestedObject();
// Removes element at specified index.
void removeAt(size_t index) {
removeNode(getNodeAt(index));
}
// Returns a reference an invalid JsonArray.
// This object is meant to replace a NULL pointer.
// This is used when memory allocation or JSON parsing fail.
static JsonArray &invalid() {
static JsonArray instance(NULL);
return instance;
}
// Serialize the array to the specified JsonWriter.
void writeTo(Internals::JsonWriter &writer) const {
writer.beginArray();
const node_type *child = _firstNode;
while (child) {
child->content.writeTo(writer);
child = child->next;
if (!child) break;
writer.writeComma();
}
writer.endArray();
}
// Imports a 1D array
template <typename T, size_t N>
bool copyFrom(T(&array)[N]) {
return copyFrom(array, N);
}
// Imports a 1D array
template <typename T>
bool copyFrom(T *array, size_t len) {
bool ok = true;
for (size_t i = 0; i < len; i++) {
ok &= add(array[i]);
}
return ok;
}
// Imports a 2D array
template <typename T, size_t N1, size_t N2>
bool copyFrom(T(&array)[N1][N2]) {
bool ok = true;
for (size_t i = 0; i < N1; i++) {
JsonArray &nestedArray = createNestedArray();
for (size_t j = 0; j < N2; j++) {
ok &= nestedArray.add(array[i][j]);
}
}
return ok;
}
// Exports a 1D array
template <typename T, size_t N>
size_t copyTo(T(&array)[N]) const {
return copyTo(array, N);
}
// Exports a 1D array
template <typename T>
size_t copyTo(T *array, size_t len) const {
size_t i = 0;
for (const_iterator it = begin(); it != end() && i < len; ++it)
array[i++] = *it;
return i;
}
// Exports a 2D array
template <typename T, size_t N1, size_t N2>
void copyTo(T(&array)[N1][N2]) const {
size_t i = 0;
for (const_iterator it = begin(); it != end() && i < N1; ++it) {
it->asArray().copyTo(array[i++]);
}
}
private:
node_type *getNodeAt(size_t index) const {
node_type *node = _firstNode;
while (node && index--) node = node->next;
return node;
}
template <typename TValue>
bool setNodeAt(size_t index, TValue value) {
node_type *node = getNodeAt(index);
return node != NULL && setNodeValue<TValue>(node, value);
}
template <typename TValue>
bool addNode(TValue value) {
node_type *node = addNewNode();
return node != NULL && setNodeValue<TValue>(node, value);
}
template <typename T>
bool setNodeValue(node_type *node, T value) {
node->content = value;
return true;
}
};
}
@@ -1,62 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "JsonArray.hpp"
#include "JsonObject.hpp"
#include "JsonArraySubscript.hpp"
namespace ArduinoJson {
template <>
inline bool JsonArray::setNodeValue(node_type *node, String &value) {
const char *copy = _buffer->strdup(value);
if (!copy) return false;
node->content = copy;
return true;
}
template <>
inline JsonArray &JsonVariant::defaultValue<JsonArray>() {
return JsonArray::invalid();
}
template <>
inline JsonArray &JsonVariant::defaultValue<JsonArray &>() {
return JsonArray::invalid();
}
template <>
inline const JsonArray &JsonVariant::defaultValue<const JsonArray>() {
return JsonArray::invalid();
}
template <>
inline const JsonArray &JsonVariant::defaultValue<const JsonArray &>() {
return JsonArray::invalid();
}
inline JsonArray &JsonVariant::asArray() const {
if (_type == Internals::JSON_ARRAY) return *_content.asArray;
return JsonArray::invalid();
}
inline JsonArray &JsonArray::createNestedArray() {
if (!_buffer) return JsonArray::invalid();
JsonArray &array = _buffer->createArray();
add(array);
return array;
}
inline JsonArray &JsonObject::createNestedArray(JsonObjectKey key) {
if (!_buffer) return JsonArray::invalid();
JsonArray &array = _buffer->createArray();
setNodeAt<const JsonVariant &>(key, array);
return array;
}
}
@@ -1,98 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Configuration.hpp"
#include "JsonVariantBase.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4522)
#endif
namespace ArduinoJson {
class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
public:
FORCE_INLINE JsonArraySubscript(JsonArray& array, size_t index)
: _array(array), _index(index) {}
JsonArraySubscript& operator=(const JsonArraySubscript& src) {
_array.set<const JsonVariant&>(_index, src);
return *this;
}
template <typename T>
typename TypeTraits::EnableIf<JsonArray::CanSet<T&>::value,
JsonArraySubscript>::type&
operator=(const T& src) {
_array.set<T&>(_index, const_cast<T&>(src));
return *this;
}
template <typename T>
typename TypeTraits::EnableIf<JsonArray::CanSet<T>::value,
JsonArraySubscript>::type&
operator=(T src) {
_array.set<T>(_index, src);
return *this;
}
FORCE_INLINE bool success() const {
return _index < _array.size();
}
FORCE_INLINE operator JsonVariant() const {
return _array.get(_index);
}
template <typename T>
FORCE_INLINE typename Internals::JsonVariantAs<T>::type as() const {
return _array.get<T>(_index);
}
template <typename T>
FORCE_INLINE bool is() const {
return _array.is<T>(_index);
}
void writeTo(Internals::JsonWriter& writer) const {
_array.get(_index).writeTo(writer);
}
template <typename TValue>
void set(TValue value) {
_array.set(_index, value);
}
private:
JsonArray& _array;
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);
}
template <typename TImplem>
inline const JsonArraySubscript JsonVariantBase<TImplem>::operator[](
int index) const {
return asArray()[index];
}
} // namespace ArduinoJson
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@@ -1,163 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include <stddef.h> // for size_t
#include <stdint.h> // for uint8_t
#include <string.h>
#include "JsonVariant.hpp"
#include "String.hpp"
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
#elif defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
namespace ArduinoJson {
class JsonArray;
class JsonObject;
// Entry point for using the library.
//
// Handle the memory management (done in derived classes) and calls the parser.
// This abstract class is implemented by StaticJsonBuffer which implements a
// fixed memory allocation.
class JsonBuffer {
public:
// CAUTION: NO VIRTUAL DESTRUCTOR!
// If we add a virtual constructor the Arduino compiler will add malloc() and
// free() to the binary, adding 706 useless bytes.
// virtual ~JsonBuffer() {}
// Allocates an empty JsonArray.
//
// Returns a reference to the new JsonArray or JsonArray::invalid() if the
// allocation fails.
JsonArray &createArray();
// Allocates an empty JsonObject.
//
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
// allocation fails.
JsonObject &createObject();
// Allocates and populate a JsonArray from a JSON string.
//
// The First argument is a pointer to the JSON string, the memory must be
// writable
// because the parser will insert null-terminators and replace escaped chars.
//
// The second argument set the nesting limit (see comment on DEFAULT_LIMIT)
//
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
// allocation fails.
JsonArray &parseArray(char *json, uint8_t nestingLimit = DEFAULT_LIMIT);
// Same with a const char*.
// With this overload, the JsonBuffer will make a copy of the string
JsonArray &parseArray(const char *json, uint8_t nesting = DEFAULT_LIMIT) {
return parseArray(strdup(json), nesting);
}
// Same as above with a String class
JsonArray &parseArray(const String &json, uint8_t nesting = DEFAULT_LIMIT) {
return parseArray(json.c_str(), nesting);
}
// Allocates and populate a JsonObject from a JSON string.
//
// The First argument is a pointer to the JSON string, the memory must be
// writable
// because the parser will insert null-terminators and replace escaped chars.
//
// The second argument set the nesting limit (see comment on DEFAULT_LIMIT)
//
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
// allocation fails.
JsonObject &parseObject(char *json, uint8_t nestingLimit = DEFAULT_LIMIT);
// Same with a const char*.
// With this overload, the JsonBuffer will make a copy of the string
JsonObject &parseObject(const char *json, uint8_t nesting = DEFAULT_LIMIT) {
return parseObject(strdup(json), nesting);
}
// Same as above with a String class
JsonObject &parseObject(const String &json, uint8_t nesting = DEFAULT_LIMIT) {
return parseObject(json.c_str(), nesting);
}
// Generalized version of parseArray() and parseObject(), also works for
// integral types.
JsonVariant parse(char *json, uint8_t nestingLimit = DEFAULT_LIMIT);
// Same with a const char*.
// With this overload, the JsonBuffer will make a copy of the string
JsonVariant parse(const char *json, uint8_t nesting = DEFAULT_LIMIT) {
return parse(strdup(json), nesting);
}
// Same as above with a String class
JsonVariant parse(const String &json, uint8_t nesting = DEFAULT_LIMIT) {
return parse(json.c_str(), nesting);
}
// Duplicate a string
char *strdup(const char *src) {
return src ? strdup(src, strlen(src)) : NULL;
}
char *strdup(const String &src) { return strdup(src.c_str(), src.length()); }
// Allocates n bytes in the JsonBuffer.
// Return a pointer to the allocated memory or NULL if allocation fails.
virtual void *alloc(size_t size) = 0;
protected:
// Preserve aligment if nessary
static FORCE_INLINE size_t round_size_up(size_t bytes) {
#if ARDUINOJSON_ENABLE_ALIGNMENT
const size_t x = sizeof(void *) - 1;
return (bytes + x) & ~x;
#else
return bytes;
#endif
}
private:
char *strdup(const char *, size_t);
// Default value of nesting limit of parseArray() and parseObject().
//
// The nesting limit is a contain on the level of nesting allowed in the
// JSON
// string.
// If set to 0, only a flat array or objects can be parsed.
// If set to 1, the object can contain nested arrays or objects but only 1
// level deep.
// And bigger values will allow more level of nesting.
//
// The purpose of this feature is to prevent stack overflow that could
// lead to
// a security risk.
static const uint8_t DEFAULT_LIMIT = 10;
};
}
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif
#endif
@@ -1,46 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Internals/JsonParser.hpp"
inline ArduinoJson::JsonArray &ArduinoJson::JsonBuffer::createArray() {
JsonArray *ptr = new (this) JsonArray(this);
return ptr ? *ptr : JsonArray::invalid();
}
inline ArduinoJson::JsonObject &ArduinoJson::JsonBuffer::createObject() {
JsonObject *ptr = new (this) JsonObject(this);
return ptr ? *ptr : JsonObject::invalid();
}
inline ArduinoJson::JsonArray &ArduinoJson::JsonBuffer::parseArray(
char *json, uint8_t nestingLimit) {
Internals::JsonParser parser(this, json, nestingLimit);
return parser.parseArray();
}
inline ArduinoJson::JsonObject &ArduinoJson::JsonBuffer::parseObject(
char *json, uint8_t nestingLimit) {
Internals::JsonParser parser(this, json, nestingLimit);
return parser.parseObject();
}
inline ArduinoJson::JsonVariant ArduinoJson::JsonBuffer::parse(
char *json, uint8_t nestingLimit) {
Internals::JsonParser parser(this, json, nestingLimit);
return parser.parseVariant();
}
inline char *ArduinoJson::JsonBuffer::strdup(const char *source,
size_t length) {
size_t size = length + 1;
char *dest = static_cast<char *>(alloc(size));
if (dest != NULL) memcpy(dest, source, size);
return dest;
}
@@ -1,201 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "String.hpp"
#include "Internals/JsonBufferAllocated.hpp"
#include "Internals/JsonPrintable.hpp"
#include "Internals/List.hpp"
#include "Internals/ReferenceType.hpp"
#include "JsonPair.hpp"
#include "TypeTraits/EnableIf.hpp"
#include "TypeTraits/IsFloatingPoint.hpp"
#include "TypeTraits/IsReference.hpp"
#include "TypeTraits/IsSame.hpp"
// Returns the size (in bytes) of an object with n elements.
// Can be very handy to determine the size of a StaticJsonBuffer.
#define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \
(sizeof(JsonObject) + (NUMBER_OF_ELEMENTS) * sizeof(JsonObject::node_type))
namespace ArduinoJson {
// Forward declarations
class JsonArray;
class JsonBuffer;
// A dictionary of JsonVariant indexed by string (char*)
//
// The constructor is private, instances must be created via
// JsonBuffer::createObject() or JsonBuffer::parseObject().
// A JsonObject can be serialized to a JSON string via JsonObject::printTo().
// It can also be deserialized from a JSON string via JsonBuffer::parseObject().
class JsonObject : public Internals::JsonPrintable<JsonObject>,
public Internals::ReferenceType,
public Internals::List<JsonPair>,
public Internals::JsonBufferAllocated {
public:
// A meta-function that returns true if type T can be used in
// JsonObject::set()
template <typename T>
struct CanSet {
static const bool value = JsonVariant::IsConstructibleFrom<T>::value ||
TypeTraits::IsSame<T, String&>::value ||
TypeTraits::IsSame<T, const String&>::value;
};
// 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) : Internals::List<JsonPair>(buffer) {}
// Gets or sets the value associated with the specified key.
JsonObjectSubscript<const char*> operator[](const char* key);
JsonObjectSubscript<const String&> operator[](const String& key);
// Gets the value associated with the specified key.
JsonVariant operator[](JsonObjectKey key) const {
return get(key);
}
// Sets the specified key with the specified value.
// bool set(TKey key, bool value);
// bool set(TKey key, char value);
// bool set(TKey key, long value);
// bool set(TKey key, int value);
// bool set(TKey key, short value);
// bool set(TKey key, float value);
// bool set(TKey key, double value);
// bool set(TKey key, const char* value);
// bool set(TKey key, RawJson value);
template <typename T>
bool set(
JsonObjectKey key, T value,
typename TypeTraits::EnableIf<
CanSet<T>::value && !TypeTraits::IsReference<T>::value>::type* = 0) {
return setNodeAt<T>(key, value);
}
// bool set(Key, String&);
// bool set(Key, JsonArray&);
// bool set(Key, JsonObject&);
// bool set(Key, JsonVariant&);
template <typename T>
bool set(JsonObjectKey key, const T& value,
typename TypeTraits::EnableIf<CanSet<T&>::value>::type* = 0) {
return setNodeAt<T&>(key, const_cast<T&>(value));
}
// bool set(Key, float value, uint8_t decimals);
// bool set(Key, double value, uint8_t decimals);
template <typename TValue>
bool set(JsonObjectKey key, TValue value, uint8_t decimals,
typename TypeTraits::EnableIf<
TypeTraits::IsFloatingPoint<TValue>::value>::type* = 0) {
return setNodeAt<const JsonVariant&>(key, JsonVariant(value, decimals));
}
// Gets the value associated with the specified key.
JsonVariant get(JsonObjectKey key) const {
node_type* node = getNodeAt(key.c_str());
return node ? node->content.value : JsonVariant();
}
// Gets the value associated with the specified key.
template <typename T>
typename Internals::JsonVariantAs<T>::type get(JsonObjectKey key) const {
node_type* node = getNodeAt(key.c_str());
return node ? node->content.value.as<T>() : JsonVariant::defaultValue<T>();
}
// Checks the type of the value associated with the specified key.
template <typename T>
bool is(JsonObjectKey key) const {
node_type* node = getNodeAt(key.c_str());
return node ? node->content.value.is<T>() : false;
}
// Creates and adds a JsonArray.
// This is a shortcut for JsonBuffer::createArray() and JsonObject::add().
JsonArray& createNestedArray(JsonObjectKey key);
// Creates and adds a JsonObject.
// This is a shortcut for JsonBuffer::createObject() and JsonObject::add().
JsonObject& createNestedObject(JsonObjectKey key);
// Tells weither the specified key is present and associated with a value.
bool containsKey(JsonObjectKey key) const {
return getNodeAt(key.c_str()) != NULL;
}
// Removes the specified key and the associated value.
void remove(JsonObjectKey key) {
removeNode(getNodeAt(key.c_str()));
}
// Returns a reference an invalid JsonObject.
// This object is meant to replace a NULL pointer.
// This is used when memory allocation or JSON parsing fail.
static JsonObject& invalid() {
static JsonObject instance(NULL);
return instance;
}
// Serialize the object to the specified JsonWriter
void writeTo(Internals::JsonWriter& writer) const {
writer.beginObject();
const node_type* node = _firstNode;
while (node) {
writer.writeString(node->content.key);
writer.writeColon();
node->content.value.writeTo(writer);
node = node->next;
if (!node) break;
writer.writeComma();
}
writer.endObject();
}
private:
// Returns the list node that matches the specified key.
node_type* getNodeAt(const char* key) const {
for (node_type* node = _firstNode; node; node = node->next) {
if (!strcmp(node->content.key, key)) return node;
}
return NULL;
}
template <typename T>
bool setNodeAt(JsonObjectKey key, T value) {
node_type* node = getNodeAt(key.c_str());
if (!node) {
node = addNewNode();
if (!node || !setNodeKey(node, key)) return false;
}
return setNodeValue<T>(node, value);
}
bool setNodeKey(node_type* node, JsonObjectKey key) {
if (key.needs_copy()) {
node->content.key = _buffer->strdup(key.c_str());
if (node->content.key == NULL) return false;
} else {
node->content.key = key.c_str();
}
return true;
}
template <typename T>
bool setNodeValue(node_type* node, T value) {
node->content.value = value;
return true;
}
};
}
@@ -1,66 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "JsonArray.hpp"
#include "JsonObject.hpp"
#include "JsonObjectSubscript.hpp"
namespace ArduinoJson {
template <>
inline bool JsonObject::setNodeValue(node_type *node, String &value) {
node->content.value = _buffer->strdup(value);
return node->content.value;
}
template <>
inline bool JsonObject::setNodeValue(node_type *node, const String &value) {
node->content.value = _buffer->strdup(value);
return node->content.value;
}
template <>
inline const JsonObject &JsonVariant::defaultValue<const JsonObject &>() {
return JsonObject::invalid();
}
template <>
inline const JsonObject &JsonVariant::defaultValue<const JsonObject>() {
return JsonObject::invalid();
}
template <>
inline JsonObject &JsonVariant::defaultValue<JsonObject &>() {
return JsonObject::invalid();
}
template <>
inline JsonObject &JsonVariant::defaultValue<JsonObject>() {
return JsonObject::invalid();
}
inline JsonObject &JsonVariant::asObject() const {
if (_type == Internals::JSON_OBJECT) return *_content.asObject;
return JsonObject::invalid();
}
inline JsonObject &JsonObject::createNestedObject(JsonObjectKey key) {
if (!_buffer) return JsonObject::invalid();
JsonObject &array = _buffer->createObject();
setNodeAt<const JsonVariant &>(key, array);
return array;
}
inline JsonObject &JsonArray::createNestedObject() {
if (!_buffer) return JsonObject::invalid();
JsonObject &object = _buffer->createObject();
add(object);
return object;
}
}
@@ -1,27 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "String.hpp"
namespace ArduinoJson {
// Represents a key in a JsonObject
class JsonObjectKey {
public:
JsonObjectKey(const char* key) : _value(key), _needs_copy(false) {}
JsonObjectKey(const String& key) : _value(key.c_str()), _needs_copy(true) {}
const char* c_str() const { return _value; }
bool needs_copy() const { return _needs_copy; }
private:
const char* _value;
bool _needs_copy;
};
}
@@ -1,127 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Configuration.hpp"
#include "JsonVariantBase.hpp"
#include "TypeTraits/EnableIf.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4522)
#endif
namespace ArduinoJson {
template <typename TKey>
class JsonObjectSubscript : public JsonVariantBase<JsonObjectSubscript<TKey> > {
public:
FORCE_INLINE JsonObjectSubscript(JsonObject& object, TKey key)
: _object(object), _key(key) {}
JsonObjectSubscript<TKey>& operator=(const JsonObjectSubscript<TKey>& src) {
_object.set<const JsonVariant&>(_key, src);
return *this;
}
template <typename T>
typename TypeTraits::EnableIf<JsonObject::CanSet<T&>::value,
JsonObjectSubscript<TKey> >::type&
operator=(const T& src) {
_object.set<T&>(_key, const_cast<T&>(src));
return *this;
}
template <typename T>
typename TypeTraits::EnableIf<JsonObject::CanSet<T>::value,
JsonObjectSubscript<TKey> >::type&
operator=(T src) {
_object.set<T>(_key, src);
return *this;
}
FORCE_INLINE bool success() const {
return _object.containsKey(_key);
}
FORCE_INLINE operator JsonVariant() const {
return _object.get(_key);
}
template <typename TValue>
FORCE_INLINE typename Internals::JsonVariantAs<TValue>::type as() const {
return _object.get<TValue>(_key);
}
template <typename TValue>
FORCE_INLINE bool is() const {
return _object.is<TValue>(_key);
}
template <typename TValue>
FORCE_INLINE bool set(TValue value) {
return _object.set<TValue>(_key, value);
}
template <typename TValue>
FORCE_INLINE bool set(TValue value, uint8_t decimals) {
return _object.set(_key, value, decimals);
}
FORCE_INLINE JsonVariant get() {
return _object.get(_key);
}
void writeTo(Internals::JsonWriter& writer) const {
_object.get(_key).writeTo(writer);
}
private:
JsonObject& _object;
TKey _key;
};
#if ARDUINOJSON_ENABLE_STD_STREAM
inline std::ostream& operator<<(
std::ostream& os, const JsonObjectSubscript<const String&>& source) {
return source.printTo(os);
}
inline std::ostream& operator<<(
std::ostream& os, const JsonObjectSubscript<const char*>& source) {
return source.printTo(os);
}
#endif
inline JsonObjectSubscript<const char*> JsonObject::operator[](
const char* key) {
return JsonObjectSubscript<const char*>(*this, key);
}
inline JsonObjectSubscript<const String&> JsonObject::operator[](
const String& key) {
return JsonObjectSubscript<const String&>(*this, key);
}
template <typename TImplem>
inline const JsonObjectSubscript<const char*> JsonVariantBase<TImplem>::
operator[](const char* key) const {
return asObject()[key];
}
template <typename TImplem>
inline const JsonObjectSubscript<const String&> JsonVariantBase<TImplem>::
operator[](const String& key) const {
return asObject()[key];
}
} // namespace ArduinoJson
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@@ -1,20 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "JsonObjectKey.hpp"
#include "JsonVariant.hpp"
namespace ArduinoJson {
// A key value pair for JsonObject.
struct JsonPair {
const char* key;
JsonVariant value;
};
}
@@ -1,367 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include <stddef.h>
#include <stdint.h> // for uint8_t
#include "Internals/JsonPrintable.hpp"
#include "Internals/JsonVariantContent.hpp"
#include "Internals/JsonVariantType.hpp"
#include "JsonVariantBase.hpp"
#include "RawJson.hpp"
#include "TypeTraits/EnableIf.hpp"
#include "TypeTraits/IsFloatingPoint.hpp"
#include "TypeTraits/IsIntegral.hpp"
#include "TypeTraits/IsSame.hpp"
#include "TypeTraits/RemoveConst.hpp"
#include "TypeTraits/RemoveReference.hpp"
namespace ArduinoJson {
// Forward declarations.
class JsonArray;
class JsonObject;
// A variant that can be a any value serializable to a JSON value.
//
// It can be set to:
// - a boolean
// - 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> {
public:
template <typename T>
struct IsConstructibleFrom;
// Creates an uninitialized JsonVariant
JsonVariant() : _type(Internals::JSON_UNDEFINED) {}
// Create a JsonVariant containing a boolean value.
// It will be serialized as "true" or "false" in JSON.
JsonVariant(bool value) {
using namespace Internals;
_type = JSON_BOOLEAN;
_content.asInteger = static_cast<JsonInteger>(value);
}
// Create a JsonVariant containing a floating point value.
// The second argument specifies the number of decimal digits to write in
// the JSON string.
// JsonVariant(double value, uint8_t decimals);
// JsonVariant(float value, uint8_t decimals);
template <typename T>
JsonVariant(T value, uint8_t decimals = 2,
typename TypeTraits::EnableIf<
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
using namespace Internals;
_type = static_cast<JsonVariantType>(JSON_FLOAT_0_DECIMALS + decimals);
_content.asFloat = static_cast<JsonFloat>(value);
}
// Create a JsonVariant containing an integer value.
// JsonVariant(signed short)
// JsonVariant(signed int)
// JsonVariant(signed long)
template <typename T>
JsonVariant(T value,
typename TypeTraits::EnableIf<
TypeTraits::IsSignedIntegral<T>::value>::type * = 0) {
using namespace Internals;
if (value >= 0) {
_type = JSON_POSITIVE_INTEGER;
_content.asInteger = static_cast<JsonUInt>(value);
} else {
_type = JSON_NEGATIVE_INTEGER;
_content.asInteger = static_cast<JsonUInt>(-value);
}
}
// JsonVariant(unsigned short)
// JsonVariant(unsigned int)
// JsonVariant(unsigned long)
template <typename T>
JsonVariant(T value,
typename TypeTraits::EnableIf<
TypeTraits::IsUnsignedIntegral<T>::value>::type * = 0) {
using namespace Internals;
_type = JSON_POSITIVE_INTEGER;
_content.asInteger = static_cast<JsonUInt>(value);
}
// Create a JsonVariant containing a string.
JsonVariant(const char *value) {
_type = Internals::JSON_STRING;
_content.asString = value;
}
// Create a JsonVariant containing an unparsed string
JsonVariant(RawJson value) {
_type = Internals::JSON_UNPARSED;
_content.asString = value;
}
// Create a JsonVariant containing a reference to an array.
JsonVariant(JsonArray &array) {
_type = Internals::JSON_ARRAY;
_content.asArray = &array;
}
// Create a JsonVariant containing a reference to an object.
JsonVariant(JsonObject &object) {
_type = Internals::JSON_OBJECT;
_content.asObject = &object;
}
// Get the variant as the specified type.
//
// short as<signed short>() const;
// int as<signed int>() const;
// long as<signed long>() const;
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsSignedIntegral<T>::value,
T>::type
as() const {
return static_cast<T>(asInteger());
}
//
// short as<unsigned short>() const;
// int as<unsigned int>() const;
// long as<unsigned long>() const;
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsUnsignedIntegral<T>::value,
T>::type
as() const {
return static_cast<T>(asUnsignedInteger());
}
//
// double as<double>() const;
// float as<float>() const;
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value,
T>::type
as() const {
return static_cast<T>(asFloat());
}
//
// const String as<String>() const;
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, String>::value,
T>::type
as() const {
return toString();
}
//
// 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
as() const {
return asString();
}
//
// const bool as<bool>() const
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value,
T>::type
as() const {
return asInteger() != 0;
}
//
// JsonArray& as<JsonArray> const;
// JsonArray& as<JsonArray&> const;
template <typename T>
typename TypeTraits::EnableIf<
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
JsonArray>::value,
JsonArray &>::type
as() const {
return asArray();
}
//
// const JsonArray& as<const JsonArray&> const;
template <typename T>
typename TypeTraits::EnableIf<
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
const JsonArray>::value,
const JsonArray &>::type
as() const {
return asArray();
}
//
// JsonObject& as<JsonObject> const;
// JsonObject& as<JsonObject&> const;
template <typename T>
typename TypeTraits::EnableIf<
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
JsonObject>::value,
JsonObject &>::type
as() const {
return asObject();
}
//
// 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,
const JsonObject &>::type
as() const {
return asObject();
}
// Tells weither the variant has the specified type.
// Returns true if the variant has type type T, false otherwise.
//
// short as<short>() const;
// int as<int>() const;
// long as<long>() const;
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsIntegral<T>::value,
bool>::type
is() const {
return isInteger();
}
//
// double is<double>() const;
// float is<float>() const;
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value,
bool>::type
is() const {
return isFloat();
}
//
// const bool is<bool>() const
template <typename T>
const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value,
bool>::type
is() const {
return isBoolean();
}
//
// bool is<const char*>() const;
// bool is<char*>() const;
template <typename T>
typename TypeTraits::EnableIf<TypeTraits::IsSame<T, const char *>::value ||
TypeTraits::IsSame<T, char *>::value,
bool>::type
is() const {
return isString();
}
//
// bool is<JsonArray> const;
// 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,
bool>::type
is() const {
return isArray();
}
//
// JsonObject& as<JsonObject> const;
// JsonObject& as<JsonObject&> const;
// JsonObject& as<const JsonObject&> const;
template <typename T>
typename TypeTraits::EnableIf<
TypeTraits::IsSame<
typename TypeTraits::RemoveConst<
typename TypeTraits::RemoveReference<T>::type>::type,
JsonObject>::value,
bool>::type
is() const {
return isObject();
}
// Returns true if the variant has a value
bool success() const {
return _type != Internals::JSON_UNDEFINED;
}
// Serialize the variant to a JsonWriter
void writeTo(Internals::JsonWriter &writer) const;
// Value returned if the variant has an incompatible type
template <typename T>
static typename Internals::JsonVariantAs<T>::type defaultValue() {
return T();
}
const char *asString() const;
JsonArray &asArray() const;
JsonObject &asObject() const;
private:
// It's not allowed to store a char
template <typename T>
JsonVariant(T value, typename TypeTraits::EnableIf<
TypeTraits::IsSame<T, char>::value>::type * = 0);
String toString() const;
Internals::JsonFloat asFloat() const;
Internals::JsonInteger asInteger() const;
Internals::JsonUInt asUnsignedInteger() const;
bool isBoolean() const;
bool isFloat() const;
bool isInteger() const;
bool isArray() const {
return _type == Internals::JSON_ARRAY;
}
bool isObject() const {
return _type == Internals::JSON_OBJECT;
}
bool isString() const {
return _type == Internals::JSON_STRING;
}
// The current type of the variant
Internals::JsonVariantType _type;
// The various alternatives for the value of the variant.
Internals::JsonVariantContent _content;
};
inline JsonVariant float_with_n_digits(float value, uint8_t digits) {
return JsonVariant(value, digits);
}
inline JsonVariant double_with_n_digits(double value, uint8_t digits) {
return JsonVariant(value, digits);
}
template <typename T>
struct JsonVariant::IsConstructibleFrom {
static const bool value =
TypeTraits::IsIntegral<T>::value ||
TypeTraits::IsFloatingPoint<T>::value ||
TypeTraits::IsSame<T, bool>::value ||
TypeTraits::IsSame<T, char *>::value ||
TypeTraits::IsSame<T, const char *>::value ||
TypeTraits::IsSame<T, RawJson>::value ||
TypeTraits::IsSame<T, JsonArray &>::value ||
TypeTraits::IsSame<T, const JsonArray &>::value ||
TypeTraits::IsSame<T, JsonArraySubscript &>::value ||
TypeTraits::IsSame<T, const JsonArraySubscript &>::value ||
TypeTraits::IsSame<T, JsonObject &>::value ||
TypeTraits::IsSame<T, const JsonObject &>::value ||
TypeTraits::IsSame<T, JsonObjectSubscript<const char *> &>::value ||
TypeTraits::IsSame<T, const JsonObjectSubscript<const char *> &>::value ||
TypeTraits::IsSame<T, JsonObjectSubscript<String> &>::value ||
TypeTraits::IsSame<T, const JsonObjectSubscript<String> &>::value ||
TypeTraits::IsSame<T, JsonVariant &>::value ||
TypeTraits::IsSame<T, const JsonVariant &>::value;
};
}
@@ -1,180 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Configuration.hpp"
#include "JsonVariant.hpp"
#include "Internals/Parse.hpp"
#include "JsonArray.hpp"
#include "JsonObject.hpp"
#include <string.h> // for strcmp
#include <errno.h> // for errno
#include <stdlib.h> // for strtol, strtod
namespace ArduinoJson {
inline Internals::JsonInteger JsonVariant::asInteger() const {
using namespace Internals;
switch (_type) {
case JSON_UNDEFINED:
return 0;
case JSON_POSITIVE_INTEGER:
case JSON_BOOLEAN:
return _content.asInteger;
case JSON_NEGATIVE_INTEGER:
return -static_cast<Internals::JsonInteger>(_content.asInteger);
case JSON_STRING:
case JSON_UNPARSED:
if (!_content.asString) return 0;
if (!strcmp("true", _content.asString)) return 1;
return parse<Internals::JsonInteger>(_content.asString);
default:
return static_cast<Internals::JsonInteger>(_content.asFloat);
}
}
inline Internals::JsonUInt JsonVariant::asUnsignedInteger() const {
using namespace Internals;
switch (_type) {
case JSON_UNDEFINED:
return 0;
case JSON_POSITIVE_INTEGER:
case JSON_BOOLEAN:
case JSON_NEGATIVE_INTEGER:
return _content.asInteger;
case JSON_STRING:
case JSON_UNPARSED:
if (!_content.asString) return 0;
if (!strcmp("true", _content.asString)) return 1;
return parse<Internals::JsonUInt>(_content.asString);
default:
return static_cast<Internals::JsonUInt>(_content.asFloat);
}
}
inline const char *JsonVariant::asString() const {
using namespace Internals;
if (_type == JSON_UNPARSED && _content.asString &&
!strcmp("null", _content.asString))
return NULL;
if (_type == JSON_STRING || _type == JSON_UNPARSED) return _content.asString;
return NULL;
}
inline Internals::JsonFloat JsonVariant::asFloat() const {
using namespace Internals;
switch (_type) {
case JSON_UNDEFINED:
return 0;
case JSON_POSITIVE_INTEGER:
case JSON_BOOLEAN:
return static_cast<JsonFloat>(_content.asInteger);
case JSON_NEGATIVE_INTEGER:
return -static_cast<JsonFloat>(_content.asInteger);
case JSON_STRING:
case JSON_UNPARSED:
return _content.asString ? parse<JsonFloat>(_content.asString) : 0;
default:
return _content.asFloat;
}
}
inline String JsonVariant::toString() const {
using namespace Internals;
String s;
if ((_type == JSON_STRING || _type == JSON_UNPARSED) &&
_content.asString != NULL)
s = _content.asString;
else
printTo(s);
return s;
}
inline bool JsonVariant::isBoolean() const {
using namespace Internals;
if (_type == JSON_BOOLEAN) return true;
if (_type != JSON_UNPARSED || _content.asString == NULL) return false;
return !strcmp(_content.asString, "true") ||
!strcmp(_content.asString, "false");
}
inline bool JsonVariant::isInteger() const {
using namespace Internals;
if (_type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER)
return true;
if (_type != JSON_UNPARSED || _content.asString == NULL) return false;
char *end;
errno = 0;
strtol(_content.asString, &end, 10);
return *end == '\0' && errno == 0;
}
inline bool JsonVariant::isFloat() const {
using namespace Internals;
if (_type >= JSON_FLOAT_0_DECIMALS) return true;
if (_type != JSON_UNPARSED || _content.asString == NULL) return false;
char *end;
errno = 0;
strtod(_content.asString, &end);
return *end == '\0' && errno == 0 && !is<long>();
}
inline void JsonVariant::writeTo(Internals::JsonWriter &writer) const {
using namespace Internals;
switch (_type) {
case JSON_UNDEFINED:
return;
case JSON_ARRAY:
_content.asArray->writeTo(writer);
return;
case JSON_OBJECT:
_content.asObject->writeTo(writer);
return;
case JSON_STRING:
writer.writeString(_content.asString);
return;
case JSON_UNPARSED:
writer.writeRaw(_content.asString);
return;
case JSON_NEGATIVE_INTEGER:
writer.writeRaw('-');
case JSON_POSITIVE_INTEGER:
writer.writeInteger(_content.asInteger);
return;
case JSON_BOOLEAN:
writer.writeBoolean(_content.asInteger != 0);
return;
default:
uint8_t decimals = static_cast<uint8_t>(_type - JSON_FLOAT_0_DECIMALS);
writer.writeFloat(_content.asFloat, decimals);
}
}
#if ARDUINOJSON_ENABLE_STD_STREAM
inline std::ostream &operator<<(std::ostream &os, const JsonVariant &source) {
return source.printTo(os);
}
#endif
} // namespace ArduinoJson
@@ -1,153 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Internals/JsonVariantAs.hpp"
#include "JsonObjectKey.hpp"
#include "Polyfills/attributes.hpp"
namespace ArduinoJson {
// Forward declarations.
class JsonArraySubscript;
template <typename TKey>
class JsonObjectSubscript;
template <typename TImpl>
class JsonVariantBase : public Internals::JsonPrintable<TImpl> {
public:
// DEPRECATED: use as<char*>() instead
FORCE_INLINE const char *asString() const {
return as<const char *>();
}
// Gets the variant as an array.
// Returns a reference to the JsonArray or JsonArray::invalid() if the
// variant
// is not an array.
FORCE_INLINE operator JsonArray &() const {
return as<JsonArray &>();
}
// DEPRECATED: use as<JsonArray>() instead
FORCE_INLINE JsonArray &asArray() const {
return as<JsonArray &>();
}
// Gets the variant as an object.
// Returns a reference to the JsonObject or JsonObject::invalid() if the
// variant is not an object.
FORCE_INLINE operator JsonObject &() const {
return as<JsonObject &>();
}
// DEPRECATED: use as<JsonObject>() instead
FORCE_INLINE JsonObject &asObject() const {
return as<JsonObject &>();
}
template <typename T>
FORCE_INLINE operator T() const {
return as<T>();
}
template <typename T>
FORCE_INLINE const typename Internals::JsonVariantAs<T>::type as() const {
return impl()->template as<T>();
}
// Mimics an array or an object.
// Returns the size of the array or object if the variant has that type.
// Returns 0 if the variant is neither an array nor an object
size_t size() const {
return asArray().size() + asObject().size();
}
// Mimics an array.
// Returns the element at specified index if the variant is an array.
// Returns JsonVariant::invalid() if the variant is not an array.
FORCE_INLINE const JsonArraySubscript operator[](int index) const;
// Mimics an object.
// Returns the value associated with the specified key if the variant is
// an object.
// Return JsonVariant::invalid() if the variant is not an object.
FORCE_INLINE const JsonObjectSubscript<const char *> operator[](
const char *key) const;
FORCE_INLINE const JsonObjectSubscript<const String &> operator[](
const String &key) const;
// Serialize the variant to a JsonWriter
void writeTo(Internals::JsonWriter &writer) const;
private:
const TImpl *impl() const {
return static_cast<const TImpl *>(this);
}
};
template <typename TImpl, typename TComparand>
inline bool operator==(const JsonVariantBase<TImpl> &left, TComparand right) {
return left.template as<TComparand>() == right;
}
template <typename TImpl, typename TComparand>
inline bool operator==(TComparand left, const JsonVariantBase<TImpl> &right) {
return left == right.template as<TComparand>();
}
template <typename TImpl, typename TComparand>
inline bool operator!=(const JsonVariantBase<TImpl> &left, TComparand right) {
return left.template as<TComparand>() != right;
}
template <typename TImpl, typename TComparand>
inline bool operator!=(TComparand left, const JsonVariantBase<TImpl> &right) {
return left != right.template as<TComparand>();
}
template <typename TImpl, typename TComparand>
inline bool operator<=(const JsonVariantBase<TImpl> &left, TComparand right) {
return left.template as<TComparand>() <= right;
}
template <typename TImpl, typename TComparand>
inline bool operator<=(TComparand left, const JsonVariantBase<TImpl> &right) {
return left <= right.template as<TComparand>();
}
template <typename TImpl, typename TComparand>
inline bool operator>=(const JsonVariantBase<TImpl> &left, TComparand right) {
return left.template as<TComparand>() >= right;
}
template <typename TImpl, typename TComparand>
inline bool operator>=(TComparand left, const JsonVariantBase<TImpl> &right) {
return left >= right.template as<TComparand>();
}
template <typename TImpl, typename TComparand>
inline bool operator<(const JsonVariantBase<TImpl> &left, TComparand right) {
return left.template as<TComparand>() < right;
}
template <typename TImpl, typename TComparand>
inline bool operator<(TComparand left, const JsonVariantBase<TImpl> &right) {
return left < right.template as<TComparand>();
}
template <typename TImpl, typename TComparand>
inline bool operator>(const JsonVariantBase<TImpl> &left, TComparand right) {
return left.template as<TComparand>() > right;
}
template <typename TImpl, typename TComparand>
inline bool operator>(TComparand left, const JsonVariantBase<TImpl> &right) {
return left > right.template as<TComparand>();
}
}
@@ -1,16 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#ifdef _MSC_VER
#define FORCE_INLINE __forceinline
#define NO_INLINE __declspec(noinline)
#else
#define FORCE_INLINE __attribute__((always_inline))
#define NO_INLINE __attribute__((noinline))
#endif
@@ -1,111 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
// If Visual Studo <= 2012
#if defined(_MSC_VER) && _MSC_VER <= 1700
#include <float.h>
namespace ArduinoJson {
namespace Polyfills {
template <typename T>
bool isNaN(T x) {
return _isnan(x) != 0;
}
template <typename T>
bool isInfinity(T x) {
return !_finite(x);
}
}
}
#else
#include <math.h>
// GCC warning: "conversion to 'float' from 'double' may alter its value"
#ifdef __GNUC__
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#endif
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#else
#pragma GCC diagnostic ignored "-Wconversion"
#endif
#endif
// Workaround for libs that #undef isnan or isinf
// https://github.com/bblanchon/ArduinoJson/issues/284
#if !defined(isnan) || !defined(isinf)
namespace std {}
#endif
namespace ArduinoJson {
namespace Polyfills {
template <typename T>
bool isNaN(T x) {
// Workaround for libs that #undef isnan
// https://github.com/bblanchon/ArduinoJson/issues/284
#ifndef isnan
using namespace std;
#endif
return isnan(x);
}
#if defined(_GLIBCXX_HAVE_ISNANL) && _GLIBCXX_HAVE_ISNANL
template <>
inline bool isNaN<double>(double x) {
return isnanl(x);
}
#endif
#if defined(_GLIBCXX_HAVE_ISNANF) && _GLIBCXX_HAVE_ISNANF
template <>
inline bool isNaN<float>(float x) {
return isnanf(x);
}
#endif
template <typename T>
bool isInfinity(T x) {
// Workaround for libs that #undef isinf
// https://github.com/bblanchon/ArduinoJson/issues/284
#ifndef isinf
using namespace std;
#endif
return isinf(x);
}
#if defined(_GLIBCXX_HAVE_ISINFL) && _GLIBCXX_HAVE_ISINFL
template <>
inline bool isInfinity<double>(double x) {
return isinfl(x);
}
#endif
#if defined(_GLIBCXX_HAVE_ISINFF) && _GLIBCXX_HAVE_ISINFF
template <>
inline bool isInfinity<float>(float x) {
return isinff(x);
}
#endif
#if defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif
#endif
}
}
#endif
@@ -1,47 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
namespace ArduinoJson {
namespace Polyfills {
#ifdef ARDUINO
// on embedded platform, favor code size over speed
template <typename T>
short normalize(T& value) {
short powersOf10 = 0;
while (value && value < 1) {
powersOf10--;
value *= 10;
}
while (value > 10) {
powersOf10++;
value /= 10;
}
return powersOf10;
}
#else
// on non-embedded platform, favor speed over code size
template <typename T>
short normalize(T& value) {
if (value == 0.0) return 0;
short powersOf10 = static_cast<short>(floor(log10(value)));
value /= pow(T(10), powersOf10);
return powersOf10;
}
#endif
}
}
@@ -1,39 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#ifndef ARDUINO
#include <stddef.h>
#include <stdint.h>
namespace ArduinoJson {
// This class reproduces Arduino's Print class
class Print {
public:
virtual ~Print() {}
virtual size_t write(uint8_t) = 0;
size_t print(const char* s) {
size_t n = 0;
while (*s) {
n += write(*s++);
}
return n;
}
size_t println() { return write('\r') + write('\n'); }
};
}
#else
#include <Print.h>
#endif
@@ -1,21 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/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,58 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "JsonBuffer.hpp"
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
#elif defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
namespace ArduinoJson {
// Implements a JsonBuffer with fixed memory allocation.
// The template paramenter CAPACITY specifies the capacity of the buffer in
// bytes.
template <size_t CAPACITY>
class StaticJsonBuffer : public JsonBuffer {
public:
explicit StaticJsonBuffer() : _size(0) {}
size_t capacity() const {
return CAPACITY;
}
size_t size() const {
return _size;
}
virtual void* alloc(size_t bytes) {
if (_size + bytes > CAPACITY) return NULL;
void* p = &_buffer[_size];
_size += round_size_up(bytes);
return p;
}
private:
uint8_t _buffer[CAPACITY];
size_t _size;
};
}
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif
#endif
@@ -1,24 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "Configuration.hpp"
#if ARDUINOJSON_USE_ARDUINO_STRING
#include <WString.h>
#else
#include <string>
namespace ArduinoJson {
typedef std::string String;
}
#endif
@@ -1,26 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
#include "../Configuration.hpp"
#include "IsSame.hpp"
#include "IsSignedIntegral.hpp"
#include "IsUnsignedIntegral.hpp"
namespace ArduinoJson {
namespace TypeTraits {
// A meta-function that returns true if T is an integral type.
template <typename T>
struct IsIntegral {
static const bool value = TypeTraits::IsSignedIntegral<T>::value ||
TypeTraits::IsUnsignedIntegral<T>::value ||
TypeTraits::IsSame<T, char>::value;
};
}
}
@@ -1,24 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
namespace ArduinoJson {
namespace TypeTraits {
// A meta-function that returns true if T is a reference
template <typename T>
struct IsReference {
static const bool value = false;
};
template <typename T>
struct IsReference<T&> {
static const bool value = true;
};
}
}
@@ -1,33 +0,0 @@
// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/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-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/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;
};
}
}
+1
View File
@@ -2,6 +2,7 @@ JsonArray KEYWORD1
JsonObject KEYWORD1
JsonVariant KEYWORD1
StaticJsonBuffer KEYWORD1
DynamicJsonBuffer KEYWORD1
add KEYWORD2
createArray KEYWORD2
createNestedArray KEYWORD2
+5 -4
View File
@@ -1,19 +1,20 @@
{
"name": "Json",
"name": "ArduinoJson",
"keywords": "json, rest, http, web",
"description": "An elegant and efficient JSON library for embedded systems",
"homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json",
"repository": {
"type": "git",
"url": "https://github.com/bblanchon/ArduinoJson.git"
},
"version": "5.6.4",
"version": "5.13.2",
"authors": {
"name": "Benoit Blanchon",
"url": "http://blog.benoitblanchon.fr"
"url": "https://blog.benoitblanchon.fr"
},
"exclude": [
"fuzzing",
"scripts",
"src/ArduinoJson.h",
"test",
"third-party"
],
+5 -3
View File
@@ -1,9 +1,11 @@
name=ArduinoJson
version=5.6.4
version=5.13.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!
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://github.com/bblanchon/ArduinoJson
url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties
architectures=*
repository=https://github.com/bblanchon/ArduinoJson.git
license=MIT
@@ -12,7 +12,7 @@ rm -f $OUTPUT
7z a $OUTPUT \
ArduinoJson/CHANGELOG.md \
ArduinoJson/examples \
ArduinoJson/include \
ArduinoJson/src \
ArduinoJson/keywords.txt \
ArduinoJson/library.properties \
ArduinoJson/LICENSE.md \
@@ -0,0 +1,53 @@
#!/bin/bash
TAG=$(git describe)
RE_INCLUDE='^#include[[:space:]]*["<](.*)[">]'
RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
declare -A INCLUDED
process()
{
local PARENT=$1
local FOLDER=$(dirname $1)
local SHOW_COMMENT=$2
while IFS= read -r LINE; do
if [[ $LINE =~ $RE_INCLUDE ]]; then
local CHILD=${BASH_REMATCH[1]}
pushd "$FOLDER" > /dev/null
if [[ -e $CHILD ]]; then
local CHILD_PATH=$(realpath $CHILD)
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
#echo "// $PARENT -> $CHILD"
INCLUDED[$CHILD_PATH]=true
process "$CHILD" false
fi
else
if [[ ! ${INCLUDED[$CHILD]} ]]; then
echo "$LINE"
INCLUDED[$CHILD]=true
fi
fi
popd > /dev/null
elif [[ "${SHOW_COMMENT}" = "true" ]] ; then
echo "$LINE"
elif [[ ! $LINE =~ $RE_EMPTY ]]; then
echo "$LINE"
fi
done < $PARENT
}
cd $(dirname $0)/../
INCLUDED=()
process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
g++ -x c++ -c -o ../smoketest.o - <<END
#include "../ArduinoJson-$TAG.h"
int main() {}
END
INCLUDED=()
process src/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp
g++ -x c++ -c -o ../smoketest.o - <<END
#include "../ArduinoJson-$TAG.hpp"
int main() {}
END
-5
View File
@@ -1,5 +0,0 @@
CPPLINT="python third-party/cpplint/cpplint.py"
FLAGS="--filter=-runtime/printf,-runtime/int,-readability/todo,-build/namespace,-runtime/references,-readability/streams"
cd ..
$CPPLINT $FLAGS $(find include src test -regex ".*\.[hc]pp$")
-7
View File
@@ -1,7 +0,0 @@
cd ..
FILES=$(find include src test -regex ".*\.[ch]pp$")
clang-format -style=Google -i $FILES
# insert newline at end of file
sed -i -e '$a\' $FILES
@@ -0,0 +1,2 @@
/.vagrant/
*.log
+33
View File
@@ -0,0 +1,33 @@
# A virtual machine to run https://github.com/google/oss-fuzz
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.synced_folder "E:\\Git\\Arduino\\libraries\\ArduinoJson", "/host/ArduinoJson"
config.vm.synced_folder "E:\\Git\\oss-fuzz", "/host/oss-fuzz"
config.vm.network "forwarded_port", guest: 8001, host: 8001
config.vm.provision "shell", privileged: false, inline: <<-SHELL
set -x
sudo apt-get update
sudo apt-get install -y make git docker.io zip
sudo groupadd docker
sudo usermod -aG docker $USER
git clone https://github.com/google/fuzzer-test-suite.git FTS
./FTS/tutorial/install-deps.sh # Get deps
./FTS/tutorial/install-clang.sh # Get fresh clang binaries
# Get libFuzzer sources and build it
svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
Fuzzer/build.sh
sudo mv libFuzzer.a /usr/local/lib/
echo "export PROJECT_NAME='arduinojson'" >> $HOME/.profile
echo "export CC='clang'" >> $HOME/.profile
echo "export CXX='clang++'" >> $HOME/.profile
echo "export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/" >> $HOME/.profile
echo "Run /host/ArduinoJson/fuzzing/fuzz.sh" | sudo tee /etc/motd
SHELL
end
-44
View File
@@ -1,44 +0,0 @@
#!/bin/bash
FILE=../bin/ArduinoJsonTests.exe
MD5=""
file_changed() {
[[ ! -f "$FILE" ]] && return 1
NEW_MD5=$(md5sum $FILE)
[[ "$MD5" == "$NEW_MD5" ]] && return 1
MD5=$NEW_MD5
return 0
}
test_succeed() {
echo -en "\007"{,}
}
test_failed() {
echo -en "\007"{,,,,,,,,,,,}
}
run_tests() {
$FILE
case $? in
0)
test_succeed
;;
1)
test_failed
;;
esac
}
while true
do
if file_changed
then
run_tests
else
sleep 2
fi
done
@@ -1,9 +0,0 @@
#!/bin/sh -eux
URL=https://cmake.org/files/v3.4/cmake-3.4.3-Darwin-x86_64.tar.gz
curl -sS $URL | tar xz -C /tmp --strip 1
/tmp/CMake.app/Contents/bin/cmake .
make
make test

Some files were not shown because too many files have changed in this diff Show More