static void __bt_hal_handle_ssp_request_event(void *buf, uint16_t len);
static void __bt_hal_handle_pin_request_event(void *buf, uint16_t len);
+static void __bt_hal_handle_device_trust_state_changed_event(void *buf, uint16_t len);
+
static bool interface_ready(void)
{
return bt_hal_cbacks != NULL;
DBG("-");
}
+static void __bt_hal_handle_device_trust_state_changed_event(void *buf, uint16_t len)
+{
+ struct hal_ev_device_trust_state_changed *ev = (struct hal_ev_device_trust_state_changed*)buf;
+ bt_bdaddr_t bd_addr;
+ DBG("+");
+
+ memcpy(bd_addr.address, ev->bdaddr, 6);
+ /* BD address*/
+ DBG("[0x%x]", bd_addr.address[0]);
+ DBG("[0x%x]", bd_addr.address[1]);
+ DBG("[0x%x]", bd_addr.address[2]);
+ DBG("[0x%x]", bd_addr.address[3]);
+ DBG("[0x%x]", bd_addr.address[4]);
+ DBG("[0x%x]", bd_addr.address[5]);
+
+ DBG("Device Trusted? [0x%x]", ev->trust);
+
+ if (!bt_hal_cbacks->device_trust_state_changed_cb) {
+ ERR("HAL User device_trust_state_changed_cb is not set!!");
+ return;
+ }
+
+ bt_hal_cbacks->device_trust_state_changed_cb(&bd_addr, ev->trust);
+ DBG("-");
+}
+
static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len)
{
DBG("+");
DBG("Event: HAL_EV_AUTHORIZE_REQUEST");
__bt_hal_handle_authorize_request_event(buf, len);
break;
+ case HAL_EV_DEVICE_TRUST_CHANGED:
+ DBG("Event: HAL_EV_DEVICE_TRUST_CHANGED");
+ __bt_hal_handle_device_trust_state_changed_event(buf, len);
+ break;
default:
DBG("Event Currently not handled!!");
break;
static void __bt_hal_send_device_acl_connection_state_event(gboolean connected, const char *address);
static void __bt_hal_handle_input_event(GVariant *msg, const char *path);
+static void __bt_hal_send_device_trust_state_event(gboolean is_trusted, const char *address);
+
static gboolean __bt_hal_discovery_finished_cb(gpointer user_data)
{
event_id = 0;
static void __bt_hal_device_property_changed_event(GVariant *msg, const char *path)
{
- GVariantIter value_iter;
- GVariant *value = NULL;
- char *key = NULL;
- g_variant_iter_init (&value_iter, msg);
- DBG("+");
+ GVariantIter value_iter;
+ GVariant *value = NULL;
+ char *key = NULL;
+ g_variant_iter_init (&value_iter, msg);
+ DBG("+");
- while (g_variant_iter_loop(&value_iter, "{sv}", &key, &value)) {
- if(!g_strcmp0(key, "Connected")) {
- guint connected = 0;
- g_variant_get(value, "i", &connected);
- DBG("Device property changed : Connected [%d]", connected);
- } else if (!g_strcmp0(key, "RSSI")) {
- DBG("Device property changed : RSSI");
- __bt_hal_dbus_device_found_properties(path);
- } else if (!g_strcmp0(key, "GattConnected")) {
- DBG("Device property changed : GattConnected");
- } else if (!g_strcmp0(key, "Paired")) {
- DBG("Device property changed : Paired");
- } else if (!g_strcmp0(key, "LegacyPaired")) {
- DBG("Device property changed : LegacyPaired");
- } else if (!g_strcmp0(key, "Trusted")) {
- DBG("Device property changed : Trusted");
- } else if (!g_strcmp0(key, "IpspConnected")) {
- DBG("Device property changed : IpspConnected");
- } else if (!g_strcmp0(key, "IpspInitStateChanged")) {
- DBG("Device property changed : IpspInitStateChanged");
- } else {
- ERR("Unhandled Property:[%s]", key);
- }
- }
- DBG("-");
+ while (g_variant_iter_loop(&value_iter, "{sv}", &key, &value)) {
+ if(!g_strcmp0(key, "Connected")) {
+ guint connected = 0;
+ g_variant_get(value, "i", &connected);
+ DBG("Device property changed : Connected [%d]", connected);
+ } else if (!g_strcmp0(key, "RSSI")) {
+ DBG("Device property changed : RSSI");
+ __bt_hal_dbus_device_found_properties(path);
+ } else if (!g_strcmp0(key, "GattConnected")) {
+ DBG("Device property changed : GattConnected");
+ } else if (!g_strcmp0(key, "Paired")) {
+ DBG("Device property changed : Paired");
+ } else if (!g_strcmp0(key, "LegacyPaired")) {
+ DBG("Device property changed : LegacyPaired");
+ } else if (!g_strcmp0(key, "Trusted")) {
+ DBG("Device property changed : Trusted");
+ gboolean trusted = FALSE;
+ gchar *address = NULL;
+ g_variant_get(value, "b", &trusted);
+ address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
+
+ _bt_convert_device_path_to_address(path, address);
+ DBG("Device [%s] trusted: [%d]", address, trusted);
+
+ __bt_hal_send_device_trust_state_event(trusted, address);
+ g_free(address);
+ } else if (!g_strcmp0(key, "IpspConnected")) {
+ DBG("Device property changed : IpspConnected");
+ } else if (!g_strcmp0(key, "IpspInitStateChanged")) {
+ DBG("Device property changed : IpspInitStateChanged");
+ } else {
+ ERR("Unhandled Property:[%s]", key);
+ }
+ }
+ DBG("-");
}
static void __bt_hal_dbus_device_found_properties(const char *device_path)
DBG("-");
}
+static void __bt_hal_send_device_trust_state_event(gboolean is_trusted,
+ const char *address)
+{
+ struct hal_ev_device_trust_state_changed ev;
+ DBG("+");
+
+ ev.trust = (is_trusted == TRUE) ?
+ HAL_DEVICE_TRUSTED :
+ HAL_DEVICE_UNTRUSTED;
+
+ _bt_convert_addr_string_to_type(ev.bdaddr, address);
+
+ if (!event_cb)
+ ERR("Bluetooth HAL event handler not registered");
+ else
+ event_cb(HAL_EV_DEVICE_TRUST_CHANGED, &ev, sizeof(ev));
+ DBG("-");
+}
+
static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *member,
const char *path)
{