Esp32 s3 support (#6341)

Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com>
Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com>
Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com>
Co-authored-by: Ivan Grokhotkov <ivan@espressif.com>
Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
This commit is contained in:
Me No Dev
2022-03-28 12:09:41 +03:00
committed by GitHub
parent 3f79097d5f
commit 8ee5f0a11e
3774 changed files with 685773 additions and 19284 deletions

View File

@ -24,10 +24,13 @@ extern "C"
#define ESP_RMAKER_CONFIG_VERSION "2020-03-20"
#define MAX_VERSION_STRING_LEN 16
/* Maximum length of the alert message that can be passed to esp_rmaker_raise_alert() */
#define ESP_RMAKER_MAX_ALERT_LEN 100
/** @cond **/
/** ESP RainMaker Event Base */
ESP_EVENT_DECLARE_BASE(RMAKER_EVENT);
/** @endcond **/
/** ESP RainMaker Events */
typedef enum {
@ -39,14 +42,15 @@ typedef enum {
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
/** Node side communication for User-Node mapping done.
* Actual mapping state will be managed by the ESP RainMaker cloud based on the user side communication.
* Associated data is the NULL terminated user id.
*/
RMAKER_EVENT_USER_NODE_MAPPING_DONE,
/** Local control started. Associated data is the NULL terminated Service Name */
RMAKER_EVENT_LOCAL_CTRL_STARTED,
/* User reset request successfully sent to ESP RainMaker Cloud */
RMAKER_EVENT_USER_NODE_MAPPING_RESET,
} esp_rmaker_event_t;
/** ESP RainMaker Node information */
@ -116,6 +120,18 @@ typedef enum {
PROP_FLAG_PERSIST = (1 << 3)
} esp_param_property_flags_t;
/** System Service Reboot Flag */
#define SYSTEM_SERV_FLAG_REBOOT (1 << 0)
/** System Service Factory Reset Flag */
#define SYSTEM_SERV_FLAG_FACTORY_RESET (1 << 1)
/** System Service Wi-Fi Reset Flag */
#define SYSTEM_SERV_FLAG_WIFI_RESET (1 << 2)
/** System Service All Flags */
#define SYSTEM_SERV_FLAGS_ALL (SYSTEM_SERV_FLAG_REBOOT | SYSTEM_SERV_FLAG_FACTORY_RESET | SYSTEM_SERV_FLAG_WIFI_RESET)
/** Generic ESP RainMaker handle */
typedef size_t esp_rmaker_handle_t;
@ -138,6 +154,12 @@ typedef enum {
ESP_RMAKER_REQ_SRC_CLOUD,
/** Request received when a schedule has triggered */
ESP_RMAKER_REQ_SRC_SCHEDULE,
/** Request received from a local controller */
ESP_RMAKER_REQ_SRC_LOCAL,
/** This will always be the last value. Any value equal to or
* greater than this should be considered invalid.
*/
ESP_RMAKER_REQ_SRC_MAX,
} esp_rmaker_req_src_t;
/** Write request Context */
@ -152,6 +174,32 @@ typedef struct {
esp_rmaker_req_src_t src;
} esp_rmaker_read_ctx_t;
/** System service configuration */
typedef struct {
/** Logical OR of system service flags (SYSTEM_SERV_FLAG_REBOOT,
* SYSTEM_SERV_FLAG_FACTORY_RESET, SYSTEM_SERV_FLAG_WIFI_RESET) as required
* or SYSTEM_SERV_FLAGS_ALL.
*/
uint16_t flags;
/** Time in seconds after which the device should reboot.
* Value of zero would trigger an immediate reboot if a write is received for
* the Reboot parameter.
* Recommended value: 2
*/
int8_t reboot_seconds;
/** Time in seconds after which the device should reset (Wi-Fi or factory).
* Value of zero would trigger an immediate action if a write is received for
* the Wi-Fi reset or Factory reset parameter.
* Recommended value: 2
*/
int8_t reset_seconds;
/** Time in seconds after which the device should reboot after it has been reset.
* Value of zero would mean that there won't be any reboot after the reset.
* Recommended value: 2
*/
int8_t reset_reboot_seconds;
} esp_rmaker_system_serv_config_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
@ -188,6 +236,28 @@ typedef esp_err_t (*esp_rmaker_device_write_cb_t)(const esp_rmaker_device_t *dev
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);
/** Convert device callback source to string
*
* Device read/write callback can be via different sources. This is a helper API
* to give the source in string format for printing.
*
* Example Usage:
* @code{c}
* static esp_err_t write_cb(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)
{
if (ctx) {
ESP_LOGI(TAG, "Received write request via : %s", esp_rmaker_device_cb_src_to_str(ctx->src));
}
* @endcode
*
* @param[in] src The src field as received in the callback context.
*
* @return NULL terminated source string on success
* @return NULL on failure
*/
const char *esp_rmaker_device_cb_src_to_str(esp_rmaker_req_src_t src);
/**
* Initialise a Boolean value
*
@ -311,7 +381,7 @@ esp_err_t esp_rmaker_node_deinit(const esp_rmaker_node_t *node);
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.
@ -458,12 +528,24 @@ esp_err_t esp_rmaker_node_add_device(const esp_rmaker_node_t *node, const esp_rm
*/
esp_err_t esp_rmaker_node_remove_device(const esp_rmaker_node_t *node, const esp_rmaker_device_t *device);
/** Get device by name
*
* Get handle for a device based on the name.
*
* @param[in] node Node handle.
* @param[in] device_name Device name to search.
*
* @return Device handle on success.
* @return NULL in case of failure.
*/
esp_rmaker_device_t *esp_rmaker_node_get_device_by_name(const esp_rmaker_node_t *node, const char *device_name);
/** 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.
@ -473,6 +555,19 @@ esp_err_t esp_rmaker_node_remove_device(const esp_rmaker_node_t *node, const esp
*/
esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, const char *attr_name, const char *val);
/** Add a Device subtype
*
* This can be something like esp.subtype.rgb-light for a device of type esp.device.lightbulb.
* This would primarily be used by the phone apps to render different icons for the same device type.
*
* @param[in] device Device handle.
* @param[in] subtype String describing the sub type.
*
* @return ESP_OK if the subtype was added successfully.
* @return error in case of failure.
*/
esp_err_t esp_rmaker_device_add_subtype(const esp_rmaker_device_t *device, const char *subtype);
/** Get device name from handle
*
* @param[in] device Device handle.
@ -489,7 +584,7 @@ char *esp_rmaker_device_get_name(const esp_rmaker_device_t *device);
* @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);
char *esp_rmaker_device_get_type(const esp_rmaker_device_t *device);
/**
* Add a parameter to a device/service
@ -638,6 +733,30 @@ esp_err_t esp_rmaker_param_add_valid_str_list(const esp_rmaker_param_t *param, c
*/
esp_err_t esp_rmaker_param_add_array_max_count(const esp_rmaker_param_t *param, int count);
/* Update a parameter
*
* This will just update the value of a parameter with esp rainmaker core, without actually reporting
* it. This can be used when multiple parameters need to be reported together.
* Eg. If x parameters are to be reported, this API can be used for the first x -1 parameters
* and the last one can be updated using esp_rmaker_param_update_and_report().
* This will report all parameters which were updated prior to this call.
*
* Sample:
*
* esp_rmaker_param_update(param1, esp_rmaker_float(10.2));
* esp_rmaker_param_update(param2, esp_rmaker_int(55));
* esp_rmaker_param_update(param3, esp_rmaker_int(95));
* esp_rmaker_param_update_and_report(param1, esp_rmaker_bool(true));
*
* @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(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val);
/** Update and report a parameter
*
* Calling this API will update the parameter and report it to ESP RainMaker cloud.
@ -651,6 +770,46 @@ esp_err_t esp_rmaker_param_add_array_max_count(const esp_rmaker_param_t *param,
*/
esp_err_t esp_rmaker_param_update_and_report(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val);
/** Update and notify a parameter
*
* Calling this API will update the parameter and report it to ESP RainMaker cloud similar to
* esp_rmaker_param_update_and_report(). However, additionally, it will also trigger a notification
* on the phone apps (if enabled).
*
* @note This should be used only when some local change requires explicit notification even when the
* phone app is in background, not otherwise.
* Eg. Alarm got triggered, temperature exceeded some threshold, etc.
*
* Alternatively, the esp_rmaker_raise_alert() API can also be used to trigger notification
* on the phone apps with pre-formatted text.
*
* @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_notify(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val);
/** Trigger an alert on the phone app
*
* This API will trigger a notification alert on the phone apps (if enabled) using the formatted text
* provided. Note that this does not send a notification directly to the phone, but reports the alert
* to the ESP RainMaker cloud which then uses the Notification framework to send notifications to the
* phone apps. The value does not get stored anywhere, nor is it linked to any node parameters.
*
* @note This should be used only if some event requires explicitly alerting the user even when the
* phone app is in background, not otherwise.
* Eg. "Motion Detected", "Fire alarm triggered"
*
* @param[in] alert_str NULL terminated pre-formatted alert string.
* Maximum length can be ESP_RMAKER_MAX_ALERT_LEN, excluding NULL character.
*
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t esp_rmaker_raise_alert(const char *alert_str);
/** Get parameter name from handle
*
* @param[in] param Parameter handle.
@ -669,11 +828,18 @@ char *esp_rmaker_param_get_name(const esp_rmaker_param_t *param);
*/
char *esp_rmaker_param_get_type(const esp_rmaker_param_t *param);
/** Prototype for ESP RainMaker Work Queue Function
/** Get parameter value
*
* @param[in] priv_data The private data associated with the work function.
* This gives the parameter value that is stored in the RainMaker core.
*
* @note This does not call any explicit functions to read value from hardware/driver.
*
* @param[in] param Parameter handle
*
* @return Pointer to parameter value on success.
* @return NULL in case of failure.
*/
typedef void (*esp_rmaker_work_fn_t)(void *priv_data);
esp_rmaker_param_val_t *esp_rmaker_param_get_val(esp_rmaker_param_t *param);
/** Report the node details to the cloud
*
@ -689,17 +855,38 @@ typedef void (*esp_rmaker_work_fn_t)(void *priv_data);
*/
esp_err_t esp_rmaker_report_node_details(void);
/** Queue execution of a function in ESP RainMaker's context
/** Enable Timezone Service
*
* This API queues a work function for execution in the ESP RainMaker Task's context.
* 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.
*
* @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.
* @return ESP_OK on success
* @return error on failure
*/
esp_err_t esp_rmaker_queue_work(esp_rmaker_work_fn_t work_fn, void *priv_data);
esp_err_t esp_rmaker_timezone_service_enable(void);
/** Enable System Service
*
* This enables the ESP RainMaker standard system service which can be
* used for operations like reboot, factory reset and Wi-Fi reset.
*
* Please refer the specifications for additional details.
*
* @param[in] config Configuration for the system service.
*
* @return ESP_OK on success
* @return error on failure
*/
esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *config);
/**
* Check if local_ctrl service has started
*
* @return true if service has started
* @return false if the service has not started
*/
bool esp_rmaker_local_ctrl_service_started(void);
#ifdef __cplusplus
}

