static struct l_dbus_message *agent_msg;
static handle_stack_msg mesh_event_cb = NULL;
-
+static uint32_t iv_index;
struct subnet_key_request {
uint16_t idx;
}
}
+static void __mesh_property_changed(struct l_dbus_proxy *proxy, const char *name,
+ struct l_dbus_message *msg, void *user_data)
+{
+ const char *interface = l_dbus_proxy_get_interface(proxy);
+ const char *path = l_dbus_proxy_get_path(proxy);
+ GSList *l;
+ meshcfg_app *app = NULL;
+
+ l = g_slist_find_custom(mesh_apps, path, __compare_proxy_path);
+ if (l) {
+ app = l->data;
+ } else {
+ ERR("Mesh: app not found for Mgmt proxy");
+ }
+
+ INFO("Property changed: %s %s %s\n", name, path, interface);
+
+ if (!app)
+ return;
+
+ if (!strcmp(interface, BT_HAL_MESH_NODE_INTERFACE)) {
+
+ if (!strcmp(name, "IvIndex")) {
+ uint32_t ivi;
+
+ if (!l_dbus_message_get_arguments(msg, "u", &ivi))
+ return;
+
+ INFO("New IV Index: %u\n", ivi);
+
+ iv_index = ivi;
+ /*TODO: save iv index */
+ }
+ }
+}
+
+
static void __mesh_dbus_client_ready(struct l_dbus_client *client_obj,
void *user_data)
{
return false;
if (!l_dbus_client_set_proxy_handlers(client,
__mesh_proxy_added, __mesh_proxy_removed,
- NULL, NULL, NULL))
+ __mesh_property_changed, NULL, NULL))
return false;
if (!l_dbus_client_set_ready_handler(client,
__mesh_dbus_client_ready, NULL, NULL))
struct l_dbus_message_iter iter_cfg;
char *path;
meshcfg_app *app = (meshcfg_app*) user_data;
+ uint32_t ivi;
+
INFO("Mesh: Attach Node Reply: App path [%s] Agent Path [%s]",
app->path, app->agent_path);
INFO("Mesh: Attached with path %s\n", app->path);
__send_network_attach_event(app, BT_STATUS_SUCCESS);
+
+ if (l_dbus_proxy_get_property(app->proxy, "IvIndex", "u", &ivi) &&
+ ivi != iv_index) {
+ iv_index = ivi;
+ /* TODO: Save IV index */
+ }
+
return;
failed:
__send_network_attach_event(app, BT_STATUS_FAIL);
l_dbus_message_builder_finalize(builder);
l_dbus_message_builder_destroy(builder);
- g_free(uuid);
+ l_free(uuid);
}
bt_status_t _bt_hal_mesh_provision_device(