forked from espressif/arduino-esp32
Add esp-rainmaker support for ESP32
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
272
tools/sdk/esp32/include/button/button/include/iot_button.h
Normal file
272
tools/sdk/esp32/include/button/button/include/iot_button.h
Normal file
@ -0,0 +1,272 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef _IOT_BUTTON_H_
|
||||
#define _IOT_BUTTON_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/portmacro.h>
|
||||
typedef void (* button_cb)(void*);
|
||||
typedef void* button_handle_t;
|
||||
|
||||
typedef enum {
|
||||
BUTTON_ACTIVE_HIGH = 1, /*!<button active level: high level*/
|
||||
BUTTON_ACTIVE_LOW = 0, /*!<button active level: low level*/
|
||||
} button_active_t;
|
||||
|
||||
typedef enum {
|
||||
BUTTON_CB_PUSH = 0, /*!<button push callback event */
|
||||
BUTTON_CB_RELEASE, /*!<button release callback event */
|
||||
BUTTON_CB_TAP, /*!<button quick tap callback event(will not trigger if there already is a "PRESS" event) */
|
||||
BUTTON_CB_SERIAL, /*!<button serial trigger callback event */
|
||||
} button_cb_type_t;
|
||||
|
||||
/**
|
||||
* @brief Init button functions
|
||||
*
|
||||
* @param gpio_num GPIO index of the pin that the button uses
|
||||
* @param active_level button hardware active level.
|
||||
* For "BUTTON_ACTIVE_LOW" it means when the button pressed, the GPIO will read low level.
|
||||
*
|
||||
* @return A button_handle_t handle to the created button object, or NULL in case of error.
|
||||
*/
|
||||
button_handle_t iot_button_create(gpio_num_t gpio_num, button_active_t active_level);
|
||||
|
||||
/**
|
||||
* @brief Register a callback function for a serial trigger event.
|
||||
*
|
||||
* @param btn_handle handle of the button object
|
||||
* @param start_after_sec define the time after which to start serial trigger action
|
||||
* @param interval_tick serial trigger interval
|
||||
* @param cb callback function for "TAP" action.
|
||||
* @param arg Parameter for callback function
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t iot_button_set_serial_cb(button_handle_t btn_handle, uint32_t start_after_sec, TickType_t interval_tick, button_cb cb, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Register a callback function for a button_cb_type_t action.
|
||||
*
|
||||
* @param btn_handle handle of the button object
|
||||
* @param type callback function type
|
||||
* @param cb callback function for "TAP" action.
|
||||
* @param arg Parameter for callback function
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t iot_button_set_evt_cb(button_handle_t btn_handle, button_cb_type_t type, button_cb cb, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Callbacks invoked as timer events occur while button is pressed.
|
||||
* Example: If a button is configured for 2 sec, 5 sec and 7 sec callbacks and if the button is pressed for 6 sec then 2 sec callback would be invoked at 2 sec event and 5 sec callback would be invoked at 5 sec event
|
||||
*
|
||||
* @param btn_handle handle of the button object
|
||||
* @param press_sec the callback function would be called if you press the button for a specified period of time
|
||||
* @param cb callback function for "PRESS and HOLD" action.
|
||||
* @param arg Parameter for callback function
|
||||
*
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t iot_button_add_on_press_cb(button_handle_t btn_handle, uint32_t press_sec, button_cb cb, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Single callback invoked according to the latest timer event on button release.
|
||||
* Example: If a button is configured for 2 sec, 5 sec and 7 sec callbacks and if the button is released at 6 sec then only 5 sec callback would be invoked
|
||||
*
|
||||
* @param btn_handle handle of the button object
|
||||
* @param press_sec the callback function would be called if you press the button for a specified period of time
|
||||
* @param cb callback function for "PRESS and RELEASE" action.
|
||||
* @param arg Parameter for callback function
|
||||
*
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t iot_button_add_on_release_cb(button_handle_t btn_handle, uint32_t press_sec, button_cb cb, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Delete button object and free memory
|
||||
* @param btn_handle handle of the button object
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t iot_button_delete(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief Remove callback
|
||||
*
|
||||
* @param btn_handle The handle of the button object
|
||||
* @param type callback function event type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t iot_button_rm_cb(button_handle_t btn_handle, button_cb_type_t type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/**
|
||||
* class of button
|
||||
* simple usage:
|
||||
* CButton* btn = new CButton(BUTTON_IO_NUM, BUTTON_ACTIVE_LEVEL, BUTTON_SERIAL_TRIGGER, 3);
|
||||
* btn->add_cb(BUTTON_CB_PUSH, button_tap_cb, (void*) push, 50 / portTICK_PERIOD_MS);
|
||||
* btn->add_custom_cb(5, button_press_5s_cb, NULL);
|
||||
* ......
|
||||
* delete btn;
|
||||
*/
|
||||
class CButton
|
||||
{
|
||||
private:
|
||||
button_handle_t m_btn_handle;
|
||||
|
||||
/**
|
||||
* prevent copy constructing
|
||||
*/
|
||||
CButton(const CButton&);
|
||||
CButton& operator = (const CButton&);
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief constructor of CButton
|
||||
*
|
||||
* @param gpio_num GPIO index of the pin that the button uses
|
||||
* @param active_level button hardware active level.
|
||||
* For "BUTTON_ACTIVE_LOW" it means when the button pressed, the GPIO will read low level.
|
||||
*/
|
||||
CButton(gpio_num_t gpio_num, button_active_t active_level = BUTTON_ACTIVE_LOW);
|
||||
|
||||
~CButton();
|
||||
|
||||
/**
|
||||
* @brief Register a callback function for a button_cb_type_t action.
|
||||
*
|
||||
* @param type callback function type
|
||||
* @param cb callback function for "TAP" action.
|
||||
* @param arg Parameter for callback function
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t set_evt_cb(button_cb_type_t type, button_cb cb, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Register a callback function for a serial trigger event.
|
||||
*
|
||||
* @param btn_handle handle of the button object
|
||||
* @param start_after_sec define the time after which to start serial trigger action
|
||||
* @param interval_tick serial trigger interval
|
||||
* @param cb callback function for "TAP" action.
|
||||
* @param arg Parameter for callback function
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t set_serial_cb(button_cb cb, void* arg, TickType_t interval_tick, uint32_t start_after_sec);
|
||||
|
||||
/**
|
||||
* @brief Callbacks invoked as timer events occur while button is pressed
|
||||
*
|
||||
* @param press_sec the callback function would be called if you press the button for a specified period of time
|
||||
* @param cb callback function for "PRESS and HOLD" action.
|
||||
* @param arg Parameter for callback function
|
||||
*
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t add_on_press_cb(uint32_t press_sec, button_cb cb, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Single callback invoked according to the latest timer event on button release.
|
||||
*
|
||||
* @param press_sec the callback function would be called if you press the button for a specified period of time
|
||||
* @param cb callback function for "PRESS and RELEASE" action.
|
||||
* @param arg Parameter for callback function
|
||||
*
|
||||
* @note
|
||||
* Button callback functions execute in the context of the timer service task.
|
||||
* It is therefore essential that button callback functions never attempt to block.
|
||||
* For example, a button callback function must not call vTaskDelay(), vTaskDelayUntil(),
|
||||
* or specify a non zero block time when accessing a queue or a semaphore.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t add_on_release_cb(uint32_t press_sec, button_cb cb, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Remove callback
|
||||
*
|
||||
* @param type callback function event type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t rm_cb(button_cb_type_t type);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
@ -42,6 +42,22 @@
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_PARTITION_TABLE_OFFSET 0x8000
|
||||
#define CONFIG_PARTITION_TABLE_MD5 1
|
||||
#define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1
|
||||
#define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com"
|
||||
#define CONFIG_ESP_RMAKER_TASK_STACK 4096
|
||||
#define CONFIG_ESP_RMAKER_TASK_PRIORITY 5
|
||||
#define CONFIG_ESP_RMAKER_MAX_NODE_CONFIG_SIZE 2048
|
||||
#define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024
|
||||
#define CONFIG_ESP_RMAKER_FACTORY_PARTITION_NAME "fctry"
|
||||
#define CONFIG_ESP_RMAKER_MQTT_PORT_443 1
|
||||
#define CONFIG_ESP_RMAKER_MQTT_PORT 1
|
||||
#define CONFIG_ESP_RMAKER_DEF_TIMEZONE ""
|
||||
#define CONFIG_ESP_RMAKER_SNTP_SERVER_NAME "pool.ntp.org"
|
||||
#define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1
|
||||
#define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP_RMAKER_OTA_AUTOFETCH 1
|
||||
#define CONFIG_ESP_RMAKER_OTA_AUTOFETCH_PERIOD 0
|
||||
#define CONFIG_ESP_RMAKER_SCHEDULING_MAX_SCHEDULES 5
|
||||
#define CONFIG_ENABLE_ARDUINO_DEPENDS 1
|
||||
#define CONFIG_AUTOSTART_ARDUINO 1
|
||||
#define CONFIG_ARDUINO_RUN_CORE1 1
|
||||
@ -348,6 +364,7 @@
|
||||
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1
|
||||
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1
|
||||
#define CONFIG_MBEDTLS_SHA512_C 1
|
||||
@ -456,12 +473,14 @@
|
||||
#define CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES 16
|
||||
#define CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT 30
|
||||
#define CONFIG_WPA_MBEDTLS_CRYPTO 1
|
||||
#define CONFIG_IO_GLITCH_FILTER_TIME_MS 50
|
||||
#define CONFIG_XTENSA_IMPL 1
|
||||
#define CONFIG_MTMN_LITE_QUANT 1
|
||||
#define CONFIG_MFN56_1X 1
|
||||
#define CONFIG_HD_NANO1 1
|
||||
#define CONFIG_HP_NANO1 1
|
||||
#define CONFIG_OV7670_SUPPORT 1
|
||||
#define CONFIG_OV7725_SUPPORT 1
|
||||
#define CONFIG_NT99141_SUPPORT 1
|
||||
#define CONFIG_OV2640_SUPPORT 1
|
||||
#define CONFIG_OV3660_SUPPORT 1
|
||||
|
@ -0,0 +1,52 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Initialize console
|
||||
*
|
||||
* Initializes serial console and adds basic commands.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failures.
|
||||
*/
|
||||
esp_err_t esp_rmaker_console_init(void);
|
||||
|
||||
/* Reference for adding custom console commands:
|
||||
#include <esp_console.h>
|
||||
|
||||
static int command_console_handler(int argc, char *argv[])
|
||||
{
|
||||
// Command code here
|
||||
}
|
||||
|
||||
static void register_console_command()
|
||||
{
|
||||
const esp_console_cmd_t cmd = {
|
||||
.command = "<command_name>",
|
||||
.help = "<help_details>",
|
||||
.func = &command_console_handler,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
706
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h
Normal file
706
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h
Normal file
@ -0,0 +1,706 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_event.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define ESP_RMAKER_CONFIG_VERSION "2020-03-20"
|
||||
|
||||
#define MAX_VERSION_STRING_LEN 16
|
||||
|
||||
/** ESP RainMaker Event Base */
|
||||
ESP_EVENT_DECLARE_BASE(RMAKER_EVENT);
|
||||
|
||||
/** ESP RainMaker Events */
|
||||
typedef enum {
|
||||
/** RainMaker Core Initialisation Done */
|
||||
RMAKER_EVENT_INIT_DONE = 1,
|
||||
/** Self Claiming Started */
|
||||
RMAKER_EVENT_CLAIM_STARTED,
|
||||
/** Self Claiming was Successful */
|
||||
RMAKER_EVENT_CLAIM_SUCCESSFUL,
|
||||
/** Self Claiming Failed */
|
||||
RMAKER_EVENT_CLAIM_FAILED,
|
||||
/** Node reboot has been triggered. The associated event data is the time in seconds
|
||||
* (type: uint8_t) after which the node will reboot. Note that this time may not be
|
||||
* accurate as the events are received asynchronously.*/
|
||||
RMAKER_EVENT_REBOOT,
|
||||
/** Wi-Fi credentials reset. Triggered after calling esp_rmaker_wifi_reset() */
|
||||
RMAKER_EVENT_WIFI_RESET,
|
||||
/** Node reset to factory defaults. Triggered after calling esp_rmaker_factory_reset() */
|
||||
RMAKER_EVENT_FACTORY_RESET
|
||||
} esp_rmaker_event_t;
|
||||
|
||||
/** ESP RainMaker Node information */
|
||||
typedef struct {
|
||||
/** Name of the Node */
|
||||
char *name;
|
||||
/** Type of the Node */
|
||||
char *type;
|
||||
/** Firmware Version (Optional). If not set, PROJECT_VER is used as default (recommended)*/
|
||||
char *fw_version;
|
||||
/** Model (Optional). If not set, PROJECT_NAME is used as default (recommended)*/
|
||||
char *model;
|
||||
} esp_rmaker_node_info_t;
|
||||
|
||||
/** ESP RainMaker Configuration */
|
||||
typedef struct {
|
||||
/** Enable Time Sync
|
||||
* Setting this true will enable SNTP and fetch the current time before
|
||||
* attempting to connect to the ESP RainMaker service
|
||||
*/
|
||||
bool enable_time_sync;
|
||||
} esp_rmaker_config_t;
|
||||
|
||||
/** ESP RainMaker Parameter Value type */
|
||||
typedef enum {
|
||||
/** Invalid */
|
||||
RMAKER_VAL_TYPE_INVALID = 0,
|
||||
/** Boolean */
|
||||
RMAKER_VAL_TYPE_BOOLEAN,
|
||||
/** Integer. Mapped to a 32 bit signed integer */
|
||||
RMAKER_VAL_TYPE_INTEGER,
|
||||
/** Floating point number */
|
||||
RMAKER_VAL_TYPE_FLOAT,
|
||||
/** NULL terminated string */
|
||||
RMAKER_VAL_TYPE_STRING,
|
||||
/** NULL terminated JSON Object string Eg. {"name":"value"} */
|
||||
RMAKER_VAL_TYPE_OBJECT,
|
||||
/** NULL terminated JSON Array string Eg. [1,2,3] */
|
||||
RMAKER_VAL_TYPE_ARRAY,
|
||||
} esp_rmaker_val_type_t;
|
||||
|
||||
/** ESP RainMaker Value */
|
||||
typedef union {
|
||||
/** Boolean */
|
||||
bool b;
|
||||
/** Integer */
|
||||
int i;
|
||||
/** Float */
|
||||
float f;
|
||||
/** NULL terminated string */
|
||||
char *s;
|
||||
} esp_rmaker_val_t;
|
||||
|
||||
/** ESP RainMaker Parameter Value */
|
||||
typedef struct {
|
||||
/** Type of Value */
|
||||
esp_rmaker_val_type_t type;
|
||||
/** Actual value. Depends on the type */
|
||||
esp_rmaker_val_t val;
|
||||
} esp_rmaker_param_val_t;
|
||||
|
||||
/** Param property flags */
|
||||
typedef enum {
|
||||
PROP_FLAG_WRITE = (1 << 0),
|
||||
PROP_FLAG_READ = (1 << 1),
|
||||
PROP_FLAG_TIME_SERIES = (1 << 2),
|
||||
PROP_FLAG_PERSIST = (1 << 3)
|
||||
} esp_param_property_flags_t;
|
||||
|
||||
/** Generic ESP RainMaker handle */
|
||||
typedef size_t esp_rmaker_handle_t;
|
||||
|
||||
/** ESP RainMaker Node Handle */
|
||||
typedef esp_rmaker_handle_t esp_rmaker_node_t;
|
||||
|
||||
/** ESP RainMaker Device Handle */
|
||||
typedef esp_rmaker_handle_t esp_rmaker_device_t;
|
||||
|
||||
/** ESP RainMaker Parameter Handle */
|
||||
typedef esp_rmaker_handle_t esp_rmaker_param_t;
|
||||
|
||||
/** Parameter read/write request source */
|
||||
typedef enum {
|
||||
/** Request triggered in the init sequence i.e. when a value is found
|
||||
* in persistent memory for parameters with PROP_FLAG_PERSIST.
|
||||
*/
|
||||
ESP_RMAKER_REQ_SRC_INIT,
|
||||
/** Request received from cloud */
|
||||
ESP_RMAKER_REQ_SRC_CLOUD,
|
||||
/** Request received when a schedule has triggered */
|
||||
ESP_RMAKER_REQ_SRC_SCHEDULE,
|
||||
} esp_rmaker_req_src_t;
|
||||
|
||||
/** Write request Context */
|
||||
typedef struct {
|
||||
/** Source of request */
|
||||
esp_rmaker_req_src_t src;
|
||||
} esp_rmaker_write_ctx_t;
|
||||
|
||||
/** Read request context */
|
||||
typedef struct {
|
||||
/** Source of request */
|
||||
esp_rmaker_req_src_t src;
|
||||
} esp_rmaker_read_ctx_t;
|
||||
|
||||
/** Callback for parameter value write requests.
|
||||
*
|
||||
* The callback should call the esp_rmaker_param_update_and_report() API if the new value is to be set
|
||||
* and reported back.
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] param Parameter handle.
|
||||
* @param[in] param Pointer to \ref esp_rmaker_param_val_t. Use appropriate elements as per the value type.
|
||||
* @param[in] priv_data Pointer to the private data paassed while creating the device.
|
||||
* @param[in] ctx Context associated with the request.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
typedef esp_err_t (*esp_rmaker_device_write_cb_t)(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param,
|
||||
const esp_rmaker_param_val_t val, void *priv_data, esp_rmaker_write_ctx_t *ctx);
|
||||
|
||||
/** Callback for parameter value changes
|
||||
*
|
||||
* The callback should call the esp_rmaker_param_update_and_report() API if the new value is to be set
|
||||
* and reported back.
|
||||
*
|
||||
* @note Currently, the read callback never gets invoked as the communication between clients (mobile phones, CLI, etc.)
|
||||
* and node is asynchronous. So, the read request does not reach the node. This callback will however be used in future.
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] param Parameter handle.
|
||||
* @param[in] priv_data Pointer to the private data passed while creating the device.
|
||||
* @param[in] ctx Context associated with the request.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
typedef esp_err_t (*esp_rmaker_device_read_cb_t)(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param,
|
||||
void *priv_data, esp_rmaker_read_ctx_t *ctx);
|
||||
|
||||
/**
|
||||
* Initialise a Boolean value
|
||||
*
|
||||
* @param[in] bval Initialising value.
|
||||
*
|
||||
* @return Value structure.
|
||||
*/
|
||||
esp_rmaker_param_val_t esp_rmaker_bool(bool bval);
|
||||
|
||||
/**
|
||||
* Initialise an Integer value
|
||||
*
|
||||
* @param[in] ival Initialising value.
|
||||
*
|
||||
* @return Value structure.
|
||||
*/
|
||||
esp_rmaker_param_val_t esp_rmaker_int(int ival);
|
||||
|
||||
/**
|
||||
* Initialise a Float value
|
||||
*
|
||||
* @param[in] fval Initialising value.
|
||||
*
|
||||
* @return Value structure.
|
||||
*/
|
||||
esp_rmaker_param_val_t esp_rmaker_float(float fval);
|
||||
|
||||
/**
|
||||
* Initialise a String value
|
||||
*
|
||||
* @param[in] sval Initialising value.
|
||||
*
|
||||
* @return Value structure.
|
||||
*/
|
||||
esp_rmaker_param_val_t esp_rmaker_str(const char *sval);
|
||||
|
||||
/**
|
||||
* Initialise a json object value
|
||||
*
|
||||
* @note the object will not be validated internally. it is the application's
|
||||
* responsibility to ensure that the object is a valid json object.
|
||||
* eg. esp_rmaker_obj("{\"name\":\"value\"}");
|
||||
*
|
||||
* param[in] val initialising value
|
||||
*
|
||||
* return value structure
|
||||
*/
|
||||
esp_rmaker_param_val_t esp_rmaker_obj(const char *val);
|
||||
|
||||
/**
|
||||
* Initialise a json array value
|
||||
*
|
||||
* @note the array will not be validated internally. it is the application's
|
||||
* responsibility to ensure that the array is a valid json array.
|
||||
* eg. esp_rmaker_array("[1,2,3]");
|
||||
*
|
||||
* param[in] val initialising value
|
||||
*
|
||||
* return value structure
|
||||
*/
|
||||
esp_rmaker_param_val_t esp_rmaker_array(const char *val);
|
||||
|
||||
|
||||
/** Initialize ESP RainMaker Node
|
||||
*
|
||||
* This initializes the ESP RainMaker agent and creates the node.
|
||||
* The model and firmware version for the node are set internally as per
|
||||
* the project name and version. These can be overridden (but not recommended) using the
|
||||
* esp_rmaker_node_add_fw_version() and esp_rmaker_node_add_model() APIs.
|
||||
*
|
||||
* @note This should be the first call before using any other ESP RainMaker API.
|
||||
*
|
||||
* @param[in] config Configuration to be used by the ESP RainMaker.
|
||||
* @param[in] name Name of the node.
|
||||
* @param[in] type Type of the node.
|
||||
*
|
||||
* @return Node handle on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
esp_rmaker_node_t *esp_rmaker_node_init(const esp_rmaker_config_t *config, const char *name, const char *type);
|
||||
|
||||
/** Start ESP RainMaker Agent
|
||||
*
|
||||
* This call starts the actual ESP RainMaker thread. This should preferably be called after a
|
||||
* successful Wi-Fi connection in order to avoid unnecessary failures.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_start(void);
|
||||
|
||||
/** Stop ESP RainMaker Agent
|
||||
*
|
||||
* This call stops the ESP RainMaker Agent instance started earlier by esp_rmaker_start().
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_stop(void);
|
||||
|
||||
/** Deinitialize ESP RainMaker Node
|
||||
*
|
||||
* This API deinitializes the ESP RainMaker agent and the node created using esp_rmaker_node_init().
|
||||
*
|
||||
* @note This should be called after rainmaker has stopped.
|
||||
*
|
||||
* @param[in] node Node Handle returned by esp_rmaker_node_init().
|
||||
*
|
||||
* @retur ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_node_deinit(const esp_rmaker_node_t *node);
|
||||
|
||||
/** Get a handle to the Node
|
||||
*
|
||||
* This API returns handle to a node created using esp_rmaker_node_init().
|
||||
*
|
||||
* @return Node handle on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
const esp_rmaker_node_t *esp_rmaker_get_node(void);
|
||||
|
||||
/** Get Node Id
|
||||
*
|
||||
* Returns pointer to the NULL terminated Node ID string.
|
||||
*
|
||||
* @return Pointer to a NULL terminated Node ID string.
|
||||
*/
|
||||
char *esp_rmaker_get_node_id(void);
|
||||
|
||||
/** Get Node Info
|
||||
*
|
||||
* Returns pointer to the node info as configured during initialisation.
|
||||
*
|
||||
* @param node Node handle.
|
||||
*
|
||||
* @return Pointer to the node info on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
esp_rmaker_node_info_t *esp_rmaker_node_get_info(const esp_rmaker_node_t *node);
|
||||
|
||||
/** Add Node attribute
|
||||
*
|
||||
* Adds a new attribute as the metadata for the node. For the sake of simplicity,
|
||||
* only string values are allowed.
|
||||
*
|
||||
* @param node Node handle.
|
||||
* @param[in] attr_name Name of the attribute.
|
||||
* @param[in] val Value for the attribute.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_node_add_attribute(const esp_rmaker_node_t *node, const char *attr_name, const char *val);
|
||||
|
||||
/** Add FW version for a node (Not recommended)
|
||||
*
|
||||
* FW version is set internally to the project version. This API can be used to
|
||||
* override that version.
|
||||
*
|
||||
* @param node Node handle.
|
||||
* @param[in] fw_version New firmware version.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const char *fw_version);
|
||||
|
||||
/** Add model for a node (Not recommended)
|
||||
*
|
||||
* Model is set internally to the project name. This API can be used to
|
||||
* override that name.
|
||||
*
|
||||
* @param node Node handle.
|
||||
* @param[in] model New model string.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_node_add_model(const esp_rmaker_node_t *node, const char *model);
|
||||
|
||||
/**
|
||||
* Create a Device
|
||||
*
|
||||
* This API will create a virtual "Device".
|
||||
* This could be something like a Switch, Lightbulb, etc.
|
||||
*
|
||||
* @note The device created needs to be added to a node using esp_rmaker_node_add_device().
|
||||
*
|
||||
* @param[in] dev_name The unique device name.
|
||||
* @param[in] type Optional device type. Can be kept NULL.
|
||||
* @param[in] priv_data (Optional) Private data associated with the device. This will be passed to callbacks.
|
||||
* It should stay allocated throughout the lifetime of the device.
|
||||
*
|
||||
* @return Device handle on success.
|
||||
* @return NULL in case of any error.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_device_create(const char *dev_name, const char *type, void *priv_data);
|
||||
|
||||
/**
|
||||
* Create a Service
|
||||
*
|
||||
* This API will create a "Service". It is exactly same like a device in terms of structure and so, all
|
||||
* APIs for device are also valid for a service.
|
||||
* A service could be something like OTA, diagnostics, etc.
|
||||
*
|
||||
* @note Name of a service should not clash with name of a device.
|
||||
* @note The service created needs to be added to a node using esp_rmaker_node_add_device().
|
||||
*
|
||||
* @param[in] serv_name The unique service name.
|
||||
* @param[in] type Optional service type. Can be kept NULL.
|
||||
* @param[in] priv_data (Optional) Private data associated with the service. This will be passed to callbacks.
|
||||
* It should stay allocated throughout the lifetime of the device.
|
||||
*
|
||||
* @return Device handle on success.
|
||||
* @return NULL in case of any error.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_service_create(const char *serv_name, const char *type, void *priv_data);
|
||||
|
||||
/**
|
||||
* Delete a Device/Service
|
||||
*
|
||||
* This API will delete a device created using esp_rmaker_device_create().
|
||||
*
|
||||
* @note The device should first be removed from the node using esp_rmaker_node_remove_device() before deleting.
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_device_delete(const esp_rmaker_device_t *device);
|
||||
|
||||
/**
|
||||
* Add callbacks for a device/service
|
||||
*
|
||||
* Add read/write callbacks for a device that will be invoked as per requests received from the cloud (or other paths
|
||||
* as may be added in future).
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] write_cb Write callback.
|
||||
* @param[in] read_cb Read callback.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_device_add_cb(const esp_rmaker_device_t *device, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb);
|
||||
|
||||
/**
|
||||
* Add a device to a node
|
||||
*
|
||||
* @param[in] node Node handle.
|
||||
* @param[in] device Device handle.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_node_add_device(const esp_rmaker_node_t *node, const esp_rmaker_device_t *device);
|
||||
|
||||
/**
|
||||
* Remove a device from a node
|
||||
*
|
||||
* @param[in] node Node handle.
|
||||
* @param[in] device Device handle.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_node_remove_device(const esp_rmaker_node_t *node, const esp_rmaker_device_t *device);
|
||||
|
||||
/** Add a Device attribute
|
||||
*
|
||||
* @note Device attributes are reported only once after a boot-up as part of the node
|
||||
* configuration.
|
||||
* Eg. Serial Number
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] attr_name Name of the attribute.
|
||||
* @param[in] val Value of the attribute.
|
||||
*
|
||||
* @return ESP_OK if the attribute was added successfully.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, const char *attr_name, const char *val);
|
||||
|
||||
/** Get device name from handle
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
*
|
||||
* @return NULL terminated device name string on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
char *esp_rmaker_device_get_name(const esp_rmaker_device_t *device);
|
||||
|
||||
/** Get device type from handle
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
*
|
||||
* @return NULL terminated device type string on success.
|
||||
* @return NULL in case of failure, or if the type wasn't provided while creating the device.
|
||||
*/
|
||||
char *esp_rmaker_device_get_name(const esp_rmaker_device_t *device);
|
||||
|
||||
/**
|
||||
* Add a parameter to a device/service
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] param Parameter handle.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_device_add_param(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param);
|
||||
|
||||
|
||||
/** Get parameter by type
|
||||
*
|
||||
* Get handle for a parameter based on the type.
|
||||
*
|
||||
* @note If there are multiple parameters with the same type, this will return the first one. The API
|
||||
* esp_rmaker_device_get_param_by_name() can be used to get a specific parameter, because the parameter
|
||||
* names in a device are unique.
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] param_type Parameter type to search.
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_device_get_param_by_type(const esp_rmaker_device_t *device, const char *param_type);
|
||||
|
||||
/** Get parameter by name
|
||||
*
|
||||
* Get handle for a parameter based on the name.
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] param_name Parameter name to search.
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_device_get_param_by_name(const esp_rmaker_device_t *device, const char *param_name);
|
||||
|
||||
/** Assign a primary parameter
|
||||
*
|
||||
* Assign a parameter (already added using esp_rmaker_device_add_param()) as a primary parameter,
|
||||
* which can be used by clients (phone apps specifically) to give prominence to it.
|
||||
*
|
||||
* @param[in] device Device handle.
|
||||
* @param[in] param Parameter handle.
|
||||
*
|
||||
* @return ESP_OK if the parameter was assigned as the primary successfully.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_device_assign_primary_param(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param);
|
||||
|
||||
/**
|
||||
* Create a Parameter
|
||||
*
|
||||
* Parameter can be something like Temperature, Outlet state, Lightbulb brightness, etc.
|
||||
*
|
||||
* Any changes should be reported using the esp_rmaker_param_update_and_report() API.
|
||||
* Any remote changes will be reported to the application via the device callback, if registered.
|
||||
*
|
||||
* @note The parameter created needs to be added to a device using esp_rmaker_device_add_param().
|
||||
* Parameter name should be unique in a given device.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter.
|
||||
a* @param[in] type Optional parameter type. Can be kept NULL.
|
||||
* @param[in] val Value of the parameter. This also specifies the type that will be assigned
|
||||
* to this parameter. You can use esp_rmaker_bool(), esp_rmaker_int(), esp_rmaker_float()
|
||||
* or esp_rmaker_str() functions as the argument here. Eg, esp_rmaker_bool(true).
|
||||
* @param[in] properties Properties of the parameter, which will be a logical OR of flags in
|
||||
* \ref esp_param_property_flags_t.
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_param_create(const char *param_name, const char *type,
|
||||
esp_rmaker_param_val_t val, uint8_t properties);
|
||||
|
||||
/**
|
||||
* Add a UI Type to a parameter
|
||||
*
|
||||
* This will be used by the Phone apps (or other clients) to render appropriate UI for the given
|
||||
* parameter. Please refer the RainMaker documetation for supported UI Types.
|
||||
*
|
||||
* @param[in] param Parameter handle.
|
||||
* @param[in] ui_type String describing the UI Type.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_param_add_ui_type(const esp_rmaker_param_t *param, const char *ui_type);
|
||||
|
||||
/**
|
||||
* Add bounds for an integer/float parameter
|
||||
*
|
||||
* This can be used to add bounds (min/max values) for a given integer parameter. Eg. brightness
|
||||
* will have bounds as 0 and 100 if it is a percentage.
|
||||
* Eg. esp_rmaker_param_add_bounds(brightness_param, esp_rmaker_int(0), esp_rmaker_int(100), esp_rmaker_int(5));
|
||||
*
|
||||
* @note The RainMaker core does not check the bounds. It is upto the application to handle it.
|
||||
*
|
||||
* @param[in] param Parameter handle.
|
||||
* @param[in] min Minimum allowed value.
|
||||
* @param[in] max Maximum allowed value.
|
||||
* @param[in] step Minimum stepping (set to 0 if no specific value is desired).
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_param_add_bounds(const esp_rmaker_param_t *param,
|
||||
esp_rmaker_param_val_t min, esp_rmaker_param_val_t max, esp_rmaker_param_val_t step);
|
||||
|
||||
/**
|
||||
* Add a list of valid strings for a string parameter
|
||||
*
|
||||
* This can be used to add a list of valid strings for a given string parameter.
|
||||
*
|
||||
* Eg.
|
||||
* static const char *valid_strs[] = {"None","Yes","No","Can't Say"};
|
||||
* esp_rmaker_param_add_valid_str_list(param, valid_strs, 4);
|
||||
*
|
||||
* @note The RainMaker core does not check the values. It is upto the application to handle it.
|
||||
*
|
||||
* @param[in] param Parameter handle.
|
||||
* @param[in] strs Pointer to an array of strings. Note that this memory should stay allocated
|
||||
* throughout the lifetime of this parameter.
|
||||
* @param[in] count Number of strings in the above array.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_param_add_valid_str_list(const esp_rmaker_param_t *param, const char *strs[], uint8_t count);
|
||||
|
||||
/** Add max count for an array parameter
|
||||
*
|
||||
* This can be used to put a limit on the maximum number of elements in an array.
|
||||
*
|
||||
* @note The RainMaker core does not check the values. It is upto the application to handle it.
|
||||
*
|
||||
* @param[in] param Parameter handle.
|
||||
* @param[in] count Max number of elements allowed in the array.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_param_add_array_max_count(const esp_rmaker_param_t *param, int count);
|
||||
|
||||
/** Update and report a parameter
|
||||
*
|
||||
* Calling this API will update the parameter and report it to ESP RainMaker cloud.
|
||||
* This should be used whenever there is any local change.
|
||||
*
|
||||
* @param[in] param Parameter handle.
|
||||
* @param[in] val New value of the parameter.
|
||||
*
|
||||
* @return ESP_OK if the parameter was updated successfully.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_param_update_and_report(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val);
|
||||
|
||||
/** Get parameter name from handle
|
||||
*
|
||||
* @param[in] param Parameter handle.
|
||||
*
|
||||
* @return NULL terminated parameter name string on success.
|
||||
* @return NULL in case of failure.
|
||||
*/
|
||||
char *esp_rmaker_param_get_name(const esp_rmaker_param_t *param);
|
||||
|
||||
/** Get parameter type from handle
|
||||
*
|
||||
* @param[in] param Parameter handle.
|
||||
*
|
||||
* @return NULL terminated parameter type string on success.
|
||||
* @return NULL in case of failure, or if the type wasn't provided while creating the parameter.
|
||||
*/
|
||||
char *esp_rmaker_param_get_type(const esp_rmaker_param_t *param);
|
||||
|
||||
/** Prototype for ESP RainMaker Work Queue Function
|
||||
*
|
||||
* @param[in] priv_data The private data associated with the work function.
|
||||
*/
|
||||
typedef void (*esp_rmaker_work_fn_t)(void *priv_data);
|
||||
|
||||
/** Report the node details to the cloud
|
||||
*
|
||||
* This API reports node details i.e. the node configuration and values of all the parameters to the ESP RainMaker cloud.
|
||||
* Eg. If a new device is created (with some parameters and attributes), then this API should be called after that
|
||||
* to send the node details to the cloud again and the changes to be reflected in the clients (like phone apps).
|
||||
*
|
||||
* @note Please use this API only if you need to create or delete devices after esp_rmaker_start() has already
|
||||
* been called, for use cases like bridges or hubs.
|
||||
*
|
||||
* @return ESP_OK if the node details are successfully queued to be published.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_report_node_details(void);
|
||||
|
||||
/** Queue execution of a function in ESP RainMaker's context
|
||||
*
|
||||
* This API queues a work function for execution in the ESP RainMaker Task's context.
|
||||
*
|
||||
* @param[in] work_fn The Work function to be queued.
|
||||
* @param[in] priv_data Private data to be passed to the work function.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_queue_work(esp_rmaker_work_fn_t work_fn, void *priv_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
108
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_mqtt.h
Normal file
108
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_mqtt.h
Normal file
@ -0,0 +1,108 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** ESP RainMaker MQTT Configuration */
|
||||
typedef struct {
|
||||
/** MQTT Host */
|
||||
char *mqtt_host;
|
||||
/** Client ID */
|
||||
char *client_id;
|
||||
/** Client Certificate in NULL terminate PEM format */
|
||||
char *client_cert;
|
||||
/** Client Key in NULL terminate PEM format */
|
||||
char *client_key;
|
||||
/** Server Certificate in NULL terminate PEM format */
|
||||
char *server_cert;
|
||||
} esp_rmaker_mqtt_config_t;
|
||||
|
||||
/** ESP RainMaker MQTT Subscribe callback prototype
|
||||
*
|
||||
* @param[in] topic Topic on which the message was received
|
||||
* @param[in] payload Data received in the message
|
||||
* @param[in] payload_len Length of the data
|
||||
* @param[in] priv_data The private data passed during subscription
|
||||
*/
|
||||
typedef void (*esp_rmaker_mqtt_subscribe_cb_t) (const char *topic, void *payload, size_t payload_len, void *priv_data);
|
||||
|
||||
/** Initialize ESP RainMaker MQTT
|
||||
*
|
||||
* @param[in] config The MQTT configuration data
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of any error.
|
||||
*/
|
||||
esp_err_t esp_rmaker_mqtt_init(esp_rmaker_mqtt_config_t *config);
|
||||
|
||||
/** MQTT Connect
|
||||
*
|
||||
* Starts the connection attempts to the MQTT broker as per the configuration
|
||||
* provided during initializing.
|
||||
* This should ideally be called after successful network connection.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of any error.
|
||||
*/
|
||||
esp_err_t esp_rmaker_mqtt_connect(void);
|
||||
|
||||
/** MQTT Disconnect
|
||||
*
|
||||
* Disconnects from the MQTT broker.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of any error.
|
||||
*/
|
||||
esp_err_t esp_rmaker_mqtt_disconnect(void);
|
||||
|
||||
/** Publish MQTT Message
|
||||
*
|
||||
* @param[in] topic The MQTT topic on which the message should be published.
|
||||
* @param[in] data Data to be published
|
||||
* @param[in] data_len Length of the data
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of any error.
|
||||
*/
|
||||
esp_err_t esp_rmaker_mqtt_publish(const char *topic, void *data, size_t data_len);
|
||||
|
||||
/** Subscribe to MQTT topic
|
||||
*
|
||||
* @param[in] topic The topic to be subscribed to.
|
||||
* @param[in] cb The callback to be invoked when a message is received on the given topic.
|
||||
* @param[in] priv_data Optional private data to be passed to the callback
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of any error.
|
||||
*/
|
||||
esp_err_t esp_rmaker_mqtt_subscribe(const char *topic, esp_rmaker_mqtt_subscribe_cb_t cb, void *priv_data);
|
||||
|
||||
/** Unsubscribe from MQTT topic
|
||||
*
|
||||
* @param[in] topic Topic from which to unsubscribe.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of any error.
|
||||
*/
|
||||
esp_err_t esp_rmaker_mqtt_unsubscribe(const char *topic);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
150
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h
Normal file
150
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h
Normal file
@ -0,0 +1,150 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Default ESP RainMaker OTA Server Certificate */
|
||||
extern const char *ESP_RMAKER_OTA_DEFAULT_SERVER_CERT;
|
||||
|
||||
/** OTA Status to be reported to ESP RainMaker Cloud */
|
||||
typedef enum {
|
||||
/** OTA is in Progress. This can be reported multiple times as the OTA progresses. */
|
||||
OTA_STATUS_IN_PROGRESS = 1,
|
||||
/** OTA Succeeded. This should be reported only once, at the end of OTA. */
|
||||
OTA_STATUS_SUCCESS,
|
||||
/** OTA Failed. This should be reported only once, at the end of OTA. */
|
||||
OTA_STATUS_FAILED,
|
||||
/** OTA was delayed by the application */
|
||||
OTA_STATUS_DELAYED,
|
||||
} ota_status_t;
|
||||
|
||||
/** OTA Workflow type */
|
||||
typedef enum {
|
||||
/** OTA will be performed using services and parameters. */
|
||||
OTA_USING_PARAMS = 1,
|
||||
/** OTA will be performed using pre-defined MQTT topics. */
|
||||
OTA_USING_TOPICS
|
||||
} esp_rmaker_ota_type_t;
|
||||
|
||||
/** The OTA Handle to be used by the OTA callback */
|
||||
typedef void *esp_rmaker_ota_handle_t;
|
||||
|
||||
/** OTA Data */
|
||||
typedef struct {
|
||||
/** The OTA URL received from ESP RainMaker Cloud */
|
||||
char *url;
|
||||
/** Size of the OTA File. Can be 0 if the file size isn't received from
|
||||
* the ESP RainMaker Cloud */
|
||||
int filesize;
|
||||
/** The server certificate passed in esp_rmaker_enable_ota() */
|
||||
const char *server_cert;
|
||||
/** The private data passed in esp_rmaker_enable_ota() */
|
||||
char *priv;
|
||||
} esp_rmaker_ota_data_t;
|
||||
|
||||
/** Function prototype for OTA Callback
|
||||
*
|
||||
* This function will be invoked by the ESP RainMaker core whenever an OTA is available.
|
||||
* The esp_rmaker_report_ota_status() API should be used to indicate the progress and
|
||||
* success/fail status.
|
||||
*
|
||||
* @param[in] handle An OTA handle assigned by the ESP RainMaker Core
|
||||
* @param[in] ota_data The data to be used for the OTA
|
||||
*
|
||||
* @return ESP_OK if the OTA was successful
|
||||
* @return ESP_FAIL if the OTA failed.
|
||||
*/
|
||||
typedef esp_err_t (*esp_rmaker_ota_cb_t) (esp_rmaker_ota_handle_t handle,
|
||||
esp_rmaker_ota_data_t *ota_data);
|
||||
|
||||
/** Function Prototype for Post OTA Diagnostics
|
||||
*
|
||||
* If the Application rollback feature is enabled, this callback will be invoked
|
||||
* as soon as you call esp_rmaker_ota_enable(), if it is the first
|
||||
* boot after an OTA. You may perform some application specific diagnostics and
|
||||
* report the status which will decide whether to roll back or not.
|
||||
*
|
||||
* @return true if diagnostics are successful, meaning that the new firmware is fine.
|
||||
* @return false if diagnostics fail and a roolback to previous firmware is required.
|
||||
*/
|
||||
typedef bool (*esp_rmaker_post_ota_diag_t)(void);
|
||||
|
||||
/** ESP RainMaker OTA Configuration */
|
||||
typedef struct {
|
||||
/** OTA Callback.
|
||||
* The callback to be invoked when an OTA Job is available.
|
||||
* If kept NULL, the internal default callback will be used (Recommended).
|
||||
*/
|
||||
esp_rmaker_ota_cb_t ota_cb;
|
||||
/** OTA Diagnostics Callback.
|
||||
* A post OTA diagnostic handler to be invoked if app rollback feature is enabled.
|
||||
* If kept NULL, the new firmware will be assumed to be fine,
|
||||
* and no rollback will be performed.
|
||||
*/
|
||||
esp_rmaker_post_ota_diag_t ota_diag;
|
||||
/** Server Certificate.
|
||||
* The certificate to be passed to the OTA callback for server authentication.
|
||||
* This is mandatory, unless you have disabled it in ESP HTTPS OTA config option.
|
||||
* If you are using the ESP RainMaker OTA Service, you can just set this to
|
||||
* `ESP_RMAKER_DEFAULT_OTA_SERVER_CERT`.
|
||||
*/
|
||||
const char *server_cert;
|
||||
/** Private Data.
|
||||
* Optional private data to be passed to the OTA callback.
|
||||
*/
|
||||
void *priv;
|
||||
} esp_rmaker_ota_config_t;
|
||||
|
||||
/** Enable OTA
|
||||
*
|
||||
* Calling this API enables OTA as per the ESP RainMaker specification.
|
||||
* Please check the various ESP RainMaker configuration options to
|
||||
* use the different variants of OTA. Refer the documentation for
|
||||
* additional details.
|
||||
*
|
||||
* @param[in] ota_config Pointer to an OTA configuration structure
|
||||
* @param[in] type The OTA workflow type
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_ota_type_t type);
|
||||
|
||||
/** Report OTA Status
|
||||
*
|
||||
* This API must be called from the OTA Callback to indicate the status of the OTA. The OTA_STATUS_IN_PROGRESS
|
||||
* can be reported multiple times with appropriate additional information. The final success/failure should
|
||||
* be reported only once, at the end.
|
||||
*
|
||||
* This can be ignored if you are using the default internal OTA callback.
|
||||
*
|
||||
* @param[in] ota_handle The OTA handle received by the callback
|
||||
* @param[in] status Status to be reported
|
||||
* @param[in] additional_info NULL terminated string indicating additional information for the status
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_ota_report_status(esp_rmaker_ota_handle_t ota_handle, ota_status_t status, char *additional_info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,36 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Enable Schedules
|
||||
*
|
||||
* This API enables the scheduling service for the node. For more information,
|
||||
* check [here](https://rainmaker.espressif.com/docs/scheduling.html)
|
||||
*
|
||||
* It is recommended to set the timezone while using schedules. Check [here](https://rainmaker.espressif.com/docs/time-service.html#time-zone) for more information on timezones
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_schedule_enable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,96 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_rmaker_core.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Create a standard Switch device
|
||||
*
|
||||
* This creates a Switch device with the mandatory parameters and also assigns
|
||||
* the primary parameter. The default parameter names will be used.
|
||||
* Refer \ref esp_rmaker_standard_params.h for default names.
|
||||
*
|
||||
* @param[in] dev_name The unique device name
|
||||
* @param[in] priv_data (Optional) Private data associated with the device. This should stay
|
||||
* allocated throughout the lifetime of the device
|
||||
* #@param[in] power Default value of the mandatory parameter "power"
|
||||
*
|
||||
* @return Device handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_switch_device_create(const char *dev_name,
|
||||
void *priv_data, bool power);
|
||||
|
||||
/** Create a standard Lightbulb device
|
||||
*
|
||||
* This creates a Lightbulb device with the mandatory parameters and also assigns
|
||||
* the primary parameter. The default parameter names will be used.
|
||||
* Refer \ref esp_rmaker_standard_params.h for default names.
|
||||
*
|
||||
* @param[in] dev_name The unique device name
|
||||
* @param[in] priv_data (Optional) Private data associated with the device. This should stay
|
||||
* allocated throughout the lifetime of the device
|
||||
* @param[in] power Default value of the mandatory parameter "power"
|
||||
*
|
||||
* @return Device handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_lightbulb_device_create(const char *dev_name,
|
||||
void *priv_data, bool power);
|
||||
|
||||
/** Create a standard Fan device
|
||||
*
|
||||
* This creates a Fan device with the mandatory parameters and also assigns
|
||||
* the primary parameter. The default parameter names will be used.
|
||||
* Refer \ref esp_rmaker_standard_params.h for default names.
|
||||
*
|
||||
* @param[in] dev_name The unique device name
|
||||
* @param[in] priv_data (Optional) Private data associated with the device. This should stay
|
||||
* allocated throughout the lifetime of the device
|
||||
* @param[in] power Default value of the mandatory parameter "power"
|
||||
*
|
||||
* @return Device handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_fan_device_create(const char *dev_name,
|
||||
void *priv_data, bool power);
|
||||
|
||||
/** Create a standard Temperature Sensor device
|
||||
*
|
||||
* This creates a Temperature Sensor device with the mandatory parameters and also assigns
|
||||
* the primary parameter. The default parameter names will be used.
|
||||
* Refer \ref esp_rmaker_standard_params.h for default names.
|
||||
*
|
||||
* @param[in] dev_name The unique device name
|
||||
* @param[in] priv_data (Optional) Private data associated with the device. This should stay
|
||||
* allocated throughout the lifetime of the device
|
||||
* @param[in] temperature Default value of the mandatory parameter "temperature"
|
||||
*
|
||||
* @return Device handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_temp_sensor_device_create(const char *dev_name,
|
||||
void *priv_data, float temperature);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,265 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_rmaker_core.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Suggested default names for the parameters.
|
||||
* These will also be used by default if you use any standard device helper APIs.
|
||||
*
|
||||
* @note These names are not mandatory. You can use the ESP RainMaker Core APIs
|
||||
* to create your own parameters with custom names, if required.
|
||||
*/
|
||||
|
||||
#define ESP_RMAKER_DEF_NAME_PARAM "Name"
|
||||
#define ESP_RMAKER_DEF_POWER_NAME "Power"
|
||||
#define ESP_RMAKER_DEF_BRIGHTNESS_NAME "Brightness"
|
||||
#define ESP_RMAKER_DEF_HUE_NAME "Hue"
|
||||
#define ESP_RMAKER_DEF_SATURATION_NAME "Saturation"
|
||||
#define ESP_RMAKER_DEF_INTENSITY_NAME "Intensity"
|
||||
#define ESP_RMAKER_DEF_CCT_NAME "CCT"
|
||||
#define ESP_RMAKER_DEF_DIRECTION_NAME "Direction"
|
||||
#define ESP_RMAKER_DEF_SPEED_NAME "Speed"
|
||||
#define ESP_RMAKER_DEF_TEMPERATURE_NAME "Temperature"
|
||||
#define ESP_RMAKER_DEF_OTA_STATUS_NAME "Status"
|
||||
#define ESP_RMAKER_DEF_OTA_INFO_NAME "Info"
|
||||
#define ESP_RMAKER_DEF_OTA_URL_NAME "URL"
|
||||
#define ESP_RMAKER_DEF_TIMEZONE_NAME "TZ"
|
||||
#define ESP_RMAKER_DEF_TIMEZONE_POSIX_NAME "TZ-POSIX"
|
||||
#define ESP_RMAKER_DEF_SCHEDULE_NAME "Schedules"
|
||||
|
||||
/**
|
||||
* Create standard name param
|
||||
*
|
||||
* This will create the standard name parameter.
|
||||
* This should be added to all devices for which you want a user customisable name.
|
||||
* The value should be same as the device name.
|
||||
*
|
||||
* All standard device creation APIs will add this internally.
|
||||
* No application registered callback will be called for this parameter,
|
||||
* and changes will be managed internally.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_name_param_create(const char *param_name, const char *val);
|
||||
|
||||
/**
|
||||
* Create standard Power param
|
||||
*
|
||||
* This will create the standard power parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_power_param_create(const char *param_name, bool val);
|
||||
|
||||
/**
|
||||
* Create standard Brightness param
|
||||
*
|
||||
* This will create the standard brightness parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_brightness_param_create(const char *param_name, int val);
|
||||
|
||||
/**
|
||||
* Create standard Hue param
|
||||
*
|
||||
* This will create the standard hue parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_hue_param_create(const char *param_name, int val);
|
||||
|
||||
/**
|
||||
* Create standard Saturation param
|
||||
*
|
||||
* This will create the standard saturation parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_saturation_param_create(const char *param_name, int val);
|
||||
|
||||
/**
|
||||
* Create standard Intensity param
|
||||
*
|
||||
* This will create the standard intensity parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_intensity_param_create(const char *param_name, int val);
|
||||
|
||||
/**
|
||||
* Create standard CCT param
|
||||
*
|
||||
* This will create the standard cct parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_cct_param_create(const char *param_name, int val);
|
||||
|
||||
/**
|
||||
* Create standard Direction param
|
||||
*
|
||||
* This will create the standard direction parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_direction_param_create(const char *param_name, int val);
|
||||
|
||||
/**
|
||||
* Create standard Speed param
|
||||
*
|
||||
* This will create the standard speed parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_speed_param_create(const char *param_name, int val);
|
||||
|
||||
/**
|
||||
* Create standard Temperature param
|
||||
*
|
||||
* This will create the standard temperature parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_temperature_param_create(const char *param_name, float val);
|
||||
|
||||
/**
|
||||
* Create standard OTA Status param
|
||||
*
|
||||
* This will create the standard ota status parameter. Default value
|
||||
* is set internally.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_ota_status_param_create(const char *param_name);
|
||||
|
||||
/**
|
||||
* Create standard OTA Info param
|
||||
*
|
||||
* This will create the standard ota info parameter. Default value
|
||||
* is set internally.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_ota_info_param_create(const char *param_name);
|
||||
|
||||
/**
|
||||
* Create standard OTA URL param
|
||||
*
|
||||
* This will create the standard ota url parameter. Default value
|
||||
* is set internally.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_ota_url_param_create(const char *param_name);
|
||||
|
||||
/**
|
||||
* Create standard Timezone param
|
||||
*
|
||||
* This will create the standard timezone parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter (Eg. "Asia/Shanghai"). Can be kept NULL.
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_timezone_param_create(const char *param_name, const char *val);
|
||||
|
||||
/**
|
||||
* Create standard POSIX Timezone param
|
||||
*
|
||||
* This will create the standard posix timezone parameter.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] val Default Value of the parameter (Eg. "CST-8"). Can be kept NULL.
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_timezone_posix_param_create(const char *param_name, const char *val);
|
||||
|
||||
/**
|
||||
* Create standard schedules param
|
||||
*
|
||||
* This will create the standard schedules parameter. Default value
|
||||
* is set internally.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] max_schedules Maximum number of schedules allowed
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_schedules_param_create(const char *param_name, int max_schedules);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,76 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_rmaker_core.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Create a standard OTA service
|
||||
*
|
||||
* This creates an OTA service with the mandatory parameters. The default parameter names will be used.
|
||||
* Refer \ref esp_rmaker_standard_params.h for default names.
|
||||
*
|
||||
* @param[in] serv_name The unique service name
|
||||
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
|
||||
* allocated throughout the lifetime of the service.
|
||||
*
|
||||
* @return service_handle on success.
|
||||
* @return NULL in case of any error.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_ota_service_create(const char *serv_name, void *priv_data);
|
||||
|
||||
/** Create a standard OTA service
|
||||
*
|
||||
* This creates an OTA service with the mandatory parameters. The default parameter names will be used.
|
||||
* Refer \ref esp_rmaker_standard_params.h for default names.
|
||||
*
|
||||
* @param[in] serv_name The unique service name
|
||||
* @param[in] timezone Default value of timezone string (Eg. "Asia/Shanghai"). Can be kept NULL.
|
||||
* @param[in] timezone_posix Default value of posix timezone string (Eg. "CST-8"). Can be kept NULL.
|
||||
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
|
||||
* allocated throughout the lifetime of the service.
|
||||
*
|
||||
* @return service_handle on success.
|
||||
* @return NULL in case of any error.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_time_service_create(const char *serv_name, const char *timezone,
|
||||
const char *timezone_posix, void *priv_data);
|
||||
|
||||
/** Create a standard Schedule service
|
||||
*
|
||||
* This creates a Schedule service with the mandatory parameters. The default parameter names will be used.
|
||||
* Refer \ref esp_rmaker_standard_params.h for default names.
|
||||
*
|
||||
* @param[in] serv_name The unique service name
|
||||
* @param[in] write_cb Write callback.
|
||||
* @param[in] read_cb Read callback.
|
||||
* @param[in] max_schedules Maximum number of schedules supported.
|
||||
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
|
||||
* allocated throughout the lifetime of the service.
|
||||
*
|
||||
* @return service_handle on success.
|
||||
* @return NULL in case of any error.
|
||||
*/
|
||||
esp_rmaker_device_t *esp_rmaker_create_schedule_service(const char *serv_name, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb, int max_schedules, void *priv_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,64 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/********** STANDARD UI TYPES **********/
|
||||
|
||||
#define ESP_RMAKER_UI_TOGGLE "esp.ui.toggle"
|
||||
#define ESP_RMAKER_UI_SLIDER "esp.ui.slider"
|
||||
#define ESP_RMAKER_UI_DROPDOWN "esp.ui.dropdown"
|
||||
#define ESP_RMAKER_UI_TEXT "esp.ui.text"
|
||||
|
||||
|
||||
/********** STANDARD PARAM TYPES **********/
|
||||
|
||||
#define ESP_RMAKER_PARAM_NAME "esp.param.name"
|
||||
#define ESP_RMAKER_PARAM_POWER "esp.param.power"
|
||||
#define ESP_RMAKER_PARAM_BRIGHTNESS "esp.param.brightness"
|
||||
#define ESP_RMAKER_PARAM_HUE "esp.param.hue"
|
||||
#define ESP_RMAKER_PARAM_SATURATION "esp.param.saturation"
|
||||
#define ESP_RMAKER_PARAM_INTENSITY "esp.param.intensity"
|
||||
#define ESP_RMAKER_PARAM_CCT "esp.param.cct"
|
||||
#define ESP_RMAKER_PARAM_SPEED "esp.param.speed"
|
||||
#define ESP_RMAKER_PARAM_DIRECTION "esp.param.direction"
|
||||
#define ESP_RMAKER_PARAM_TEMPERATURE "esp.param.temperature"
|
||||
#define ESP_RMAKER_PARAM_OTA_STATUS "esp.param.ota_status"
|
||||
#define ESP_RMAKER_PARAM_OTA_INFO "esp.param.ota_info"
|
||||
#define ESP_RMAKER_PARAM_OTA_URL "esp.param.ota_url"
|
||||
#define ESP_RMAKER_PARAM_TIMEZONE "esp.param.tz"
|
||||
#define ESP_RMAKER_PARAM_TIMEZONE_POSIX "esp.param.tz_posix"
|
||||
#define ESP_RMAKER_PARAM_SCHEDULES "esp.param.schedules"
|
||||
|
||||
|
||||
/********** STANDARD DEVICE TYPES **********/
|
||||
|
||||
#define ESP_RMAKER_DEVICE_SWITCH "esp.device.switch"
|
||||
#define ESP_RMAKER_DEVICE_LIGHTBULB "esp.device.lightbulb"
|
||||
#define ESP_RMAKER_DEVICE_FAN "esp.device.fan"
|
||||
#define ESP_RMAKER_DEVICE_TEMP_SENSOR "esp.device.temperature-sensor"
|
||||
|
||||
|
||||
/********** STANDARD SERVICE TYPES **********/
|
||||
#define ESP_RMAKER_SERVICE_OTA "esp.service.ota"
|
||||
#define ESP_RMAKER_SERVICE_TIME "esp.service.time"
|
||||
#define ESP_RMAKER_SERVICE_SCHEDULE "esp.service.schedule"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,64 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create User Mapping Endpoint
|
||||
*
|
||||
* This will create a custom provisioning endpoint for user-node mapping.
|
||||
* This should be called after wifi_prov_mgr_init() but before
|
||||
* wifi_prov_mgr_start_provisioning()
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_user_mapping_endpoint_create(void);
|
||||
|
||||
/**
|
||||
* Register User Mapping Endpoint
|
||||
*
|
||||
* This will register the callback for the custom provisioning endpoint
|
||||
* for user-node mapping which was created with esp_rmaker_user_mapping_endpoint_create().
|
||||
* This should be called immediately after wifi_prov_mgr_start_provisioning().
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_user_mapping_endpoint_register(void);
|
||||
|
||||
/** Add User-Node mapping
|
||||
*
|
||||
* This call will start the user-node mapping workflow on the node.
|
||||
* This is automatically called if you have used esp_rmaker_user_mapping_endpoint_register().
|
||||
* Use this API only if you want to trigger the user-node mapping after the Wi-Fi provisioning
|
||||
* has already been done.
|
||||
*
|
||||
* @param[in] user_id The User identifier received from the client (Phone app/CLI)
|
||||
* @param[in] secret_key The Secret key received from the client (Phone app/CLI)
|
||||
*
|
||||
* @return ESP_OK if the workflow was successfully triggered. This does not guarantee success
|
||||
* of the actual mapping. The mapping status needs to be checked separately by the clients.
|
||||
* @return error on failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_start_user_node_mapping(char *user_id, char *secret_key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
174
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_utils.h
Normal file
174
tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_utils.h
Normal file
@ -0,0 +1,174 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <sntp.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct esp_rmaker_time_config {
|
||||
/** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */
|
||||
char *sntp_server_name;
|
||||
/** Optional callback to invoke, whenever time is synchronised. This will be called
|
||||
* periodically as per the SNTP polling interval (which is 60min by default).
|
||||
* If kept NULL, the default callback will be invoked, which will just print the
|
||||
* current local time.
|
||||
*/
|
||||
sntp_sync_time_cb_t sync_time_cb;
|
||||
} esp_rmaker_time_config_t;
|
||||
|
||||
/** Reboot the chip after a delay
|
||||
*
|
||||
* This API just starts a reboot timer and returns immediately.
|
||||
* The actual reboot is trigerred asynchronously in the timer callback.
|
||||
* This is useful if you want to reboot after a delay, to allow other tasks to finish
|
||||
* their operations (Eg. MQTT publish to indicate OTA success). The \ref RMAKER_EVENT_REBOOT
|
||||
* event is triggered when the reboot timer is started.
|
||||
*
|
||||
* @param[in] seconds Time in seconds after which the chip should reboot.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error on failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_reboot(uint8_t seconds);
|
||||
|
||||
/** Reset Wi-Fi credentials and reboot
|
||||
*
|
||||
* This will reset just the Wi-Fi credentials and trigger a reboot.
|
||||
* This is useful when you want to keep all the entries in NVS memory
|
||||
* intact, but just change the Wi-Fi credentials. The \ref RMAKER_EVENT_WIFI_RESET
|
||||
* event is triggered after the reset.
|
||||
*
|
||||
* @note This function internally calls esp_rmaker_reboot() and returns
|
||||
* immediately. The reboot happens asynchronously.
|
||||
*
|
||||
* @param[in] seconds Time in seconds after which the chip should reboot.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error on failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_wifi_reset(uint8_t seconds);
|
||||
|
||||
/** Reset to factory defaults and reboot
|
||||
*
|
||||
* This will clear entire NVS partition and trigger a reboot.
|
||||
* The \ref RMAKER_EVENT_FACTORY_RESET event is triggered after the reset.
|
||||
*
|
||||
* @note This function internally calls esp_rmaker_reboot() and returns.
|
||||
* The reboot happens asynchronously.
|
||||
*
|
||||
* @param[in] seconds Time in seconds after which the chip should reboot.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error on failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_factory_reset(uint8_t seconds);
|
||||
|
||||
/** Initialize time synchronization
|
||||
*
|
||||
* This API initializes SNTP for time synchronization.
|
||||
*
|
||||
* @param[in] config Configuration to be used for SNTP time synchronization. The default configuration is used if NULL is passed.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_time_sync_init(esp_rmaker_time_config_t *config);
|
||||
|
||||
/** Check if current time is updated
|
||||
*
|
||||
* This API checks if the current system time is updated against the reference time of 1-Jan-2019.
|
||||
*
|
||||
* @return true if time is updated
|
||||
* @return false if time is not updated
|
||||
*/
|
||||
bool esp_rmaker_time_check(void);
|
||||
|
||||
/** Wait for time synchronization
|
||||
*
|
||||
* This API waits for the system time to be updated against the reference time of 1-Jan-2019.
|
||||
* This is a blocking call.
|
||||
*
|
||||
* @param[in] ticks_to_wait Number of ticks to wait for time synchronization. Accepted values: 0 to portMAX_DELAY.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_time_wait_for_sync(uint32_t ticks_to_wait);
|
||||
|
||||
/** Set POSIX timezone
|
||||
*
|
||||
* Set the timezone (TZ environment variable) as per the POSIX format
|
||||
* specified in the [GNU libc documentation](https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html).
|
||||
* Eg. For China: "CST-8"
|
||||
* For US Pacific Time (including daylight saving information): "PST8PDT,M3.2.0,M11.1.0"
|
||||
*
|
||||
* @param[in] tz_posix NULL terminated TZ POSIX string
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_time_set_timezone_posix(const char *tz_posix);
|
||||
|
||||
/** Set timezone location string
|
||||
*
|
||||
* Set the timezone as a user friendly location string.
|
||||
* Check [here](https://rainmaker.espressif.com/docs/time-service.html) for a list of valid values.
|
||||
*
|
||||
* Eg. For China: "Asia/Shanghai"
|
||||
* For US Pacific Time: "America/Los_Angeles"
|
||||
*
|
||||
* @note Setting timezone using this API internally also sets the POSIX timezone string.
|
||||
*
|
||||
* @param[in] tz NULL terminated Timezone location string
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_time_set_timezone(const char *tz);
|
||||
|
||||
/** Enable Timezone Service
|
||||
*
|
||||
* This enables the ESP RainMaker standard timezone service which can be used to set
|
||||
* timezone, either in POSIX or location string format. Please refer the specifications
|
||||
* for additional details.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_timezone_service_enable(void);
|
||||
|
||||
/** Get printable local time string
|
||||
*
|
||||
* Get a printable local time string, with information of timezone and Daylight Saving.
|
||||
* Eg. "Tue Sep 1 09:04:38 2020 -0400[EDT], DST: Yes"
|
||||
* "Tue Sep 1 21:04:04 2020 +0800[CST], DST: No"
|
||||
*
|
||||
*
|
||||
* @param[out] buf Pointer to a pre-allocated buffer into which the time string will
|
||||
* be populated.
|
||||
* @param[in] buf_len Length of the above buffer.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_get_local_time_str(char *buf, size_t buf_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
225
tools/sdk/esp32/include/esp_schedule/include/esp_schedule.h
Normal file
225
tools/sdk/esp32/include/esp_schedule/include/esp_schedule.h
Normal file
@ -0,0 +1,225 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** Schedule Handle */
|
||||
typedef void *esp_schedule_handle_t;
|
||||
|
||||
/** Maximum length of the schedule name allowed. This value cannot be more than 16 as it is used for NVS key. */
|
||||
#define MAX_SCHEDULE_NAME_LEN 16
|
||||
|
||||
/** Callback for schedule trigger
|
||||
*
|
||||
* This callback is called when the schedule is triggered.
|
||||
*
|
||||
* @param[in] handle Schedule handle.
|
||||
* @param[in] priv_data Pointer to the private data passed while creating/editing the schedule.
|
||||
*/
|
||||
typedef void (*esp_schedule_trigger_cb_t)(esp_schedule_handle_t handle, void *priv_data);
|
||||
|
||||
/** Callback for schedule timestamp
|
||||
*
|
||||
* This callback is called when the next trigger timestamp of the schedule is changed. This might be useful to check if
|
||||
* one time schedules have already passed while the device was powered off.
|
||||
*
|
||||
* @param[in] handle Schedule handle.
|
||||
* @param[in] next_timestamp timestamp at which the schedule will trigger next.
|
||||
* @param[in] priv_data Pointer to the user data passed while creating/editing the schedule.
|
||||
*/
|
||||
typedef void (*esp_schedule_timestamp_cb_t)(esp_schedule_handle_t handle, uint32_t next_timestamp, void *priv_data);
|
||||
|
||||
/** Schedule type */
|
||||
typedef enum esp_schedule_type {
|
||||
ESP_SCHEDULE_TYPE_INVALID = 0,
|
||||
ESP_SCHEDULE_TYPE_DAYS_OF_WEEK,
|
||||
ESP_SCHEDULE_TYPE_DATE,
|
||||
} esp_schedule_type_t;
|
||||
|
||||
/** Schedule days. Used for ESP_SCHEDULE_TYPE_DAYS_OF_WEEK. */
|
||||
typedef enum esp_schedule_days {
|
||||
ESP_SCHEDULE_DAY_ONCE = 0,
|
||||
ESP_SCHEDULE_DAY_EVERYDAY = 0b1111111,
|
||||
ESP_SCHEDULE_DAY_MONDAY = 1 << 0,
|
||||
ESP_SCHEDULE_DAY_TUESDAY = 1 << 1,
|
||||
ESP_SCHEDULE_DAY_WEDNESDAY = 1 << 2,
|
||||
ESP_SCHEDULE_DAY_THURSDAY = 1 << 3,
|
||||
ESP_SCHEDULE_DAY_FRIDAY = 1 << 4,
|
||||
ESP_SCHEDULE_DAY_SATURDAY = 1 << 5,
|
||||
ESP_SCHEDULE_DAY_SUNDAY = 1 << 6,
|
||||
} esp_schedule_days_t;
|
||||
|
||||
/** Schedule months. Used for ESP_SCHEDULE_TYPE_DATE. */
|
||||
typedef enum esp_schedule_months {
|
||||
ESP_SCHEDULE_MONTH_ONCE = 0,
|
||||
ESP_SCHEDULE_MONTH_ALL = 0b1111111,
|
||||
ESP_SCHEDULE_MONTH_JANUARY = 1 << 0,
|
||||
ESP_SCHEDULE_MONTH_FEBRUARY = 1 << 1,
|
||||
ESP_SCHEDULE_MONTH_MARCH = 1 << 2,
|
||||
ESP_SCHEDULE_MONTH_APRIL = 1 << 3,
|
||||
ESP_SCHEDULE_MONTH_MAY = 1 << 4,
|
||||
ESP_SCHEDULE_MONTH_JUNE = 1 << 5,
|
||||
ESP_SCHEDULE_MONTH_JULY = 1 << 6,
|
||||
ESP_SCHEDULE_MONTH_AUGUST = 1 << 7,
|
||||
ESP_SCHEDULE_MONTH_SEPTEMBER = 1 << 8,
|
||||
ESP_SCHEDULE_MONTH_OCTOBER = 1 << 9,
|
||||
ESP_SCHEDULE_MONTH_NOVEMBER = 1 << 10,
|
||||
ESP_SCHEDULE_MONTH_DECEMBER = 1 << 11,
|
||||
} esp_schedule_months_t;
|
||||
|
||||
/** Trigger details of the schedule */
|
||||
typedef struct esp_schedule_trigger {
|
||||
/** Type of schedule */
|
||||
esp_schedule_type_t type;
|
||||
/** Hours in 24 hour format. Accepted values: 0-23 */
|
||||
uint8_t hours;
|
||||
/** Minutes in the given hour. Accepted values: 0-59. */
|
||||
uint8_t minutes;
|
||||
/** For type ESP_SCHEDULE_TYPE_DAYS_OF_WEEK */
|
||||
struct {
|
||||
/** 'OR' list of esp_schedule_days_t */
|
||||
uint8_t repeat_days;
|
||||
} day;
|
||||
/** For type ESP_SCHEDULE_TYPE_DATE */
|
||||
struct {
|
||||
/** Day of the month. Accepted values: 1-31. */
|
||||
uint8_t day;
|
||||
/* 'OR' list of esp_schedule_months_t */
|
||||
uint16_t repeat_months;
|
||||
/** Year */
|
||||
uint16_t year;
|
||||
/** If the schedule is to be repeated every year. */
|
||||
bool repeat_every_year;
|
||||
} date;
|
||||
} esp_schedule_trigger_t;
|
||||
|
||||
/** Schedule config */
|
||||
typedef struct esp_schedule_config {
|
||||
/** Name of the schedule. This is like a primary key for the schedule. This is required. +1 for NULL termination. */
|
||||
char name[MAX_SCHEDULE_NAME_LEN + 1];
|
||||
/** Trigger details */
|
||||
esp_schedule_trigger_t trigger;
|
||||
/** Trigger callback */
|
||||
esp_schedule_trigger_cb_t trigger_cb;
|
||||
/** Timestamp callback */
|
||||
esp_schedule_timestamp_cb_t timestamp_cb;
|
||||
/** Private data associated with the schedule. This will be passed to callbacks. */
|
||||
void *priv_data;
|
||||
} esp_schedule_config_t;
|
||||
|
||||
/** Initialize ESP Schedule
|
||||
*
|
||||
* This initializes ESP Schedule. This must be called first before calling any of the other APIs.
|
||||
* This API also gets all the schedules from NVS (if it has been enabled).
|
||||
*
|
||||
* Note: After calling this API, the pointers to the callbacks should be updated for all the schedules by calling
|
||||
* esp_schedule_get() followed by esp_schedule_edit() with the correct callbacks.
|
||||
*
|
||||
* @param[in] enable_nvs If NVS is to be enabled or not.
|
||||
* @param[in] nvs_partition (Optional) The NVS partition to be used. If NULL is passed, the default partition is used.
|
||||
* @param[out] schedule_count Number of active schedules found in NVS.
|
||||
*
|
||||
* @return Array of schedule handles if any schedules have been found.
|
||||
* @return NULL if no schedule is found in NVS (or if NVS is not enabled).
|
||||
*/
|
||||
esp_schedule_handle_t *esp_schedule_init(bool enable_nvs, char *nvs_partition, uint8_t *schedule_count);
|
||||
|
||||
/** Create Schedule
|
||||
*
|
||||
* This API can be used to create a new schedule. The schedule still needs to be enabled using
|
||||
* esp_schedule_enable().
|
||||
*
|
||||
* @param[in] schedule_config Configuration of the schedule to be created.
|
||||
*
|
||||
* @return Schedule handle if successfully created.
|
||||
* @return NULL in case of error.
|
||||
*/
|
||||
esp_schedule_handle_t esp_schedule_create(esp_schedule_config_t *schedule_config);
|
||||
|
||||
/** Remove Schedule
|
||||
*
|
||||
* This API can be used to remove an existing schedule.
|
||||
*
|
||||
* @param[in] handle Schedule handle for the schedule to be removed.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_schedule_delete(esp_schedule_handle_t handle);
|
||||
|
||||
/** Edit Schedule
|
||||
*
|
||||
* This API can be used to edit an existing schedule.
|
||||
* The schedule name should be same as when the schedule was created. The complete config must be provided
|
||||
* or the previously stored config might be over-written.
|
||||
*
|
||||
* Note: If a schedule is edited when it is on-going, the new changes will not be reflected.
|
||||
* You will need to disable the schedule, edit it, and then enable it again.
|
||||
*
|
||||
* @param[in] handle Schedule handle for the schedule to be edited.
|
||||
* @param[in] schedule_config Configuration of the schedule to be edited.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_schedule_edit(esp_schedule_handle_t handle, esp_schedule_config_t *schedule_config);
|
||||
|
||||
/** Enable Schedule
|
||||
*
|
||||
* This API can be used to enable an existing schedule.
|
||||
* It can be used to enable a schedule after it has been created using esp_schedule_create()
|
||||
* or if the schedule has been disabled using esp_schedule_disable().
|
||||
*
|
||||
* @param[in] handle Schedule handle for the schedule to be enabled.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_schedule_enable(esp_schedule_handle_t handle);
|
||||
|
||||
/** Disable Schedule
|
||||
*
|
||||
* This API can be used to disable an on-going schedule.
|
||||
* It does not remove the schedule, just stops it. The schedule can be enabled again using
|
||||
* esp_schedule_enable().
|
||||
*
|
||||
* @param[in] handle Schedule handle for the schedule to be disabled.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_schedule_disable(esp_schedule_handle_t handle);
|
||||
|
||||
/** Get Schedule
|
||||
*
|
||||
* This API can be used to get details of an existing schedule.
|
||||
* The schedule_config is populated with the schedule details.
|
||||
*
|
||||
* @param[in] handle Schedule handle.
|
||||
* @param[out] schedule_config Details of the schedule whose handle is passed.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_schedule_get(esp_schedule_handle_t handle, esp_schedule_config_t *schedule_config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
485
tools/sdk/esp32/include/json_generator/json_generator.h
Executable file
485
tools/sdk/esp32/include/json_generator/json_generator.h
Executable file
@ -0,0 +1,485 @@
|
||||
/** \file json_gen_generator.h
|
||||
* \brief JSON String Generator
|
||||
*
|
||||
* This module can be used to create JSON strings with a facility
|
||||
* to flush out data if the destination buffer is full. All commas
|
||||
* and colons as required are automatically added by the APIs
|
||||
*
|
||||
* Code taken from: https://github.com/shahpiyushv/json_gen_generator
|
||||
*/
|
||||
#ifndef _JSON_GENERATOR_H
|
||||
#define _JSON_GENERATOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define JSON_FLOAT_PRECISION 5
|
||||
|
||||
/** JSON string flush callback prototype
|
||||
*
|
||||
* This is a prototype of the function that needs to be passed to
|
||||
* json_gen_str_start() and which will be invoked by the JSON generator
|
||||
* module either when the buffer is full or json_gen_str_end() ins invoked.
|
||||
*
|
||||
* \param[in] buf Pointer to a NULL terminated JSON string
|
||||
* \param[in] priv Private data to be passed to the flush callback. Will
|
||||
* be the same as the one passed to json_gen_str_start()
|
||||
*/
|
||||
typedef void (*json_gen_flush_cb_t) (char *buf, void *priv);
|
||||
|
||||
/** JSON String structure
|
||||
*
|
||||
* Please do not set/modify any elements.
|
||||
* Just define this structure and pass a pointer to it in the APIs below
|
||||
*/
|
||||
typedef struct {
|
||||
char *buf;
|
||||
int buf_size;
|
||||
json_gen_flush_cb_t flush_cb;
|
||||
void *priv;
|
||||
bool comma_req;
|
||||
char *free_ptr;
|
||||
} json_gen_str_t;
|
||||
|
||||
/** Start a JSON String
|
||||
*
|
||||
* This is the first function to be called for creating a JSON string.
|
||||
* It initializes the internal data structures. After the JSON string
|
||||
* generation is over, the json_gen_str_end() function should be called.
|
||||
*
|
||||
* \param[out] jstr Pointer to an allocated \ref json_gen_str_t structure.
|
||||
* This will be initialised internally and needs to be passed to all
|
||||
* subsequent function calls
|
||||
* \param[out] buf Pointer to an allocated buffer into which the JSON
|
||||
* string will be written
|
||||
* \param[in] buf_size Size of the buffer
|
||||
* \param[in] Pointer to the flushing function of type \ref json_gen_flush_cb_t
|
||||
* which will be invoked either when the buffer is full or when json_gen_str_end()
|
||||
* is invoked. Can be left NULL.
|
||||
* \param[in] priv Private data to be passed to the flushing function callback.
|
||||
* Can be something like a session identifier (Eg. socket). Can be left NULL
|
||||
*/
|
||||
void json_gen_str_start(json_gen_str_t *jstr, char *buf, int buf_size,
|
||||
json_gen_flush_cb_t flush_cb, void *priv);
|
||||
|
||||
/** End JSON string
|
||||
*
|
||||
* This should be the last function to be called after the entire JSON string
|
||||
* has been generated.
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*/
|
||||
void json_gen_str_end(json_gen_str_t *jstr);
|
||||
|
||||
/** Start a JSON object
|
||||
*
|
||||
* This starts a JSON object by adding a '{'
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_start_object(json_gen_str_t *jstr);
|
||||
|
||||
/** End a JSON object
|
||||
*
|
||||
* This ends a JSON object by adding a '}'
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_end_object(json_gen_str_t *jstr);
|
||||
|
||||
/** Start a JSON array
|
||||
*
|
||||
* This starts a JSON object by adding a '['
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_start_array(json_gen_str_t *jstr);
|
||||
|
||||
/** End a JSON object
|
||||
*
|
||||
* This ends a JSON object by adding a ']'
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_end_array(json_gen_str_t *jstr);
|
||||
|
||||
/** Push a named JSON object
|
||||
*
|
||||
* This adds a JSON object like "name":{
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the object
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_push_object(json_gen_str_t *jstr, char *name);
|
||||
|
||||
/** Pop a named JSON object
|
||||
*
|
||||
* This ends a JSON object by adding a '}'. This is basically same as
|
||||
* json_gen_end_object() but included so as to complement json_gen_push_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_pop_object(json_gen_str_t *jstr);
|
||||
|
||||
/** Push a JSON object string
|
||||
*
|
||||
* This adds a complete pre-formatted JSON object string to the JSON object.
|
||||
*
|
||||
* Eg. json_gen_push_object_str(jstr, "pre-formatted", "{\"a\":1,\"b\":2}");
|
||||
* This will add "pre-formatted":{"a":1,"b":2}
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the JSON object string
|
||||
* \param[in] object_str The pre-formatted JSON object string
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that.
|
||||
*/
|
||||
int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str);
|
||||
|
||||
/** Push a named JSON array
|
||||
*
|
||||
* This adds a JSON array like "name":[
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the array
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_push_array(json_gen_str_t *jstr, char *name);
|
||||
|
||||
/** Pop a named JSON array
|
||||
*
|
||||
* This ends a JSON array by adding a ']'. This is basically same as
|
||||
* json_gen_end_array() but included so as to complement json_gen_push_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_pop_array(json_gen_str_t *jstr);
|
||||
|
||||
/** Push a JSON array string
|
||||
*
|
||||
* This adds a complete pre-formatted JSON array string to the JSON object.
|
||||
*
|
||||
* Eg. json_gen_push_object_str(jstr, "pre-formatted", "[1,2,3]");
|
||||
* This will add "pre-formatted":[1,2,3]
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the JSON array string
|
||||
* \param[in] array_str The pre-formatted JSON array string
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that.
|
||||
*/
|
||||
int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str);
|
||||
|
||||
/** Add a boolean element to an object
|
||||
*
|
||||
* This adds a boolean element to an object. Eg. "bool_val":true
|
||||
*
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Boolean value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val);
|
||||
|
||||
/** Add an integer element to an object
|
||||
*
|
||||
* This adds an integer element to an object. Eg. "int_val":28
|
||||
*
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Integer value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val);
|
||||
|
||||
/** Add a float element to an object
|
||||
*
|
||||
* This adds a float element to an object. Eg. "float_val":23.8
|
||||
*
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Float value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val);
|
||||
|
||||
/** Add a string element to an object
|
||||
*
|
||||
* This adds a string element to an object. Eg. "string_val":"my_string"
|
||||
*
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Null terminated string value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val);
|
||||
|
||||
/** Add a NULL element to an object
|
||||
*
|
||||
* This adds a NULL element to an object. Eg. "null_val":null
|
||||
*
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_obj_set_null(json_gen_str_t *jstr, char *name);
|
||||
|
||||
/** Add a boolean element to an array
|
||||
*
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Boolean value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_arr_set_bool(json_gen_str_t *jstr, bool val);
|
||||
|
||||
/** Add an integer element to an array
|
||||
*
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Integer value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_arr_set_int(json_gen_str_t *jstr, int val);
|
||||
|
||||
/** Add a float element to an array
|
||||
*
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Float value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_arr_set_float(json_gen_str_t *jstr, float val);
|
||||
|
||||
/** Add a string element to an array
|
||||
*
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Null terminated string value of the element
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_arr_set_string(json_gen_str_t *jstr, char *val);
|
||||
|
||||
/** Add a NULL element to an array
|
||||
*
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_arr_set_null(json_gen_str_t *jstr);
|
||||
|
||||
/** Start a Long string in an object
|
||||
*
|
||||
* This starts a string in an object, but does not end it (i.e., does not add the
|
||||
* terminating quotes. This is useful for long strings. Eg. "string_val":"my_string.
|
||||
* The API json_gen_add_to_long_string() must be used to add to this string and the API
|
||||
* json_gen_end_long_string() must be used to terminate it (i.e. add the ending quotes).
|
||||
*
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Null terminated initial part of the string value. It can also be NULL
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val);
|
||||
|
||||
/** Start a Long string in an array
|
||||
*
|
||||
* This starts a string in an arrayt, but does not end it (i.e., does not add the
|
||||
* terminating quotes. This is useful for long strings.
|
||||
* The API json_gen_add_to_long_string() must be used to add to this string and the API
|
||||
* json_gen_end_long_string() must be used to terminate it (i.e. add the ending quotes).
|
||||
*
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Null terminated initial part of the string value. It can also be NULL
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val);
|
||||
|
||||
/** Add to a JSON Long string
|
||||
*
|
||||
* This extends the string initialised by json_gen_obj_start_long_string() or
|
||||
* json_gen_arr_start_long_string(). After the entire string is created, it should be terminated
|
||||
* with json_gen_end_long_string().
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by json_gen_str_start()
|
||||
* \param[in] val Null terminated extending part of the string value.
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val);
|
||||
|
||||
/** End a JSON Long string
|
||||
*
|
||||
* This ends the string initialised by json_gen_obj_start_long_string() or
|
||||
* json_gen_arr_start_long_string() by adding the ending quotes.
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by json_gen_str_start()
|
||||
*
|
||||
*
|
||||
* \return 0 on Success
|
||||
* \return -1 if buffer is out of space (possible only if no callback function
|
||||
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_end_long_string(json_gen_str_t *jstr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
110
tools/sdk/esp32/include/json_parser/jsmn/include/jsmn-changed.h
Normal file
110
tools/sdk/esp32/include/json_parser/jsmn/include/jsmn-changed.h
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Serge A. Zaitsev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file jsmn.h
|
||||
* @brief Definition of the JSMN (Jasmine) JSON parser.
|
||||
*
|
||||
* For more information on JSMN:
|
||||
* @see http://zserge.com/jsmn.html
|
||||
*/
|
||||
|
||||
#ifndef __JSMN_CHANGED_H_
|
||||
#define __JSMN_CHANGED_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define JSMN_PARENT_LINKS
|
||||
#define JSMN_STRICT
|
||||
|
||||
/**
|
||||
* JSON type identifier. Basic types are:
|
||||
* o Object
|
||||
* o Array
|
||||
* o String
|
||||
* o Other primitive: number, boolean (true/false) or null
|
||||
*/
|
||||
typedef enum {
|
||||
JSMN_UNDEFINED = 0,
|
||||
JSMN_OBJECT = 1,
|
||||
JSMN_ARRAY = 2,
|
||||
JSMN_STRING = 3,
|
||||
JSMN_PRIMITIVE = 4
|
||||
} _jsmntype_t;
|
||||
|
||||
enum jsmnerr {
|
||||
/* Not enough tokens were provided */
|
||||
JSMN_ERROR_NOMEM = -1,
|
||||
/* Invalid character inside JSON string */
|
||||
JSMN_ERROR_INVAL = -2,
|
||||
/* The string is not a full JSON packet, more bytes expected */
|
||||
JSMN_ERROR_PART = -3
|
||||
};
|
||||
|
||||
/**
|
||||
* JSON token description.
|
||||
* @param type type (object, array, string etc.)
|
||||
* @param start start position in JSON data string
|
||||
* @param end end position in JSON data string
|
||||
*/
|
||||
typedef struct {
|
||||
_jsmntype_t type;
|
||||
int start;
|
||||
int end;
|
||||
int size;
|
||||
#ifdef JSMN_PARENT_LINKS
|
||||
int parent;
|
||||
#endif
|
||||
} _jsmntok_t;
|
||||
|
||||
/**
|
||||
* JSON parser. Contains an array of token blocks available. Also stores
|
||||
* the string being parsed now and current position in that string
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int pos; /* offset in the JSON string */
|
||||
unsigned int toknext; /* next token to allocate */
|
||||
int toksuper; /* superior token node, e.g parent object or array */
|
||||
} _jsmn_parser;
|
||||
|
||||
/**
|
||||
* Create JSON parser over an array of tokens
|
||||
*/
|
||||
void __jsmn_init(_jsmn_parser *parser);
|
||||
|
||||
/**
|
||||
* Run JSON parser. It parses a JSON data string into and array of tokens, each describing
|
||||
* a single JSON object.
|
||||
*/
|
||||
int __jsmn_parse(_jsmn_parser *parser, const char *js, size_t len,
|
||||
_jsmntok_t *tokens, unsigned int num_tokens);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __JSMN_CHANGED_H_ */
|
61
tools/sdk/esp32/include/json_parser/json_parser.h
Executable file
61
tools/sdk/esp32/include/json_parser/json_parser.h
Executable file
@ -0,0 +1,61 @@
|
||||
/* Code taken from: https://github.com/shahpiyushv/json_parser */
|
||||
#ifndef _JSON_PARSER_H_
|
||||
#define _JSON_PARSER_H_
|
||||
|
||||
#include <jsmn-changed.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define OS_SUCCESS 0
|
||||
#define OS_FAIL -1
|
||||
|
||||
typedef _jsmn_parser json_parser_t;
|
||||
typedef _jsmntok_t json_tok_t;
|
||||
|
||||
typedef struct {
|
||||
json_parser_t parser;
|
||||
char *js;
|
||||
json_tok_t *tokens;
|
||||
json_tok_t *cur;
|
||||
int num_tokens;
|
||||
} jparse_ctx_t;
|
||||
|
||||
int json_parse_start(jparse_ctx_t *jctx, char *js, int len);
|
||||
int json_parse_end(jparse_ctx_t *jctx);
|
||||
|
||||
int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem);
|
||||
int json_obj_leave_array(jparse_ctx_t *jctx);
|
||||
int json_obj_get_object(jparse_ctx_t *jctx, char *name);
|
||||
int json_obj_leave_object(jparse_ctx_t *jctx);
|
||||
int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val);
|
||||
int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val);
|
||||
int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val);
|
||||
int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val);
|
||||
int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size);
|
||||
int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen);
|
||||
int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size);
|
||||
int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen);
|
||||
int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size);
|
||||
int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen);
|
||||
|
||||
int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index);
|
||||
int json_arr_leave_array(jparse_ctx_t *jctx);
|
||||
int json_arr_get_object(jparse_ctx_t *jctx, uint32_t index);
|
||||
int json_arr_leave_object(jparse_ctx_t *jctx);
|
||||
int json_arr_get_bool(jparse_ctx_t *jctx, uint32_t index, bool *val);
|
||||
int json_arr_get_int(jparse_ctx_t *jctx, uint32_t index, int *val);
|
||||
int json_arr_get_int64(jparse_ctx_t *jctx, uint32_t index, int64_t *val);
|
||||
int json_arr_get_float(jparse_ctx_t *jctx, uint32_t index, float *val);
|
||||
int json_arr_get_string(jparse_ctx_t *jctx, uint32_t index, char *val, int size);
|
||||
int json_arr_get_strlen(jparse_ctx_t *jctx, uint32_t index, int *strlen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _JSON_PARSER_H_ */
|
40
tools/sdk/esp32/include/qrcode/include/qrcode.h
Normal file
40
tools/sdk/esp32/include/qrcode/include/qrcode.h
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Generate and display QR Code on the console
|
||||
* Encodes the given string into a QR Code & displays it on the console
|
||||
*
|
||||
* @attention 1. Can successfully encode a UTF-8 string of up to 2953 bytes or an alphanumeric
|
||||
* string of up to 4296 characters or any digit string of up to 7089 characters
|
||||
*
|
||||
* @param text string to encode into a QR Code.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_FAIL: Failed to encode string into a QR Code
|
||||
* - ESP_ERR_NO_MEM: Failed to allocate buffer for given MAX_QRCODE_VERSION
|
||||
*/
|
||||
esp_err_t qrcode_display(const char *text);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
126
tools/sdk/esp32/include/ws2812_led/led_strip.h
Normal file
126
tools/sdk/esp32/include/ws2812_led/led_strip.h
Normal file
@ -0,0 +1,126 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* @brief LED Strip Type
|
||||
*
|
||||
*/
|
||||
typedef struct led_strip_s led_strip_t;
|
||||
|
||||
/**
|
||||
* @brief LED Strip Device Type
|
||||
*
|
||||
*/
|
||||
typedef void *led_strip_dev_t;
|
||||
|
||||
/**
|
||||
* @brief Declare of LED Strip Type
|
||||
*
|
||||
*/
|
||||
struct led_strip_s {
|
||||
/**
|
||||
* @brief Set RGB for a specific pixel
|
||||
*
|
||||
* @param strip: LED strip
|
||||
* @param index: index of pixel to set
|
||||
* @param red: red part of color
|
||||
* @param green: green part of color
|
||||
* @param blue: blue part of color
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Set RGB for a specific pixel successfully
|
||||
* - ESP_ERR_INVALID_ARG: Set RGB for a specific pixel failed because of invalid parameters
|
||||
* - ESP_FAIL: Set RGB for a specific pixel failed because other error occurred
|
||||
*/
|
||||
esp_err_t (*set_pixel)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue);
|
||||
|
||||
/**
|
||||
* @brief Refresh memory colors to LEDs
|
||||
*
|
||||
* @param strip: LED strip
|
||||
* @param timeout_ms: timeout value for refreshing task
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Refresh successfully
|
||||
* - ESP_ERR_TIMEOUT: Refresh failed because of timeout
|
||||
* - ESP_FAIL: Refresh failed because some other error occurred
|
||||
*
|
||||
* @note:
|
||||
* After updating the LED colors in the memory, a following invocation of this API is needed to flush colors to strip.
|
||||
*/
|
||||
esp_err_t (*refresh)(led_strip_t *strip, uint32_t timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Clear LED strip (turn off all LEDs)
|
||||
*
|
||||
* @param strip: LED strip
|
||||
* @param timeout_ms: timeout value for clearing task
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Clear LEDs successfully
|
||||
* - ESP_ERR_TIMEOUT: Clear LEDs failed because of timeout
|
||||
* - ESP_FAIL: Clear LEDs failed because some other error occurred
|
||||
*/
|
||||
esp_err_t (*clear)(led_strip_t *strip, uint32_t timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Free LED strip resources
|
||||
*
|
||||
* @param strip: LED strip
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Free resources successfully
|
||||
* - ESP_FAIL: Free resources failed because error occurred
|
||||
*/
|
||||
esp_err_t (*del)(led_strip_t *strip);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief LED Strip Configuration Type
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t max_leds; /*!< Maximum LEDs in a single strip */
|
||||
led_strip_dev_t dev; /*!< LED strip device (e.g. RMT channel, PWM channel, etc) */
|
||||
} led_strip_config_t;
|
||||
|
||||
/**
|
||||
* @brief Default configuration for LED strip
|
||||
*
|
||||
*/
|
||||
#define LED_STRIP_DEFAULT_CONFIG(number, dev_hdl) \
|
||||
{ \
|
||||
.max_leds = number, \
|
||||
.dev = dev_hdl, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Install a new ws2812 driver (based on RMT peripheral)
|
||||
*
|
||||
* @param config: LED strip configuration
|
||||
* @return
|
||||
* LED strip instance or NULL
|
||||
*/
|
||||
led_strip_t *led_strip_new_rmt_ws2812(const led_strip_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
44
tools/sdk/esp32/include/ws2812_led/ws2812_led.h
Normal file
44
tools/sdk/esp32/include/ws2812_led/ws2812_led.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#pragma once
|
||||
#include <esp_err.h>
|
||||
|
||||
/** Initialize the WS2812 RGB LED
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t ws2812_led_init(void);
|
||||
|
||||
/** Set RGB value for the WS2812 LED
|
||||
*
|
||||
* @param[in] red Intensity of Red color (0-100)
|
||||
* @param[in] green Intensity of Green color (0-100)
|
||||
* @param[in] blue Intensity of Green color (0-100)
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t ws2812_led_set_rgb(uint32_t red, uint32_t green, uint32_t blue);
|
||||
|
||||
/** Set HSV value for the WS2812 LED
|
||||
*
|
||||
* @param[in] hue Value of hue in arc degrees (0-360)
|
||||
* @param[in] saturation Saturation in percentage (0-100)
|
||||
* @param[in] value Value (also called Intensity) in percentage (0-100)
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t ws2812_led_set_hsv(uint32_t hue, uint32_t saturation, uint32_t value);
|
||||
|
||||
/** Clear (turn off) the WS2812 LED
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t ws2812_led_clear(void);
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32/lib/libbutton.a
Normal file
BIN
tools/sdk/esp32/lib/libbutton.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32/lib/libesp_rainmaker.a
Normal file
BIN
tools/sdk/esp32/lib/libesp_rainmaker.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32/lib/libesp_schedule.a
Normal file
BIN
tools/sdk/esp32/lib/libesp_schedule.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32/lib/libjson_generator.a
Normal file
BIN
tools/sdk/esp32/lib/libjson_generator.a
Normal file
Binary file not shown.
BIN
tools/sdk/esp32/lib/libjson_parser.a
Normal file
BIN
tools/sdk/esp32/lib/libjson_parser.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32/lib/libqrcode.a
Normal file
BIN
tools/sdk/esp32/lib/libqrcode.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user