mirror of
https://github.com/espressif/esp-rainmaker.git
synced 2026-01-14 19:58:01 +00:00
ota: Make "OTA using Topics" as default and provide a simplified API for that
- OTA using topics is now enabled in all examples - esp_rmaker_ota_enable_default() is the simplified API that enables OTA using Topics with the default server certificates
This commit is contained in:
@@ -917,6 +917,20 @@ esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *conf
|
||||
*/
|
||||
bool esp_rmaker_local_ctrl_service_started(void);
|
||||
|
||||
/**
|
||||
* Enable Default RainMaker OTA Firmware Upgrade
|
||||
*
|
||||
* This enables the default recommended RainMaker OTA Firmware Upgrade, which is
|
||||
* "Using the Topics", which allows performing OTA from Dashboard.
|
||||
* This OTA can be triggered by Admin Users only.
|
||||
* On Public RainMaker deployment, for nodes using "Self Claiming", since there
|
||||
* is no associated admin user, the Primary user will automatically become the admin
|
||||
* and can perform OTA from dashboard.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_ota_enable_default(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ static esp_err_t esp_rmaker_report_info(json_gen_str_t *jptr)
|
||||
}
|
||||
json_gen_obj_set_string(jptr, "model", info->model);
|
||||
const esp_app_desc_t *app_desc = esp_ota_get_app_description();
|
||||
json_gen_obj_set_string(jptr, "project_name", app_desc->project_name);
|
||||
json_gen_obj_set_string(jptr, "project_name", (char *)app_desc->project_name);
|
||||
json_gen_obj_set_string(jptr, "platform", CONFIG_IDF_TARGET);
|
||||
json_gen_pop_object(jptr);
|
||||
return ESP_OK;
|
||||
|
||||
@@ -284,10 +284,16 @@ ota_end:
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
static const esp_rmaker_ota_config_t ota_default_config = {
|
||||
.server_cert = esp_rmaker_ota_def_cert,
|
||||
};
|
||||
/* Enable the ESP RainMaker specific OTA */
|
||||
esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_ota_type_t type)
|
||||
{
|
||||
if (!ota_config || ((type != OTA_USING_PARAMS) && (type != OTA_USING_TOPICS))) {
|
||||
if (ota_config == NULL) {
|
||||
ota_config = (esp_rmaker_ota_config_t *)&ota_default_config;
|
||||
}
|
||||
if ((type != OTA_USING_PARAMS) && (type != OTA_USING_TOPICS)) {
|
||||
ESP_LOGE(TAG,"Invalid arguments for esp_rmaker_ota_enable()");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -343,3 +349,8 @@ esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_rmaker_ota_enable_default(void)
|
||||
{
|
||||
return esp_rmaker_ota_enable(NULL, OTA_USING_TOPICS);
|
||||
}
|
||||
|
||||
@@ -91,6 +91,9 @@ void app_main()
|
||||
esp_rmaker_device_add_param(fan_device, esp_rmaker_speed_param_create(ESP_RMAKER_DEF_SPEED_NAME, DEFAULT_SPEED));
|
||||
esp_rmaker_node_add_device(node, fan_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
/* Enable timezone service which will be require for setting appropriate timezone
|
||||
* from the phone apps for scheduling to work correctly.
|
||||
* For more information on the various ways of setting timezone, please check
|
||||
|
||||
@@ -86,6 +86,9 @@ void app_main()
|
||||
|
||||
esp_rmaker_node_add_device(node, gpio_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
/* Enable Insights. Requires CONFIG_ESP_INSIGHTS_ENABLED=y */
|
||||
app_insights_enable();
|
||||
|
||||
|
||||
@@ -182,10 +182,7 @@ void app_main()
|
||||
esp_rmaker_node_add_device(node, switch_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_config_t ota_config = {
|
||||
.server_cert = ESP_RMAKER_OTA_DEFAULT_SERVER_CERT,
|
||||
};
|
||||
esp_rmaker_ota_enable(&ota_config, OTA_USING_PARAMS);
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
/* Enable Insights. Requires CONFIG_ESP_INSIGHTS_ENABLED=y */
|
||||
app_insights_enable();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <esp_rmaker_core.h>
|
||||
#include <esp_rmaker_standard_params.h>
|
||||
#include <esp_rmaker_standard_devices.h>
|
||||
#include <esp_rmaker_ota.h>
|
||||
#include <esp_rmaker_schedule.h>
|
||||
#include <esp_rmaker_scenes.h>
|
||||
|
||||
@@ -105,10 +104,7 @@ void app_main()
|
||||
esp_rmaker_node_add_device(node, light_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_config_t ota_config = {
|
||||
.server_cert = ESP_RMAKER_OTA_DEFAULT_SERVER_CERT,
|
||||
};
|
||||
esp_rmaker_ota_enable(&ota_config, OTA_USING_PARAMS);
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
/* Enable timezone service which will be require for setting appropriate timezone
|
||||
* from the phone apps for scheduling to work correctly.
|
||||
|
||||
@@ -120,6 +120,9 @@ void app_main()
|
||||
temp_sensor_device = esp_rmaker_temp_sensor_device_create("Temperature Sensor", NULL, app_get_current_temperature());
|
||||
esp_rmaker_node_add_device(node, temp_sensor_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
/* Enable timezone service which will be require for setting appropriate timezone
|
||||
* from the phone apps for scheduling to work correctly.
|
||||
* For more information on the various ways of setting timezone, please check
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <esp_rmaker_standard_types.h>
|
||||
#include <esp_rmaker_standard_params.h>
|
||||
#include <esp_rmaker_standard_devices.h>
|
||||
#include <esp_rmaker_ota.h>
|
||||
#include <esp_rmaker_schedule.h>
|
||||
#include <esp_rmaker_scenes.h>
|
||||
#include <esp_rmaker_console.h>
|
||||
@@ -184,10 +183,7 @@ void app_main()
|
||||
esp_rmaker_node_add_device(node, switch_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_config_t ota_config = {
|
||||
.server_cert = ESP_RMAKER_OTA_DEFAULT_SERVER_CERT,
|
||||
};
|
||||
esp_rmaker_ota_enable(&ota_config, OTA_USING_PARAMS);
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
/* Enable timezone service which will be require for setting appropriate timezone
|
||||
* from the phone apps for scheduling to work correctly.
|
||||
|
||||
@@ -62,6 +62,9 @@ void app_main()
|
||||
temp_sensor_device = esp_rmaker_temp_sensor_device_create("Temperature Sensor", NULL, app_get_current_temperature());
|
||||
esp_rmaker_node_add_device(node, temp_sensor_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
/* Enable Insights. Requires CONFIG_ESP_INSIGHTS_ENABLED=y */
|
||||
app_insights_enable();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user