View File

@ -14,34 +14,14 @@
#pragma once
#include <stdint.h>
#include <esp_err.h>
#include <esp_rmaker_mqtt_glue.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);
esp_rmaker_mqtt_conn_params_t *esp_rmaker_mqtt_get_conn_params(void);
/** Initialize ESP RainMaker MQTT
*
@ -50,7 +30,7 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t) (const char *topic, void *payload
* @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);
esp_err_t esp_rmaker_mqtt_init(esp_rmaker_mqtt_conn_params_t *conn_params);
/** MQTT Connect
*
@ -77,22 +57,24 @@ esp_err_t esp_rmaker_mqtt_disconnect(void);
* @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
* @param[in] qos Quality of Service for the Publish. Can be 0, 1 or 2. Also depends on what the MQTT broker supports.
*
* @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);
esp_err_t esp_rmaker_mqtt_publish(const char *topic, void *data, size_t data_len, uint8_t qos, int *msg_id);
/** 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
* @param[in] qos Quality of Service for the Subscription. Can be 0, 1 or 2. Also depends on what the MQTT broker supports.
*
* @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);
esp_err_t esp_rmaker_mqtt_subscribe(const char *topic, esp_rmaker_mqtt_subscribe_cb_t cb, uint8_t qos, void *priv_data);
/** Unsubscribe from MQTT topic
*
@ -102,7 +84,7 @@ esp_err_t esp_rmaker_mqtt_subscribe(const char *topic, esp_rmaker_mqtt_subscribe
* @return error in case of any error.
*/
esp_err_t esp_rmaker_mqtt_unsubscribe(const char *topic);
esp_err_t esp_rmaker_mqtt_setup(esp_rmaker_mqtt_config_t mqtt_config);
#ifdef __cplusplus
}
#endif

