mirror of
https://github.com/espressif/esp-rainmaker.git
synced 2026-01-19 18:05:36 +00:00
esp_rmaker_core: Added an event to indicate that local control service has started
Signed-off-by: Vikram <vikram.dattu@espressif.com>
This commit is contained in:
@@ -47,6 +47,8 @@ typedef enum {
|
||||
* 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,
|
||||
} esp_rmaker_event_t;
|
||||
|
||||
/** ESP RainMaker Node information */
|
||||
@@ -377,7 +379,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.
|
||||
@@ -541,7 +543,7 @@ esp_rmaker_device_t *esp_rmaker_node_get_device_by_name(const esp_rmaker_node_t
|
||||
* @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.
|
||||
@@ -852,6 +854,13 @@ esp_err_t esp_rmaker_timezone_service_enable(void);
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ enum property_flags {
|
||||
PROP_FLAG_READONLY = (1 << 0)
|
||||
};
|
||||
|
||||
static bool g_local_ctrl_is_started = false;
|
||||
|
||||
static char *g_serv_name;
|
||||
static bool wait_for_wifi_prov;
|
||||
/********* Handler functions for responding to control requests / commands *********/
|
||||
@@ -322,6 +324,10 @@ static esp_err_t __esp_rmaker_start_local_ctrl_service(const char *serv_name)
|
||||
/* Now register the properties */
|
||||
ESP_ERROR_CHECK(esp_local_ctrl_add_property(&node_config));
|
||||
ESP_ERROR_CHECK(esp_local_ctrl_add_property(&node_params));
|
||||
|
||||
/* update the global status */
|
||||
g_local_ctrl_is_started = true;
|
||||
esp_rmaker_post_event(RMAKER_EVENT_LOCAL_CTRL_STARTED, serv_name, strlen(serv_name) + 1);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -352,6 +358,11 @@ static void esp_rmaker_local_ctrl_prov_event_handler(void* arg, esp_event_base_t
|
||||
}
|
||||
}
|
||||
|
||||
bool esp_rmaker_local_ctrl_service_started(void)
|
||||
{
|
||||
return g_local_ctrl_is_started;
|
||||
}
|
||||
|
||||
esp_err_t esp_rmaker_init_local_ctrl_service(void)
|
||||
{
|
||||
/* ESP Local Control uses protocomm_httpd, which is also used by SoftAP Provisioning.
|
||||
|
||||
Reference in New Issue
Block a user