From e78c0cb892566afdc564de244d74c50abe7f8301 Mon Sep 17 00:00:00 2001 From: Inga Stotland Date: Wed, 10 Jun 2020 10:11:18 -0700 Subject: [PATCH] mesh: Make "Busy" and "InProgress" to be distinct errors This separates "Busy" and "InProgress" error codes: MESH_ERROR_IN_PROGRESS maps to org.bluez.mesh.Error.InProgress MESH_ERROR_BUSY maps to org.bluez.mesh.Error.Busy Minor API change: UpdateAppKey() returns "InProgress" error instead of "Busy" Change-Id: I4d30be4542e6f8c5130dab24a056f6a94877da5c Signed-off-by: anuj.bhumiya --- doc/mesh-api.txt | 2 +- mesh/dbus.c | 3 ++- mesh/error.h | 1 + mesh/manager.c | 11 +++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index e71cf78..107599a 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -666,7 +666,7 @@ Methods: org.bluez.mesh.Error.Failed org.bluez.mesh.Error.InvalidArguments org.bluez.mesh.Error.DoesNotExist - org.bluez.mesh.Error.Busy + org.bluez.mesh.Error.InProgress void DeleteAppKey(uint16 app_index) diff --git a/mesh/dbus.c b/mesh/dbus.c index bf0f73b..83ae22c 100644 --- a/mesh/dbus.c +++ b/mesh/dbus.c @@ -56,7 +56,8 @@ static struct error_entry const error_table[] = { ERROR_INTERFACE ".NotAuthorized", "Permission denied"}, { ERROR_INTERFACE ".NotFound", "Object not found"}, { ERROR_INTERFACE ".InvalidArgs", "Invalid arguments"}, - { ERROR_INTERFACE ".InProgress", "Already in progress"}, + { ERROR_INTERFACE ".InProgress", "Operation already in progress"}, + { ERROR_INTERFACE ".Busy", "Busy"}, { ERROR_INTERFACE ".AlreadyExists", "Already exists"}, { ERROR_INTERFACE ".DoesNotExist", "Does not exist"}, { ERROR_INTERFACE ".Canceled", "Operation canceled"}, diff --git a/mesh/error.h b/mesh/error.h index f3e0f54..2809915 100644 --- a/mesh/error.h +++ b/mesh/error.h @@ -27,6 +27,7 @@ enum mesh_error { MESH_ERROR_NOT_AUTHORIZED, MESH_ERROR_NOT_FOUND, MESH_ERROR_INVALID_ARGS, + MESH_ERROR_IN_PROGRESS, MESH_ERROR_BUSY, MESH_ERROR_ALREADY_EXISTS, MESH_ERROR_DOES_NOT_EXIST, diff --git a/mesh/manager.c b/mesh/manager.c index 710b916..a2aa721 100644 --- a/mesh/manager.c +++ b/mesh/manager.c @@ -62,7 +62,7 @@ static void scan_cancel(struct l_timeout *timeout, void *user_data) struct mesh_io *io; struct mesh_net *net; - l_debug("scan_cancel"); + l_debug(""); if (scan_timeout) l_timeout_remove(scan_timeout); @@ -251,11 +251,10 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); if (!l_dbus_message_iter_get_fixed_array(&iter_uuid, &uuid, &n) - || n != 16) { - l_debug("n = %u", n); + || n != 16) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Bad device UUID"); - } + /* Allow AddNode to cancel Scanning if from the same node */ if (scan_node) { if (scan_node != node) @@ -265,7 +264,6 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus, } /* Invoke Prov Initiator */ - add_pending = l_new(struct add_data, 1); memcpy(add_pending->uuid, uuid, 16); add_pending->node = node; @@ -556,7 +554,8 @@ static struct l_dbus_message *update_subnet_call(struct l_dbus *dbus, } /* All other phases mean KR already in progress over-the-air */ - return dbus_error(msg, MESH_ERROR_BUSY, "Key Refresh in progress"); + return dbus_error(msg, MESH_ERROR_IN_PROGRESS, + "Key Refresh in progress"); } static struct l_dbus_message *delete_subnet_call(struct l_dbus *dbus, -- 2.7.4