View File

@ -104,7 +104,7 @@ typedef struct {
* 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`.
* `ESP_RMAKER_OTA_DEFAULT_SERVER_CERT`.
*/
const char *server_cert;
/** Private Data.

View File

@ -26,6 +26,8 @@ extern "C"
*
* 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
*
* @note This API should be called after esp_rmaker_node_init() but before esp_rmaker_start().
*
* @return ESP_OK on success.
* @return error in case of failure.
*/

View File

@ -45,6 +45,11 @@ extern "C"
#define ESP_RMAKER_DEF_TIMEZONE_NAME "TZ"
#define ESP_RMAKER_DEF_TIMEZONE_POSIX_NAME "TZ-POSIX"
#define ESP_RMAKER_DEF_SCHEDULE_NAME "Schedules"
#define ESP_RMAKER_DEF_REBOOT_NAME "Reboot"
#define ESP_RMAKER_DEF_FACTORY_RESET_NAME "Factory-Reset"
#define ESP_RMAKER_DEF_WIFI_RESET_NAME "Wi-Fi-Reset"
#define ESP_RMAKER_DEF_LOCAL_CONTROL_POP "POP"
#define ESP_RMAKER_DEF_LOCAL_CONTROL_TYPE "Type"
/**
* Create standard name param
@ -247,7 +252,7 @@ esp_rmaker_param_t *esp_rmaker_timezone_param_create(const char *param_name, con
esp_rmaker_param_t *esp_rmaker_timezone_posix_param_create(const char *param_name, const char *val);
/**
* Create standard schedules param
* Create standard Schedules param
*
* This will create the standard schedules parameter. Default value
* is set internally.
@ -260,6 +265,71 @@ esp_rmaker_param_t *esp_rmaker_timezone_posix_param_create(const char *param_nam
*/
esp_rmaker_param_t *esp_rmaker_schedules_param_create(const char *param_name, int max_schedules);
/**
* Create standard Reboot param
*
* This will create the standard reboot parameter.
* Set value to true (via write param) for the action to trigger.
*
* @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_reboot_param_create(const char *param_name);
/**
* Create standard Factory Reset param
*
* This will create the standard factory reset parameter.
* Set value to true (via write param) for the action to trigger.
*
* @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_factory_reset_param_create(const char *param_name);
/**
* Create standard Wi-Fi Reset param
*
* This will create the standard Wi-Fi Reset parameter.
* Set value to true (via write param) for the action to trigger.
*
* @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_wifi_reset_param_create(const char *param_name);
/**
* Create standard Local Control POP param
*
* This will create the standard Local Control POP parameter.
*
* @param[in] param_name Name of the parameter
* @param[in] val Default Value of the parameter (Eg. "abcd1234"). Can be kept NULL.
*
* @return Parameter handle on success.
* @return NULL in case of failures.
*/
esp_rmaker_param_t *esp_rmaker_local_control_pop_param_create(const char *param_name, const char *val);
/**
* Create standard Local Control Type param
*
* This will create the standard Local Control security type 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_local_control_type_param_create(const char *param_name, int val);
#ifdef __cplusplus
}
#endif

View File

@ -71,6 +71,36 @@ esp_rmaker_device_t *esp_rmaker_time_service_create(const char *serv_name, const
*/
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);
/** Create a standard System service
*
* This creates an empty System service. Appropriate parameters should be added by the caller.
*
* @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_create_system_service(const char *serv_name, void *priv_data);
/** Create a standard Local Control service
*
* This creates a Local Control 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] pop Proof of possession
* @param[in] sec_type Security type
* @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_local_control_service(const char *serv_name, const char *pop, int sec_type, void *priv_data);
#ifdef __cplusplus
}
#endif

View File

@ -24,7 +24,7 @@ extern "C"
#define ESP_RMAKER_UI_SLIDER "esp.ui.slider"
#define ESP_RMAKER_UI_DROPDOWN "esp.ui.dropdown"
#define ESP_RMAKER_UI_TEXT "esp.ui.text"
#define ESP_RMAKER_UI_HUE_SLIDER "esp.ui.hue-slider"
/********** STANDARD PARAM TYPES **********/
@ -44,6 +44,11 @@ extern "C"
#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"
#define ESP_RMAKER_PARAM_REBOOT "esp.param.reboot"
#define ESP_RMAKER_PARAM_FACTORY_RESET "esp.param.factory-reset"
#define ESP_RMAKER_PARAM_WIFI_RESET "esp.param.wifi-reset"
#define ESP_RMAKER_PARAM_LOCAL_CONTROL_POP "esp.param.local_control_pop"
#define ESP_RMAKER_PARAM_LOCAL_CONTROL_TYPE "esp.param.local_control_type"
/********** STANDARD DEVICE TYPES **********/
@ -58,6 +63,8 @@ extern "C"
#define ESP_RMAKER_SERVICE_OTA "esp.service.ota"
#define ESP_RMAKER_SERVICE_TIME "esp.service.time"
#define ESP_RMAKER_SERVICE_SCHEDULE "esp.service.schedule"
#define ESP_RMAKER_SERVICE_SYSTEM "esp.service.system"
#define ESP_RMAKER_SERVICE_LOCAL_CONTROL "esp.service.local_control"
#ifdef __cplusplus
}

View File

@ -19,6 +19,25 @@ extern "C"
{
#endif
/** User-Node Mapping states */
typedef enum {
/** Mapping does not exist or is not initialized */
ESP_RMAKER_USER_MAPPING_RESET = 0,
/** Mapping has started */
ESP_RMAKER_USER_MAPPING_STARTED,
/** Mapping is done */
ESP_RMAKER_USER_MAPPING_DONE,
} esp_rmaker_user_mapping_state_t;
/**
* Get User-Node mapping state
*
* This returns the current user-node mapping state.
*
* @return user mapping state
*/
esp_rmaker_user_mapping_state_t esp_rmaker_user_node_mapping_get_state(void);
/**
* Create User Mapping Endpoint
*

View File

@ -1,174 +0,0 @@
// 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