Initial commit.
Some checks failed
Sync remain PRs to Jira / Sync PRs to Jira (push) Has been cancelled
Some checks failed
Sync remain PRs to Jira / Sync PRs to Jira (push) Has been cancelled
This commit is contained in:
52
components/esp_rainmaker/include/esp_rmaker_console.h
Normal file
52
components/esp_rainmaker/include/esp_rmaker_console.h
Normal file
@@ -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
|
||||
1068
components/esp_rainmaker/include/esp_rmaker_core.h
Normal file
1068
components/esp_rainmaker/include/esp_rmaker_core.h
Normal file
File diff suppressed because it is too large
Load Diff
125
components/esp_rainmaker/include/esp_rmaker_mqtt.h
Normal file
125
components/esp_rainmaker/include/esp_rmaker_mqtt.h
Normal file
@@ -0,0 +1,125 @@
|
||||
// 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>
|
||||
#include <esp_rmaker_mqtt_glue.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
esp_rmaker_mqtt_conn_params_t *esp_rmaker_mqtt_get_conn_params(void);
|
||||
|
||||
/** Initialize ESP RainMaker MQTT
|
||||
*
|
||||
* @param[in] conn_params 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_conn_params_t *conn_params);
|
||||
|
||||
/* Deinitialize ESP RainMaker MQTT
|
||||
*
|
||||
* Call this function after MQTT has disconnected.
|
||||
*/
|
||||
void esp_rmaker_mqtt_deinit(void);
|
||||
|
||||
/** 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
|
||||
* @param[in] qos Quality of Service for the Publish. Can be 0, 1 or 2. Also depends on what the MQTT broker supports.
|
||||
* @param[out] msg_id msg_id for tracking if message is queued
|
||||
*
|
||||
* @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, 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, uint8_t qos, 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);
|
||||
esp_err_t esp_rmaker_mqtt_setup(esp_rmaker_mqtt_config_t mqtt_config);
|
||||
|
||||
/** Creates appropriate MQTT Topic String based on CONFIG_ESP_RMAKER_MQTT_USE_BASIC_INGEST_TOPICS
|
||||
* @param[out] buf Buffer to hold topic string
|
||||
* @param[in] buf_size Size of buffer
|
||||
* @param[in] topic_suffix MQTT Topic suffix
|
||||
* @param[in] rule Basic Ingests Rule Name
|
||||
*/
|
||||
void esp_rmaker_create_mqtt_topic(char *buf, size_t buf_size, const char *topic_suffix, const char *rule);
|
||||
|
||||
/**
|
||||
* @brief Check if budget is available to publish an mqtt message
|
||||
*
|
||||
* @return true if budget is available
|
||||
* @return false if budget is exhausted
|
||||
*
|
||||
* @note `esp_rmaker_mqtt_publish` API already does this check. In addition to that,
|
||||
* some use-cases might still need to check for this.
|
||||
*/
|
||||
bool esp_rmaker_mqtt_is_budget_available(void);
|
||||
|
||||
/**
|
||||
* @brief Check if device is connected to MQTT Server
|
||||
*
|
||||
* @return true if device is connected
|
||||
* @return false if device is not connected
|
||||
*
|
||||
*/
|
||||
bool esp_rmaker_is_mqtt_connected();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
272
components/esp_rainmaker/include/esp_rmaker_ota.h
Normal file
272
components/esp_rainmaker/include/esp_rmaker_ota.h
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** @cond **/
|
||||
/** ESP RainMaker Event Base */
|
||||
ESP_EVENT_DECLARE_BASE(RMAKER_OTA_EVENT);
|
||||
/** @endcond **/
|
||||
|
||||
/** ESP RainMaker Events */
|
||||
typedef enum {
|
||||
/* Invalid event. Used for internal handling only */
|
||||
RMAKER_OTA_EVENT_INVALID = 0,
|
||||
/** RainMaker OTA is Starting */
|
||||
RMAKER_OTA_EVENT_STARTING,
|
||||
/** RainMaker OTA has Started */
|
||||
RMAKER_OTA_EVENT_IN_PROGRESS,
|
||||
/** RainMaker OTA Successful */
|
||||
RMAKER_OTA_EVENT_SUCCESSFUL,
|
||||
/** RainMaker OTA Failed */
|
||||
RMAKER_OTA_EVENT_FAILED,
|
||||
/** RainMaker OTA Rejected */
|
||||
RMAKER_OTA_EVENT_REJECTED,
|
||||
/** RainMaker OTA Delayed */
|
||||
RMAKER_OTA_EVENT_DELAYED,
|
||||
/** OTA Image has been flashed and active partition changed. Reboot is requested. Applicable only if Auto reboot is disabled **/
|
||||
RMAKER_OTA_EVENT_REQ_FOR_REBOOT,
|
||||
} esp_rmaker_ota_event_t;
|
||||
|
||||
/** 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 rejected due to some reason (wrong project, version, etc.) */
|
||||
OTA_STATUS_REJECTED,
|
||||
} 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 firmware version of the OTA image **/
|
||||
char *fw_version;
|
||||
/** The OTA Job ID received from cloud **/
|
||||
char *ota_job_id;
|
||||
/** The server certificate passed in esp_rmaker_enable_ota() */
|
||||
const char *server_cert;
|
||||
/** The private data passed in esp_rmaker_enable_ota() */
|
||||
char *priv;
|
||||
/** OTA Metadata. Applicable only for OTA using Topics. Will be received (if applicable) from the backend, along with the OTA URL */
|
||||
char *metadata;
|
||||
} 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);
|
||||
|
||||
typedef enum {
|
||||
/** OTA Diagnostics Failed. Rollback the firmware. */
|
||||
OTA_DIAG_STATUS_FAIL,
|
||||
/** OTA Diagnostics Pending. Additional validations will be done later. */
|
||||
OTA_DIAG_STATUS_PENDING,
|
||||
/** OTA Diagnostics Succeeded. Firmware can be considered valid. */
|
||||
OTA_DIAG_STATUS_SUCCESS
|
||||
} esp_rmaker_ota_diag_status_t;
|
||||
|
||||
typedef enum {
|
||||
/** OTA State: Initialised. */
|
||||
OTA_DIAG_STATE_INIT,
|
||||
/** OTA state: MQTT has connected. */
|
||||
OTA_DIAG_STATE_POST_MQTT
|
||||
} esp_rmaker_ota_diag_state_t;
|
||||
|
||||
typedef struct {
|
||||
/** OTA diagnostic state */
|
||||
esp_rmaker_ota_diag_state_t state;
|
||||
/** Flag to indicate whether the OTA which has triggered the Diagnostics checks for rollback
|
||||
* was triggered via RainMaker or not. This would be useful only when your application has some
|
||||
* other mechanism for OTA too.
|
||||
*/
|
||||
bool rmaker_ota;
|
||||
} esp_rmaker_ota_diag_priv_t;
|
||||
|
||||
/** 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.
|
||||
*
|
||||
* This will be invoked once again after MQTT has connected, in case some additional validations
|
||||
* are to be done later.
|
||||
*
|
||||
* If OTA state == OTA_DIAG_STATE_INIT, then
|
||||
* return OTA_DIAG_STATUS_FAIL to indicate failure and rollback.
|
||||
* return OTA_DIAG_STATUS_SUCCESS or OTA_DIAG_STATUS_PENDING to tell internal OTA logic to continue further.
|
||||
*
|
||||
* If OTA state == OTA_DIAG_STATE_POST_MQTT, then
|
||||
* return OTA_DIAG_STATUS_FAIL to indicate failure and rollback.
|
||||
* return OTA_DIAG_STATUS_SUCCESS to indicate validation was successful and mark OTA as valid
|
||||
* return OTA_DIAG_STATUS_PENDING to indicate that some additional validations will be done later
|
||||
* and the OTA will eventually be marked valid/invalid using esp_rmaker_ota_mark_valid() or
|
||||
* esp_rmaker_ota_mark_invalid() respectively.
|
||||
*
|
||||
* @return esp_rmaker_ota_diag_status_t as applicable
|
||||
*/
|
||||
typedef esp_rmaker_ota_diag_status_t (*esp_rmaker_post_ota_diag_t)(esp_rmaker_ota_diag_priv_t *ota_diag_priv, void *priv);
|
||||
|
||||
/** 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_OTA_DEFAULT_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);
|
||||
|
||||
/** Default OTA callback
|
||||
*
|
||||
* This is the default OTA callback which will get used if you do not pass your own callback. You can call this
|
||||
* even from your callback, in case you want better control on when the OTA can proceed and yet let the actual
|
||||
* OTA process be managed by the RainMaker Core.
|
||||
*
|
||||
* @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.
|
||||
* */
|
||||
esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t handle, esp_rmaker_ota_data_t *ota_data);
|
||||
|
||||
/** Fetch OTA Info
|
||||
*
|
||||
* For OTA using Topics, this API can be used to explicitly ask the backend if an OTA is available.
|
||||
* If it is, then the OTA callback would get invoked.
|
||||
*
|
||||
* @return ESP_OK if the OTA fetch publish message was successful.
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_ota_fetch(void);
|
||||
|
||||
/** Fetch OTA Info with a delay
|
||||
*
|
||||
* For OTA using Topics, this API can be used to explicitly ask the backend if an OTA is available
|
||||
* after a delay (in seconds) passed as an argument.
|
||||
*
|
||||
* @param[in] time Delay (in seconds)
|
||||
*
|
||||
* @return ESP_OK if the OTA fetch timer was created.
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_ota_fetch_with_delay(int time);
|
||||
|
||||
/** Mark OTA as valid
|
||||
*
|
||||
* This should be called if the OTA validation has been kept pending by returning OTA_DIAG_STATUS_PENDING
|
||||
* in the ota_diag callback and then, the validation was eventually successful. This can also be used to mark
|
||||
* the OTA valid even before RainMaker core does its own validations (primarily MQTT connection).
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_ota_mark_valid(void);
|
||||
|
||||
/** Mark OTA as invalid
|
||||
*
|
||||
* This should be called if the OTA validation has been kept pending by returning OTA_DIAG_STATUS_PENDING
|
||||
* in the ota_diag callback and then, the validation eventually failed. This can even be used to rollback
|
||||
* at any point of time before RainMaker core's internal logic and the application's logic mark the OTA
|
||||
* as valid.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_ota_mark_invalid(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
38
components/esp_rainmaker/include/esp_rmaker_scenes.h
Normal file
38
components/esp_rainmaker/include/esp_rmaker_scenes.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright 2022 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>
|
||||
|
||||
/** Enable Scenes
|
||||
*
|
||||
* This API enables the scenes service for the node. For more information,
|
||||
* check [here](https://rainmaker.espressif.com/docs/scenes.html)
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
esp_err_t esp_rmaker_scenes_enable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
38
components/esp_rainmaker/include/esp_rmaker_schedule.h
Normal file
38
components/esp_rainmaker/include/esp_rmaker_schedule.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
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
|
||||
352
components/esp_rainmaker/include/esp_rmaker_standard_params.h
Normal file
352
components/esp_rainmaker/include/esp_rmaker_standard_params.h
Normal file
@@ -0,0 +1,352 @@
|
||||
// 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"
|
||||
#define ESP_RMAKER_DEF_SCENES_NAME "Scenes"
|
||||
#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"
|
||||
#define ESP_RMAKER_DEF_ADD_ZIGBEE_DEVICE "Add_zigbee_device"
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param[in] val The device name
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Create standard Scenes param
|
||||
*
|
||||
* This will create the standard scenes parameter. Default value
|
||||
* is set internally.
|
||||
*
|
||||
* @param[in] param_name Name of the parameter
|
||||
* @param[in] max_scenes Maximum number of scenes allowed
|
||||
*
|
||||
* @return Parameter handle on success.
|
||||
* @return NULL in case of failures.
|
||||
*/
|
||||
esp_rmaker_param_t *esp_rmaker_scenes_param_create(const char *param_name, int max_scenes);
|
||||
|
||||
/**
|
||||
* 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
|
||||
124
components/esp_rainmaker/include/esp_rmaker_standard_services.h
Normal file
124
components/esp_rainmaker/include/esp_rmaker_standard_services.h
Normal file
@@ -0,0 +1,124 @@
|
||||
// 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 Time service
|
||||
*
|
||||
* This creates a Time 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);
|
||||
|
||||
/** Create a standard Scenes service
|
||||
*
|
||||
* This creates a Scenes 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_scenes Maximum number of scenes supported.
|
||||
* @param[in] deactivation_support Deactivation callback support.
|
||||
* @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_scenes_service(const char *serv_name, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb, int max_scenes, bool deactivation_support, 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
|
||||
102
components/esp_rainmaker/include/esp_rmaker_standard_types.h
Normal file
102
components/esp_rainmaker/include/esp_rmaker_standard_types.h
Normal file
@@ -0,0 +1,102 @@
|
||||
// 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"
|
||||
#define ESP_RMAKER_UI_HUE_SLIDER "esp.ui.hue-slider"
|
||||
#define ESP_RMAKER_UI_HUE_CIRCLE "esp.ui.hue-circle"
|
||||
#define ESP_RMAKER_UI_PUSHBUTTON "esp.ui.push-btn-big"
|
||||
#define ESP_RMAKER_UI_TRIGGER "esp.ui.trigger"
|
||||
#define ESP_RMAKER_UI_HIDDEN "esp.ui.hidden"
|
||||
#define ESP_RMAKER_UI_QR_SCAN "esp.ui.qr-scan"
|
||||
|
||||
/********** 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"
|
||||
#define ESP_RMAKER_PARAM_SCENES "esp.param.scenes"
|
||||
#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"
|
||||
#define ESP_RMAKER_PARAM_TOGGLE "esp.param.toggle"
|
||||
#define ESP_RMAKER_PARAM_RANGE "esp.param.range"
|
||||
#define ESP_RMAKER_PARAM_MODE "esp.param.mode"
|
||||
#define ESP_RMAKER_PARAM_BLINDS_POSITION "esp.param.blinds-position"
|
||||
#define ESP_RMAKER_PARAM_GARAGE_POSITION "esp.param.garage-position"
|
||||
#define ESP_RMAKER_PARAM_LIGHT_MODE "esp.param.light-mode"
|
||||
#define ESP_RMAKER_PARAM_AC_MODE "esp.param.ac-mode"
|
||||
#define ESP_RMAKER_PARAM_ADD_ZIGBEE_DEVICE "esp.param.add_zigbee_device"
|
||||
|
||||
|
||||
/********** 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"
|
||||
#define ESP_RMAKER_DEVICE_LIGHT "esp.device.light"
|
||||
#define ESP_RMAKER_DEVICE_OUTLET "esp.device.outlet"
|
||||
#define ESP_RMAKER_DEVICE_PLUG "esp.device.plug"
|
||||
#define ESP_RMAKER_DEVICE_SOCKET "esp.device.socket"
|
||||
#define ESP_RMAKER_DEVICE_LOCK "esp.device.lock"
|
||||
#define ESP_RMAKER_DEVICE_BLINDS_INTERNAL "esp.device.blinds-internal"
|
||||
#define ESP_RMAKER_DEVICE_BLINDS_EXTERNAL "esp.device.blinds-external"
|
||||
#define ESP_RMAKER_DEVICE_GARAGE_DOOR "esp.device.garage-door"
|
||||
#define ESP_RMAKER_DEVICE_GARAGE_LOCK "esp.device.garage-door-lock"
|
||||
#define ESP_RMAKER_DEVICE_SPEAKER "esp.device.speaker"
|
||||
#define ESP_RMAKER_DEVICE_AIR_CONDITIONER "esp.device.air-conditioner"
|
||||
#define ESP_RMAKER_DEVICE_THERMOSTAT "esp.device.thermostat"
|
||||
#define ESP_RMAKER_DEVICE_TV "esp.device.tv"
|
||||
#define ESP_RMAKER_DEVICE_WASHER "esp.device.washer"
|
||||
#define ESP_RMAKER_DEVICE_OTHER "esp.device.other"
|
||||
#define ESP_RMAKER_DEVICE_ZIGBEE_GATEWAY "esp.device.zigbee_gateway"
|
||||
#define ESP_RMAKER_DEVICE_THREAD_BR "esp.device.thread-br"
|
||||
|
||||
/********** 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"
|
||||
#define ESP_RMAKER_SERVICE_SCENES "esp.service.scenes"
|
||||
#define ESP_RMAKER_SERVICE_SYSTEM "esp.service.system"
|
||||
#define ESP_RMAKER_SERVICE_LOCAL_CONTROL "esp.service.local_control"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
44
components/esp_rainmaker/include/esp_rmaker_thread_br.h
Normal file
44
components/esp_rainmaker/include/esp_rmaker_thread_br.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2024 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>
|
||||
#include <esp_openthread.h>
|
||||
#include <esp_rcp_update.h>
|
||||
|
||||
/** Enable Thread Border Router
|
||||
*
|
||||
* This API enables the Thread Border Router service for the node. For more information,
|
||||
* check [here](https://openthread.io/guides/border-router/espressif-esp32)
|
||||
*
|
||||
* @note This API should be called after esp_rmaker_node_init() but before esp_rmaker_start().
|
||||
*
|
||||
* @param[in] platform_config Platform config for OpenThread
|
||||
* @param[in] rcp_update_config RCP update config
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
* @return error in case of failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_thread_br_enable(const esp_openthread_platform_config_t *platform_config,
|
||||
const esp_rcp_update_config_t *rcp_update_config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
84
components/esp_rainmaker/include/esp_rmaker_user_mapping.h
Normal file
84
components/esp_rainmaker/include/esp_rmaker_user_mapping.h
Normal file
@@ -0,0 +1,84 @@
|
||||
// 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
|
||||
|
||||
/** 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 request sent to cloud */
|
||||
ESP_RMAKER_USER_MAPPING_REQ_SENT,
|
||||
/** 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
|
||||
*
|
||||
* This will create a custom provisioning endpoint for user-node mapping.
|
||||
* This should be called after network_prov_mgr_init()/wifi_prov_mgr_init() but before
|
||||
* network_prov_mgr_start_provisioning()/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 network_prov_mgr_start_provisioning()/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
|
||||
Reference in New Issue
Block a user