From 2ada8954ecd3601d115a22696c4c3ab90858cec3 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Sun, 17 Nov 2019 00:07:12 +0100 Subject: [HICN-379] Add face priority support in face manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If4f75d44fc66414a4a70135de7827f5082b97112 Signed-off-by: Jordan Augé --- .../facemgr/src/interfaces/hicn_light/hicn_light.c | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c') diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c index 53aa95a75..a6cd44fe0 100644 --- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c +++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c @@ -294,9 +294,12 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet) int rc; int ret = 0; hl_data_t * data = (hl_data_t *)interface->data; - face_t * face = NULL; + hc_face.id = 0; + memset(hc_face.name, 0, sizeof(hc_face.name)); + + /* NOTE * - One example where this fails (and it is normal) is when we delete a * face that was not completely created, because for instance bonjour did @@ -324,8 +327,6 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet) facelet_snprintf(buf, MAXSZ_FACELET, facelet); DEBUG("Create facelet %s", buf); } - hc_face.id = 0; - memset(hc_face.name, 0, sizeof(hc_face.name)); hc_face.face = *face; rc = hc_face_create(data->s, &hc_face); if (rc < 0) { @@ -415,7 +416,7 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet) break; case FACELET_EVENT_UPDATE: - /* Currently, only admin_state is supported */ + /* Currently, only admin_state & priority are supported */ if (facelet_get_admin_state_status(facelet) == FACELET_ATTR_STATUS_DIRTY) { hc_face.face = *face; hc_face_t * face_found; @@ -449,6 +450,35 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet) } INFO("Admin state updated"); } + if (facelet_get_admin_state_status(facelet) == FACELET_ATTR_STATUS_DIRTY) { + hc_face.face = *face; + hc_face_t * face_found; + + rc = hc_face_get(data->s, &hc_face, &face_found); + if (rc < 0) { + ERROR("Failed to find face\n"); + goto ERR; + } + if (!face_found) { + ERROR("Face to update has not been found"); + goto ERR; + } + char conn_id_or_name[SYMBOLIC_NAME_LEN]; + snprintf(conn_id_or_name, SYMBOLIC_NAME_LEN, "%d", face_found->id); + free(face_found); + + uint32_t priority; + if (facelet_get_priority(facelet, &priority) < 0) { + ERROR("Failed to retrieve facelet priority"); + goto ERR; + } + + if (hc_connection_set_priority(data->s, conn_id_or_name, priority) < 0) { + ERROR("Failed to update priority"); + goto ERR; + } + INFO("Priority updated"); + } break; default: -- cgit 1.2.3-korg