Publish refactoring (#298)

* factoring of the publishing function
* integration of json publishing to MQTT
* receiving and transcode json messages from mqtt
* replace the TRACE runtime condition by a buildtime one so as to decrease program size
* remove retainFlag parameter not necessary for the moment
* Increase the scope of tests for arduino mega and esp32
* Update arduinojson library to 5.13.3
* add macros to choose between simple or json publishing or both
* differentiate build test for ATmega2560
* correct wrong sprintf definition
* change IDE version for continuous integration
* let default warning level in arduino ide
* correct pins for ESP32
* reorganize user_config
This commit is contained in:
Florian authored and GitHub committed 2018-11-05 22:02:27 +01:00
1 parent f77df7347f
commit d8dba15a81
182 files changed
+2701 -20768

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
something isn't working as expected. In many cases the problem is a common issue
that you will more quickly receive help from the forum community. GitHub issues
are meant for known defects in the code. If you don't know if there is a defect
in the code then start with troubleshooting on the forum first.
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
check all of the steps and commands to run have been followed. Consult the
forum if you're unsure or have questions about steps in a guide/tutorial.
- **For Arduino projects check these very common issues to ensure they don't apply**:
- For uploading sketches or communicating with the board make sure you're using
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
very hard to tell the difference between a data and charge cable! Try using the
cable with other devices or swapping to another cable to confirm it is not
the problem.
- **Be sure you are supplying adequate power to the board.** Check the specs of
your board and plug in an external power supply. In many cases just
plugging a board into your computer is not enough to power it and other
peripherals.
- **Double check all soldering joints and connections.** Flakey connections
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
- **Ensure you are using an official Arduino or Adafruit board.** We can't
guarantee a clone board will have the same functionality and work as expected
with this code and don't support them.
If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
VERSION HERE**
- List the steps to reproduce the problem below (if possible attach a sketch or
copy the sketch code in too): **LIST REPRO STEPS BELOW**
+26
View File
@@ -0,0 +1,26 @@
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
Before you open the request please review the following guidelines and tips to
help it be more easily integrated:
- **Describe the scope of your change--i.e. what the change does and what parts
of the code were modified.** This will help us understand any risks of integrating
the code.
- **Describe any known limitations with your change.** For example if the change
doesn't apply to a supported platform of the library please mention it.
- **Please run any tests or examples that can exercise your modified code.** We
strive to not break users of the code and running tests/examples helps with this
process.
Thank you again for contributing! We will try to test and integrate the change
as soon as we can, but be aware we have many GitHub repositories to manage and
can't immediately respond to every request. There is no need to bump or check in
on a pull request (it will clutter the discussion of the request).
Also don't be worried if the request is closed or not integrated--sometimes the
priorities of Adafruit's GitHub code (education, ease of use) might not match the
priorities of the pull request. Don't fret, the open source community thrives on
forks and GitHub makes it easy to keep your changes in a forked repo.
After reviewing the guidelines above you can delete this text from the pull request.
+27
View File
@@ -0,0 +1,27 @@
language: c
sudo: false
# Blacklist
branches:
except:
- gh-pages
env:
global:
- PRETTYNAME="Adafruit TSL2561 Arduino Library"
# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile"
# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile
before_install:
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
install:
- arduino --install-library "Adafruit Unified Sensor"
script:
- build_main_platforms
# Generate and deploy documentation
after_success:
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh)
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)
+236 -181
View File
@@ -1,179 +1,58 @@
/**************************************************************************/
/*!
@file Adafruit_TSL2561.cpp
@author K.Townsend (Adafruit Industries)
@license BSD (see license.txt)
Driver for the TSL2561 digital luminosity (light) sensors.
Pick one up at http://www.adafruit.com/products/439
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v2.0 - Rewrote driver for Adafruit_Sensor and Auto-Gain support, and
added lux clipping check (returns 0 lux on sensor saturation)
v1.0 - First release (previously TSL2561)
* @file Adafruit_TSL2561_U.cpp
*
* @mainpage Adafruit TSL2561 Light/Lux sensor driver
*
* @section intro_sec Introduction
*
* This is the documentation for Adafruit's TSL2561 driver for the
* Arduino platform. It is designed specifically to work with the
* Adafruit TSL2561 breakout: http://www.adafruit.com/products/439
*
* These sensors use I2C to communicate, 2 pins (SCL+SDA) are required
* to interface with the breakout.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* @section dependencies Dependencies
*
* This library depends on <a href="https://github.com/adafruit/Adafruit_Sensor">
* Adafruit_Sensor</a> being present on your system. Please make sure you have
* installed the latest version before using this library.
*
* @section author Author
*
* Written by Kevin "KTOWN" Townsend for Adafruit Industries.
*
* @section license License
*
* BSD license, all text here must be included in any redistribution.
*
* @section HISTORY
*
* v2.0 - Rewrote driver for Adafruit_Sensor and Auto-Gain support, and
* added lux clipping check (returns 0 lux on sensor saturation)
* v1.0 - First release (previously TSL2561)
*/
/**************************************************************************/
#if defined(__AVR__)
#include <avr/pgmspace.h>
#include <util/delay.h>
#else
#include "pgmspace.h"
#endif
#include <stdlib.h>
#include "Adafruit_TSL2561_U.h"
#define TSL2561_DELAY_INTTIME_13MS (15)
#define TSL2561_DELAY_INTTIME_101MS (120)
#define TSL2561_DELAY_INTTIME_402MS (450)
/*========================================================================*/
/* PRIVATE FUNCTIONS */
/*========================================================================*/
/**************************************************************************/
/*!
@brief Writes a register and an 8 bit value over I2C
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::write8 (uint8_t reg, uint32_t value)
{
Wire.beginTransmission(_addr);
#if ARDUINO >= 100
Wire.write(reg);
Wire.write(value & 0xFF);
#else
Wire.send(reg);
Wire.send(value & 0xFF);
#endif
Wire.endTransmission();
}
/**************************************************************************/
/*!
@brief Reads an 8 bit value over I2C
*/
/**************************************************************************/
uint8_t Adafruit_TSL2561_Unified::read8(uint8_t reg)
{
Wire.beginTransmission(_addr);
#if ARDUINO >= 100
Wire.write(reg);
#else
Wire.send(reg);
#endif
Wire.endTransmission();
Wire.requestFrom(_addr, 1);
#if ARDUINO >= 100
return Wire.read();
#else
return Wire.receive();
#endif
}
/**************************************************************************/
/*!
@brief Reads a 16 bit values over I2C
*/
/**************************************************************************/
uint16_t Adafruit_TSL2561_Unified::read16(uint8_t reg)
{
uint16_t x; uint16_t t;
Wire.beginTransmission(_addr);
#if ARDUINO >= 100
Wire.write(reg);
#else
Wire.send(reg);
#endif
Wire.endTransmission();
Wire.requestFrom(_addr, 2);
#if ARDUINO >= 100
t = Wire.read();
x = Wire.read();
#else
t = Wire.receive();
x = Wire.receive();
#endif
x <<= 8;
x |= t;
return x;
}
/**************************************************************************/
/*!
Enables the device
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::enable(void)
{
/* Enable the device by setting the control bit to 0x03 */
write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWERON);
}
/**************************************************************************/
/*!
Disables the device (putting it in lower power sleep mode)
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::disable(void)
{
/* Turn the device off to save power */
write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWEROFF);
}
/**************************************************************************/
/*!
Private function to read luminosity on both channels
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::getData (uint16_t *broadband, uint16_t *ir)
{
/* Enable the device by setting the control bit to 0x03 */
enable();
/* Wait x ms for ADC to complete */
switch (_tsl2561IntegrationTime)
{
case TSL2561_INTEGRATIONTIME_13MS:
delay(TSL2561_DELAY_INTTIME_13MS); // KTOWN: Was 14ms
break;
case TSL2561_INTEGRATIONTIME_101MS:
delay(TSL2561_DELAY_INTTIME_101MS); // KTOWN: Was 102ms
break;
default:
delay(TSL2561_DELAY_INTTIME_402MS); // KTOWN: Was 403ms
break;
}
/* Reads a two byte value from channel 0 (visible + infrared) */
*broadband = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN0_LOW);
/* Reads a two byte value from channel 1 (infrared) */
*ir = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN1_LOW);
/* Turn the device off to save power */
disable();
}
/*========================================================================*/
/* CONSTRUCTORS */
/*========================================================================*/
/**************************************************************************/
/*!
Constructor
@brief Constructor
@param addr The I2C address this chip can be found on, 0x29, 0x39 or 0x49
@param sensorID An optional ID that will be placed in sensor events to help
keep track if you have many sensors in use
*/
/**************************************************************************/
Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID)
Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID)
{
_addr = addr;
_tsl2561Initialised = false;
@@ -189,18 +68,46 @@ Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorI
/**************************************************************************/
/*!
Initializes I2C and configures the sensor (call this function before
doing anything else)
@brief Initializes I2C and configures the sensor with default Wire I2C
(call this function before doing anything else)
@returns True if sensor is found and initialized, false otherwise.
*/
/**************************************************************************/
boolean Adafruit_TSL2561_Unified::begin(void)
boolean Adafruit_TSL2561_Unified::begin()
{
Wire.begin();
_i2c = &Wire;
_i2c->begin();
return init();
}
/**************************************************************************/
/*!
@brief Initializes I2C and configures the sensor with provided I2C device
(call this function before doing anything else)
@param theWire A pointer to any I2C interface (e.g. &Wire1)
@returns True if sensor is found and initialized, false otherwise.
*/
/**************************************************************************/
boolean Adafruit_TSL2561_Unified::begin(TwoWire *theWire)
{
_i2c = theWire;
_i2c-> begin();
return init();
}
/**************************************************************************/
/*!
@brief Initializes I2C connection and settings.
Attempts to determine if the sensor is contactable, then sets up a default
integration time and gain. Then powers down the chip.
@returns True if sensor is found and initialized, false otherwise.
*/
/**************************************************************************/
boolean Adafruit_TSL2561_Unified::init()
{
/* Make sure we're actually connected */
uint8_t x = read8(TSL2561_REGISTER_ID);
if (!(x & 0x0A))
{
if (x & 0xF0 != 0x10) { // ID code for TSL2561
return false;
}
_tsl2561Initialised = true;
@@ -214,11 +121,12 @@ boolean Adafruit_TSL2561_Unified::begin(void)
return true;
}
/**************************************************************************/
/*!
@brief Enables or disables the auto-gain settings when reading
data from the sensor
@param enable Set to true to enable, False to disable
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::enableAutoRange(bool enable)
@@ -228,7 +136,10 @@ void Adafruit_TSL2561_Unified::enableAutoRange(bool enable)
/**************************************************************************/
/*!
Sets the integration time for the TSL2561
@brief Sets the integration time for the TSL2561. Higher time means
more light captured (better for low light conditions) but will
take longer to run readings.
@param time The amount of time we'd like to add up values
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::setIntegrationTime(tsl2561IntegrationTime_t time)
@@ -250,7 +161,8 @@ void Adafruit_TSL2561_Unified::setIntegrationTime(tsl2561IntegrationTime_t time)
/**************************************************************************/
/*!
Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
@brief Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
@param gain The value we'd like to set the gain to
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::setGain(tsl2561Gain_t gain)
@@ -274,6 +186,10 @@ void Adafruit_TSL2561_Unified::setGain(tsl2561Gain_t gain)
/*!
@brief Gets the broadband (mixed lighting) and IR only values from
the TSL2561, adjusting gain if auto-gain is enabled
@param broadband Pointer to a uint16_t we will fill with a sensor
reading from the IR+visible light diode.
@param ir Pointer to a uint16_t we will fill with a sensor the
IR-only light diode.
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::getLuminosity (uint16_t *broadband, uint16_t *ir)
@@ -358,18 +274,87 @@ void Adafruit_TSL2561_Unified::getLuminosity (uint16_t *broadband, uint16_t *ir)
} while (!valid);
}
/**************************************************************************/
/*!
Converts the raw sensor values to the standard SI lux equivalent.
Returns 0 if the sensor is saturated and the values are unreliable.
Enables the device
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::enable(void)
{
/* Enable the device by setting the control bit to 0x03 */
write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWERON);
}
/**************************************************************************/
/*!
Disables the device (putting it in lower power sleep mode)
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::disable(void)
{
/* Turn the device off to save power */
write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWEROFF);
}
/**************************************************************************/
/*!
Private function to read luminosity on both channels
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::getData (uint16_t *broadband, uint16_t *ir)
{
/* Enable the device by setting the control bit to 0x03 */
enable();
/* Wait x ms for ADC to complete */
switch (_tsl2561IntegrationTime)
{
case TSL2561_INTEGRATIONTIME_13MS:
delay(TSL2561_DELAY_INTTIME_13MS); // KTOWN: Was 14ms
break;
case TSL2561_INTEGRATIONTIME_101MS:
delay(TSL2561_DELAY_INTTIME_101MS); // KTOWN: Was 102ms
break;
default:
delay(TSL2561_DELAY_INTTIME_402MS); // KTOWN: Was 403ms
break;
}
/* Reads a two byte value from channel 0 (visible + infrared) */
*broadband = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN0_LOW);
/* Reads a two byte value from channel 1 (infrared) */
*ir = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN1_LOW);
/* Turn the device off to save power */
disable();
}
/**************************************************************************/
/*!
@brief Converts the raw sensor values to the standard SI lux equivalent.
@param broadband The 16-bit sensor reading from the IR+visible light diode.
@param ir The 16-bit sensor reading from the IR-only light diode.
@returns The integer Lux value we calcuated.
Returns 0 if the sensor is saturated and the values are
unreliable, or 65536 if the sensor is saturated.
*/
/**************************************************************************/
/**************************************************************************/
/*!
Returns
*/
/**************************************************************************/
uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
{
unsigned long chScale;
unsigned long channel1;
unsigned long channel0;
unsigned long channel0;
/* Make sure the sensor isn't saturated! */
uint16_t clipThreshold;
switch (_tsl2561IntegrationTime)
@@ -385,10 +370,10 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
break;
}
/* Return 0 lux if the sensor is saturated */
/* Return 65536 lux if the sensor is saturated */
if ((broadband > clipThreshold) || (ir > clipThreshold))
{
return 0;
return 65536;
}
/* Get the correct scale depending on the intergration time */
@@ -476,15 +461,19 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
/**************************************************************************/
/*!
@brief Gets the most recent sensor event
@param event Pointer to a sensor_event_t type that will be filled
with the lux value, timestamp, data type and sensor ID.
@returns True if sensor reading is between 0 and 65535 lux,
false if sensor is saturated
*/
/**************************************************************************/
bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
{
uint16_t broadband, ir;
/* Clear the event */
memset(event, 0, sizeof(sensors_event_t));
event->version = sizeof(sensors_event_t);
event->sensor_id = _tsl2561SensorID;
event->type = SENSOR_TYPE_LIGHT;
@@ -493,13 +482,18 @@ bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
/* Calculate the actual lux value */
getLuminosity(&broadband, &ir);
event->light = calculateLux(broadband, ir);
if (event->light == 65536) {
return false;
}
return true;
}
/**************************************************************************/
/*!
@brief Gets the sensor_t data
@param sensor A pointer to a sensor_t structure that we will fill with
details about the TSL2561 and its capabilities
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::getSensor(sensor_t *sensor)
@@ -515,6 +509,67 @@ void Adafruit_TSL2561_Unified::getSensor(sensor_t *sensor)
sensor->type = SENSOR_TYPE_LIGHT;
sensor->min_delay = 0;
sensor->max_value = 17000.0; /* Based on trial and error ... confirm! */
sensor->min_value = 0.0;
sensor->min_value = 1.0;
sensor->resolution = 1.0;
}
/*========================================================================*/
/* PRIVATE FUNCTIONS */
/*========================================================================*/
/**************************************************************************/
/*!
@brief Writes a register and an 8 bit value over I2C
@param reg I2C register to write the value to
@param value The 8-bit value we're writing to the register
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::write8 (uint8_t reg, uint8_t value)
{
_i2c->beginTransmission(_addr);
_i2c->write(reg);
_i2c->write(value);
_i2c->endTransmission();
}
/**************************************************************************/
/*!
@brief Reads an 8 bit value over I2C
@param reg I2C register to read from
@returns 8-bit value containing single byte data read
*/
/**************************************************************************/
uint8_t Adafruit_TSL2561_Unified::read8(uint8_t reg)
{
_i2c->beginTransmission(_addr);
_i2c->write(reg);
_i2c->endTransmission();
_i2c->requestFrom(_addr, 1);
return _i2c-> read();
}
/**************************************************************************/
/*!
@brief Reads a 16 bit values over I2C
@param reg I2C register to read from
@returns 16-bit value containing 2-byte data read
*/
/**************************************************************************/
uint16_t Adafruit_TSL2561_Unified::read16(uint8_t reg)
{
uint16_t x, t;
_i2c->beginTransmission(_addr);
_i2c->write(reg);
_i2c->endTransmission();
_i2c->requestFrom(_addr, 2);
t = _i2c->read();
x = _i2c->read();
x <<= 8;
x |= t;
return x;
}
+133 -132
View File
@@ -1,158 +1,146 @@
/**************************************************************************/
/*!
@file Adafruit_TSL2561.h
@author K. Townsend (Adafruit Industries)
/*!
* @file Adafruit_TSL2561_U.h
*
* This is part of Adafruit's FXOS8700 driver for the Arduino platform. It is
* designed specifically to work with the Adafruit FXOS8700 breakout:
* https://www.adafruit.com/products/3463
*
* These sensors use I2C to communicate, 2 pins (SCL+SDA) are required
* to interface with the breakout.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Written by Kevin "KTOWN" Townsend for Adafruit Industries.
*
* BSD license, all text here must be included in any redistribution.
*
*/
@section LICENSE
#ifndef ADAFRUIT_TSL2561_H_
#define ADAFRUIT_TSL2561_H_
Software License Agreement (BSD License)
Copyright (c) 2013, Adafruit Industries
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**************************************************************************/
#ifndef _TSL2561_H_
#define _TSL2561_H_
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include <Arduino.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#define TSL2561_VISIBLE 2 // channel 0 - channel 1
#define TSL2561_INFRARED 1 // channel 1
#define TSL2561_FULLSPECTRUM 0 // channel 0
#define TSL2561_VISIBLE 2 ///< channel 0 - channel 1
#define TSL2561_INFRARED 1 ///< channel 1
#define TSL2561_FULLSPECTRUM 0 ///< channel 0
// I2C address options
#define TSL2561_ADDR_LOW (0x29)
#define TSL2561_ADDR_FLOAT (0x39) // Default address (pin left floating)
#define TSL2561_ADDR_HIGH (0x49)
#define TSL2561_ADDR_LOW (0x29) ///< Default address (pin pulled low)
#define TSL2561_ADDR_FLOAT (0x39) ///< Default address (pin left floating)
#define TSL2561_ADDR_HIGH (0x49) ///< Default address (pin pulled high)
// Lux calculations differ slightly for CS package
//#define TSL2561_PACKAGE_CS
#define TSL2561_PACKAGE_T_FN_CL
//#define TSL2561_PACKAGE_CS ///< Chip scale package
#define TSL2561_PACKAGE_T_FN_CL ///< Dual Flat No-Lead package
#define TSL2561_COMMAND_BIT (0x80) // Must be 1
#define TSL2561_CLEAR_BIT (0x40) // Clears any pending interrupt (write 1 to clear)
#define TSL2561_WORD_BIT (0x20) // 1 = read/write word (rather than byte)
#define TSL2561_BLOCK_BIT (0x10) // 1 = using block read/write
#define TSL2561_COMMAND_BIT (0x80) ///< Must be 1
#define TSL2561_CLEAR_BIT (0x40) ///< Clears any pending interrupt (write 1 to clear)
#define TSL2561_WORD_BIT (0x20) ///< 1 = read/write word (rather than byte)
#define TSL2561_BLOCK_BIT (0x10) ///< 1 = using block read/write
#define TSL2561_CONTROL_POWERON (0x03)
#define TSL2561_CONTROL_POWEROFF (0x00)
#define TSL2561_CONTROL_POWERON (0x03) ///< Control register setting to turn on
#define TSL2561_CONTROL_POWEROFF (0x00) ///< Control register setting to turn off
#define TSL2561_LUX_LUXSCALE (14) // Scale by 2^14
#define TSL2561_LUX_RATIOSCALE (9) // Scale ratio by 2^9
#define TSL2561_LUX_CHSCALE (10) // Scale channel values by 2^10
#define TSL2561_LUX_CHSCALE_TINT0 (0x7517) // 322/11 * 2^TSL2561_LUX_CHSCALE
#define TSL2561_LUX_CHSCALE_TINT1 (0x0FE7) // 322/81 * 2^TSL2561_LUX_CHSCALE
#define TSL2561_LUX_LUXSCALE (14) ///< Scale by 2^14
#define TSL2561_LUX_RATIOSCALE (9) ///< Scale ratio by 2^9
#define TSL2561_LUX_CHSCALE (10) ///< Scale channel values by 2^10
#define TSL2561_LUX_CHSCALE_TINT0 (0x7517) ///< 322/11 * 2^TSL2561_LUX_CHSCALE
#define TSL2561_LUX_CHSCALE_TINT1 (0x0FE7) ///< 322/81 * 2^TSL2561_LUX_CHSCALE
// T, FN and CL package values
#define TSL2561_LUX_K1T (0x0040) // 0.125 * 2^RATIO_SCALE
#define TSL2561_LUX_B1T (0x01f2) // 0.0304 * 2^LUX_SCALE
#define TSL2561_LUX_M1T (0x01be) // 0.0272 * 2^LUX_SCALE
#define TSL2561_LUX_K2T (0x0080) // 0.250 * 2^RATIO_SCALE
#define TSL2561_LUX_B2T (0x0214) // 0.0325 * 2^LUX_SCALE
#define TSL2561_LUX_M2T (0x02d1) // 0.0440 * 2^LUX_SCALE
#define TSL2561_LUX_K3T (0x00c0) // 0.375 * 2^RATIO_SCALE
#define TSL2561_LUX_B3T (0x023f) // 0.0351 * 2^LUX_SCALE
#define TSL2561_LUX_M3T (0x037b) // 0.0544 * 2^LUX_SCALE
#define TSL2561_LUX_K4T (0x0100) // 0.50 * 2^RATIO_SCALE
#define TSL2561_LUX_B4T (0x0270) // 0.0381 * 2^LUX_SCALE
#define TSL2561_LUX_M4T (0x03fe) // 0.0624 * 2^LUX_SCALE
#define TSL2561_LUX_K5T (0x0138) // 0.61 * 2^RATIO_SCALE
#define TSL2561_LUX_B5T (0x016f) // 0.0224 * 2^LUX_SCALE
#define TSL2561_LUX_M5T (0x01fc) // 0.0310 * 2^LUX_SCALE
#define TSL2561_LUX_K6T (0x019a) // 0.80 * 2^RATIO_SCALE
#define TSL2561_LUX_B6T (0x00d2) // 0.0128 * 2^LUX_SCALE
#define TSL2561_LUX_M6T (0x00fb) // 0.0153 * 2^LUX_SCALE
#define TSL2561_LUX_K7T (0x029a) // 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B7T (0x0018) // 0.00146 * 2^LUX_SCALE
#define TSL2561_LUX_M7T (0x0012) // 0.00112 * 2^LUX_SCALE
#define TSL2561_LUX_K8T (0x029a) // 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B8T (0x0000) // 0.000 * 2^LUX_SCALE
#define TSL2561_LUX_M8T (0x0000) // 0.000 * 2^LUX_SCALE
#define TSL2561_LUX_K1T (0x0040) ///< 0.125 * 2^RATIO_SCALE
#define TSL2561_LUX_B1T (0x01f2) ///< 0.0304 * 2^LUX_SCALE
#define TSL2561_LUX_M1T (0x01be) ///< 0.0272 * 2^LUX_SCALE
#define TSL2561_LUX_K2T (0x0080) ///< 0.250 * 2^RATIO_SCALE
#define TSL2561_LUX_B2T (0x0214) ///< 0.0325 * 2^LUX_SCALE
#define TSL2561_LUX_M2T (0x02d1) ///< 0.0440 * 2^LUX_SCALE
#define TSL2561_LUX_K3T (0x00c0) ///< 0.375 * 2^RATIO_SCALE
#define TSL2561_LUX_B3T (0x023f) ///< 0.0351 * 2^LUX_SCALE
#define TSL2561_LUX_M3T (0x037b) ///< 0.0544 * 2^LUX_SCALE
#define TSL2561_LUX_K4T (0x0100) ///< 0.50 * 2^RATIO_SCALE
#define TSL2561_LUX_B4T (0x0270) ///< 0.0381 * 2^LUX_SCALE
#define TSL2561_LUX_M4T (0x03fe) ///< 0.0624 * 2^LUX_SCALE
#define TSL2561_LUX_K5T (0x0138) ///< 0.61 * 2^RATIO_SCALE
#define TSL2561_LUX_B5T (0x016f) ///< 0.0224 * 2^LUX_SCALE
#define TSL2561_LUX_M5T (0x01fc) ///< 0.0310 * 2^LUX_SCALE
#define TSL2561_LUX_K6T (0x019a) ///< 0.80 * 2^RATIO_SCALE
#define TSL2561_LUX_B6T (0x00d2) ///< 0.0128 * 2^LUX_SCALE
#define TSL2561_LUX_M6T (0x00fb) ///< 0.0153 * 2^LUX_SCALE
#define TSL2561_LUX_K7T (0x029a) ///< 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B7T (0x0018) ///< 0.00146 * 2^LUX_SCALE
#define TSL2561_LUX_M7T (0x0012) ///< 0.00112 * 2^LUX_SCALE
#define TSL2561_LUX_K8T (0x029a) ///< 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B8T (0x0000) ///< 0.000 * 2^LUX_SCALE
#define TSL2561_LUX_M8T (0x0000) ///< 0.000 * 2^LUX_SCALE
// CS package values
#define TSL2561_LUX_K1C (0x0043) // 0.130 * 2^RATIO_SCALE
#define TSL2561_LUX_B1C (0x0204) // 0.0315 * 2^LUX_SCALE
#define TSL2561_LUX_M1C (0x01ad) // 0.0262 * 2^LUX_SCALE
#define TSL2561_LUX_K2C (0x0085) // 0.260 * 2^RATIO_SCALE
#define TSL2561_LUX_B2C (0x0228) // 0.0337 * 2^LUX_SCALE
#define TSL2561_LUX_M2C (0x02c1) // 0.0430 * 2^LUX_SCALE
#define TSL2561_LUX_K3C (0x00c8) // 0.390 * 2^RATIO_SCALE
#define TSL2561_LUX_B3C (0x0253) // 0.0363 * 2^LUX_SCALE
#define TSL2561_LUX_M3C (0x0363) // 0.0529 * 2^LUX_SCALE
#define TSL2561_LUX_K4C (0x010a) // 0.520 * 2^RATIO_SCALE
#define TSL2561_LUX_B4C (0x0282) // 0.0392 * 2^LUX_SCALE
#define TSL2561_LUX_M4C (0x03df) // 0.0605 * 2^LUX_SCALE
#define TSL2561_LUX_K5C (0x014d) // 0.65 * 2^RATIO_SCALE
#define TSL2561_LUX_B5C (0x0177) // 0.0229 * 2^LUX_SCALE
#define TSL2561_LUX_M5C (0x01dd) // 0.0291 * 2^LUX_SCALE
#define TSL2561_LUX_K6C (0x019a) // 0.80 * 2^RATIO_SCALE
#define TSL2561_LUX_B6C (0x0101) // 0.0157 * 2^LUX_SCALE
#define TSL2561_LUX_M6C (0x0127) // 0.0180 * 2^LUX_SCALE
#define TSL2561_LUX_K7C (0x029a) // 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B7C (0x0037) // 0.00338 * 2^LUX_SCALE
#define TSL2561_LUX_M7C (0x002b) // 0.00260 * 2^LUX_SCALE
#define TSL2561_LUX_K8C (0x029a) // 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B8C (0x0000) // 0.000 * 2^LUX_SCALE
#define TSL2561_LUX_M8C (0x0000) // 0.000 * 2^LUX_SCALE
#define TSL2561_LUX_K1C (0x0043) ///< 0.130 * 2^RATIO_SCALE
#define TSL2561_LUX_B1C (0x0204) ///< 0.0315 * 2^LUX_SCALE
#define TSL2561_LUX_M1C (0x01ad) ///< 0.0262 * 2^LUX_SCALE
#define TSL2561_LUX_K2C (0x0085) ///< 0.260 * 2^RATIO_SCALE
#define TSL2561_LUX_B2C (0x0228) ///< 0.0337 * 2^LUX_SCALE
#define TSL2561_LUX_M2C (0x02c1) ///< 0.0430 * 2^LUX_SCALE
#define TSL2561_LUX_K3C (0x00c8) ///< 0.390 * 2^RATIO_SCALE
#define TSL2561_LUX_B3C (0x0253) ///< 0.0363 * 2^LUX_SCALE
#define TSL2561_LUX_M3C (0x0363) ///< 0.0529 * 2^LUX_SCALE
#define TSL2561_LUX_K4C (0x010a) ///< 0.520 * 2^RATIO_SCALE
#define TSL2561_LUX_B4C (0x0282) ///< 0.0392 * 2^LUX_SCALE
#define TSL2561_LUX_M4C (0x03df) ///< 0.0605 * 2^LUX_SCALE
#define TSL2561_LUX_K5C (0x014d) ///< 0.65 * 2^RATIO_SCALE
#define TSL2561_LUX_B5C (0x0177) ///< 0.0229 * 2^LUX_SCALE
#define TSL2561_LUX_M5C (0x01dd) ///< 0.0291 * 2^LUX_SCALE
#define TSL2561_LUX_K6C (0x019a) ///< 0.80 * 2^RATIO_SCALE
#define TSL2561_LUX_B6C (0x0101) ///< 0.0157 * 2^LUX_SCALE
#define TSL2561_LUX_M6C (0x0127) ///< 0.0180 * 2^LUX_SCALE
#define TSL2561_LUX_K7C (0x029a) ///< 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B7C (0x0037) ///< 0.00338 * 2^LUX_SCALE
#define TSL2561_LUX_M7C (0x002b) ///< 0.00260 * 2^LUX_SCALE
#define TSL2561_LUX_K8C (0x029a) ///< 1.3 * 2^RATIO_SCALE
#define TSL2561_LUX_B8C (0x0000) ///< 0.000 * 2^LUX_SCALE
#define TSL2561_LUX_M8C (0x0000) ///< 0.000 * 2^LUX_SCALE
// Auto-gain thresholds
#define TSL2561_AGC_THI_13MS (4850) // Max value at Ti 13ms = 5047
#define TSL2561_AGC_TLO_13MS (100)
#define TSL2561_AGC_THI_101MS (36000) // Max value at Ti 101ms = 37177
#define TSL2561_AGC_TLO_101MS (200)
#define TSL2561_AGC_THI_402MS (63000) // Max value at Ti 402ms = 65535
#define TSL2561_AGC_TLO_402MS (500)
#define TSL2561_AGC_THI_13MS (4850) ///< Max value at Ti 13ms = 5047
#define TSL2561_AGC_TLO_13MS (100) ///< Min value at Ti 13ms = 100
#define TSL2561_AGC_THI_101MS (36000) ///< Max value at Ti 101ms = 37177
#define TSL2561_AGC_TLO_101MS (200) ///< Min value at Ti 101ms = 200
#define TSL2561_AGC_THI_402MS (63000) ///< Max value at Ti 402ms = 65535
#define TSL2561_AGC_TLO_402MS (500) ///< Min value at Ti 402ms = 500
// Clipping thresholds
#define TSL2561_CLIPPING_13MS (4900)
#define TSL2561_CLIPPING_101MS (37000)
#define TSL2561_CLIPPING_402MS (65000)
#define TSL2561_CLIPPING_13MS (4900) ///< # Counts that trigger a change in gain/integration
#define TSL2561_CLIPPING_101MS (37000) ///< # Counts that trigger a change in gain/integration
#define TSL2561_CLIPPING_402MS (65000) ///< # Counts that trigger a change in gain/integration
// Delay for integration times
#define TSL2561_DELAY_INTTIME_13MS (15) ///< Wait 15ms for 13ms integration
#define TSL2561_DELAY_INTTIME_101MS (120) ///< Wait 120ms for 101ms integration
#define TSL2561_DELAY_INTTIME_402MS (450) ///< Wait 450ms for 402ms integration
/** TSL2561 I2C Registers */
enum
{
TSL2561_REGISTER_CONTROL = 0x00,
TSL2561_REGISTER_TIMING = 0x01,
TSL2561_REGISTER_THRESHHOLDL_LOW = 0x02,
TSL2561_REGISTER_THRESHHOLDL_HIGH = 0x03,
TSL2561_REGISTER_THRESHHOLDH_LOW = 0x04,
TSL2561_REGISTER_THRESHHOLDH_HIGH = 0x05,
TSL2561_REGISTER_INTERRUPT = 0x06,
TSL2561_REGISTER_CRC = 0x08,
TSL2561_REGISTER_ID = 0x0A,
TSL2561_REGISTER_CHAN0_LOW = 0x0C,
TSL2561_REGISTER_CHAN0_HIGH = 0x0D,
TSL2561_REGISTER_CHAN1_LOW = 0x0E,
TSL2561_REGISTER_CHAN1_HIGH = 0x0F
TSL2561_REGISTER_CONTROL = 0x00, // Control/power register
TSL2561_REGISTER_TIMING = 0x01, // Set integration time register
TSL2561_REGISTER_THRESHHOLDL_LOW = 0x02, // Interrupt low threshold low-byte
TSL2561_REGISTER_THRESHHOLDL_HIGH = 0x03, // Interrupt low threshold high-byte
TSL2561_REGISTER_THRESHHOLDH_LOW = 0x04, // Interrupt high threshold low-byte
TSL2561_REGISTER_THRESHHOLDH_HIGH = 0x05, // Interrupt high threshold high-byte
TSL2561_REGISTER_INTERRUPT = 0x06, // Interrupt settings
TSL2561_REGISTER_CRC = 0x08, // Factory use only
TSL2561_REGISTER_ID = 0x0A, // TSL2561 identification setting
TSL2561_REGISTER_CHAN0_LOW = 0x0C, // Light data channel 0, low byte
TSL2561_REGISTER_CHAN0_HIGH = 0x0D, // Light data channel 0, high byte
TSL2561_REGISTER_CHAN1_LOW = 0x0E, // Light data channel 1, low byte
TSL2561_REGISTER_CHAN1_HIGH = 0x0F // Light data channel 1, high byte
};
/** Three options for how long to integrate readings for */
typedef enum
{
TSL2561_INTEGRATIONTIME_13MS = 0x00, // 13.7ms
@@ -161,6 +149,7 @@ typedef enum
}
tsl2561IntegrationTime_t;
/** TSL2561 offers 2 gain settings */
typedef enum
{
TSL2561_GAIN_1X = 0x00, // No gain
@@ -168,10 +157,19 @@ typedef enum
}
tsl2561Gain_t;
/**************************************************************************/
/*!
@brief Class that stores state and functions for interacting with TSL2561 Light Sensor
*/
/**************************************************************************/
class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
public:
Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID = -1);
boolean begin(void);
boolean begin(TwoWire *theWire);
boolean init();
/* TSL2561 Functions */
void enableAutoRange(bool enable);
@@ -185,6 +183,8 @@ class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
void getSensor(sensor_t*);
private:
TwoWire *_i2c;
int8_t _addr;
boolean _tsl2561Initialised;
boolean _tsl2561AutoGain;
@@ -194,9 +194,10 @@ class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
void enable (void);
void disable (void);
void write8 (uint8_t reg, uint32_t value);
void write8 (uint8_t reg, uint8_t value);
uint8_t read8 (uint8_t reg);
uint16_t read16 (uint8_t reg);
void getData (uint16_t *broadband, uint16_t *ir);
};
#endif
#endif // ADAFRUIT_TSL2561_H
+6 -3
View File
@@ -1,7 +1,10 @@
#Adafruit TSL2561 Light Sensor Driver #
# Adafruit TSL2561 Light Sensor Driver [![Build Status](https://travis-ci.org/adafruit/Adafruit_TSL2561.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_TSL2561)
This driver is for the Adafruit TSL2561 Breakout, and is based on Adafruit's Unified Sensor Library (Adafruit_Sensor).
<img src="https://cdn-shop.adafruit.com/970x728/439-00.jpg" height="300"/>
The driver supports manual or 'auto' gain. Adjusting the gain allows you to make the sensor more or less 'sensitive' to light (depending on if you are indoors or outdoors, for example):
```
tsl.setGain(TSL2561_GAIN_1X); /* No gain ... use in bright light to avoid sensor saturation */
@@ -9,7 +12,7 @@ tsl.setGain(TSL2561_GAIN_16X); /* 16x gain ... use in low light to boost sen
tsl.enableAutoGain(true); /* Auto-gain ... switches automatically between 1x and 16x */
```
The driver also supports as automatic clipping detection, and will return '0' lux when the sensor is saturated and data is unreliable.
The driver also supports as automatic clipping detection, and will return '65536' lux when the sensor is saturated and data is unreliable. tsl.getEvent will return false in case of saturation and true in case of valid light data.
## About the TSL2561 ##
@@ -44,4 +47,4 @@ Light sensors will always report units in lux, gyroscopes will always report uni
Adafruit invests time and resources providing this open source code. Please support Adafruit and open-source hardware by purchasing products from Adafruit!
Written by Kevin (KTOWN) Townsend for Adafruit Industries.
Written by Kevin (KTOWN) Townsend for Adafruit Industries.
@@ -16,9 +16,9 @@
Connections
===========
Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect SCL to I2C SCL Clock
Connect SDA to I2C SDA Data
Connect VDD to 3.3V or 5V (whatever your logic level is)
Connect GROUND to common ground
I2C Address
@@ -94,9 +94,11 @@ void setup(void)
Serial.println("Light Sensor Test"); Serial.println("");
/* Initialise the sensor */
//use tsl.begin() to default to Wire,
//tsl.begin(&Wire2) directs api to use Wire2, etc.
if(!tsl.begin())
{
/* There was a problem detecting the ADXL345 ... check your connections */
/* There was a problem detecting the TSL2561 ... check your connections */
Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
while(1);
}
+1 -1
View File
@@ -1,5 +1,5 @@
name=Adafruit TSL2561
version=1.0.0
version=1.0.2
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Unified sensor driver for Adafruit's TSL2561 breakouts
-74
View File
@@ -1,74 +0,0 @@
/**************************************************************************/
/*!
@file pgmspace.h
@author Mike Roberts
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2013, Mike Roberts
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**************************************************************************/
#ifndef delorean_pgmspace_h
#define delorean_pgmspace_h
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcat_P(dest, src) strcat((dest), (src))
#define strcmp_P(a, b) strcmp((a), (b))
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#endif
-5
View File
@@ -1,5 +0,0 @@
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Google
Standard: Cpp03
AllowShortFunctionsOnASingleLine: Empty
-1
View File
@@ -1 +0,0 @@
*.sh text eol=lf
-11
View File
@@ -1,11 +0,0 @@
.DS_Store
/.idea
/build
/bin
/lib
/sftp-config.json
.tags
.tags_sorted_by_file
/fuzzing/*_fuzzer
/fuzzing/*_fuzzer.options
/fuzzing/*_fuzzer_seed_corpus.zip
-6
View File
@@ -1,6 +0,0 @@
.github/
examples/
fuzzing/
scripts/
test/
third-party/
-96
View File
@@ -1,96 +0,0 @@
sudo: false
language: cpp
matrix:
include:
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.4']
env: SCRIPT=cmake GCC=4.4
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['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 GCC=4.7
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['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 GCC=4.9 SANITIZE=leak
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
env: SCRIPT=cmake GCC=5 SANITIZE=undefined
- 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
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5']
packages: ['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 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 CLANG=3.7
- compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8']
packages: ['clang-3.8']
env: SCRIPT=cmake CLANG=3.8 SANITIZE=undefined
- compiler: gcc
env: SCRIPT=coverage
- os: osx
osx_image: xcode6.4
compiler: clang
env: SCRIPT=cmake
- os: osx
osx_image: xcode7.3
compiler: clang
env: SCRIPT=cmake SANITIZE=address
- env: SCRIPT=arduino VERSION=1.6.7 BOARD=arduino:avr:uno
- env: SCRIPT=arduino VERSION=1.8.2 BOARD=arduino:avr:uno
- env: SCRIPT=platformio BOARD=uno
- env: SCRIPT=platformio BOARD=esp01
cache:
directories:
- "~/.platformio"
script: scripts/travis/$SCRIPT.sh
+15
View File
@@ -1,6 +1,21 @@
ArduinoJson: change log
=======================
v5.13.3
-------
* Improved float serialization when `-fsingle-precision-constant` is used
* Fixed `JsonVariant::is<int>()` that returned true for empty strings
* Fixed `JsonVariant::is<String>()` (closes #763)
v5.13.2
-------
* Fixed `JsonBuffer::parse()` not respecting nesting limit correctly (issue #693)
* Fixed inconsistencies in nesting level counting (PR #695 from Zhenyu Wu)
* Fixed null values that could be pass to `strcmp()` (PR #745 from Mike Karlesky)
* Added macros `ARDUINOJSON_VERSION`, `ARDUINOJSON_VERSION_MAJOR`...
v5.13.1
-------
-16
View File
@@ -1,16 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
cmake_minimum_required(VERSION 3.0)
project(ArduinoJson)
enable_testing()
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
@@ -1,11 +0,0 @@
# 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)
-27
View File
@@ -1,27 +0,0 @@
# 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!
-20
View File
@@ -1,20 +0,0 @@
version: 5.13.1.{build}
environment:
matrix:
- 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
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
- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" .
build_script:
- cmake --build . --config %CONFIGURATION%
test_script:
- ctest --output-on-failure .
-367
View File
@@ -1,367 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1001"
height="250"
viewBox="0 0 264.84791 66.145837"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="logo.svg">
<defs
id="defs2">
<clipPath
id="clipPath831"
clipPathUnits="userSpaceOnUse">
<path
inkscape:connector-curvature="0"
id="path829"
d="M 0,638 H 1000 V 0 H 0 Z" />
</clipPath>
<clipPath
id="clipPath839"
clipPathUnits="userSpaceOnUse">
<path
inkscape:connector-curvature="0"
id="path837"
d="M 0,638 H 1000 V 0 H 0 Z" />
</clipPath>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="399.91304"
inkscape:cy="242.52487"
inkscape:document-units="mm"
inkscape:current-layer="g823"
showgrid="false"
fit-margin-top="5"
fit-margin-bottom="5"
fit-margin-right="5"
fit-margin-left="5"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
units="px" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-1.2883269,-86.047553)">
<g
transform="matrix(0.35277777,0,0,-0.35277777,-137.80575,256.55859)"
inkscape:label="logo (2)"
id="g823">
<g
id="g825"
transform="matrix(0.44331091,0,0,0.44331091,559.35527,248.127)">
<g
clip-path="url(#clipPath831)"
id="g827">
<g
transform="translate(246.9092,120.1406)"
id="g847">
<path
inkscape:connector-curvature="0"
id="path849"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 20.015,58.057 H 39.896 L 59.909,0 H 44.138 L 41.22,10.34 H 18.82 L 15.772,0 Z m 22.135,21.605 h 15.771 l -5.83,19.219 c -0.265,0.53 -0.53,1.457 -0.797,2.787 -0.398,1.323 -0.795,3.043 -1.192,5.034 -0.398,-1.461 -0.662,-2.784 -1.062,-4.11 -0.397,-1.322 -0.662,-2.519 -1.059,-3.711 z" />
</g>
<g
transform="translate(311.457,120.1406)"
id="g851">
<path
inkscape:connector-curvature="0"
id="path853"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 v 40.029 h 13.387 v -9.41 c 1.326,3.447 3.182,5.965 5.566,7.69 2.387,1.72 5.304,2.648 8.616,2.648 0.661,0 1.192,-0.133 1.723,-0.133 0.53,0 1.192,-0.135 1.722,-0.135 L 29.689,27.836 c -0.928,0.266 -1.723,0.533 -2.517,0.664 -0.795,0.133 -1.592,0.133 -2.386,0.133 -3.446,0 -6.098,-1.065 -7.953,-3.182 C 14.978,23.332 14.05,20.414 14.05,16.568 V 0 Z" />
</g>
<g
transform="translate(390.7183,181.6387)"
id="g855">
<path
inkscape:connector-curvature="0"
id="path857"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 v -61.498 h -12.989 v 6.494 c -1.724,-2.648 -3.844,-4.769 -5.966,-6.096 -2.253,-1.322 -4.771,-1.984 -7.554,-1.984 -5.567,0 -10.073,1.984 -13.387,5.83 -3.314,3.977 -5.036,9.147 -5.036,15.772 0,6.359 1.722,11.531 5.036,15.375 3.314,3.976 7.556,5.962 12.856,5.962 3.446,0 6.229,-0.664 8.35,-1.853 2.121,-1.191 3.977,-3.314 5.701,-6.098 -0.265,0.928 -0.265,1.989 -0.397,3.182 -0.135,1.193 -0.135,2.519 -0.135,3.975 V 0 Z m -12.459,-41.482 c 0,3.05 -0.795,5.566 -2.519,7.287 -1.591,1.859 -3.845,2.787 -6.76,2.787 -2.783,0 -5.036,-0.928 -6.761,-2.787 -1.588,-1.721 -2.385,-4.237 -2.385,-7.287 0,-3.182 0.797,-5.698 2.385,-7.426 1.725,-1.852 3.978,-2.647 6.761,-2.647 2.915,0 5.169,0.795 6.76,2.647 1.724,1.859 2.519,4.244 2.519,7.426" />
</g>
<g
transform="translate(442.2769,160.1699)"
id="g859">
<path
inkscape:connector-curvature="0"
id="path861"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 v -20.412 c 0,-4.506 -0.265,-7.953 -1.061,-10.072 -0.663,-2.254 -1.989,-4.11 -3.71,-5.83 -1.724,-1.727 -3.978,-3.051 -6.496,-3.979 -2.65,-0.793 -5.831,-1.322 -9.41,-1.322 -3.578,0 -6.626,0.529 -9.277,1.322 -2.651,0.928 -4.771,2.252 -6.628,3.979 -1.724,1.587 -3.048,3.576 -3.712,5.83 -0.663,2.119 -1.06,5.566 -1.06,10.072 V 0 h 13.519 v -21.336 c 0,-3.316 0.532,-5.836 1.591,-7.293 1.195,-1.457 2.916,-2.252 5.434,-2.252 2.518,0 4.375,0.795 5.435,2.252 1.06,1.457 1.59,3.842 1.59,7.293 V 0 Z" />
</g>
<path
inkscape:connector-curvature="0"
id="path863"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 452.88,160.17 h 14.05 v -40.029 h -14.05 z m -0.795,12.461 c 0,2.119 0.795,3.974 2.386,5.435 1.457,1.588 3.313,2.25 5.434,2.25 2.254,0 4.108,-0.662 5.567,-2.119 1.458,-1.592 2.254,-3.316 2.254,-5.566 0,-2.123 -0.796,-3.977 -2.254,-5.57 -1.592,-1.457 -3.447,-2.25 -5.567,-2.25 -2.121,0 -3.977,0.793 -5.434,2.25 -1.591,1.593 -2.386,3.447 -2.386,5.57" />
<g
transform="translate(477.7983,120.1406)"
id="g865">
<path
inkscape:connector-curvature="0"
id="path867"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 v 40.029 h 12.856 v -8.088 c 1.988,3.186 4.109,5.567 6.496,7.163 2.517,1.455 5.434,2.25 8.881,2.25 2.648,0 4.904,-0.53 6.891,-1.325 1.99,-0.795 3.712,-1.984 4.903,-3.58 1.059,-1.322 1.854,-2.912 2.256,-4.902 0.529,-1.986 0.662,-4.774 0.662,-8.613 V 0 h -14.05 v 21.473 c 0,3.181 -0.53,5.433 -1.59,6.896 -1.062,1.455 -2.651,2.25 -5.035,2.25 -2.918,0 -5.04,-1.058 -6.365,-3.316 C 14.58,25.184 13.918,21.605 13.918,16.834 V 0 Z" />
</g>
<g
transform="translate(573.2275,140.0254)"
id="g869">
<path
inkscape:connector-curvature="0"
id="path871"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 0,-2.918 -0.529,-5.566 -1.721,-8.221 -1.059,-2.515 -2.653,-4.904 -4.905,-6.89 -2.118,-2.125 -4.507,-3.711 -7.287,-4.774 -2.653,-1.056 -5.439,-1.586 -8.484,-1.586 -3.05,0 -5.963,0.53 -8.617,1.586 -2.653,1.063 -5.037,2.649 -7.155,4.774 -2.124,1.986 -3.845,4.242 -4.904,6.89 -1.064,2.522 -1.594,5.303 -1.594,8.221 0,2.918 0.53,5.697 1.594,8.35 1.059,2.515 2.648,4.904 4.904,6.892 1.986,2.117 4.37,3.578 7.155,4.639 2.654,1.058 5.567,1.588 8.617,1.588 3.045,0 5.962,-0.53 8.612,-1.588 2.652,-1.061 5.041,-2.522 7.159,-4.639 2.252,-2.119 3.846,-4.377 4.905,-7.025 C -0.529,5.697 0,2.918 0,0 m -14.05,0 c 0,3.049 -0.795,5.299 -2.252,7.021 -1.457,1.727 -3.579,2.655 -6.095,2.655 -2.654,0 -4.639,-0.928 -6.096,-2.655 -1.461,-1.722 -2.256,-3.972 -2.256,-7.021 0,-2.918 0.795,-5.303 2.256,-7.027 1.457,-1.725 3.442,-2.518 6.096,-2.518 2.516,0 4.638,0.793 6.095,2.518 1.457,1.724 2.252,4.109 2.252,7.027" />
</g>
<g
transform="translate(593.7715,178.1973)"
id="g873">
<path
inkscape:connector-curvature="0"
id="path875"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 h 15.776 v -37.643 c 0,-4.109 -0.264,-7.287 -0.799,-9.545 -0.53,-2.117 -1.457,-4.109 -2.649,-5.832 -1.589,-2.115 -3.58,-3.843 -5.964,-4.902 -2.387,-1.191 -4.903,-1.721 -7.821,-1.721 -3.712,0 -7.022,0.793 -9.808,2.383 -2.914,1.588 -5.301,3.846 -7.289,6.889 l 9.676,8.75 c 0.133,-1.723 0.796,-3.045 1.589,-3.977 0.928,-0.927 1.987,-1.326 3.316,-1.326 1.456,0 2.516,0.797 3.178,2.524 0.529,1.586 0.795,5.83 0.795,12.455 z" />
</g>
<g
transform="translate(616.4375,123.457)"
id="g877">
<path
inkscape:connector-curvature="0"
id="path879"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 3.051,10.734 C 5.036,9.01 7.288,7.553 9.809,6.627 c 2.519,-0.928 4.903,-1.459 7.424,-1.459 1.854,0 3.178,0.268 4.105,0.928 0.933,0.531 1.329,1.326 1.329,2.384 0,1.86 -1.858,3.182 -5.571,3.979 -1.192,0.264 -2.251,0.529 -2.913,0.793 -4.242,1.191 -7.292,2.652 -9.279,4.639 -1.853,1.859 -2.786,4.244 -2.786,7.293 0,3.839 1.462,7.021 4.375,9.277 2.917,2.385 6.895,3.576 11.8,3.576 2.648,0 5.168,-0.396 7.816,-0.928 2.654,-0.66 5.434,-1.588 8.22,-2.785 l -2.918,-9.67 c -1.853,1.192 -3.841,2.25 -5.698,2.912 -1.986,0.664 -3.846,0.928 -5.831,0.928 -1.589,0 -2.786,-0.264 -3.713,-0.793 -0.794,-0.533 -1.192,-1.193 -1.192,-2.119 0,-1.463 1.855,-2.654 5.566,-3.582 0.928,-0.264 1.457,-0.396 1.859,-0.529 4.904,-1.455 8.348,-3.051 10.205,-4.903 1.987,-1.988 2.914,-4.507 2.914,-7.691 0,-4.104 -1.589,-7.42 -4.771,-9.939 -3.047,-2.518 -7.289,-3.84 -12.457,-3.84 -3.448,0 -6.763,0.396 -9.809,1.191 C 5.566,-2.918 2.653,-1.592 0,0" />
</g>
<g
transform="translate(701.9268,140.0254)"
id="g881">
<path
inkscape:connector-curvature="0"
id="path883"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 0,-2.918 -0.53,-5.566 -1.723,-8.221 -1.057,-2.515 -2.651,-4.904 -4.77,-6.89 -2.252,-2.125 -4.64,-3.711 -7.288,-4.774 -2.785,-1.056 -5.571,-1.586 -8.616,-1.586 -3.051,0 -5.964,0.53 -8.618,1.586 -2.647,1.063 -5.036,2.649 -7.155,4.774 -2.123,1.986 -3.712,4.242 -4.903,6.89 -1.065,2.522 -1.594,5.303 -1.594,8.221 0,2.918 0.529,5.697 1.594,8.35 1.191,2.515 2.78,4.904 4.903,6.892 2.119,2.117 4.508,3.578 7.155,4.639 2.654,1.058 5.567,1.588 8.618,1.588 3.177,0 5.962,-0.53 8.616,-1.588 C -11,18.82 -8.612,17.359 -6.493,15.242 -4.374,13.123 -2.78,10.865 -1.589,8.217 -0.53,5.697 0,2.918 0,0 m -14.05,0 c 0,3.049 -0.663,5.299 -2.252,7.021 -1.457,1.727 -3.447,2.655 -6.095,2.655 -2.521,0 -4.64,-0.928 -6.097,-2.655 -1.461,-1.722 -2.255,-3.972 -2.255,-7.021 0,-2.918 0.794,-5.303 2.255,-7.027 1.457,-1.725 3.576,-2.518 6.097,-2.518 2.648,0 4.638,0.793 6.095,2.518 1.589,1.724 2.252,4.109 2.252,7.027" />
</g>
<g
transform="translate(710.0127,120.1406)"
id="g885">
<path
inkscape:connector-curvature="0"
id="path887"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 v 40.029 h 12.992 v -8.088 c 1.854,3.186 3.973,5.567 6.492,7.163 2.516,1.455 5.434,2.25 8.882,2.25 2.516,0 4.904,-0.53 6.89,-1.325 1.986,-0.795 3.58,-1.984 4.904,-3.58 1.06,-1.322 1.854,-2.912 2.257,-4.902 0.396,-1.986 0.661,-4.774 0.661,-8.613 V 0 h -14.05 v 21.473 c 0,3.181 -0.529,5.433 -1.589,6.896 -1.064,1.455 -2.786,2.25 -5.042,2.25 -2.913,0 -5.036,-1.058 -6.492,-3.316 -1.324,-2.119 -1.987,-5.698 -1.987,-10.469 L 13.918,0 Z" />
</g>
<g
transform="translate(703.3916,417.1084)"
id="g889">
<path
inkscape:connector-curvature="0"
id="path891"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 -8.81,-3.271 c 5.363,-15.116 8.291,-31.384 8.291,-48.338 0,-4.616 -0.226,-9.177 -0.648,-13.683 l 9.375,-0.627 c 0.434,4.712 0.667,9.484 0.667,14.31 C 8.875,-33.505 5.739,-16.134 0,0" />
</g>
<g
transform="translate(558.3203,220.9473)"
id="g893">
<path
inkscape:connector-curvature="0"
id="path895"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c -15.705,0 -30.819,2.516 -44.978,7.146 -3.751,-1.978 -7.583,-3.82 -11.51,-5.49 -0.144,-0.06 -0.29,-0.117 -0.434,-0.177 C -39.313,-5.533 -20.108,-9.395 0,-9.395 c 48.132,0 91.098,22.094 119.328,56.688 l -8.571,4.381 C 84.24,20.088 44.469,0 0,0" />
</g>
<g
transform="translate(441.6821,219.5352)"
id="g897">
<path
inkscape:connector-curvature="0"
id="path899"
style="fill:#e47128;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 C -21.463,0 -41.833,4.674 -60.154,13.053 L -64.849,5.168 C -45.139,-4.002 -23.17,-9.131 0,-9.131 c 21.177,0 41.352,4.283 59.716,12.022 C 55.719,4.482 51.807,6.24 47.983,8.148 32.965,2.875 16.819,0 0,0" />
</g>
<g
transform="translate(552.4727,271.1309)"
id="g901">
<path
inkscape:connector-curvature="0"
id="path903"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 C 0.009,0 0.017,-0.004 0.023,-0.004 0.017,-0.004 0.009,0 0,0" />
</g>
<g
transform="translate(554.5205,271.0293)"
id="g905">
<path
inkscape:connector-curvature="0"
id="path907"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 C 1.26,-0.057 2.524,-0.098 3.8,-0.098 5.079,-0.098 6.349,-0.057 7.614,0 6.347,-0.051 5.076,-0.096 3.796,-0.096 2.523,-0.096 1.262,-0.051 0,0" />
</g>
<g
transform="translate(554.3145,459.9658)"
id="g909">
<path
inkscape:connector-curvature="0"
id="path911"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 C 1.311,0.054 2.624,0.099 3.947,0.1 2.624,0.099 1.31,0.062 0,0" />
</g>
<g
transform="translate(550.6484,459.731)"
id="g913">
<path
inkscape:connector-curvature="0"
id="path915"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 V 0 C 0.003,0 0.004,0 0.006,0 0.004,0 0.003,0 0,0" />
</g>
<g
transform="translate(564.1133,271.125)"
id="g917">
<path
inkscape:connector-curvature="0"
id="path919"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 C 0.021,0.002 0.04,0.002 0.061,0.006 H 0.062 C 0.041,0.006 0.021,0.002 0,0" />
</g>
<g
transform="translate(562.3379,459.9663)"
id="g921">
<path
inkscape:connector-curvature="0"
id="path923"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 C -1.334,0.056 -2.67,0.101 -4.018,0.101 H -4.02 c 1.349,0 2.686,-0.046 4.021,-0.102 C 0,0 0,0 0,0" />
</g>
<g
transform="translate(595.6299,364.3545)"
id="g925">
<path
inkscape:connector-curvature="0"
id="path927"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 0,33.746 -10.866,64.951 -29.28,90.321 -2.649,0.236 -5.324,0.377 -8.033,0.377 -1.23,0 -2.45,-0.044 -3.667,-0.093 C -21.057,65.797 -9.131,34.293 -9.131,0 c 0,-33.273 -11.235,-63.909 -30.102,-88.358 0.64,-0.014 1.276,-0.049 1.92,-0.049 3.298,0 6.55,0.191 9.755,0.539 C -10.197,-62.95 0,-32.672 0,0" />
</g>
<g
transform="translate(672.6201,365.4995)"
id="g929">
<path
inkscape:connector-curvature="0"
id="path931"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 0,63.125 -51.175,114.299 -114.3,114.299 -4.692,0 -9.316,-0.289 -13.861,-0.839 -3.962,-0.48 -7.86,-1.156 -11.687,-2.03 3.089,-2.502 6.077,-5.122 8.947,-7.866 3.831,0.61 7.731,1.013 11.688,1.195 1.629,0.076 3.266,0.119 4.913,0.119 57.922,0 104.878,-46.956 104.878,-104.878 0,-3.787 -0.206,-7.525 -0.597,-11.208 l 9.292,-1.675 C -0.253,-8.653 0,-4.357 0,0" />
</g>
<g
transform="translate(383.3794,235.6973)"
id="g933">
<path
inkscape:connector-curvature="0"
id="path935"
style="fill:#62aeb2;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 2.881,4.838 c -47.274,21.193 -80.206,68.66 -80.206,123.819 0,8.489 0.321,14.111 1.814,22.167 l -18.228,2.079 c -1.249,-7.899 -1.907,-15.995 -1.907,-24.246 0,-61.852 36.484,-115.178 89.1,-139.651 l 4.695,7.885 z" />
</g>
<g
transform="translate(475.9927,495.5977)"
id="g937">
<path
inkscape:connector-curvature="0"
id="path939"
style="fill:#62aeb2;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 4.099,-1.069 8.124,-2.323 12.062,-3.756 2.162,1.206 4.357,2.358 6.585,3.453 1.45,0.713 2.909,1.406 4.384,2.071 3.797,1.711 7.685,3.255 11.648,4.638 14.921,5.208 30.952,8.047 47.649,8.047 50.216,0 94.445,-25.61 120.356,-64.478 l 7.703,5.385 C 182.777,-3.349 135.73,23.848 82.328,23.848 61.15,23.848 40.972,19.57 22.608,11.833 18.644,10.163 14.768,8.325 10.98,6.34 9.503,5.566 8.039,4.77 6.59,3.949 -6.357,7.861 -20.087,9.974 -34.311,9.974 c -3.094,0 -6.163,-0.111 -9.207,-0.307 l -0.323,-5.623 c 3.149,0.219 6.326,0.339 9.53,0.339 C -22.457,4.383 -10.959,2.857 0,0" />
</g>
<g
transform="translate(342.8081,347.3779)"
id="g941">
<path
inkscape:connector-curvature="0"
id="path943"
style="fill:#62aeb2;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 4.169,2.559 c -0.711,4.703 -1.083,9.516 -1.083,14.418 0,51.248 40.26,93.047 90.872,95.611 1.237,1.59 2.509,3.154 3.806,4.693 1.986,2.356 4.035,4.656 6.155,6.887 -1.673,0.08 -3.352,0.136 -5.045,0.136 -59.276,0 -107.328,-48.053 -107.328,-107.327 0,-57.863 45.79,-105.023 103.111,-107.238 l -5.896,7.424 C 43.744,-78.327 7.513,-44.065 0,0" />
</g>
<g
transform="translate(454.5591,264.8711)"
id="g945">
<path
inkscape:connector-curvature="0"
id="path947"
style="fill:#62aeb2;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c -1.312,1.354 -2.598,2.729 -3.857,4.131 -5.416,6.037 -10.324,12.535 -14.674,19.422 l -10.18,-1.379 c 3.833,-6.455 8.123,-12.606 12.825,-18.408 1.262,-1.559 2.553,-3.09 3.872,-4.596 2.034,-2.32 4.137,-4.578 6.305,-6.772 2.299,-2.324 4.68,-4.566 7.121,-6.742 l 10.99,2.959 C 10.322,-9.689 8.29,-7.939 6.311,-6.131 4.144,-4.154 2.042,-2.105 0,0" />
</g>
<g
transform="translate(420.0469,407.7637)"
id="g949">
<path
inkscape:connector-curvature="0"
id="path951"
style="fill:#62aeb2;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 -9.694,0.332 c -3.889,-13.529 -5.979,-27.818 -5.979,-42.596 0,-20.788 4.126,-40.609 11.596,-58.699 H 6.143 C -1.84,-83.025 -6.279,-63.164 -6.279,-42.264 -6.279,-27.56 -4.082,-13.369 0,0" />
</g>
<g
transform="translate(458.4263,365.4995)"
id="g953">
<path
inkscape:connector-curvature="0"
id="path955"
style="fill:#62aeb2;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 0,-17.657 4.593,-34.231 12.636,-48.619 l 4.824,2.261 c -0.085,0.15 -0.164,0.305 -0.247,0.456 -0.309,0.553 -0.611,1.11 -0.909,1.671 -0.37,0.698 -0.728,1.404 -1.082,2.114 -0.377,0.757 -0.743,1.519 -1.101,2.286 -0.322,0.692 -0.638,1.387 -0.944,2.088 -0.239,0.55 -0.476,1.1 -0.706,1.654 -0.434,1.049 -0.854,2.106 -1.251,3.173 -0.178,0.479 -0.342,0.965 -0.512,1.449 -0.281,0.795 -0.552,1.595 -0.813,2.401 -0.16,0.498 -0.323,0.994 -0.476,1.496 -0.35,1.149 -0.68,2.307 -0.986,3.474 -0.119,0.448 -0.225,0.9 -0.337,1.351 -0.232,0.939 -0.45,1.884 -0.654,2.834 -0.087,0.408 -0.181,0.812 -0.263,1.222 -0.251,1.249 -0.473,2.509 -0.674,3.776 -0.067,0.418 -0.126,0.838 -0.186,1.258 -0.161,1.109 -0.303,2.223 -0.425,3.343 -0.031,0.282 -0.069,0.562 -0.097,0.844 -0.133,1.337 -0.23,2.684 -0.307,4.037 -0.023,0.4 -0.041,0.801 -0.059,1.202 -0.058,1.316 -0.097,2.637 -0.1,3.965 0,0.088 -0.007,0.175 -0.007,0.264 0,0.173 0.012,0.344 0.013,0.517 0.007,1.306 0.039,2.606 0.099,3.898 0.025,0.564 0.069,1.123 0.105,1.685 0.058,0.914 0.124,1.826 0.208,2.733 0.058,0.626 0.125,1.249 0.195,1.872 0.094,0.837 0.202,1.671 0.318,2.502 0.089,0.638 0.178,1.276 0.28,1.91 0.132,0.823 0.284,1.64 0.438,2.456 0.116,0.616 0.222,1.236 0.349,1.848 0.271,1.292 0.566,2.576 0.888,3.849 0.192,0.756 0.41,1.501 0.62,2.251 0.166,0.593 0.328,1.188 0.505,1.777 0.243,0.808 0.505,1.608 0.77,2.407 0.164,0.498 0.33,0.995 0.503,1.489 0.297,0.848 0.604,1.692 0.924,2.531 0.146,0.38 0.298,0.759 0.449,1.138 0.369,0.93 0.743,1.856 1.14,2.771 0.007,0.016 0.015,0.032 0.022,0.048 1.999,4.596 4.359,8.995 7.034,13.177 0.004,0.009 0.01,0.017 0.015,0.025 1.34,2.093 2.745,4.138 4.24,6.115 l -5.094,2.048 C 7.191,42.509 0,22.1 0,0" />
</g>
<g
transform="translate(581.1611,243.5664)"
id="g957">
<path
inkscape:connector-curvature="0"
id="path959"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 -2.615,9.418 -2.535,9.131 c 45.885,7.797 81.619,45.39 86.59,92.177 0.391,3.682 0.597,7.42 0.597,11.207 0,57.922 -46.956,104.878 -104.878,104.878 -1.647,0 -3.284,-0.043 -4.913,-0.119 -3.957,-0.182 -7.857,-0.585 -11.688,-1.194 -1.485,-0.237 -2.96,-0.499 -4.422,-0.797 -2.233,-0.454 -4.436,-0.984 -6.613,-1.578 -2.298,-0.625 -4.565,-1.328 -6.796,-2.103 -3.646,-1.267 -7.203,-2.727 -10.653,-4.372 -4.115,-1.962 -8.082,-4.187 -11.881,-6.648 -2.119,-1.375 -4.185,-2.822 -6.195,-4.34 -2.869,1.81 -5.835,3.481 -8.89,4.998 2.008,1.632 4.07,3.201 6.187,4.695 3.793,2.68 7.758,5.133 11.873,7.343 3.445,1.849 6.998,3.525 10.644,5.02 2.225,0.913 4.484,1.764 6.778,2.54 2.179,0.735 4.39,1.399 6.626,2.004 1.455,0.394 2.919,0.766 4.395,1.103 3.826,0.874 7.725,1.551 11.687,2.031 4.545,0.549 9.169,0.838 13.861,0.838 63.125,0 114.3,-51.173 114.3,-114.299 0,-4.357 -0.253,-8.653 -0.727,-12.883 l 9.607,-1.732 C 93.994,53.27 52.901,9.85 0,0 m -22.841,27.365 c -1.275,0 -2.54,0.041 -3.8,0.098 -0.676,0.025 -1.35,0.058 -2.024,0.098 -0.007,0 -0.015,0.003 -0.023,0.003 -19.058,1.165 -36.591,7.956 -50.95,18.756 -1.006,0.758 -1.994,1.537 -2.969,2.332 -0.391,0.323 -0.775,0.651 -1.161,0.975 -0.656,0.555 -1.306,1.115 -1.947,1.686 -0.425,0.38 -0.849,0.761 -1.269,1.148 -0.604,0.56 -1.197,1.131 -1.786,1.705 -0.4,0.389 -0.807,0.772 -1.2,1.168 -0.863,0.869 -1.708,1.756 -2.536,2.66 -0.474,0.516 -0.932,1.047 -1.394,1.574 -0.414,0.471 -0.827,0.942 -1.231,1.418 -0.487,0.58 -0.966,1.162 -1.439,1.752 -0.354,0.442 -0.701,0.885 -1.048,1.332 -0.48,0.621 -0.96,1.241 -1.424,1.869 -0.029,0.041 -0.06,0.079 -0.089,0.118 l -4.694,-2.575 -4.419,-2.419 c -12.258,17.162 -19.475,38.172 -19.475,60.87 0,25.55 9.142,48.961 24.325,67.153 l 4.675,-2.22 4.99,-2.369 c 7.854,8.892 17.353,16.287 28.026,21.725 0.266,0.137 0.532,0.277 0.803,0.411 0.77,0.384 1.547,0.755 2.33,1.118 0.419,0.194 0.841,0.382 1.263,0.571 9.537,4.253 19.904,6.968 30.794,7.843 0.003,0 0.004,0 0.006,0 1.216,0.097 2.434,0.183 3.66,0.234 1.31,0.062 2.624,0.099 3.948,0.101 0.018,0 0.036,0 0.054,0 h 0.002 0.002 c 1.348,0 2.684,-0.044 4.018,-0.1 0.008,-0.001 0.015,-0.001 0.024,-0.002 1.471,-0.062 2.93,-0.163 4.382,-0.292 0.116,-0.009 0.234,-0.015 0.352,-0.026 1.395,-0.128 2.778,-0.294 4.156,-0.483 0.171,-0.023 0.344,-0.041 0.514,-0.065 1.33,-0.189 2.645,-0.414 3.956,-0.657 0.213,-0.041 0.431,-0.075 0.646,-0.116 1.267,-0.245 2.521,-0.522 3.769,-0.817 0.252,-0.06 0.505,-0.113 0.756,-0.175 1.208,-0.295 2.404,-0.621 3.593,-0.963 0.283,-0.082 0.571,-0.158 0.853,-0.243 1.152,-0.343 2.293,-0.713 3.426,-1.099 0.31,-0.106 0.623,-0.207 0.933,-0.316 1.1,-0.387 2.186,-0.798 3.267,-1.225 0.332,-0.13 0.666,-0.257 0.997,-0.392 1.047,-0.427 2.082,-0.877 3.11,-1.339 0.354,-0.159 0.708,-0.315 1.059,-0.479 0.995,-0.462 1.978,-0.945 2.954,-1.441 0.371,-0.189 0.742,-0.376 1.109,-0.569 0.945,-0.495 1.876,-1.009 2.801,-1.535 0.387,-0.219 0.771,-0.439 1.154,-0.664 0.893,-0.524 1.775,-1.065 2.648,-1.617 0.399,-0.253 0.796,-0.506 1.192,-0.764 0.841,-0.55 1.672,-1.114 2.493,-1.69 0.411,-0.286 0.819,-0.577 1.224,-0.869 0.792,-0.573 1.573,-1.158 2.346,-1.754 0.417,-0.323 0.831,-0.648 1.242,-0.977 0.742,-0.593 1.473,-1.194 2.196,-1.808 0.424,-0.36 0.843,-0.725 1.261,-1.092 0.691,-0.608 1.375,-1.224 2.048,-1.852 0.426,-0.397 0.846,-0.802 1.267,-1.207 0.642,-0.622 1.279,-1.25 1.904,-1.89 0.426,-0.437 0.845,-0.881 1.263,-1.326 0.595,-0.633 1.184,-1.27 1.761,-1.918 0.425,-0.478 0.84,-0.964 1.255,-1.449 0.547,-0.641 1.091,-1.284 1.621,-1.939 0.419,-0.518 0.826,-1.045 1.235,-1.572 0.501,-0.647 1,-1.295 1.485,-1.954 0.41,-0.559 0.806,-1.128 1.205,-1.696 0.455,-0.649 0.91,-1.3 1.35,-1.962 0.4,-0.601 0.783,-1.212 1.168,-1.822 0.412,-0.652 0.825,-1.301 1.22,-1.963 0.384,-0.643 0.752,-1.297 1.121,-1.95 0.368,-0.65 0.738,-1.297 1.092,-1.956 0.367,-0.687 0.715,-1.386 1.065,-2.083 0.326,-0.644 0.655,-1.286 0.965,-1.939 0.348,-0.731 0.673,-1.474 1.002,-2.216 0.283,-0.637 0.573,-1.272 0.842,-1.917 0.324,-0.778 0.624,-1.567 0.929,-2.354 0.242,-0.627 0.493,-1.25 0.722,-1.883 0.299,-0.828 0.571,-1.668 0.848,-2.506 0.201,-0.61 0.413,-1.215 0.602,-1.83 0.272,-0.884 0.513,-1.781 0.759,-2.676 0.162,-0.585 0.335,-1.164 0.486,-1.753 0.242,-0.952 0.451,-1.916 0.665,-2.879 0.12,-0.546 0.256,-1.087 0.367,-1.638 0.211,-1.038 0.384,-2.089 0.56,-3.138 0.082,-0.488 0.18,-0.97 0.255,-1.461 0.178,-1.174 0.316,-2.361 0.451,-3.549 0.042,-0.376 0.1,-0.747 0.139,-1.124 0.148,-1.468 0.256,-2.947 0.337,-4.434 0.005,-0.103 0.018,-0.205 0.023,-0.307 0.082,-1.609 0.125,-3.227 0.125,-4.855 0,-1.619 -0.044,-3.227 -0.124,-4.826 -0.013,-0.244 -0.04,-0.484 -0.054,-0.728 -0.077,-1.336 -0.171,-2.667 -0.304,-3.987 -0.045,-0.459 -0.114,-0.911 -0.167,-1.368 -0.125,-1.096 -0.253,-2.193 -0.416,-3.278 -0.083,-0.549 -0.189,-1.089 -0.28,-1.634 -0.167,-0.983 -0.329,-1.966 -0.526,-2.937 -0.119,-0.594 -0.261,-1.179 -0.391,-1.769 -0.203,-0.911 -0.402,-1.823 -0.629,-2.724 -0.157,-0.62 -0.335,-1.231 -0.505,-1.847 -0.234,-0.855 -0.467,-1.711 -0.726,-2.557 -0.195,-0.639 -0.41,-1.267 -Line truncated
</g>
<g
transform="translate(554.6494,454.96)"
id="g961">
<path
inkscape:connector-curvature="0"
id="path963"
style="fill:#00868e;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c -10.023,-0.405 -19.616,-2.459 -28.527,-5.896 21.724,-21.656 35.173,-51.611 35.173,-84.709 0,-13.873 -2.363,-27.191 -6.707,-39.58 l -12.005,2.938 c 4.153,11.435 6.425,23.771 6.425,36.642 0,31.303 -13.42,59.455 -34.8,79.071 -3.475,-1.972 -6.812,-4.159 -9.978,-6.562 20.346,-17.563 33.238,-43.523 33.238,-72.509 0,-28.309 -12.292,-53.734 -31.815,-71.269 14.298,-10.416 31.794,-16.689 50.743,-17.09 18.867,24.449 30.103,55.086 30.103,88.359 C 31.85,-56.312 19.924,-24.808 0,0" />
</g>
<g
transform="translate(393.1943,500.7769)"
id="g965">
<path
inkscape:connector-curvature="0"
id="path967"
style="fill:#e5ad23;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="M 0,0 -2.466,8.942 C -39.654,-4.079 -70.318,-30.977 -88.254,-65.542 l 9.666,-1.535 C -61.654,-36.083 -33.706,-11.967 0,0" />
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 32 KiB

@@ -133,12 +133,12 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization or deserialization problem.
// 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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
@@ -70,12 +70,12 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// 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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
@@ -100,13 +100,13 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// 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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
@@ -67,12 +67,12 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// deserialization problem.
// 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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
@@ -98,12 +98,12 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// 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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
@@ -90,12 +90,12 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// 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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
@@ -59,12 +59,12 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any memory
// problem.
// 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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
@@ -64,11 +64,11 @@ void loop() {
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// https://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/
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
-19
View File
@@ -1,19 +0,0 @@
# 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" >> $@
-9
View File
@@ -1,9 +0,0 @@
#!/bin/bash
# This script mimics an invocation from https://github.com/google/oss-fuzz
cd $(dirname $0)
export CXX='clang++'
export CXXFLAGS='-fsanitize-coverage=trace-pc-guard -fsanitize=address'
export LIB_FUZZING_ENGINE=-lFuzzer
make OUT=.
./json_fuzzer my_corpus seed_corpus -max_len=1024 -timeout=10
-26
View File
@@ -1,26 +0,0 @@
#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;
}
@@ -1,2 +0,0 @@
*
!.gitignore
@@ -1,10 +0,0 @@
//comment
/*comment*/
[ //comment
/*comment*/"comment"/*comment*/,//comment
/*comment*/{//comment
/* comment*/"key"//comment
: //comment
"value"//comment
}/*comment*/
]//comment
@@ -1 +0,0 @@
[]
@@ -1 +0,0 @@
{}
@@ -1 +0,0 @@
[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]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
@@ -1,24 +0,0 @@
[
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
]
@@ -1,53 +0,0 @@
{
"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
}
@@ -1,8 +0,0 @@
[
"hello",
'hello',
hello,
{"hello":"world"},
{'hello':'world'},
{hello:world}
]
@@ -1,90 +0,0 @@
{
"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"
}
}
-23
View File
@@ -1,23 +0,0 @@
{
"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.13.1",
"authors": {
"name": "Benoit Blanchon",
"url": "https://blog.benoitblanchon.fr"
},
"exclude": [
"fuzzing",
"scripts",
"test",
"third-party"
],
"frameworks": "arduino",
"platforms": "*"
}
+1 -1
View File
@@ -1,5 +1,5 @@
name=ArduinoJson
version=5.13.1
version=5.13.3
author=Benoit Blanchon <blog.benoitblanchon.fr>
maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
sentence=An efficient and elegant JSON library for Arduino.
@@ -1,20 +0,0 @@
#!/bin/bash
TAG=$(git describe)
OUTPUT="ArduinoJson-$TAG.zip"
cd $(dirname $0)/../..
# remove existing file
rm -f $OUTPUT
# create zip
7z a $OUTPUT \
ArduinoJson/CHANGELOG.md \
ArduinoJson/examples \
ArduinoJson/src \
ArduinoJson/keywords.txt \
ArduinoJson/library.properties \
ArduinoJson/LICENSE.md \
ArduinoJson/README.md \
ArduinoJson/ArduinoJson.h
@@ -1,53 +0,0 @@
#!/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
@@ -1,29 +0,0 @@
#!/bin/bash
export PATH="$PATH:/Applications/CMake.app/Contents/bin/"
cd $(dirname $0)/..
ROOT=$(pwd)
mkdir "build"
cd build
BUILD=$(pwd)
build-env()
{
cd $BUILD
mkdir "$1"
cd "$1"
cmake "$ROOT" -G "$2"
}
if [[ $(uname) == MINGW* ]]
then
build-env "Make" "MinGW Makefiles"
build-env "SublimeText" "Sublime Text 2 - Ninja"
build-env "VisualStudio" "Visual Studio 14 2015"
else
build-env "SublimeText" "Sublime Text 2 - Ninja"
build-env "Make" "Unix Makefiles"
build-env "Xcode" "Xcode"
fi
@@ -1,42 +0,0 @@
#!/bin/bash
set -eu
OUTPUT="$(pwd)/sizes.csv"
echo "Tag;Date;Parser;Generator" > $OUTPUT
cd $(dirname $(dirname $0))
git tag | while read TAG
do
git checkout -q tags/$TAG
DATE=$(git log -1 --date=short --pretty=format:%cd)
PARSER_SIZE=$(arduino --verify examples/JsonParserExample/JsonParserExample.ino 2>/dev/null | grep -e 'Sketch uses' | sed 's/.*uses \([0-9]*\).\([0-9]\+\).*/\1\2/')
if [ -e 'examples/JsonGeneratorExample/JsonGeneratorExample.ino' ]; then
GENERATOR_SIZE=$(arduino --verify examples/JsonGeneratorExample/JsonGeneratorExample.ino 2>/dev/null | grep -e 'Sketch uses' | sed 's/.*uses \([0-9]*\).\([0-9]\+\).*/\1\2/')
else
GENERATOR_SIZE=""
fi
echo $TAG
if [ ! -z "$PARSER_SIZE" ]
then
echo "JsonParserExample = $PARSER_SIZE bytes"
else
echo "JsonParserExample compilation failed."
fi
if [ ! -z "$GENERATOR_SIZE" ]
then
echo "JsonGeneratorExample = $GENERATOR_SIZE bytes"
else
echo "JsonGeneratorExample compilation failed."
fi
echo "$TAG;$DATE;$PARSER_SIZE;$GENERATOR_SIZE" >> $OUTPUT
done
@@ -1,2 +0,0 @@
/.vagrant/
*.log
-33
View File
@@ -1,33 +0,0 @@
# 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
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh -eux
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
sleep 3
export DISPLAY=:1.0
mkdir -p /tmp/arduino
curl -sS http://downloads.arduino.cc/arduino-$VERSION-linux64.tar.xz | tar xJ -C /tmp/arduino --strip 1 ||
curl -sS http://downloads.arduino.cc/arduino-$VERSION-linux64.tgz | tar xz -C /tmp/arduino --strip 1
export PATH=$PATH:/tmp/arduino/
ln -s $PWD /tmp/arduino/libraries/ArduinoJson
for EXAMPLE in $PWD/examples/*/*.ino; do
arduino --verify --board $BOARD $EXAMPLE
done
-30
View File
@@ -1,30 +0,0 @@
#!/bin/sh -ex
if [ $(uname) = 'Darwin' ]; then
URL=https://cmake.org/files/v3.4/cmake-3.4.3-Darwin-x86_64.tar.gz
CMAKE=/tmp/CMake.app/Contents/bin/cmake
CTEST=/tmp/CMake.app/Contents/bin/ctest
else
URL=https://cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.tar.gz
CMAKE=/tmp/bin/cmake
CTEST=/tmp/bin/ctest
fi
curl -sS $URL | tar xz -C /tmp --strip 1
if [ -n "$GCC" ]; then
export CC="gcc-$GCC"
export CXX="g++-$GCC"
fi
if [ -n "$CLANG" ]; then
export CC="clang-$CLANG"
export CXX="clang++-$CLANG"
fi
if [ -n "$SANITIZE" ]; then
export CXXFLAGS="-fsanitize=$SANITIZE"
fi
$CMAKE .
$CMAKE --build .
$CTEST --output-on-failure .
@@ -1,10 +0,0 @@
#!/bin/sh -eux
curl https://cmake.org/files/v3.4/cmake-3.4.0-Linux-x86_64.tar.gz | tar xz -C /tmp --strip 1
/tmp/bin/cmake -DCOVERAGE=true .
make
make test
pip install --user cpp-coveralls 'requests[security]'
coveralls --exclude third-party --gcov-options '\-lp'; fi
@@ -1,10 +0,0 @@
#!/bin/sh -eux
pip install --user platformio
rm -r test
for EXAMPLE in $PWD/examples/*/*.ino;
do
platformio ci $EXAMPLE -l '.' -b $BOARD
done
+2
View File
@@ -4,6 +4,8 @@
#pragma once
#include "ArduinoJson/version.hpp"
#include "ArduinoJson/DynamicJsonBuffer.hpp"
#include "ArduinoJson/JsonArray.hpp"
#include "ArduinoJson/JsonObject.hpp"
@@ -44,7 +44,6 @@ class JsonParser {
const char *parseString();
bool parseAnythingTo(JsonVariant *destination);
FORCE_INLINE bool parseAnythingToUnsafe(JsonVariant *destination);
inline bool parseArrayTo(JsonVariant *destination);
inline bool parseObjectTo(JsonVariant *destination);
@@ -20,17 +20,6 @@ template <typename TReader, typename TWriter>
inline bool
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseAnythingTo(
JsonVariant *destination) {
if (_nestingLimit == 0) return false;
_nestingLimit--;
bool success = parseAnythingToUnsafe(destination);
_nestingLimit++;
return success;
}
template <typename TReader, typename TWriter>
inline bool
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseAnythingToUnsafe(
JsonVariant *destination) {
skipSpacesAndComments(_reader);
switch (_reader.current()) {
@@ -48,6 +37,9 @@ ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseAnythingToUnsafe(
template <typename TReader, typename TWriter>
inline ArduinoJson::JsonArray &
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArray() {
if (_nestingLimit == 0) return JsonArray::invalid();
_nestingLimit--;
// Create an empty array
JsonArray &array = _buffer->createArray();
@@ -69,6 +61,7 @@ ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArray() {
SUCCESS_EMPTY_ARRAY:
SUCCES_NON_EMPTY_ARRAY:
_nestingLimit++;
return array;
ERROR_INVALID_VALUE:
@@ -91,6 +84,9 @@ inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArrayTo(
template <typename TReader, typename TWriter>
inline ArduinoJson::JsonObject &
ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObject() {
if (_nestingLimit == 0) return JsonObject::invalid();
_nestingLimit--;
// Create an empty object
JsonObject &object = _buffer->createObject();
@@ -117,6 +113,7 @@ ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObject() {
SUCCESS_EMPTY_OBJECT:
SUCCESS_NON_EMPTY_OBJECT:
_nestingLimit++;
return object;
ERROR_INVALID_KEY:
@@ -286,15 +286,21 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
template <typename TStringRef, typename TValueRef>
bool set_impl(TStringRef key, TValueRef value) {
// ignore null key
if (Internals::StringTraits<TStringRef>::is_null(key)) return false;
// search a matching key
iterator it = findKey<TStringRef>(key);
if (it == end()) {
// add the key
it = Internals::List<JsonPair>::add();
if (it == end()) return false;
bool key_ok =
Internals::ValueSaver<TStringRef>::save(_buffer, it->key, key);
if (!key_ok) return false;
}
// save the value
return Internals::ValueSaver<TValueRef>::save(_buffer, it->value, value);
}
@@ -318,5 +324,5 @@ struct JsonVariantDefault<JsonObject> {
return JsonObject::invalid();
}
};
}
}
} // namespace Internals
} // namespace ArduinoJson
@@ -274,9 +274,11 @@ class JsonVariant : public Internals::JsonVariantBase<JsonVariant> {
//
// bool is<const char*>() const;
// bool is<char*>() const;
// bool is<std::string>() const;
template <typename T>
typename Internals::EnableIf<Internals::IsSame<T, const char *>::value ||
Internals::IsSame<T, char *>::value,
Internals::IsSame<T, char *>::value ||
Internals::StringTraits<T>::has_append,
bool>::type
is() const {
return variantIsString();
@@ -352,4 +354,4 @@ DEPRECATED("Decimal places are ignored, use the double value instead")
inline JsonVariant double_with_n_digits(double value, uint8_t) {
return JsonVariant(value);
}
}
} // namespace ArduinoJson
@@ -129,10 +129,11 @@ class JsonVariantComparisons {
if (is<JsonObject>() && right.template is<JsonObject>())
return as<JsonObject>() == right.template as<JsonObject>();
if (is<char *>() && right.template is<char *>())
return strcmp(as<char *>(), right.template as<char *>()) == 0;
return StringTraits<const char *>::equals(as<char *>(),
right.template as<char *>());
return false;
}
};
}
}
} // namespace Internals
} // namespace ArduinoJson
@@ -10,10 +10,10 @@ namespace ArduinoJson {
namespace Internals {
inline bool isInteger(const char* s) {
if (!s) return false;
if (!s || !*s) return false;
if (issign(*s)) s++;
while (isdigit(*s)) s++;
return *s == '\0';
}
}
}
} // namespace Internals
} // namespace ArduinoJson
@@ -30,7 +30,9 @@ struct CharPointerTraits {
};
static bool equals(const TChar* str, const char* expected) {
return strcmp(reinterpret_cast<const char*>(str), expected) == 0;
const char* actual = reinterpret_cast<const char*>(str);
if (!actual || !expected) return actual == expected;
return strcmp(actual, expected) == 0;
}
static bool is_null(const TChar* str) {
@@ -58,5 +60,5 @@ struct CharPointerTraits {
template <typename TChar>
struct StringTraits<TChar*, typename EnableIf<IsChar<TChar>::value>::type>
: CharPointerTraits<TChar> {};
}
}
} // namespace Internals
} // namespace ArduinoJson
@@ -31,7 +31,9 @@ struct StringTraits<const __FlashStringHelper*, void> {
};
static bool equals(const __FlashStringHelper* str, const char* expected) {
return strcmp_P(expected, (const char*)str) == 0;
const char* actual = reinterpret_cast<const char*>(str);
if (!actual || !expected) return actual == expected;
return strcmp_P(expected, actual) == 0;
}
static bool is_null(const __FlashStringHelper* str) {
@@ -53,7 +55,7 @@ struct StringTraits<const __FlashStringHelper*, void> {
static const bool has_equals = true;
static const bool should_duplicate = true;
};
}
}
} // namespace Internals
} // namespace ArduinoJson
#endif
@@ -40,7 +40,10 @@ struct StdStringTraits {
};
static bool equals(const TString& str, const char* expected) {
return 0 == strcmp(str.c_str(), expected);
// Arduino's String::c_str() can return NULL
const char* actual = str.c_str();
if (!actual || !expected) return actual == expected;
return 0 == strcmp(actual, expected);
}
static void append(TString& str, char c) {
@@ -68,7 +71,7 @@ struct StringTraits<StringSumHelper, void> : StdStringTraits<StringSumHelper> {
template <>
struct StringTraits<std::string, void> : StdStringTraits<std::string> {};
#endif
}
}
} // namespace Internals
} // namespace ArduinoJson
#endif
@@ -44,28 +44,46 @@ struct FloatTraits<T, 8 /*64bits*/> {
static T positiveBinaryPowerOfTen(int index) {
static T factors[] = {
1e1, 1e2, 1e4, 1e8, 1e16, 1e32,
// workaround to support platforms with single precision literals
forge(0x4D384F03, 0xE93FF9F5), forge(0x5A827748, 0xF9301D32),
forge(0x75154FDD, 0x7F73BF3C)};
1e1,
1e2,
1e4,
1e8,
1e16,
forge(0x4693B8B5, 0xB5056E17), // 1e32
forge(0x4D384F03, 0xE93FF9F5), // 1e64
forge(0x5A827748, 0xF9301D32), // 1e128
forge(0x75154FDD, 0x7F73BF3C) // 1e256
};
return factors[index];
}
static T negativeBinaryPowerOfTen(int index) {
static T factors[] = {
1e-1, 1e-2, 1e-4, 1e-8, 1e-16, 1e-32,
// workaround to support platforms with single precision literals
forge(0x32A50FFD, 0x44F4A73D), forge(0x255BBA08, 0xCF8C979D),
forge(0x0AC80628, 0x64AC6F43)};
forge(0x3FB99999, 0x9999999A), // 1e-1
forge(0x3F847AE1, 0x47AE147B), // 1e-2
forge(0x3F1A36E2, 0xEB1C432D), // 1e-4
forge(0x3E45798E, 0xE2308C3A), // 1e-8
forge(0x3C9CD2B2, 0x97D889BC), // 1e-16
forge(0x3949F623, 0xD5A8A733), // 1e-32
forge(0x32A50FFD, 0x44F4A73D), // 1e-64
forge(0x255BBA08, 0xCF8C979D), // 1e-128
forge(0x0AC80628, 0x64AC6F43) // 1e-256
};
return factors[index];
}
static T negativeBinaryPowerOfTenPlusOne(int index) {
static T factors[] = {
1e0, 1e-1, 1e-3, 1e-7, 1e-15, 1e-31,
// workaround to support platforms with single precision literals
forge(0x32DA53FC, 0x9631D10D), forge(0x25915445, 0x81B7DEC2),
forge(0x0AFE07B2, 0x7DD78B14)};
1e0,
forge(0x3FB99999, 0x9999999A), // 1e-1
forge(0x3F50624D, 0xD2F1A9FC), // 1e-3
forge(0x3E7AD7F2, 0x9ABCAF48), // 1e-7
forge(0x3CD203AF, 0x9EE75616), // 1e-15
forge(0x398039D6, 0x65896880), // 1e-31
forge(0x32DA53FC, 0x9631D10D), // 1e-63
forge(0x25915445, 0x81B7DEC2), // 1e-127
forge(0x0AFE07B2, 0x7DD78B14) // 1e-255
};
return factors[index];
}
@@ -77,6 +95,9 @@ struct FloatTraits<T, 8 /*64bits*/> {
return forge(0x7ff00000, 0x00000000);
}
// constructs a double floating point values from its binary representation
// we use this function to workaround platforms with single precision literals
// (for example, when -fsingle-precision-constant is passed to GCC)
static T forge(uint32_t msb, uint32_t lsb) {
union {
uint64_t integerBits;
@@ -0,0 +1,10 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#pragma once
#define ARDUINOJSON_VERSION "5.13.3"
#define ARDUINOJSON_VERSION_MAJOR 5
#define ARDUINOJSON_VERSION_MINOR 13
#define ARDUINOJSON_VERSION_REVISION 3
-76
View File
@@ -1,76 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(
-pedantic
-Wall
-Wcast-align
-Wcast-qual
-Wconversion
-Wctor-dtor-privacy
-Wdisabled-optimization
-Werror
-Wextra
-Wformat=2
-Winit-self
-Wmissing-include-dirs
-Wnon-virtual-dtor
-Wold-style-cast
-Woverloaded-virtual
-Wparentheses
-Wredundant-decls
-Wshadow
-Wsign-promo
-Wstrict-aliasing
-Wstrict-overflow=5
-Wundef
)
if(NOT MINGW)
add_compile_options(
-std=c++98
)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(
-Wstrict-null-sentinel
)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.5)
add_compile_options(-Wlogical-op) # the flag exists in 4.4 but is buggy
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6)
add_compile_options(-Wnoexcept)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(
-Wc++11-compat
-Wdeprecated-register
)
endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_compile_options(
/W4 # Set warning level
/WX # Treats all compiler warnings as errors.
)
endif()
add_subdirectory(DynamicJsonBuffer)
add_subdirectory(IntegrationTests)
add_subdirectory(JsonArray)
add_subdirectory(JsonBuffer)
add_subdirectory(JsonObject)
add_subdirectory(JsonVariant)
add_subdirectory(JsonWriter)
add_subdirectory(Misc)
add_subdirectory(Polyfills)
add_subdirectory(StaticJsonBuffer)
@@ -1,15 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
add_executable(DynamicJsonBufferTests
alloc.cpp
createArray.cpp
createObject.cpp
no_memory.cpp
size.cpp
startString.cpp
)
target_link_libraries(DynamicJsonBufferTests catch)
add_test(DynamicJsonBuffer DynamicJsonBufferTests)
@@ -1,77 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
#include <sstream>
using namespace ArduinoJson::Internals;
static bool isAligned(void* ptr) {
const size_t mask = sizeof(void*) - 1;
size_t addr = reinterpret_cast<size_t>(ptr);
return (addr & mask) == 0;
}
std::stringstream allocatorLog;
struct SpyingAllocator : DefaultAllocator {
void* allocate(size_t n) {
allocatorLog << "A" << (n - DynamicJsonBuffer::EmptyBlockSize);
return DefaultAllocator::allocate(n);
}
void deallocate(void* p) {
allocatorLog << "F";
return DefaultAllocator::deallocate(p);
}
};
TEST_CASE("DynamicJsonBuffer::alloc()") {
SECTION("Returns different pointers") {
DynamicJsonBuffer buffer;
void* p1 = buffer.alloc(1);
void* p2 = buffer.alloc(2);
REQUIRE(p1 != p2);
}
SECTION("Doubles allocation size when full") {
allocatorLog.str("");
{
DynamicJsonBufferBase<SpyingAllocator> buffer(1);
buffer.alloc(1);
buffer.alloc(1);
}
REQUIRE(allocatorLog.str() == "A1A2FF");
}
SECTION("Resets allocation size after clear()") {
allocatorLog.str("");
{
DynamicJsonBufferBase<SpyingAllocator> buffer(1);
buffer.alloc(1);
buffer.alloc(1);
buffer.clear();
buffer.alloc(1);
}
REQUIRE(allocatorLog.str() == "A1A2FFA1F");
}
SECTION("Makes a big allocation when needed") {
allocatorLog.str("");
{
DynamicJsonBufferBase<SpyingAllocator> buffer(1);
buffer.alloc(42);
}
REQUIRE(allocatorLog.str() == "A42F");
}
SECTION("Alignment") {
// make room for two but not three
DynamicJsonBuffer tinyBuf(2 * sizeof(void*) + 1);
REQUIRE(isAligned(tinyBuf.alloc(1))); // this on is aligned by design
REQUIRE(isAligned(tinyBuf.alloc(1))); // this one fits in the first block
REQUIRE(isAligned(tinyBuf.alloc(1))); // this one requires a new block
}
}
@@ -1,28 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("DynamicJsonBuffer::createArray()") {
DynamicJsonBuffer jsonBuffer;
JsonArray &array = jsonBuffer.createArray();
SECTION("GrowsWithArray") {
REQUIRE(JSON_ARRAY_SIZE(0) == jsonBuffer.size());
array.add("hello");
REQUIRE(JSON_ARRAY_SIZE(1) == jsonBuffer.size());
array.add("world");
REQUIRE(JSON_ARRAY_SIZE(2) == jsonBuffer.size());
}
SECTION("CanAdd1000Values") {
for (size_t i = 1; i <= 1000; i++) {
array.add("hello");
REQUIRE(array.size() == i);
}
}
}
@@ -1,22 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("DynamicJsonBuffer::createObject()") {
DynamicJsonBuffer json;
JsonObject &obj = json.createObject();
REQUIRE(JSON_OBJECT_SIZE(0) == json.size());
obj["hello"] = 1;
REQUIRE(JSON_OBJECT_SIZE(1) == json.size());
obj["world"] = 2;
REQUIRE(JSON_OBJECT_SIZE(2) == json.size());
obj["world"] = 3; // <- same key, should not grow
REQUIRE(JSON_OBJECT_SIZE(2) == json.size());
}
@@ -1,49 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ArduinoJson::Internals;
struct NoMemoryAllocator {
void* allocate(size_t) {
return NULL;
}
void deallocate(void*) {}
};
TEST_CASE("DynamicJsonBuffer no memory") {
DynamicJsonBufferBase<NoMemoryAllocator> _jsonBuffer;
SECTION("FixCodeCoverage") {
// call this function to fix code coverage
NoMemoryAllocator().deallocate(NULL);
}
SECTION("createArray()") {
REQUIRE_FALSE(_jsonBuffer.createArray().success());
}
SECTION("createObject()") {
REQUIRE_FALSE(_jsonBuffer.createObject().success());
}
SECTION("parseArray()") {
char json[] = "[]";
REQUIRE_FALSE(_jsonBuffer.parseArray(json).success());
}
SECTION("parseObject()") {
char json[] = "{}";
REQUIRE_FALSE(_jsonBuffer.parseObject(json).success());
}
SECTION("startString()") {
DynamicJsonBufferBase<NoMemoryAllocator>::String str =
_jsonBuffer.startString();
str.append('!');
REQUIRE(0 == str.c_str());
}
}
@@ -1,27 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("DynamicJsonBuffer::size()") {
DynamicJsonBuffer buffer;
SECTION("Initial size is 0") {
REQUIRE(0 == buffer.size());
}
SECTION("Increases after alloc()") {
buffer.alloc(1);
REQUIRE(1U <= buffer.size());
buffer.alloc(1);
REQUIRE(2U <= buffer.size());
}
SECTION("Goes back to 0 after clear()") {
buffer.alloc(1);
buffer.clear();
REQUIRE(0 == buffer.size());
}
}
@@ -1,47 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("DynamicJsonBuffer::startString()") {
SECTION("WorksWhenBufferIsBigEnough") {
DynamicJsonBuffer jsonBuffer(6);
DynamicJsonBuffer::String str = jsonBuffer.startString();
str.append('h');
str.append('e');
str.append('l');
str.append('l');
str.append('o');
REQUIRE(std::string("hello") == str.c_str());
}
SECTION("GrowsWhenBufferIsTooSmall") {
DynamicJsonBuffer jsonBuffer(5);
DynamicJsonBuffer::String str = jsonBuffer.startString();
str.append('h');
str.append('e');
str.append('l');
str.append('l');
str.append('o');
REQUIRE(std::string("hello") == str.c_str());
}
SECTION("SizeIncreases") {
DynamicJsonBuffer jsonBuffer(5);
DynamicJsonBuffer::String str = jsonBuffer.startString();
REQUIRE(0 == jsonBuffer.size());
str.append('h');
REQUIRE(1 == jsonBuffer.size());
str.c_str();
REQUIRE(2 == jsonBuffer.size());
}
}
@@ -1,18 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
add_executable(IntegrationTests
gbathree.cpp
round_trip.cpp
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(IntegrationTests
PUBLIC
-fsingle-precision-constant # issue 544
)
endif()
target_link_libraries(IntegrationTests catch)
add_test(IntegrationTests IntegrationTests)
@@ -1,208 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("Gbathree") {
DynamicJsonBuffer _buffer;
const JsonObject& _object = _buffer.parseObject(
"{\"protocol_name\":\"fluorescence\",\"repeats\":1,\"wait\":0,"
"\"averages\":1,\"measurements\":3,\"meas2_light\":15,\"meas1_"
"baseline\":0,\"act_light\":20,\"pulsesize\":25,\"pulsedistance\":"
"10000,\"actintensity1\":50,\"actintensity2\":255,\"measintensity\":"
"255,\"calintensity\":255,\"pulses\":[50,50,50],\"act\":[2,1,2,2],"
"\"red\":[2,2,2,2],\"detectors\":[[34,34,34,34],[34,34,34,34],[34,"
"34,34,34],[34,34,34,34]],\"alta\":[2,2,2,2],\"altb\":[2,2,2,2],"
"\"measlights\":[[15,15,15,15],[15,15,15,15],[15,15,15,15],[15,15,"
"15,15]],\"measlights2\":[[15,15,15,15],[15,15,15,15],[15,15,15,15],"
"[15,15,15,15]],\"altc\":[2,2,2,2],\"altd\":[2,2,2,2]}");
SECTION("Success") {
REQUIRE(_object.success());
}
SECTION("ProtocolName") {
REQUIRE("fluorescence" == _object["protocol_name"]);
}
SECTION("Repeats") {
REQUIRE(1 == _object["repeats"]);
}
SECTION("Wait") {
REQUIRE(0 == _object["wait"]);
}
SECTION("Measurements") {
REQUIRE(3 == _object["measurements"]);
}
SECTION("Meas2_Light") {
REQUIRE(15 == _object["meas2_light"]);
}
SECTION("Meas1_Baseline") {
REQUIRE(0 == _object["meas1_baseline"]);
}
SECTION("Act_Light") {
REQUIRE(20 == _object["act_light"]);
}
SECTION("Pulsesize") {
REQUIRE(25 == _object["pulsesize"]);
}
SECTION("Pulsedistance") {
REQUIRE(10000 == _object["pulsedistance"]);
}
SECTION("Actintensity1") {
REQUIRE(50 == _object["actintensity1"]);
}
SECTION("Actintensity2") {
REQUIRE(255 == _object["actintensity2"]);
}
SECTION("Measintensity") {
REQUIRE(255 == _object["measintensity"]);
}
SECTION("Calintensity") {
REQUIRE(255 == _object["calintensity"]);
}
SECTION("Pulses") {
// "pulses":[50,50,50]
JsonArray& array = _object["pulses"];
REQUIRE(array.success());
REQUIRE(3 == array.size());
for (size_t i = 0; i < 3; i++) {
REQUIRE(50 == array[i]);
}
}
SECTION("Act") {
// "act":[2,1,2,2]
JsonArray& array = _object["act"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
REQUIRE(2 == array[0]);
REQUIRE(1 == array[1]);
REQUIRE(2 == array[2]);
REQUIRE(2 == array[3]);
}
SECTION("Detectors") {
// "detectors":[[34,34,34,34],[34,34,34,34],[34,34,34,34],[34,34,34,34]]
JsonArray& array = _object["detectors"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
for (size_t i = 0; i < 4; i++) {
JsonArray& nestedArray = array[i];
REQUIRE(4 == nestedArray.size());
for (size_t j = 0; j < 4; j++) {
REQUIRE(34 == nestedArray[j]);
}
}
}
SECTION("Alta") {
// alta:[2,2,2,2]
JsonArray& array = _object["alta"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
for (size_t i = 0; i < 4; i++) {
REQUIRE(2 == array[i]);
}
}
SECTION("Altb") {
// altb:[2,2,2,2]
JsonArray& array = _object["altb"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
for (size_t i = 0; i < 4; i++) {
REQUIRE(2 == array[i]);
}
}
SECTION("Measlights") {
// "measlights":[[15,15,15,15],[15,15,15,15],[15,15,15,15],[15,15,15,15]]
JsonArray& array = _object["measlights"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
for (size_t i = 0; i < 4; i++) {
JsonArray& nestedArray = array[i];
REQUIRE(4 == nestedArray.size());
for (size_t j = 0; j < 4; j++) {
REQUIRE(15 == nestedArray[j]);
}
}
}
SECTION("Measlights2") {
// "measlights2":[[15,15,15,15],[15,15,15,15],[15,15,15,15],[15,15,15,15]]
JsonArray& array = _object["measlights2"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
for (size_t i = 0; i < 4; i++) {
JsonArray& nestedArray = array[i];
REQUIRE(4 == nestedArray.size());
for (size_t j = 0; j < 4; j++) {
REQUIRE(15 == nestedArray[j]);
}
}
}
SECTION("Altc") {
// altc:[2,2,2,2]
JsonArray& array = _object["altc"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
for (size_t i = 0; i < 4; i++) {
REQUIRE(2 == array[i]);
}
}
SECTION("Altd") {
// altd:[2,2,2,2]
JsonArray& array = _object["altd"];
REQUIRE(array.success());
REQUIRE(4 == array.size());
for (size_t i = 0; i < 4; i++) {
REQUIRE(2 == array[i]);
}
}
}
@@ -1,80 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
void check(std::string originalJson) {
DynamicJsonBuffer jb;
std::string prettyJson;
jb.parseObject(originalJson).prettyPrintTo(prettyJson);
std::string finalJson;
jb.parseObject(prettyJson).printTo(finalJson);
REQUIRE(originalJson == finalJson);
}
TEST_CASE("Round Trip: parse -> prettyPrint -> parse -> print") {
SECTION("OpenWeatherMap") {
check(
"{\"coord\":{\"lon\":145.77,\"lat\":-16.92},\"sys\":{\"type\":1,\"id\":"
"8166,\"message\":0.1222,\"country\":\"AU\",\"sunrise\":1414784325,"
"\"sunset\":1414830137},\"weather\":[{\"id\":801,\"main\":\"Clouds\","
"\"description\":\"few clouds\",\"icon\":\"02n\"}],\"base\":\"cmc "
"stations\",\"main\":{\"temp\":296.15,\"pressure\":1014,\"humidity\":"
"83,\"temp_min\":296.15,\"temp_max\":296.15},\"wind\":{\"speed\":2.22,"
"\"deg\":114.501},\"clouds\":{\"all\":20},\"dt\":1414846800,\"id\":"
"2172797,\"name\":\"Cairns\",\"cod\":200}");
}
SECTION("YahooQueryLanguage") {
check(
"{\"query\":{\"count\":40,\"created\":\"2014-11-01T14:16:49Z\","
"\"lang\":\"fr-FR\",\"results\":{\"item\":[{\"title\":\"Burkina army "
"backs Zida as interim leader\"},{\"title\":\"British jets intercept "
"Russian bombers\"},{\"title\":\"Doubts chip away at nation's most "
"trusted agencies\"},{\"title\":\"Cruise ship stuck off Norway, no "
"damage\"},{\"title\":\"U.S. military launches 10 air strikes in "
"Syria, Iraq\"},{\"title\":\"Blackout hits Bangladesh as line from "
"India fails\"},{\"title\":\"Burkina Faso president in Ivory Coast "
"after ouster\"},{\"title\":\"Kurds in Turkey rally to back city "
"besieged by IS\"},{\"title\":\"A majority of Scots would vote for "
"independence now:poll\"},{\"title\":\"Tunisia elections possible "
"model for region\"},{\"title\":\"Islamic State kills 85 more members "
"of Iraqi tribe\"},{\"title\":\"Iraqi officials:IS extremists line "
"up, kill 50\"},{\"title\":\"Burkina Faso army backs presidential "
"guard official to lead transition\"},{\"title\":\"Kurdish peshmerga "
"arrive with weapons in Syria's Kobani\"},{\"title\":\"Driver sought "
"in crash that killed 3 on Halloween\"},{\"title\":\"Ex-Marine arrives "
"in US after release from Mexico jail\"},{\"title\":\"UN panel "
"scrambling to finish climate report\"},{\"title\":\"Investigators, "
"Branson go to spacecraft crash site\"},{\"title\":\"Soldiers vie for "
"power after Burkina Faso president quits\"},{\"title\":\"For a man "
"without a party, turnout is big test\"},{\"title\":\"'We just had a "
"hunch':US marshals nab Eric Frein\"},{\"title\":\"Boko Haram leader "
"threatens to kill German hostage\"},{\"title\":\"Nurse free to move "
"about as restrictions eased\"},{\"title\":\"Former Burkina president "
"Compaore arrives in Ivory Coast:sources\"},{\"title\":\"Libyan port "
"rebel leader refuses to hand over oil ports to rival "
"group\"},{\"title\":\"Iraqi peshmerga fighters prepare for Syria "
"battle\"},{\"title\":\"1 Dem Senate candidate welcoming Obama's "
"help\"},{\"title\":\"Bikers cancel party after police recover "
"bar\"},{\"title\":\"New question in Texas:Can Davis survive "
"defeat?\"},{\"title\":\"Ukraine rebels to hold election, despite "
"criticism\"},{\"title\":\"Iraqi officials say Islamic State group "
"lines up, kills 50 tribesmen, women in Anbar "
"province\"},{\"title\":\"James rebounds, leads Cavaliers past "
"Bulls\"},{\"title\":\"UK warns travelers they could be terror "
"targets\"},{\"title\":\"Hello Kitty celebrates 40th "
"birthday\"},{\"title\":\"A look at people killed during space "
"missions\"},{\"title\":\"Nigeria's purported Boko Haram leader says "
"has 'married off' girls:AFP\"},{\"title\":\"Mexico orders immediate "
"release of Marine veteran\"},{\"title\":\"As election closes in, "
"Obama on center stage\"},{\"title\":\"Body of Zambian president "
"arrives home\"},{\"title\":\"South Africa arrests 2 Vietnamese for "
"poaching\"}]}}}");
}
}
@@ -1,21 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
add_executable(JsonArrayTests
add.cpp
basics.cpp
copyFrom.cpp
copyTo.cpp
invalid.cpp
iterator.cpp
prettyPrintTo.cpp
printTo.cpp
remove.cpp
set.cpp
size.cpp
subscript.cpp
)
target_link_libraries(JsonArrayTests catch)
add_test(JsonArray JsonArrayTests)
-110
View File
@@ -1,110 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::add()") {
DynamicJsonBuffer _jsonBuffer;
JsonArray& _array = _jsonBuffer.createArray();
SECTION("int") {
_array.add(123);
REQUIRE(123 == _array[0].as<int>());
REQUIRE(_array[0].is<int>());
REQUIRE(_array[0].is<double>());
}
SECTION("double") {
_array.add(123.45);
REQUIRE(123.45 == _array[0].as<double>());
REQUIRE(_array[0].is<double>());
REQUIRE_FALSE(_array[0].is<bool>());
}
SECTION("bool") {
_array.add(true);
REQUIRE(true == _array[0].as<bool>());
REQUIRE(_array[0].is<bool>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("const char*") {
const char* str = "hello";
_array.add(str);
REQUIRE(str == _array[0].as<std::string>());
REQUIRE(_array[0].is<const char*>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("nested array") {
JsonArray& arr = _jsonBuffer.createArray();
_array.add(arr);
REQUIRE(&arr == &_array[0].as<JsonArray&>());
REQUIRE(_array[0].is<JsonArray&>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("nested object") {
JsonObject& obj = _jsonBuffer.createObject();
_array.add(obj);
REQUIRE(&obj == &_array[0].as<JsonObject&>());
REQUIRE(_array[0].is<JsonObject&>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("array subscript") {
const char* str = "hello";
JsonArray& arr = _jsonBuffer.createArray();
arr.add(str);
_array.add(arr[0]);
REQUIRE(str == _array[0]);
}
SECTION("object subscript") {
const char* str = "hello";
JsonObject& obj = _jsonBuffer.createObject();
obj["x"] = str;
_array.add(obj["x"]);
REQUIRE(str == _array[0]);
}
SECTION("should not duplicate const char*") {
_array.add("world");
const size_t expectedSize = JSON_ARRAY_SIZE(1);
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate char*") {
_array.add(const_cast<char*>("world"));
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate std::string") {
_array.add(std::string("world"));
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should not duplicate RawJson(const char*)") {
_array.add(RawJson("{}"));
const size_t expectedSize = JSON_ARRAY_SIZE(1);
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate RawJson(char*)") {
_array.add(RawJson(const_cast<char*>("{}")));
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 3;
REQUIRE(expectedSize == _jsonBuffer.size());
}
}
-29
View File
@@ -1,29 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray basics") {
DynamicJsonBuffer jb;
JsonArray& array = jb.createArray();
SECTION("SuccessIsTrue") {
REQUIRE(array.success());
}
SECTION("InitialSizeIsZero") {
REQUIRE(0U == array.size());
}
SECTION("CreateNestedArray") {
JsonArray& arr = array.createNestedArray();
REQUIRE(&arr == &array[0].as<JsonArray&>());
}
SECTION("CreateNestedObject") {
JsonObject& obj = array.createNestedObject();
REQUIRE(&obj == &array[0].as<JsonObject&>());
}
}
@@ -1,63 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::copyFrom()") {
SECTION("OneDimension") {
DynamicJsonBuffer jsonBuffer;
JsonArray& array = jsonBuffer.createArray();
char json[32];
int source[] = {1, 2, 3};
bool ok = array.copyFrom(source);
REQUIRE(ok);
array.printTo(json, sizeof(json));
REQUIRE(std::string("[1,2,3]") == json);
}
SECTION("OneDimension_JsonBufferTooSmall") {
const size_t SIZE = JSON_ARRAY_SIZE(2);
StaticJsonBuffer<SIZE> jsonBuffer;
JsonArray& array = jsonBuffer.createArray();
char json[32];
int source[] = {1, 2, 3};
bool ok = array.copyFrom(source);
REQUIRE_FALSE(ok);
array.printTo(json, sizeof(json));
REQUIRE(std::string("[1,2]") == json);
}
SECTION("TwoDimensions") {
DynamicJsonBuffer jsonBuffer;
JsonArray& array = jsonBuffer.createArray();
char json[32];
int source[][3] = {{1, 2, 3}, {4, 5, 6}};
bool ok = array.copyFrom(source);
REQUIRE(ok);
array.printTo(json, sizeof(json));
REQUIRE(std::string("[[1,2,3],[4,5,6]]") == json);
}
SECTION("TwoDimensions_JsonBufferTooSmall") {
const size_t SIZE =
JSON_ARRAY_SIZE(2) + JSON_ARRAY_SIZE(3) + JSON_ARRAY_SIZE(2);
StaticJsonBuffer<SIZE> jsonBuffer;
JsonArray& array = jsonBuffer.createArray();
char json[32];
int source[][3] = {{1, 2, 3}, {4, 5, 6}};
bool ok = array.copyFrom(source);
REQUIRE_FALSE(ok);
array.printTo(json, sizeof(json));
REQUIRE(std::string("[[1,2,3],[4,5]]") == json);
}
}
-52
View File
@@ -1,52 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::copyTo()") {
DynamicJsonBuffer jsonBuffer;
SECTION("BiggerOneDimensionIntegerArray") {
char json[] = "[1,2,3]";
JsonArray& array = jsonBuffer.parseArray(json);
int destination[4] = {0};
size_t result = array.copyTo(destination);
REQUIRE(3 == result);
REQUIRE(1 == destination[0]);
REQUIRE(2 == destination[1]);
REQUIRE(3 == destination[2]);
REQUIRE(0 == destination[3]);
}
SECTION("SmallerOneDimensionIntegerArray") {
char json[] = "[1,2,3]";
JsonArray& array = jsonBuffer.parseArray(json);
int destination[2] = {0};
size_t result = array.copyTo(destination);
REQUIRE(2 == result);
REQUIRE(1 == destination[0]);
REQUIRE(2 == destination[1]);
}
SECTION("TwoOneDimensionIntegerArray") {
char json[] = "[[1,2],[3],[4]]";
JsonArray& array = jsonBuffer.parseArray(json);
int destination[3][2] = {{0}};
array.copyTo(destination);
REQUIRE(1 == destination[0][0]);
REQUIRE(2 == destination[0][1]);
REQUIRE(3 == destination[1][0]);
REQUIRE(0 == destination[1][1]);
REQUIRE(4 == destination[2][0]);
REQUIRE(0 == destination[2][1]);
}
}
@@ -1,34 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("JsonArray::invalid()") {
SECTION("SubscriptFails") {
REQUIRE_FALSE(JsonArray::invalid()[0].success());
}
SECTION("AddFails") {
JsonArray& array = JsonArray::invalid();
array.add(1);
REQUIRE(0 == array.size());
}
SECTION("CreateNestedArrayFails") {
REQUIRE_FALSE(JsonArray::invalid().createNestedArray().success());
}
SECTION("CreateNestedObjectFails") {
REQUIRE_FALSE(JsonArray::invalid().createNestedObject().success());
}
SECTION("PrintToWritesBrackets") {
char buffer[32];
JsonArray::invalid().printTo(buffer, sizeof(buffer));
REQUIRE_THAT(buffer, Equals("[]"));
}
}
@@ -1,38 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
template <typename TIterator>
static void run_iterator_test() {
StaticJsonBuffer<JSON_ARRAY_SIZE(2)> jsonBuffer;
JsonArray &array = jsonBuffer.createArray();
array.add(12);
array.add(34);
TIterator it = array.begin();
TIterator end = array.end();
REQUIRE(end != it);
REQUIRE(12 == it->template as<int>());
REQUIRE(12 == static_cast<int>(*it));
++it;
REQUIRE(end != it);
REQUIRE(34 == it->template as<int>());
REQUIRE(34 == static_cast<int>(*it));
++it;
REQUIRE(end == it);
}
TEST_CASE("JsonArray::begin()/end()") {
SECTION("Mutable") {
run_iterator_test<JsonArray::iterator>();
}
SECTION("Const") {
run_iterator_test<JsonArray::const_iterator>();
}
}
@@ -1,75 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
static void check(JsonArray& array, std::string expected) {
std::string actual;
size_t actualLen = array.prettyPrintTo(actual);
size_t measuredLen = array.measurePrettyLength();
CHECK(actualLen == expected.size());
CHECK(measuredLen == expected.size());
REQUIRE(expected == actual);
}
TEST_CASE("JsonArray::prettyPrintTo()") {
DynamicJsonBuffer jb;
JsonArray& array = jb.createArray();
SECTION("Empty") {
check(array, "[]");
}
SECTION("OneElement") {
array.add(1);
check(array,
"[\r\n"
" 1\r\n"
"]");
}
SECTION("TwoElements") {
array.add(1);
array.add(2);
check(array,
"[\r\n"
" 1,\r\n"
" 2\r\n"
"]");
}
SECTION("EmptyNestedArrays") {
array.createNestedArray();
array.createNestedArray();
check(array,
"[\r\n"
" [],\r\n"
" []\r\n"
"]");
}
SECTION("NestedArrays") {
JsonArray& nested1 = array.createNestedArray();
nested1.add(1);
nested1.add(2);
JsonObject& nested2 = array.createNestedObject();
nested2["key"] = 3;
check(array,
"[\r\n"
" [\r\n"
" 1,\r\n"
" 2\r\n"
" ],\r\n"
" {\r\n"
" \"key\": 3\r\n"
" }\r\n"
"]");
}
}
-132
View File
@@ -1,132 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
static void check(JsonArray &array, std::string expected) {
std::string actual;
size_t actualLen = array.printTo(actual);
REQUIRE(expected == actual);
REQUIRE(actualLen == expected.size());
size_t measuredLen = array.measureLength();
REQUIRE(measuredLen == expected.size());
}
TEST_CASE("JsonArray::printTo()") {
StaticJsonBuffer<JSON_ARRAY_SIZE(2)> jb;
JsonArray &array = jb.createArray();
SECTION("Empty") {
check(array, "[]");
}
SECTION("Null") {
array.add(static_cast<char *>(0));
check(array, "[null]");
}
SECTION("OneString") {
array.add("hello");
check(array, "[\"hello\"]");
}
SECTION("TwoStrings") {
array.add("hello");
array.add("world");
check(array, "[\"hello\",\"world\"]");
}
SECTION("OneStringOverCapacity") {
array.add("hello");
array.add("world");
array.add("lost");
check(array, "[\"hello\",\"world\"]");
}
SECTION("One double") {
array.add(3.1415927);
check(array, "[3.1415927]");
}
SECTION("OneInteger") {
array.add(1);
check(array, "[1]");
}
SECTION("TwoIntegers") {
array.add(1);
array.add(2);
check(array, "[1,2]");
}
SECTION("RawJson(const char*)") {
array.add(RawJson("{\"key\":\"value\"}"));
check(array, "[{\"key\":\"value\"}]");
}
SECTION("RawJson(char*)") {
DynamicJsonBuffer jb2;
JsonArray &arr = jb2.createArray();
char tmp[] = "{\"key\":\"value\"}";
arr.add(RawJson(tmp));
check(arr, "[{\"key\":\"value\"}]");
}
SECTION("OneIntegerOverCapacity") {
array.add(1);
array.add(2);
array.add(3);
check(array, "[1,2]");
}
SECTION("OneTrue") {
array.add(true);
check(array, "[true]");
}
SECTION("OneFalse") {
array.add(false);
check(array, "[false]");
}
SECTION("TwoBooleans") {
array.add(false);
array.add(true);
check(array, "[false,true]");
}
SECTION("OneBooleanOverCapacity") {
array.add(false);
array.add(true);
array.add(false);
check(array, "[false,true]");
}
SECTION("OneEmptyNestedArray") {
array.createNestedArray();
check(array, "[[]]");
}
SECTION("OneEmptyNestedHash") {
array.createNestedObject();
check(array, "[{}]");
}
}
-68
View File
@@ -1,68 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::remove()") {
DynamicJsonBuffer _jsonBuffer;
JsonArray& _array = _jsonBuffer.createArray();
_array.add(1);
_array.add(2);
_array.add(3);
SECTION("RemoveFirstByIndex") {
_array.remove(0);
REQUIRE(2 == _array.size());
REQUIRE(_array[0] == 2);
REQUIRE(_array[1] == 3);
}
SECTION("RemoveMiddleByIndex") {
_array.remove(1);
REQUIRE(2 == _array.size());
REQUIRE(_array[0] == 1);
REQUIRE(_array[1] == 3);
}
SECTION("RemoveLastByIndex") {
_array.remove(2);
REQUIRE(2 == _array.size());
REQUIRE(_array[0] == 1);
REQUIRE(_array[1] == 2);
}
SECTION("RemoveFirstByIterator") {
JsonArray::iterator it = _array.begin();
_array.remove(it);
REQUIRE(2 == _array.size());
REQUIRE(_array[0] == 2);
REQUIRE(_array[1] == 3);
}
SECTION("RemoveMiddleByIterator") {
JsonArray::iterator it = _array.begin();
++it;
_array.remove(it);
REQUIRE(2 == _array.size());
REQUIRE(_array[0] == 1);
REQUIRE(_array[1] == 3);
}
SECTION("RemoveLastByIterator") {
JsonArray::iterator it = _array.begin();
++it;
++it;
_array.remove(it);
REQUIRE(2 == _array.size());
REQUIRE(_array[0] == 1);
REQUIRE(_array[1] == 2);
}
}
-98
View File
@@ -1,98 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("JsonArray::set()") {
DynamicJsonBuffer _jsonBuffer;
JsonArray& _array = _jsonBuffer.createArray();
_array.add(0);
SECTION("int") {
_array.set(0, 123);
REQUIRE(123 == _array[0].as<int>());
REQUIRE(_array[0].is<int>());
REQUIRE_FALSE(_array[0].is<bool>());
}
SECTION("double") {
_array.set(0, 123.45);
REQUIRE(123.45 == _array[0].as<double>());
REQUIRE(_array[0].is<double>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("bool") {
_array.set(0, true);
REQUIRE(true == _array[0].as<bool>());
REQUIRE(_array[0].is<bool>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("const char*") {
_array.set(0, "hello");
REQUIRE_THAT(_array[0].as<const char*>(), Equals("hello"));
REQUIRE(_array[0].is<const char*>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("nested array") {
JsonArray& arr = _jsonBuffer.createArray();
_array.set(0, arr);
REQUIRE(&arr == &_array[0].as<JsonArray&>());
REQUIRE(_array[0].is<JsonArray&>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("nested object") {
JsonObject& obj = _jsonBuffer.createObject();
_array.set(0, obj);
REQUIRE(&obj == &_array[0].as<JsonObject&>());
REQUIRE(_array[0].is<JsonObject&>());
REQUIRE_FALSE(_array[0].is<int>());
}
SECTION("array subscript") {
JsonArray& arr = _jsonBuffer.createArray();
arr.add("hello");
_array.set(0, arr[0]);
REQUIRE_THAT(_array[0].as<char*>(), Equals("hello"));
}
SECTION("object subscript") {
JsonObject& obj = _jsonBuffer.createObject();
obj["x"] = "hello";
_array.set(0, obj["x"]);
REQUIRE_THAT(_array[0].as<char*>(), Equals("hello"));
}
SECTION("should not duplicate const char*") {
_array.set(0, "world");
const size_t expectedSize = JSON_ARRAY_SIZE(1);
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate char*") {
_array.set(0, const_cast<char*>("world"));
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate std::string") {
_array.set(0, std::string("world"));
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
}
}
-35
View File
@@ -1,35 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::size()") {
DynamicJsonBuffer _jsonBuffer;
JsonArray& _array = _jsonBuffer.createArray();
SECTION("increases after add()") {
_array.add("hello");
REQUIRE(1U == _array.size());
_array.add("world");
REQUIRE(2U == _array.size());
}
SECTION("remains the same after set()") {
_array.add("hello");
REQUIRE(1U == _array.size());
_array.set(0, "hello");
REQUIRE(1U == _array.size());
}
SECTION("remains the same after assigment") {
_array.add("hello");
REQUIRE(1U == _array.size());
_array[0] = "hello";
REQUIRE(1U == _array.size());
}
}
@@ -1,119 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <stdint.h>
#include <catch.hpp>
TEST_CASE("JsonArray::operator[]") {
DynamicJsonBuffer _jsonBuffer;
JsonArray& _array = _jsonBuffer.createArray();
_array.add(0);
SECTION("int") {
_array[0] = 123;
REQUIRE(123 == _array[0].as<int>());
REQUIRE(true == _array[0].is<int>());
REQUIRE(false == _array[0].is<bool>());
}
#if ARDUINOJSON_USE_LONG_LONG || ARDUINOJSON_USE_INT64
SECTION("long long") {
_array[0] = 9223372036854775807;
REQUIRE(9223372036854775807 == _array[0].as<long long>());
REQUIRE(true == _array[0].is<int>());
REQUIRE(false == _array[0].is<bool>());
}
#endif
SECTION("double") {
_array[0] = 123.45;
REQUIRE(123.45 == _array[0].as<double>());
REQUIRE(true == _array[0].is<double>());
REQUIRE(false == _array[0].is<int>());
}
SECTION("bool") {
_array[0] = true;
REQUIRE(true == _array[0].as<bool>());
REQUIRE(true == _array[0].is<bool>());
REQUIRE(false == _array[0].is<int>());
}
SECTION("const char*") {
const char* str = "hello";
_array[0] = str;
REQUIRE(str == _array[0].as<const char*>());
REQUIRE(str == _array[0].as<char*>()); // <- short hand
REQUIRE(true == _array[0].is<const char*>());
REQUIRE(false == _array[0].is<int>());
}
SECTION("nested array") {
JsonArray& arr = _jsonBuffer.createArray();
_array[0] = arr;
REQUIRE(&arr == &_array[0].as<JsonArray&>());
REQUIRE(&arr == &_array[0].as<JsonArray>()); // <- short hand
REQUIRE(&arr == &_array[0].as<const JsonArray&>());
REQUIRE(&arr == &_array[0].as<const JsonArray>()); // <- short hand
REQUIRE(true == _array[0].is<JsonArray&>());
REQUIRE(false == _array[0].is<int>());
}
SECTION("nested object") {
JsonObject& obj = _jsonBuffer.createObject();
_array[0] = obj;
REQUIRE(&obj == &_array[0].as<JsonObject&>());
REQUIRE(&obj == &_array[0].as<JsonObject>()); // <- short hand
REQUIRE(&obj == &_array[0].as<const JsonObject&>());
REQUIRE(&obj == &_array[0].as<const JsonObject>()); // <- short hand
REQUIRE(true == _array[0].is<JsonObject&>());
REQUIRE(false == _array[0].is<int>());
}
SECTION("array subscript") {
JsonArray& arr = _jsonBuffer.createArray();
const char* str = "hello";
arr.add(str);
_array[0] = arr[0];
REQUIRE(str == _array[0]);
}
SECTION("object subscript") {
JsonObject& obj = _jsonBuffer.createObject();
const char* str = "hello";
obj["x"] = str;
_array[0] = obj["x"];
REQUIRE(str == _array[0]);
}
SECTION("should not duplicate const char*") {
_array[0] = "world";
const size_t expectedSize = JSON_ARRAY_SIZE(1);
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate char*") {
_array[0] = const_cast<char*>("world");
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate std::string") {
_array[0] = std::string("world");
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
}
}
@@ -1,14 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
add_executable(JsonBufferTests
nested.cpp
nestingLimit.cpp
parse.cpp
parseArray.cpp
parseObject.cpp
)
target_link_libraries(JsonBufferTests catch)
add_test(JsonBuffer JsonBufferTests)
@@ -1,63 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonBuffer nested objects") {
SECTION("ArrayNestedInObject") {
DynamicJsonBuffer jsonBuffer;
char jsonString[] = " { \"ab\" : [ 1 , 2 ] , \"cd\" : [ 3 , 4 ] } ";
JsonObject &object = jsonBuffer.parseObject(jsonString);
JsonArray &array1 = object["ab"];
const JsonArray &array2 = object["cd"];
JsonArray &array3 = object["ef"];
REQUIRE(true == object.success());
REQUIRE(true == array1.success());
REQUIRE(true == array2.success());
REQUIRE(false == array3.success());
REQUIRE(2 == array1.size());
REQUIRE(2 == array2.size());
REQUIRE(0 == array3.size());
REQUIRE(1 == array1[0].as<int>());
REQUIRE(2 == array1[1].as<int>());
REQUIRE(3 == array2[0].as<int>());
REQUIRE(4 == array2[1].as<int>());
REQUIRE(0 == array3[0].as<int>());
}
SECTION("ObjectNestedInArray") {
DynamicJsonBuffer jsonBuffer;
char jsonString[] =
" [ { \"a\" : 1 , \"b\" : 2 } , { \"c\" : 3 , \"d\" : 4 } ] ";
JsonArray &array = jsonBuffer.parseArray(jsonString);
JsonObject &object1 = array[0];
const JsonObject &object2 = array[1];
JsonObject &object3 = array[2];
REQUIRE(true == array.success());
REQUIRE(true == object1.success());
REQUIRE(true == object2.success());
REQUIRE(false == object3.success());
REQUIRE(2 == object1.size());
REQUIRE(2 == object2.size());
REQUIRE(0 == object3.size());
REQUIRE(1 == object1["a"].as<int>());
REQUIRE(2 == object1["b"].as<int>());
REQUIRE(3 == object2["c"].as<int>());
REQUIRE(4 == object2["d"].as<int>());
REQUIRE(0 == object3["e"].as<int>());
}
}
@@ -1,48 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
bool tryParseArray(const char *json, uint8_t nestingLimit) {
DynamicJsonBuffer buffer;
return buffer.parseArray(json, nestingLimit).success();
}
bool tryParseObject(const char *json, uint8_t nestingLimit) {
DynamicJsonBuffer buffer;
return buffer.parseObject(json, nestingLimit).success();
}
TEST_CASE("JsonParser nestingLimit") {
SECTION("ParseArrayWithNestingLimit0") {
REQUIRE(true == tryParseArray("[]", 0));
REQUIRE(false == tryParseArray("[[]]", 0));
}
SECTION("ParseArrayWithNestingLimit1") {
REQUIRE(true == tryParseArray("[[]]", 1));
REQUIRE(false == tryParseArray("[[[]]]", 1));
}
SECTION("ParseArrayWithNestingLimit2") {
REQUIRE(true == tryParseArray("[[[]]]", 2));
REQUIRE(false == tryParseArray("[[[[]]]]", 2));
}
SECTION("ParseObjectWithNestingLimit0") {
REQUIRE(true == tryParseObject("{}", 0));
REQUIRE(false == tryParseObject("{\"key\":{}}", 0));
}
SECTION("ParseObjectWithNestingLimit1") {
REQUIRE(true == tryParseObject("{\"key\":{}}", 1));
REQUIRE(false == tryParseObject("{\"key\":{\"key\":{}}}", 1));
}
SECTION("ParseObjectWithNestingLimit2") {
REQUIRE(true == tryParseObject("{\"key\":{\"key\":{}}}", 2));
REQUIRE(false == tryParseObject("{\"key\":{\"key\":{\"key\":{}}}}", 2));
}
}
-80
View File
@@ -1,80 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("JsonBuffer::parse()") {
DynamicJsonBuffer jb;
SECTION("EmptyObject") {
JsonVariant variant = jb.parse("{}");
REQUIRE(variant.success());
REQUIRE(variant.is<JsonObject>());
}
SECTION("EmptyArray") {
JsonVariant variant = jb.parse("[]");
REQUIRE(variant.success());
REQUIRE(variant.is<JsonArray>());
}
SECTION("Integer") {
JsonVariant variant = jb.parse("-42");
REQUIRE(variant.success());
REQUIRE(variant.is<int>());
REQUIRE_FALSE(variant.is<bool>());
REQUIRE(variant == -42);
}
SECTION("Double") {
JsonVariant variant = jb.parse("-1.23e+4");
REQUIRE(variant.success());
REQUIRE_FALSE(variant.is<int>());
REQUIRE(variant.is<double>());
REQUIRE(variant.as<double>() == Approx(-1.23e+4));
}
SECTION("Double quoted string") {
JsonVariant variant = jb.parse("\"hello world\"");
REQUIRE(variant.success());
REQUIRE(variant.is<char*>());
REQUIRE_THAT(variant.as<char*>(), Equals("hello world"));
}
SECTION("Single quoted string") {
JsonVariant variant = jb.parse("\'hello world\'");
REQUIRE(variant.success());
REQUIRE(variant.is<char*>());
REQUIRE_THAT(variant.as<char*>(), Equals("hello world"));
}
SECTION("True") {
JsonVariant variant = jb.parse("true");
REQUIRE(variant.success());
REQUIRE(variant.is<bool>());
REQUIRE(variant == true);
}
SECTION("False") {
JsonVariant variant = jb.parse("false");
REQUIRE(variant.success());
REQUIRE(variant.is<bool>());
REQUIRE(variant == false);
}
SECTION("OpenBrace") {
JsonVariant variant = jb.parse("{");
REQUIRE_FALSE(variant.success());
}
SECTION("Incomplete string") {
JsonVariant variant = jb.parse("\"hello");
REQUIRE(variant.success());
REQUIRE(variant.is<char*>());
REQUIRE_THAT(variant.as<char*>(), Equals("hello"));
}
}
@@ -1,318 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonBuffer::parseArray()") {
DynamicJsonBuffer jb;
SECTION("EmptyArray") {
JsonArray& arr = jb.parseArray("[]");
REQUIRE(arr.success());
REQUIRE(0 == arr.size());
}
SECTION("MissingOpeningBracket") {
JsonArray& arr = jb.parseArray("]");
REQUIRE_FALSE(arr.success());
}
SECTION("ArrayWithNoEnd") {
JsonArray& arr = jb.parseArray("[");
REQUIRE_FALSE(arr.success());
}
SECTION("EmptyArrayWithLeadingSpaces") {
JsonArray& arr = jb.parseArray(" []");
REQUIRE(arr.success());
REQUIRE(0 == arr.size());
}
SECTION("Garbage") {
JsonArray& arr = jb.parseArray("%*$£¤");
REQUIRE_FALSE(arr.success());
}
SECTION("OneInteger") {
JsonArray& arr = jb.parseArray("[42]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == 42);
}
SECTION("OneIntegerWithSpacesBefore") {
JsonArray& arr = jb.parseArray("[ \t\r\n42]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == 42);
}
SECTION("OneIntegerWithSpaceAfter") {
JsonArray& arr = jb.parseArray("[42 \t\r\n]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == 42);
}
SECTION("TwoIntegers") {
JsonArray& arr = jb.parseArray("[42,84]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == 42);
REQUIRE(arr[1] == 84);
}
SECTION("TwoDoubles") {
JsonArray& arr = jb.parseArray("[4.2,1e2]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == 4.2);
REQUIRE(arr[1] == 1e2);
}
SECTION("UnsignedLong") {
JsonArray& arr = jb.parseArray("[4294967295]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == 4294967295UL);
}
SECTION("TwoBooleans") {
JsonArray& arr = jb.parseArray("[true,false]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == true);
REQUIRE(arr[1] == false);
}
SECTION("TwoNulls") {
JsonArray& arr = jb.parseArray("[null,null]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0].as<char*>() == 0);
REQUIRE(arr[1].as<char*>() == 0);
}
SECTION("TwoStringsDoubleQuotes") {
JsonArray& arr = jb.parseArray("[ \"hello\" , \"world\" ]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "hello");
REQUIRE(arr[1] == "world");
}
SECTION("TwoStringsSingleQuotes") {
JsonArray& arr = jb.parseArray("[ 'hello' , 'world' ]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "hello");
REQUIRE(arr[1] == "world");
}
SECTION("TwoStringsNoQuotes") {
JsonArray& arr = jb.parseArray("[ hello , world ]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "hello");
REQUIRE(arr[1] == "world");
}
SECTION("EmptyStringsDoubleQuotes") {
JsonArray& arr = jb.parseArray("[\"\",\"\"]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "");
REQUIRE(arr[1] == "");
}
SECTION("EmptyStringSingleQuotes") {
JsonArray& arr = jb.parseArray("[\'\',\'\']");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "");
REQUIRE(arr[1] == "");
}
SECTION("EmptyStringNoQuotes") {
JsonArray& arr = jb.parseArray("[,]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "");
REQUIRE(arr[1] == "");
}
SECTION("ClosingDoubleQuoteMissing") {
JsonArray& arr = jb.parseArray("[\"]");
REQUIRE_FALSE(arr.success());
}
SECTION("ClosingSignleQuoteMissing") {
JsonArray& arr = jb.parseArray("[\']");
REQUIRE_FALSE(arr.success());
}
SECTION("StringWithEscapedChars") {
JsonArray& arr = jb.parseArray("[\"1\\\"2\\\\3\\/4\\b5\\f6\\n7\\r8\\t9\"]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "1\"2\\3/4\b5\f6\n7\r8\t9");
}
SECTION("StringWithUnterminatedEscapeSequence") {
JsonArray& arr = jb.parseArray("\"\\\0\"", 4);
REQUIRE_FALSE(arr.success());
}
SECTION("CCommentBeforeOpeningBracket") {
JsonArray& arr = jb.parseArray("/*COMMENT*/ [\"hello\"]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CCommentAfterOpeningBracket") {
JsonArray& arr = jb.parseArray("[/*COMMENT*/ \"hello\"]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CCommentBeforeClosingBracket") {
JsonArray& arr = jb.parseArray("[\"hello\"/*COMMENT*/]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CCommentAfterClosingBracket") {
JsonArray& arr = jb.parseArray("[\"hello\"]/*COMMENT*/");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CCommentBeforeComma") {
JsonArray& arr = jb.parseArray("[\"hello\"/*COMMENT*/,\"world\"]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "hello");
REQUIRE(arr[1] == "world");
}
SECTION("CCommentAfterComma") {
JsonArray& arr = jb.parseArray("[\"hello\",/*COMMENT*/ \"world\"]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "hello");
REQUIRE(arr[1] == "world");
}
SECTION("CppCommentBeforeOpeningBracket") {
JsonArray& arr = jb.parseArray("//COMMENT\n\t[\"hello\"]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CppCommentAfterOpeningBracket") {
JsonArray& arr = jb.parseArray("[//COMMENT\n\"hello\"]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CppCommentBeforeClosingBracket") {
JsonArray& arr = jb.parseArray("[\"hello\"//COMMENT\r\n]");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CppCommentAfterClosingBracket") {
JsonArray& arr = jb.parseArray("[\"hello\"]//COMMENT\n");
REQUIRE(arr.success());
REQUIRE(1 == arr.size());
REQUIRE(arr[0] == "hello");
}
SECTION("CppCommentBeforeComma") {
JsonArray& arr = jb.parseArray("[\"hello\"//COMMENT\n,\"world\"]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "hello");
REQUIRE(arr[1] == "world");
}
SECTION("CppCommentAfterComma") {
JsonArray& arr = jb.parseArray("[\"hello\",//COMMENT\n\"world\"]");
REQUIRE(arr.success());
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == "hello");
REQUIRE(arr[1] == "world");
}
SECTION("InvalidCppComment") {
JsonArray& arr = jb.parseArray("[/COMMENT\n]");
REQUIRE_FALSE(arr.success());
}
SECTION("InvalidComment") {
JsonArray& arr = jb.parseArray("[/*/\n]");
REQUIRE_FALSE(arr.success());
}
SECTION("UnfinishedCComment") {
JsonArray& arr = jb.parseArray("[/*COMMENT]");
REQUIRE_FALSE(arr.success());
}
SECTION("EndsInCppComment") {
JsonArray& arr = jb.parseArray("[//COMMENT");
REQUIRE_FALSE(arr.success());
}
SECTION("AfterClosingStar") {
JsonArray& arr = jb.parseArray("[/*COMMENT*");
REQUIRE_FALSE(arr.success());
}
SECTION("DeeplyNested") {
JsonArray& arr =
jb.parseArray("[[[[[[[[[[[[[[[[[[[\"Not too deep\"]]]]]]]]]]]]]]]]]]]");
REQUIRE(arr.success());
}
}
@@ -1,170 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonBuffer::parseObject()") {
DynamicJsonBuffer jb;
SECTION("An empty object") {
JsonObject& obj = jb.parseObject("{}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 0);
}
SECTION("Quotes") {
SECTION("Double quotes") {
JsonObject& obj = jb.parseObject("{\"key\":\"value\"}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["key"] == "value");
}
SECTION("Single quotes") {
JsonObject& obj = jb.parseObject("{'key':'value'}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["key"] == "value");
}
SECTION("No quotes") {
JsonObject& obj = jb.parseObject("{key:value}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["key"] == "value");
}
SECTION("No quotes, allow underscore in key") {
JsonObject& obj = jb.parseObject("{_k_e_y_:42}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["_k_e_y_"] == 42);
}
}
SECTION("Spaces") {
SECTION("Before the key") {
JsonObject& obj = jb.parseObject("{ \"key\":\"value\"}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["key"] == "value");
}
SECTION("After the key") {
JsonObject& obj = jb.parseObject("{\"key\" :\"value\"}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["key"] == "value");
}
SECTION("Before the value") {
JsonObject& obj = jb.parseObject("{\"key\": \"value\"}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["key"] == "value");
}
SECTION("After the value") {
JsonObject& obj = jb.parseObject("{\"key\":\"value\" }");
REQUIRE(obj.success());
REQUIRE(obj.size() == 1);
REQUIRE(obj["key"] == "value");
}
SECTION("Before the colon") {
JsonObject& obj =
jb.parseObject("{\"key1\":\"value1\" ,\"key2\":\"value2\"}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"] == "value1");
REQUIRE(obj["key2"] == "value2");
}
SECTION("After the colon") {
JsonObject& obj =
jb.parseObject("{\"key1\":\"value1\" ,\"key2\":\"value2\"}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"] == "value1");
REQUIRE(obj["key2"] == "value2");
}
}
SECTION("Values types") {
SECTION("String") {
JsonObject& obj =
jb.parseObject("{\"key1\":\"value1\",\"key2\":\"value2\"}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"] == "value1");
REQUIRE(obj["key2"] == "value2");
}
SECTION("Integer") {
JsonObject& obj = jb.parseObject("{\"key1\":42,\"key2\":-42}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"] == 42);
REQUIRE(obj["key2"] == -42);
}
SECTION("Double") {
JsonObject& obj = jb.parseObject("{\"key1\":12.345,\"key2\":-7E89}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"] == 12.345);
REQUIRE(obj["key2"] == -7E89);
}
SECTION("Booleans") {
JsonObject& obj = jb.parseObject("{\"key1\":true,\"key2\":false}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"] == true);
REQUIRE(obj["key2"] == false);
}
SECTION("Null") {
JsonObject& obj = jb.parseObject("{\"key1\":null,\"key2\":null}");
REQUIRE(obj.success());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"].as<char*>() == 0);
REQUIRE(obj["key2"].as<char*>() == 0);
}
}
SECTION("Misc") {
SECTION("The opening brace is missing") {
JsonObject& obj = jb.parseObject("}");
REQUIRE_FALSE(obj.success());
}
SECTION("The closing brace is missing") {
JsonObject& obj = jb.parseObject("{");
REQUIRE_FALSE(obj.success());
}
SECTION("A quoted key without value") {
JsonObject& obj = jb.parseObject("{\"key\"}");
REQUIRE_FALSE(obj.success());
}
SECTION("A non-quoted key without value") {
JsonObject& obj = jb.parseObject("{key}");
REQUIRE_FALSE(obj.success());
}
SECTION("A dangling comma") {
JsonObject& obj = jb.parseObject("{\"key1\":\"value1\",}");
REQUIRE_FALSE(obj.success());
REQUIRE(obj.size() == 0);
}
SECTION("null as a key") {
JsonObject& obj = jb.parseObject("null:\"value\"}");
REQUIRE_FALSE(obj.success());
}
}
}
@@ -1,20 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2018
# MIT License
add_executable(JsonObjectTests
basics.cpp
containsKey.cpp
get.cpp
invalid.cpp
iterator.cpp
prettyPrintTo.cpp
printTo.cpp
remove.cpp
set.cpp
size.cpp
subscript.cpp
)
target_link_libraries(JsonObjectTests catch)
add_test(JsonObject JsonObjectTests)
@@ -1,19 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonObject basics") {
DynamicJsonBuffer _jsonBuffer;
JsonObject& _object = _jsonBuffer.createObject();
SECTION("InitialSizeIsZero") {
REQUIRE(0 == _object.size());
}
SECTION("SuccessIsTrue") {
REQUIRE(_object.success());
}
}
@@ -1,30 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonObject::containsKey()") {
DynamicJsonBuffer _jsonBuffer;
JsonObject& _object = _jsonBuffer.createObject();
SECTION("ContainsKeyReturnsFalseForNonExistingKey") {
_object.set("hello", 42);
REQUIRE(false == _object.containsKey("world"));
}
SECTION("ContainsKeyReturnsTrueForDefinedValue") {
_object.set("hello", 42);
REQUIRE(true == _object.containsKey("hello"));
}
SECTION("ContainsKeyReturnsFalseAfterRemove") {
_object.set("hello", 42);
_object.remove("hello");
REQUIRE(false == _object.containsKey("hello"));
}
}
-19
View File
@@ -1,19 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("JsonObject::get()") {
DynamicJsonBuffer jb;
JsonObject& obj = jb.createObject();
SECTION("GetConstCharPointer_GivenStringLiteral") {
obj.set("hello", "world");
const char* value = obj.get<const char*>("hello");
REQUIRE_THAT(value, Equals("world"));
}
}
@@ -1,35 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("JsonObject::invalid()") {
JsonObject& obj = JsonObject::invalid();
SECTION("SubscriptFails") {
REQUIRE_FALSE(obj["key"].success());
}
SECTION("AddFails") {
obj.set("hello", "world");
REQUIRE(0 == obj.size());
}
SECTION("CreateNestedArrayFails") {
REQUIRE_FALSE(obj.createNestedArray("hello").success());
}
SECTION("CreateNestedObjectFails") {
REQUIRE_FALSE(obj.createNestedObject("world").success());
}
SECTION("PrintToWritesBraces") {
char buffer[32];
obj.printTo(buffer, sizeof(buffer));
REQUIRE_THAT(buffer, Equals("{}"));
}
}
@@ -1,51 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("JsonObject::begin()/end()") {
StaticJsonBuffer<JSON_OBJECT_SIZE(2)> jb;
JsonObject& obj = jb.createObject();
obj["ab"] = 12;
obj["cd"] = 34;
SECTION("NonConstIterator") {
JsonObject::iterator it = obj.begin();
REQUIRE(obj.end() != it);
REQUIRE_THAT(it->key, Equals("ab"));
REQUIRE(12 == it->value);
it->key = "a.b";
it->value = 1.2;
++it;
REQUIRE(obj.end() != it);
REQUIRE_THAT(it->key, Equals("cd"));
REQUIRE(34 == it->value);
it->key = "c.d";
it->value = 3.4;
++it;
REQUIRE(obj.end() == it);
REQUIRE(2 == obj.size());
REQUIRE(1.2 == obj["a.b"]);
REQUIRE(3.4 == obj["c.d"]);
}
SECTION("ConstIterator") {
const JsonObject& const_object = obj;
JsonObject::const_iterator it = const_object.begin();
REQUIRE(const_object.end() != it);
REQUIRE_THAT(it->key, Equals("ab"));
REQUIRE(12 == it->value);
++it;
REQUIRE(const_object.end() != it);
REQUIRE_THAT(it->key, Equals("cd"));
REQUIRE(34 == it->value);
++it;
REQUIRE(const_object.end() == it);
}
}
Loaded 100 of 182 files, more files were not shown because too many files have changed in this diff. Show more