### Device with temperature sensor Example Source: https://github.com/electroniccats/cayennelpp/wiki/1.-CayenneLPP This example demonstrates encoding a single temperature sensor reading. The data channel and type are specified, followed by the temperature value. ```text Payload (Hex) | 01 67 FF D7 | -- | -- | -- Data Channel | Type | Value 01 => 1 | 67 => Temperature | FFD7 = -41 => -4.1°C ``` -------------------------------- ### Device with GPS Example Source: https://github.com/electroniccats/cayennelpp/wiki/1.-CayenneLPP This example illustrates encoding GPS data, including latitude, longitude, and altitude. Each component is associated with the GPS data type. ```text Payload (Hex) | 01 88 06 76 5f f2 96 0a 00 03 e8 | -- | -- | -- Data Channel | Type | Value 01 => 1 | 88 => GPS | Latitude: 06765f => 42.3519 01 => 1 | 88 => GPS | Longitude: F2960a => -87.9094 01 => 1 | 88 => GPS | Altitude: 0003E8 => 10 meters ``` -------------------------------- ### Device with 2 temperature sensors Example Source: https://github.com/electroniccats/cayennelpp/wiki/1.-CayenneLPP This example shows how to encode data from two temperature sensors. Each sensor is assigned a data channel and the temperature value is encoded. ```text Payload (Hex) | 03 67 01 10 05 67 00 FF | -- | -- | -- Data Channel | Type | Value 03 => 3 | 67 => Temperature | 0110 = 272 => 27.2°C 05 => 5 | 67 => Temperature | 00FF = 255 => 25.5°C ``` -------------------------------- ### Device with acceleration sensors Example Source: https://github.com/electroniccats/cayennelpp/wiki/1.-CayenneLPP This example shows how to encode accelerometer data for X, Y, and Z axes. Each axis reading is prefixed with the same data channel and accelerometer type. ```text Payload (Hex) | 06 71 04 D2 FB 2E 00 00 | -- | -- | -- Data Channel | Type | Value 06 => 6 | 71 => Accelerometer | X: 04D2 = +1234 => + 1.234G 06 => 6 | 71 => Accelerometer | Y: FB2E = -1234 => - 1.234G 06 => 6 | 71 => Accelerometer | Z: 0000 = 0 => 0G ``` -------------------------------- ### Get Buffer Size Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Returns the current size of the internal buffer. No setup is required. ```c uint8_t getSize(void); ``` -------------------------------- ### Encode and Send Sensor Data with CayenneLPP Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Example demonstrating how to reset the LPP buffer, add various sensor data types (temperature, barometric pressure, GPS), and send the encoded buffer using The Things Network library. Ensure the buffer size is appropriate for your transmission constraints. ```c++ TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan); CayenneLPP lpp(51); lpp.reset(); lpp.addTemperature(1, 22.5); lpp.addBarometricPressure(2, 1073.21); lpp.addGPS(3, 52.37365, 4.88650, 2); ttn.sendBytes(lpp.getBuffer(), lpp.getSize()); ``` -------------------------------- ### Get Buffer Pointer Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Returns a pointer to the internal buffer. Use this to access the raw data. ```c uint8_t *getBuffer(void); ``` -------------------------------- ### Get Type Name Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Returns a C-string pointer to the name of a given sensor type. Accepts a uint8_t representing the type. ```c const char * getTypeName(uint8_t type); ``` -------------------------------- ### Get Last Error ID Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Retrieves the last error ID encountered by the library. The error is reset to OK after retrieval. Use this to diagnose issues during encoding or decoding. ```c uint8_t getError(void); ``` -------------------------------- ### Fetch Catch2 Testing Framework Source: https://github.com/electroniccats/cayennelpp/blob/master/test/catch2/CMakeLists.txt This snippet demonstrates how to declare and make available the Catch2 testing framework using CMake's FetchContent module. It specifies the Git repository and tag for Catch2. ```cmake Include(FetchContent) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.0.0-preview3 ) FetchContent_MakeAvailable(Catch2) ``` -------------------------------- ### Instantiate CayenneLPP Class Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Include and instantiate the CayenneLPP class. The constructor takes the size of the allocated buffer, which should be set based on LoRa frequency plan and data rate constraints. A common safe value is 51 bytes. ```c++ #include CayenneLPP lpp(uint8_t size); ``` -------------------------------- ### Set Include Directories for Test Executable Source: https://github.com/electroniccats/cayennelpp/blob/master/test/catch2/CMakeLists.txt Configures the include directories for the 'clpp_test' executable. It specifies that the '../../src' directory should be searched for header files during compilation. ```cmake target_include_directories(clpp_test PRIVATE ../../src ) ``` -------------------------------- ### CayenneLPP Constructor Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Include and instantiate the CayenneLPP class. The constructor takes the size of the allocated buffer. Depending on the LoRa frequency plan and data rate used, the maximum payload varies. It's safe to send up to 51 bytes of payload. ```APIDOC ## `CayenneLPP` Constructor ### Description Instantiates the CayenneLPP class with a specified buffer size. ### Parameters #### Path Parameters - **size** (uint8_t) - Required - The maximum payload size to send, e.g. `51`. ``` -------------------------------- ### `getSize` Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Returns the size of the internal buffer. ```APIDOC ## `getSize` ### Description Returns the size of the buffer. ### Signature ```c uint8_t getSize(void); ``` ``` -------------------------------- ### Define Test Executable and Sources Source: https://github.com/electroniccats/cayennelpp/blob/master/test/catch2/CMakeLists.txt This CMake code defines the test executable 'clpp_test' and lists its source files. It includes test files for LppMessage and LppPolyline, along with the main CayenneLPP source files. ```cmake add_executable(clpp_test LppMessageTest.cpp LppPolylineTest.cpp ../../src/CayenneLPP.cpp ../../src/CayenneLPPPolyline.cpp ) ``` -------------------------------- ### addSwitch Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds switch data (0 or 1) to the buffer. ```APIDOC ## addSwitch ### Description Adds switch data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The switch value (0 or 1). ### Method `uint8_t addSwitch(uint8_t channel, uint32_t value);` ``` -------------------------------- ### addEnergy Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds energy data (in kWh) to the buffer with 3 decimal places of precision. ```APIDOC ## addEnergy ### Description Adds energy data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The energy value in kWh (3 decimals). ### Method `uint8_t addEnergy(uint8_t channel, float value);` ``` -------------------------------- ### addTemperature Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds temperature data (in Celsius) to the buffer with 1 decimal place of precision. ```APIDOC ## addTemperature ### Description Adds temperature data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The temperature value in Celsius (1 decimal). ### Method `uint8_t addTemperature(uint8_t channel, float value);` ``` -------------------------------- ### addConcentration Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds concentration data (1 PPM unsigned) to the buffer. PPM means Parts per million (1PPM = 1 * 10^-6 = 0.000001). ```APIDOC ## addConcentration ### Description Adds concentration data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The concentration value (1 PPM unsigned). ### Method `uint8_t CayenneLPP::addConcentration(uint8_t channel, uint32_t value);` ``` -------------------------------- ### Add Concentration Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a concentration value (1 PPM unsigned) to the buffer. PPM means Parts per million. ```c++ uint8_t CayenneLPP::addConcentration(uint8_t channel, uint32_t value); ``` -------------------------------- ### `getBuffer` Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Returns a pointer to the internal buffer. ```APIDOC ## `getBuffer` ### Description Returns a pointer to the buffer. ### Signature ```c uint8_t *getBuffer(void); ``` ``` -------------------------------- ### addAnalogInput Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds analog input data to the buffer with 3 decimal places of precision. ```APIDOC ## addAnalogInput ### Description Adds analog input data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The analog input value (3 decimals). ### Method `uint8_t addAnalogInput(uint8_t channel, float value);` ``` -------------------------------- ### Add Energy Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds an energy value (in kWh with 3 decimal places) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addEnergy(uint8_t channel, float value); ``` -------------------------------- ### `copy` Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Copies the internal buffer to a specified buffer and returns the number of bytes copied. ```APIDOC ## `copy` ### Description Copies the internal buffer to a specified buffer and returns the copied size. ### Signature ```c uint8_t copy(uint8_t *buffer); ``` ``` -------------------------------- ### addPower Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds power data (in watts) to the buffer. ```APIDOC ## addPower ### Description Adds power data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The power value in watts. ### Method `uint8_t addPower(uint8_t channel, float value);` ``` -------------------------------- ### addPresence Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds presence detection data to the buffer. ```APIDOC ## addPresence ### Description Adds presence detection data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The presence value. ### Method `uint8_t addPresence(uint8_t channel, uint32_t value);` ``` -------------------------------- ### addLuminosity Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds luminosity data (in luxes) to the buffer. ```APIDOC ## addLuminosity ### Description Adds luminosity data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The luminosity value in luxes. ### Method `uint8_t addLuminosity(uint8_t channel, uint32_t value);` ``` -------------------------------- ### addAnalogOutput Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds analog output data to the buffer with 3 decimal places of precision. ```APIDOC ## addAnalogOutput ### Description Adds analog output data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The analog output value (3 decimals). ### Method `uint8_t addAnalogOutput(uint8_t channel, float value);` ``` -------------------------------- ### Link Test Executable with Catch2 Source: https://github.com/electroniccats/cayennelpp/blob/master/test/catch2/CMakeLists.txt Links the 'clpp_test' executable against the Catch2 testing library. This makes the Catch2 testing functionalities available to the test program. ```cmake target_link_libraries(clpp_test PRIVATE Catch2::Catch2WithMain ) ``` -------------------------------- ### Add Temperature Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a temperature value (in Celsius with 1 decimal place) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addTemperature(uint8_t channel, float value); ``` -------------------------------- ### reset Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Resets the internal data buffer, preparing it for new data entries. ```APIDOC ## reset ### Description Resets the buffer. ### Method `void reset(void);` ``` -------------------------------- ### Add Analog Input Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds an analog input value (float with 3 decimal places) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addAnalogInput(uint8_t channel, float value); ``` -------------------------------- ### addDigitalInput Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds digital input data to the buffer. ```APIDOC ## addDigitalInput ### Description Adds digital input data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The digital input value. ### Method `uint8_t addDigitalInput(uint8_t channel, uint32_t value);` ``` -------------------------------- ### addAltitude Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds altitude data (in meters) to the buffer. ```APIDOC ## addAltitude ### Description Adds altitude data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The altitude value in meters. ### Method `uint8_t addAltitude(uint8_t channel, float value);` ``` -------------------------------- ### Add Power Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a power value (in watts) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addPower(uint8_t channel, float value); ``` -------------------------------- ### Add Analog Output Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds an analog output value (float with 3 decimal places) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addAnalogOutput(uint8_t channel, float value); ``` -------------------------------- ### addAccelerometer Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds accelerometer data (X, Y, Z axes) to the buffer, with 3 decimal places of precision for each axis. ```APIDOC ## addAccelerometer ### Description Adds accelerometer data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **x** (float) - Required - The X-axis value (3 decimals). - **y** (float) - Required - The Y-axis value (3 decimals). - **z** (float) - Required - The Z-axis value (3 decimals). ### Method `uint8_t addAccelerometer(uint8_t channel, float x, float y, float z);` ``` -------------------------------- ### Add Voltage Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a voltage value (in volts with 2 decimal places) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addVoltage(uint8_t channel, float value); ``` -------------------------------- ### Configure ESP-IDF Component Source: https://github.com/electroniccats/cayennelpp/blob/master/CMakeLists.txt This snippet registers CayenneLPP as an ESP-IDF component, specifying source files, include directories, and dependencies. It is used when building for an ESP platform. ```cmake cmake_minimum_required(VERSION 3.13) if(ESP_PLATFORM) # Build CayenneLPP as an ESP-IDF component # required because ESP-IDF runs cmake in script mode # and needs idf_component_register() file(GLOB_RECURSE CAYENNELPP_ESP_SOURCES "src/*.*" ) idf_component_register( SRCS ${CAYENNELPP_ESP_SOURCES} INCLUDE_DIRS src REQUIRES bblanchon__arduinojson ) return() endif() ``` -------------------------------- ### Add Generic Sensor Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a generic sensor reading (float) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addGenericSensor(uint8_t channel, float value); ``` -------------------------------- ### addPercentage Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds percentage data (0 to 100) to the buffer. ```APIDOC ## addPercentage ### Description Adds percentage data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The percentage value (0 to 100). ### Method `uint8_t addPercentage(uint8_t channel, uint32_t value);` ``` -------------------------------- ### Add Colour Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds RGB colour values (Red, Green, Blue, each 0-255) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t CayenneLPP::addColour(uint8_t channel, uint8_t r, uint8_t g, uint8_t b); ``` -------------------------------- ### reset Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Resets the buffer, clearing any previously added sensor data. ```APIDOC ## `reset` ### Description Resets the buffer, clearing any previously added sensor data. ### Method `void reset(void);` ``` -------------------------------- ### Add GPS Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds GPS coordinates (latitude and longitude with 4 decimals, altitude with 2 decimals) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addGPS(uint8_t channel, float latitude, float longitude, float altitude); ``` -------------------------------- ### `getTypeName` Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Returns a pointer to a C-string containing the name of the requested type. ```APIDOC ## `getTypeName` ### Description Returns a pointer to a C-string containing the name of the requested type. ### Signature ```c const char * getTypeName(uint8_t type); ``` ``` -------------------------------- ### Add Digital Input Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a digital input value to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addDigitalInput(uint8_t channel, uint32_t value); ``` -------------------------------- ### addGPS Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds GPS data (latitude, longitude, altitude) to the buffer. Latitude and longitude have 4 decimal places, and altitude has 2 decimal places. ```APIDOC ## addGPS ### Description Adds GPS data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **latitude** (float) - Required - The latitude value (4 decimals). - **longitude** (float) - Required - The longitude value (4 decimals). - **altitude** (float) - Required - The altitude value in meters (2 decimals). ### Method `uint8_t addGPS(uint8_t channel, float latitude, float longitude, float altitude);` ``` -------------------------------- ### CayenneLPP add Data Functions Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Use these functions to add various sensor data types to the CayenneLPP buffer. Each function requires a channel identifier and specific data values, with precision noted for floating-point types. ```c++ uint8_t addDigitalInput(uint8_t channel, uint32_t value); uint8_t addDigitalOutput(uint8_t channel, uint32_t value); uint8_t addAnalogInput(uint8_t channel, float value); // 3 decimals uint8_t addAnalogOutput(uint8_t channel, float value); // 3 decimals uint8_t addLuminosity(uint8_t channel, uint32_t value); // in luxes uint8_t addPresence(uint8_t channel, uint32_t value); uint8_t addTemperature(uint8_t channel, float value); // in celcius (1 decimal) uint8_t addRelativeHumidity(uint8_t channel, float value); // in % (0.5% steps) uint8_t addAccelerometer(uint8_t channel, float x, float y, float z); // 3 decimals for each axis uint8_t addBarometricPressure(uint8_t channel, float value); // in hPa (1 decimal) uint8_t addGyrometer(uint8_t channel, float x, float y, float z); // 2 decimals for each axis uint8_t addGPS(uint8_t channel, float latitude, float longitude, float altitude); // lat & long with 4 decimals, altitude with 2 decimals uint8_t addUnixTime(uint8_t channel, uint32_t value); uint8_t addGenericSensor(uint8_t channel, float value); uint8_t addVoltage(uint8_t channel, float value); // in volts (2 decimals) uint8_t addCurrent(uint8_t channel, float value); // in amperes (3 decimals) uint8_t addFrequency(uint8_t channel, uint32_t value); // in hertzs uint8_t addPercentage(uint8_t channel, uint32_t value); // 0 to 100 uint8_t addAltitude(uint8_t channel, float value); // in meters uint8_t addPower(uint8_t channel, uint32_t value); // in watts uint8_t addDistance(uint8_t channel, float value); // in meters (3 decimals) uint8_t addEnergy(uint8_t channel, float value); // in kWh (3 decimals) uint8_t addDirection(uint8_t channel, float value); // in degrees uint8_t addSwitch(uint8_t channel, uint32_t value); // 0 or 1 uint8_t CayenneLPP::addConcentration(uint8_t channel, uint32_t value); // 1 PPM unsigned - PPM means Parts per million 1PPM = 1 * 10 ^-6 = 0.000 001 uint8_t CayenneLPP::addColour(uint8_t channel, uint8_t r, uint8_t g, uint8_t b); // R: 255 G: 255 B: 255 ``` -------------------------------- ### addCurrent Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds current data (in amperes) to the buffer with 3 decimal places of precision. ```APIDOC ## addCurrent ### Description Adds current data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The current value in amperes (3 decimals). ### Method `uint8_t addCurrent(uint8_t channel, float value);` ``` -------------------------------- ### Add Percentage Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a percentage value (0 to 100) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addPercentage(uint8_t channel, uint32_t value); ``` -------------------------------- ### Decode LPP Buffer to JsonObject (TTN format) Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Decodes a byte array using CayenneLPP format into an ArduinoJson JsonObject, suitable for The Things Network. Requires the ArduinoJson library. Returns the number of decoded fields or 0 on error. ```c++ uint8_t decodeTTN(uint8_t *buffer, uint8_t size, JsonObject& root); ``` -------------------------------- ### addColour Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds colour data (RGB values) to the buffer. ```APIDOC ## addColour ### Description Adds colour data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **r** (uint8_t) - Required - The red value (0-255). - **g** (uint8_t) - Required - The green value (0-255). - **b** (uint8_t) - Required - The blue value (0-255). ### Method `uint8_t CayenneLPP::addColour(uint8_t channel, uint8_t r, uint8_t g, uint8_t b);` ``` -------------------------------- ### addGyrometer Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds gyrometer data (X, Y, Z axes) to the buffer, with 2 decimal places of precision for each axis. ```APIDOC ## addGyrometer ### Description Adds gyrometer data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **x** (float) - Required - The X-axis value (2 decimals). - **y** (float) - Required - The Y-axis value (2 decimals). - **z** (float) - Required - The Z-axis value (2 decimals). ### Method `uint8_t addGyrometer(uint8_t channel, float x, float y, float z);` ``` -------------------------------- ### Add Current Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a current value (in amperes with 3 decimal places) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addCurrent(uint8_t channel, float value); ``` -------------------------------- ### Add Barometric Pressure Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a barometric pressure value (in hPa with 1 decimal place) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addBarometricPressure(uint8_t channel, float value); ``` -------------------------------- ### Add Relative Humidity Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a relative humidity value (in % with 0.5% steps) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addRelativeHumidity(uint8_t channel, float value); ``` -------------------------------- ### Add Digital Output Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a digital output value to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addDigitalOutput(uint8_t channel, uint32_t value); ``` -------------------------------- ### Add Presence Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a presence detection value to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addPresence(uint8_t channel, uint32_t value); ``` -------------------------------- ### addUnixTime Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds Unix time data to the buffer. ```APIDOC ## addUnixTime ### Description Adds Unix time data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The Unix time value. ### Method `uint8_t addUnixTime(uint8_t channel, uint32_t value);` ``` -------------------------------- ### Copy Buffer Content Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Copies the internal buffer to a user-provided buffer. Returns the number of bytes copied. ```c uint8_t copy(uint8_t *buffer); ``` -------------------------------- ### Add Accelerometer Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds accelerometer data (X, Y, Z axes with 3 decimals each) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addAccelerometer(uint8_t channel, float x, float y, float z); ``` -------------------------------- ### addDigitalOutput Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds digital output data to the buffer. ```APIDOC ## addDigitalOutput ### Description Adds digital output data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The digital output value. ### Method `uint8_t addDigitalOutput(uint8_t channel, uint32_t value);` ``` -------------------------------- ### Add Unix Time Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a Unix timestamp value to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addUnixTime(uint8_t channel, uint32_t value); ``` -------------------------------- ### addGenericSensor Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds generic sensor data to the buffer. ```APIDOC ## addGenericSensor ### Description Adds generic sensor data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The sensor value. ### Method `uint8_t addGenericSensor(uint8_t channel, float value);` ``` -------------------------------- ### Decode LPP Buffer to JsonArray Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Decodes a byte array using CayenneLPP format into an ArduinoJson JsonArray. Requires the ArduinoJson library. Returns the number of decoded fields or 0 on error. ```c++ uint8_t decode(uint8_t *buffer, uint8_t size, JsonArray& root); ``` -------------------------------- ### Add Luminosity Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a luminosity value (in luxes) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addLuminosity(uint8_t channel, uint32_t value); ``` -------------------------------- ### Add Switch Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a switch state value (0 or 1) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addSwitch(uint8_t channel, uint32_t value); ``` -------------------------------- ### Add Altitude Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds an altitude value (in meters) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addAltitude(uint8_t channel, float value); ``` -------------------------------- ### Add Gyrometer Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds gyrometer data (X, Y, Z axes with 2 decimals each) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addGyrometer(uint8_t channel, float x, float y, float z); ``` -------------------------------- ### Add Distance Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a distance value (in meters with 3 decimal places) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addDistance(uint8_t channel, float value); ``` -------------------------------- ### decode Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Decodes a byte array into a JsonArray using the ArduinoJson library. The output is an array of objects, each detailing the channel, type, type name, and value of the sensor data. ```APIDOC ## decode ### Description Decodes a byte array into a JsonArray (requires ArduinoJson library). The result is an array of objects, each one containing channel, type, type name and value. The value can be a scalar or an object (for accelerometer, gyroscope and GPS data). The method call returns the number of decoded fields or 0 if error. ### Parameters #### Path Parameters - **buffer** (uint8_t *) - Required - A pointer to the byte array to decode. - **size** (uint8_t) - Required - The size of the buffer to decode. - **root** (JsonArray&) - Required - A reference to a JsonArray to store the decoded data. ### Method `uint8_t decode(uint8_t *buffer, uint8_t size, JsonArray& root);` ### Response Example ```json [ { "channel": 1, "type": 136, "name": "gps", "value": { "latitude": 42.3518, "longitude": -87.9094, "altitude": 10 } } ] ``` ``` -------------------------------- ### addBarometricPressure Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds barometric pressure data (in hPa) to the buffer with 1 decimal place of precision. ```APIDOC ## addBarometricPressure ### Description Adds barometric pressure data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The barometric pressure value in hPa (1 decimal). ### Method `uint8_t addBarometricPressure(uint8_t channel, float value);` ``` -------------------------------- ### addVoltage Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds voltage data (in volts) to the buffer with 2 decimal places of precision. ```APIDOC ## addVoltage ### Description Adds voltage data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The voltage value in volts (2 decimals). ### Method `uint8_t addVoltage(uint8_t channel, float value);` ``` -------------------------------- ### addFrequency Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds frequency data (in hertzs) to the buffer. ```APIDOC ## addFrequency ### Description Adds frequency data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (uint32_t) - Required - The frequency value in hertzs. ### Method `uint8_t addFrequency(uint8_t channel, uint32_t value);` ``` -------------------------------- ### addDistance Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds distance data (in meters) to the buffer with 3 decimal places of precision. ```APIDOC ## addDistance ### Description Adds distance data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The distance value in meters (3 decimals). ### Method `uint8_t addDistance(uint8_t channel, float value);` ``` -------------------------------- ### `decodeTTN` Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Decodes a byte array into a JsonObject. The result is a JSON object where keys are type names combined with channel numbers. Values can be scalars or objects. ```APIDOC ## `decodeTTN` ### Description Decodes a byte array into a JsonObject (requires ArduinoJson library). The result is a json objects, each object name contain name type plus channel. The value can be a scalar or an object (for accelerometer, gyroscope and GPS data). The method call returns the number of decoded fields or 0 if error. ### Signature ```c uint8_t decodeTTN(uint8_t *buffer, uint8_t size, JsonObject& root); ``` ### Example Output ```json { "gps_1": { "latitude": 42.3518, "longitude": -87.9094, "altitude": 10 } } ``` ``` -------------------------------- ### Add Frequency Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a frequency value (in Hertz) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addFrequency(uint8_t channel, uint32_t value); ``` -------------------------------- ### Add Direction Data Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Encodes and adds a direction value (in degrees) to the buffer. The channel acts as a key for the data field. ```c++ uint8_t addDirection(uint8_t channel, float value); ``` -------------------------------- ### getError Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Retrieves the last error ID from the Cayenne LPP library. After retrieval, the error status is reset to OK. This function is crucial for debugging encoding and decoding issues. ```APIDOC ## getError ### Description Returns the last error ID. Once returned, the error is reset to OK. ### Function Signature ```c uint8_t getError(void); ``` ### Possible Error Values * `LPP_ERROR_OK`: Indicates that no error has occurred. * `LPP_ERROR_OVERFLOW`: - When encoding: The latest field exceeded the internal buffer size. Consider increasing the buffer size. - When decoding: The payload was too short for the expected data, likely due to a size mismatch. * `LPP_ERROR_UNKNOWN_TYPE`: When decoding, the data type encountered is not supported. ``` -------------------------------- ### addRelativeHumidity Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds relative humidity data (in % with 0.5% steps) to the buffer. ```APIDOC ## addRelativeHumidity ### Description Adds relative humidity data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The relative humidity value in % (0.5% steps). ### Method `uint8_t addRelativeHumidity(uint8_t channel, float value);` ``` -------------------------------- ### addDirection Source: https://github.com/electroniccats/cayennelpp/blob/master/API.md Adds direction data (in degrees) to the buffer. ```APIDOC ## addDirection ### Description Adds direction data to the buffer. ### Parameters #### Path Parameters - **channel** (uint8_t) - Required - The channel identifier for the data field. - **value** (float) - Required - The direction value in degrees. ### Method `uint8_t addDirection(uint8_t channel, float value);` ``` -------------------------------- ### Decode Byte Array to JsonArray Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Decodes a byte array into a JsonArray using the ArduinoJson library. Returns the number of decoded fields or 0 on error. Ensure ArduinoJson is included. ```c uint8_t decode(uint8_t *buffer, uint8_t size, JsonArray& root); ``` ```json [ { "channel": 1, "type": 136, "name": "gps", "value": { "latitude": 42.3518, "longitude": -87.9094, "altitude": 10 } } ] ``` -------------------------------- ### Decode Byte Array to JsonObject (TTN) Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Decodes a byte array into a JsonObject for The Things Network using the ArduinoJson library. Returns the number of decoded fields or 0 on error. Ensure ArduinoJson is included. ```c uint8_t decodeTTN(uint8_t *buffer, uint8_t size, JsonObject& root); ``` ```json { "gps_1": { "latitude": 42.3518, "longitude": -87.9094, "altitude": 10 } } ``` -------------------------------- ### `decode` Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Decodes a byte array into a JsonArray. The result is an array of objects, each containing channel, type, type name, and value. The method returns the number of decoded fields or 0 if an error occurs. ```APIDOC ## `decode` ### Description Decodes a byte array into a JsonArray (requires ArduinoJson library). The result is an array of objects, each one containing channel, type, type name, and value. The value can be a scalar or an object (for accelerometer, gyroscope, and GPS data). The method call returns the number of decoded fields or 0 if error. ### Signature ```c uint8_t decode(uint8_t *buffer, uint8_t size, JsonArray& root); ``` ### Example Output ```json [ { "channel": 1, "type": 136, "name": "gps", "value": { "latitude": 42.3518, "longitude": -87.9094, "altitude": 10 } } ] ``` ``` -------------------------------- ### Reset CayenneLPP Buffer Source: https://github.com/electroniccats/cayennelpp/wiki/3.-Reference Resets the internal buffer of the CayenneLPP object, preparing it for new data encoding. This should typically be called before adding new sensor readings. ```c++ void reset(void); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.