summaryrefslogtreecommitdiff
path: root/mesh/manager.c
diff options
context:
space:
mode:
authorMichaƂ Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>2020-04-01 12:25:00 +0200
committerBrian Gix <brian.gix@intel.com>2020-04-01 12:06:14 -0700
commitf333ce2d956015822021ecb43065e1b31e0e29fd (patch)
treebb3f4b6999bea449e991c4d9e2316d20787b92ce /mesh/manager.c
parent037d45241544ec94588fe8b40ea4e0f4a164148e (diff)
downloadbluez-f333ce2d956015822021ecb43065e1b31e0e29fd.tar.gz
mesh: Refresh provisioner's capabilities
As provisioner's capabilities might change during application lifetime (e.g. no network link to download OOB key), let's query the agent again after application calls AddNode().
Diffstat (limited to 'mesh/manager.c')
-rw-r--r--mesh/manager.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/mesh/manager.c b/mesh/manager.c
index 2fecc2eb2..0242bb9e9 100644
--- a/mesh/manager.c
+++ b/mesh/manager.c
@@ -81,6 +81,9 @@ static void free_pending_add_call()
l_dbus_remove_watch(dbus_get_bus(),
add_pending->disc_watch);
+ if (add_pending->msg)
+ l_dbus_message_unref(add_pending->msg);
+
l_free(add_pending);
add_pending = NULL;
}
@@ -212,6 +215,23 @@ static bool add_data_get(void *user_data, uint8_t num_ele)
return true;
}
+static void add_start(void *user_data, int err)
+{
+ struct l_dbus_message *reply;
+
+ l_info("Start callback");
+
+ if (err == MESH_ERROR_NONE)
+ reply = l_dbus_message_new_method_return(add_pending->msg);
+ else
+ reply = dbus_error(add_pending->msg, MESH_ERROR_FAILED,
+ "Failed to start provisioning initiator");
+
+ l_dbus_send(dbus_get_bus(), reply);
+
+ add_pending->msg = NULL;
+}
+
static struct l_dbus_message *add_node_call(struct l_dbus *dbus,
struct l_dbus_message *msg,
void *user_data)
@@ -244,6 +264,7 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus,
/* Invoke Prov Initiator */
add_pending = l_new(struct add_data, 1);
+ add_pending->msg = l_dbus_message_ref(msg);
memcpy(add_pending->uuid, uuid, 16);
add_pending->node = node;
add_pending->agent = node_get_agent(node);
@@ -256,20 +277,14 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus,
goto fail;
}
-
- if (!initiator_start(PB_ADV, uuid, 99, 60, add_pending->agent,
- add_data_get, add_cmplt, node, add_pending)) {
- reply = dbus_error(msg, MESH_ERROR_FAILED,
- "Failed to start provisioning initiator");
- goto fail;
- }
+ initiator_start(PB_ADV, uuid, 99, 60, add_pending->agent, add_start,
+ add_data_get, add_cmplt, node, add_pending);
add_pending->disc_watch = l_dbus_add_disconnect_watch(dbus,
node_get_owner(node),
prov_disc_cb, NULL, NULL);
- return l_dbus_message_new_method_return(msg);
-
+ return NULL;
fail:
l_free(add_pending);
add_pending = NULL;