Skip to content

Commit 84ab732

Browse files
committed
Merge branch 'support/local_ctrl_started_cb' into 'master'
Add local_ctrl_started callback See merge request app-frameworks/esp-rainmaker!275
2 parents 0638c58 + 2ee18ee commit 84ab732

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

components/esp_rainmaker/include/esp_rmaker_core.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ typedef enum {
4747
* Associated data is the NULL terminated user id.
4848
*/
4949
RMAKER_EVENT_USER_NODE_MAPPING_DONE,
50+
/** Local control started. Associated data is the NULL terminated Service Name */
51+
RMAKER_EVENT_LOCAL_CTRL_STARTED,
5052
} esp_rmaker_event_t;
5153

5254
/** ESP RainMaker Node information */
@@ -377,7 +379,7 @@ esp_err_t esp_rmaker_node_deinit(const esp_rmaker_node_t *node);
377379
const esp_rmaker_node_t *esp_rmaker_get_node(void);
378380

379381
/** Get Node Id
380-
*
382+
*
381383
* Returns pointer to the NULL terminated Node ID string.
382384
*
383385
* @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
541543
* @note Device attributes are reported only once after a boot-up as part of the node
542544
* configuration.
543545
* Eg. Serial Number
544-
*
546+
*
545547
* @param[in] device Device handle.
546548
* @param[in] attr_name Name of the attribute.
547549
* @param[in] val Value of the attribute.
@@ -852,6 +854,13 @@ esp_err_t esp_rmaker_timezone_service_enable(void);
852854
*/
853855
esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *config);
854856

857+
/**
858+
* Check if local_ctrl service has started
859+
*
860+
* @return true if service has started
861+
* @return false if the service has not started
862+
*/
863+
bool esp_rmaker_local_ctrl_service_started(void);
855864

856865
#ifdef __cplusplus
857866
}

components/esp_rainmaker/src/core/esp_rmaker_local_ctrl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ enum property_flags {
6060
PROP_FLAG_READONLY = (1 << 0)
6161
};
6262

63+
static bool g_local_ctrl_is_started = false;
64+
6365
static char *g_serv_name;
6466
static bool wait_for_wifi_prov;
6567
/********* 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)
322324
/* Now register the properties */
323325
ESP_ERROR_CHECK(esp_local_ctrl_add_property(&node_config));
324326
ESP_ERROR_CHECK(esp_local_ctrl_add_property(&node_params));
327+
328+
/* update the global status */
329+
g_local_ctrl_is_started = true;
330+
esp_rmaker_post_event(RMAKER_EVENT_LOCAL_CTRL_STARTED, serv_name, strlen(serv_name) + 1);
325331
return ESP_OK;
326332
}
327333

@@ -352,6 +358,11 @@ static void esp_rmaker_local_ctrl_prov_event_handler(void* arg, esp_event_base_t
352358
}
353359
}
354360

361+
bool esp_rmaker_local_ctrl_service_started(void)
362+
{
363+
return g_local_ctrl_is_started;
364+
}
365+
355366
esp_err_t esp_rmaker_init_local_ctrl_service(void)
356367
{
357368
/* ESP Local Control uses protocomm_httpd, which is also used by SoftAP Provisioning.

0 commit comments

Comments
 (0)