+/* Mesh Event Handler */
+static void __bt_mesh_event_filter(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ BT_INFO("Mesh event handler Entry >>");
+ bt_event_info_t *event_info;
+
+ event_info = (bt_event_info_t *)user_data;
+ ret_if(event_info == NULL);
+
+ if (strcasecmp(signal_name, BT_MESH_SCAN_STARTED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_network_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_network_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_SCAN_STARTED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_SCAN_FINISHED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_network_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_network_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_SCAN_FINISHED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_SCAN_RESULT) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_scan_result_t *info = NULL;
+ BT_INFO("Mesh: BT_MESH_SCAN_RESULT");
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_scan_result_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_SCAN_RESULT,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_AUTHENTICATION_REQ) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_authentication_request_t *info = NULL;
+ BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REQ");
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_authentication_request_t, 0);
+ BT_INFO("Mesh: Authentication Type [%d]", info->auth_type);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_AUTHENTICATION_REQUEST,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_PROVISIONING_RESULT) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_provisioning_result_t *info = NULL;
+ BT_INFO("Mesh: BT_MESH_PROVISIONING_RESULT");
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_provisioning_result_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_PROVISIONING_FINISHED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_NODE_BROWSED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_node_discover_t *info = NULL;
+ BT_INFO("Mesh: Node browsed event");
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_node_discover_t, 0);
+
+ BT_INFO("Mesh: Send Node Browse event: Net UID [%s], Node UUID [%s]",
+ info->net_uuid, info->dev_uuid);
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_BROWSED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_NODE_VEND_FEATS) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_node_features_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_node_features_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_VENDOR_FEATURES,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_NODE_KEY_CONFIGURED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_key_configure_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_KEY_CONFIGURED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_MODEL_APPKEY_CONFIGURED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_model_configure_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_model_configure_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_MODEL_APPKEY_LIST) == 0) {
+ int result;
+ GVariantIter *iter = NULL;
+ bluetooth_mesh_model_configure_t info;
+ uint16_t node_unicast;
+ int elem_idx;
+ uint32_t model;
+ const char *net_uuid = NULL;
+ int total = 0;
+ uint16_t appkey_idx;
+ int i;
+
+ g_variant_get(parameters, "(i&sqiui(aq))", &result, &net_uuid,
+ &node_unicast, &elem_idx, &model, &total, &iter);
+
+ memset(&info, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+ info.primary_unicast = node_unicast;
+ g_strlcpy(info.net_uuid, net_uuid, 33);
+ info.elem_index = elem_idx;
+ info.model = model;
+ info.appkeylist_count = total;
+ BT_INFO("Mesh: Total appkeys bound to model [%d]", total);
+ if (total) {
+ info.appkey_list = (uint16_t**)g_malloc0(sizeof(uint16_t*) * total);
+
+ for (i = 0; i < total && g_variant_iter_loop(iter, "q", &appkey_idx); ++i) {
+ info.appkey_list[i] = g_malloc0(sizeof(uint16_t));
+ *info.appkey_list[i] = appkey_idx;
+ }
+ }
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_APPKEY_LIST,
+ result, &info,
+ event_info->cb, event_info->user_data);
+
+ for (i = 0; i < total; i++)
+ g_free(info.appkey_list[i]);
+ if (info.appkey_list) {
+ g_free(info.appkey_list);
+ g_variant_iter_free(iter);
+ }
+
+ } else if (strcasecmp(signal_name, BT_MESH_MODEL_SUB_LIST) == 0) {
+ int result;
+ GVariantIter *iter = NULL;
+ bluetooth_mesh_model_configure_t info;
+ uint16_t node_unicast;
+ int elem_idx;
+ uint32_t model;
+ const char *net_uuid = NULL;
+ int total = 0;
+ uint16_t sub_addr;
+ int i;
+
+ g_variant_get(parameters, "(i&sqiui(aq))", &result, &net_uuid,
+ &node_unicast, &elem_idx, &model, &total, &iter);
+
+ memset(&info, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+ info.primary_unicast = node_unicast;
+ g_strlcpy(info.net_uuid, net_uuid, 33);
+ info.elem_index = elem_idx;
+ info.model = model;
+ info.sublist_count = total;
+
+ BT_INFO("Mesh: Total Subscriptions Bound to model [%d]", total);
+ if (total) {
+ info.sub_list = (uint16_t**)g_malloc0(sizeof(uint16_t*) * total);
+ for (i = 0; i < total && g_variant_iter_loop(iter, "q", &sub_addr); ++i) {
+ info.sub_list[i] = g_malloc0(sizeof(uint16_t));
+ *info.sub_list[i] = sub_addr;
+ BT_INFO("Mesh: Subscription Address [0x%2.2x]", sub_addr);
+ }
+ }
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_LIST,
+ result, &info,
+ event_info->cb, event_info->user_data);
+
+ for (i = 0; i < total; i++)
+ g_free(info.sub_list[i]);
+ if (info.sub_list) {
+ g_free(info.sub_list);
+ g_variant_iter_free(iter);
+ }
+ } else if (strcasecmp(signal_name, BT_MESH_NODE_TTL_CONFIGURED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_node_ttl_info_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_node_ttl_info_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_NODE_TTL_CONFIGURED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_node_ttl_info_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_node_ttl_info_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_MODEL_SUB_CONF) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_key_configure_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_MODEL_VIR_SUB_CONF) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_key_configure_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_MODEL_PUB_STATUS) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_key_configure_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS,
+ result, info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MESH_MODEL_MSG_EXECUTED) == 0) {
+ int result;
+ GVariant *param = NULL;
+ GArray *dbus_data = NULL;
+ bluetooth_mesh_model_msg_t *info = NULL;
+
+ g_variant_get(parameters, "(iv)", &result, ¶m);
+ dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+ __bt_fill_garray_from_variant(param, dbus_data);
+ g_variant_unref(param);
+
+ info = &g_array_index(dbus_data, bluetooth_mesh_model_msg_t, 0);
+
+ _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_MSG_EXECUTED,
+ result, info,
+ event_info->cb, event_info->user_data);
+ }
+ BT_INFO("Mesh event handler Exit <<");
+}
+