#include "bt-hal-gatt-client.h"
#include "bt-hal-adapter-dbus-handler.h"
+#include "bt-internal-types.h"
+
#define BASELEN_PROP_CHANGED (sizeof(struct hal_ev_adapter_props_changed) \
+ sizeof(struct hal_property))
struct hal_ev_discovery_state_changed ev;
ev.state = HAL_DISCOVERY_STATE_STOPPED;
event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, &ev, sizeof(ev));
- DBG("-");
return FALSE;
}
ev->num_props = 0;
ev->status = BT_STATUS_SUCCESS;
- DBG("+");
-
while (g_variant_iter_loop(&value_iter, "{sv}", &key, &value)) {
if (!g_strcmp0(key, "Address")) {
uint8_t bdaddr[6];
/* TODO: Need to check this operation!! */
if (powered == FALSE) {
DBG("###### Adapter Powered Down ######");
- struct hal_ev_adapter_state_changed ev;
- ev.state = HAL_POWER_OFF;
- event_cb(HAL_EV_ADAPTER_STATE_CHANGED, &ev, sizeof(ev));
+
+ if (TIZEN_FEATURE_BT_USB_DONGLE) {
+ struct hal_ev_adapter_state_changed ev;
+ ev.state = HAL_POWER_OFF;
+ event_cb(HAL_EV_ADAPTER_STATE_CHANGED, &ev, sizeof(ev));
#ifdef TIZEN_BT_HAL
- struct hal_ev_le_state_changed le_ev;
- le_ev.state = HAL_POWER_OFF;
- event_cb(HAL_EV_LE_STATE_CHANGED, &le_ev, sizeof(le_ev));
+ struct hal_ev_le_state_changed le_ev;
+ le_ev.state = HAL_POWER_OFF;
+ event_cb(HAL_EV_LE_STATE_CHANGED, &le_ev, sizeof(le_ev));
#endif
- /* Destroy Agent */
- _bt_hal_destroy_adapter_agent();
+ /* Destroy Agent */
+ _bt_hal_destroy_adapter_agent();
+ } else {
+ DBG("Pending disalbed event after bluetoothd is terminated");
+ }
} else {
DBG("###### Adapter Powered Up ######");
if (_bt_hal_get_adapter_request_state()) {
DBG("##Discovering = [%d]", is_discovering);
if (is_discovering == FALSE) {
- DBG("###### Adapter Has stopped Discovering ######");
/* In Tizen Bluez, this actually does not mean Discovery is stopped
in Bluez. Tizen Bluez sends this event after a certain timeout,
Therefore, we must forecefully call StopDiscovery to stop discovery in BlueZ */
DBUS_TIMEOUT, NULL,
&err);
if (err) {
+ struct hal_ev_discovery_state_changed ev;
+
ERR("Dbus Error : %s", err->message);
+ if (g_strrstr(err->message, "No discovery started"))
+ continue;
+
/* This error is thrown by Bluez, as Discovery is already stopped.
Discovery is stopped if user cancels on going discovery.
In order to maintain correct state of Bluetooth Discovery state,
simply send Discovery stopped event to HAL user */
- struct hal_ev_discovery_state_changed ev;
ev.state = HAL_DISCOVERY_STATE_STOPPED;
event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, &ev, sizeof(ev));
g_clear_error(&err);
}
} else {
- DBG("###### Adapter Has started Discovering ######");
struct hal_ev_discovery_state_changed ev;
ev.state = HAL_DISCOVERY_STATE_STARTED;
event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, &ev, sizeof(ev));
ev->num_props++;
} else if (!g_strcmp0(key, "Modalias")) {
char *modalias = NULL;
- g_variant_get(value, "s", &modalias);
+ g_variant_get(value, "&s", &modalias);
DBG("##Adapter ModAlias [%s]", modalias);
} else if (!g_strcmp0(key, "SupportedLEFeatures")) {
DBG("##LE Supported features");
DBG("Send Adapter properties changed event to HAL user, Num Prop [%d] total size [%zd]", ev->num_props, size);
event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, buf, size);
}
-
- DBG("-");
-}
-
-static void __bt_hal_flight_ps_mode_cb(keynode_t *node, void *data)
-{
- gboolean flight_mode = FALSE;
- int type;
- DBG_SECURE("HAL callback hit");
- DBG_SECURE("key=%s", vconf_keynode_get_name(node));
- type = vconf_keynode_get_type(node);
- if (type == VCONF_TYPE_BOOL) {
- flight_mode = vconf_keynode_get_bool(node);
- if (flight_mode != TRUE) {
- ERR("Ignore the event");
- return;
- } else {
- ERR("Flight Mode == TRUE");
- }
- } else {
- ERR("Invaild vconf key type : %d", type);
- return;
- }
- DBG("Enabling core now");
- _bt_hal_enable_core();
-}
-
-static void _bt_hal_register_vconf_handler(void)
-{
- DBG("+");
-
- if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- (vconf_callback_fn)__bt_hal_flight_ps_mode_cb, NULL) < 0)
- ERR("Unable to register key handler");
- DBG("Telephony is disabled");
- if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
- (vconf_callback_fn)__bt_hal_flight_ps_mode_cb, NULL) < 0)
- ERR("Unable to register key handler");
}
void _bt_hal_handle_adapter_event(GVariant *msg, const char *member)
{
- DBG("+");
-
if (member == NULL)
return;
if (strcasecmp(member, "DeviceCreated") == 0) {
DBG("DeviceCreated: Unhandled");
- } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
- DBG("InterfacesRemoved: Unhandled");
} else if (strcasecmp(member, "AdvertisingEnabled") == 0) {
- DBG("AdvertisingEnabled");
- DBG("Advertising Enabled");
int slot_id;
gboolean status = FALSE;
g_variant_get(msg, "(ib)", &slot_id, &status);
- DBG("Advertising Enabled : server_slot_id [%d] status [%d]", slot_id, status);
+
/* Send event to application */
_bt_hal_set_advertising_status(slot_id, status);
} else if (strcasecmp(member, "RssiEnabled") == 0) {
g_free(address);
} else if (strcasecmp(member, BT_HAL_HARDWARE_ERROR) == 0) {
+#ifndef TIZEN_BT_HAL
DBG("BT Hardware Error: Unhandled");
+#else
+ struct hal_ev_controller_error_recieved info;
+
+ INFO("### BT Hardware Error");
+ info.code = HAL_CONTROLLER_ERROR_HW_ERROR;
+ event_cb(HAL_EV_CONTROLLER_ERROR_RECIEVED, &info, sizeof(info));
+#endif
} else if (strcasecmp(member, BT_HAL_TX_TIMEOUT_ERROR) == 0) {
- DBG("BT TX Timeout Error: Unhandled");
+#ifndef TIZEN_BT_HAL
+ DBG("BT Hardware Error: Unhandled");
+#else
+ struct hal_ev_controller_error_recieved info;
+ INFO("### BT TX Timeout Error");
+ info.code = HAL_CONTROLLER_ERROR_TX_TIMEOUT;
+ event_cb(HAL_EV_CONTROLLER_ERROR_RECIEVED, &info, sizeof(info));
+#endif
+ } else if (strcasecmp(member, BT_HAL_DBFW_PLUS_INFO) == 0) {
+#ifdef TIZEN_BT_HAL
+ DBG("### DBFW+ info received from BLUEZ");
+ struct hal_ev_dbfw_plus_info_recieved info;
+ int length;
+ char event_code;
+ unsigned char *buffer = NULL;
+ GVariant *value = NULL;
+
+ g_variant_get(msg, "(y@ay)", &event_code, &value);
+ if (value == NULL) {
+ ERR("g_variant_get fails");
+ } else {
+ length = g_variant_get_size(value);
+ if (length <= 0) {
+ ERR("Invalid g_variant len = %d", length);
+ } else {
+ info.event_code = event_code;
+ buffer = (unsigned char*)g_variant_get_data(value);
+ info.data = g_memdup(buffer, length);
+ info.data_len = length;
+ if (!event_cb)
+ ERR("event_cb is NULL");
+ else
+ event_cb(HAL_EV_DBFW_PLUS_INFO_RECIEVED, &info, sizeof(info));
+ g_free(info.data);
+ }
+ }
+#endif
}
- DBG("-");
}
static gboolean __bt_hal_parse_device_properties(GVariant *item)
gchar *key;
GVariant *val;
gsize len = 0;
+ gboolean is_bredr_dev = FALSE;
+
if (!item)
return FALSE;
- DBG("+");
/* Buffer and propety count management */
uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
while (g_variant_iter_loop(&iter, "{sv}", &key, &val)) {
if (strcasecmp(key, "Address") == 0) {
-
char * address = NULL;
address = g_variant_dup_string(val, &len);
uint8_t bdaddr[6];
ev->num_props++;
DBG("Device address [%s] property Num [%d]", address, ev->num_props);
g_free(address);
+ } else if (strcasecmp(key, "AddressType") == 0) {
+ char *addresstype = g_variant_dup_string(val, &len);
+ if (addresstype)
+ DBG("AddressType [%s]", addresstype);
+ g_free(addresstype);
} else if (strcasecmp(key, "Class") == 0) {
unsigned int class = g_variant_get_uint32(val);
size += __bt_insert_hal_properties(buf + size, HAL_PROP_DEVICE_CLASS,
sizeof(unsigned int), &class);
ev->num_props++;
DBG("Device class [%d] Property num [%d]", class, ev->num_props);
+ is_bredr_dev = TRUE;
} else if (strcasecmp(key, "name") == 0) {
char *name = g_variant_dup_string(val, &len);
if (name) {
} else if (strcasecmp(key, "LegacyManufacturerData") == 0) {
/* TODO: To be handled later*/
} else {
- ERR("Unhandled Property:[%s]", key);
+ DBG("Unhandled Property:[%s]", key);
}
}
- DBG("-");
- if (size > 1) {
+ if (size > 1 && is_bredr_dev) {
DBG("Send Device found event to HAL user, Num Prop [%d] total size [%zd]", ev->num_props, size);
event_cb(HAL_EV_DEVICE_FOUND, (void*) buf, size);
}
g_variant_unref(value);
return;
}
-
- DBG("-");
}
static void __bt_hal_send_hid_connection_state_event(
g_variant_unref(val);
g_variant_unref(child);
}
-
- DBG("-");
}
static gboolean __bt_hal_parse_interface(GVariant *msg)
}
}
+static void __bt_hal_handle_gatt_service_event(GVariant *parameters, const char *signal_name)
+{
+ if (signal_name == NULL)
+ return;
+
+ if (strcasecmp(signal_name, "GattServiceAdded") == 0) {
+ char *path = NULL;
+ g_variant_get(parameters, "(&s)", &path);
+ _bt_hal_handle_gattc_service_changed_event(TRUE, path);
+ }
+}
static gboolean __bt_hal_event_manager(gpointer data)
{
g_variant_get(param->parameters, "(&o@a{sa{sv}})", &obj_path, &value);
if (obj_path == NULL) {
- DBG("obj_path is NULL");
+ ERR("obj_path is NULL");
return FALSE;
}
} else {
bt_event = __bt_hal_parse_event(value);
if (bt_event == BT_HAL_DEVICE_EVENT) {
+ DBG("InterfacesAdded %s ", obj_path);
__bt_hal_handle_device_event(value, param->parameters);
} else if (bt_event == BT_HAL_AVRCP_CONTROL_EVENT) {
+ DBG("InterfacesAdded %s ", obj_path);
_bt_hal_set_control_device_path(obj_path);
}
}
/*TODO: Handle Interfaces Removed Signal from stack */
g_variant_get(param->parameters, "(&oas)", &obj_path, &iter);
-
+ DBG("InterfacesRemoved %s ", obj_path);
while (g_variant_iter_loop(iter, "s", &str)) {
if (g_strcmp0(str, BT_HAL_PLAYER_CONTROL_INTERFACE) == 0)
_bt_hal_remove_control_device_path(obj_path);
+ else if (g_strcmp0(str, BT_HAL_GATT_SERVICE_INTERFACE) == 0)
+ _bt_hal_handle_gattc_service_changed_event(FALSE, obj_path);
}
g_variant_iter_free(iter);
} else if (strcasecmp(param->signal_name, "NameOwnerChanged") == 0) {
/* TODO: Handle Name Owener changed Signal */
if (__bt_hal_get_owner_info(param->parameters, &name, &previous, ¤t)) {
- DBG("Fail to get the owner info");
+ ERR("Fail to get the owner info");
return FALSE;
}
return FALSE;
if (strcasecmp(name, BT_HAL_BLUEZ_NAME) == 0) {
- DBG("Bluetoothd is terminated");
+ struct hal_ev_adapter_state_changed ev;
+ struct hal_ev_le_state_changed le_ev;
+
+ INFO("Bluetoothd is terminated");
+
+ /* Send the disable event in here */
- /* TODO: Handle Bluetoothd terminating scenario */
+ ev.state = HAL_POWER_OFF;
+ le_ev.state = HAL_POWER_OFF;
+
+ event_cb(HAL_EV_ADAPTER_STATE_CHANGED, &ev, sizeof(ev));
+ event_cb(HAL_EV_LE_STATE_CHANGED, &le_ev, sizeof(le_ev));
+
+ /* Destroy Agent */
+ _bt_hal_destroy_adapter_agent();
_bt_hal_le_deinit();
}
} else if (g_strcmp0(param->interface_name, BT_HAL_PROPERTIES_INTERFACE) == 0) {
__bt_hal_handle_property_changed_event(param->parameters, param->object_path);
} else if (g_strcmp0(param->interface_name, BT_HAL_ADAPTER_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name: BT_HAL_ADAPTER_INTERFACE");
_bt_hal_handle_adapter_event(param->parameters, param->signal_name);
} else if (g_strcmp0(param->interface_name, BT_HAL_INPUT_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name: BT_HAL_INPUT_INTERFACE");
__bt_hal_handle_input_event(param->parameters, param->object_path);
} else if (g_strcmp0(param->interface_name, BT_HAL_NETWORK_SERVER_INTERFACE) == 0) {
/* TODO: Handle Network Server events from stack */
DBG("Manager Event: Interface Name: BT_HAL_NETWORK_SERVER_INTERFACE");
} else if (g_strcmp0(param->interface_name, BT_HAL_HEADSET_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name: BT_HAL_HEADSET_INTERFACE");
__bt_hal_handle_headset_events(param->parameters, param->signal_name, param->object_path);
} else if (g_strcmp0(param->interface_name, BT_HAL_SINK_INTERFACE) == 0) {
/* TODO: Handle Sink interface events from stack */
/* TODO: Handle Agent events from stack */
DBG("Manager Event: Interface Name:BT_HAL_AGENT_INTERFACE");
} else if (g_strcmp0(param->interface_name, BT_HAL_DEVICE_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name:BT_HAL_DEVICE_INTERFACE");
__bt_hal_handle_device_specific_events(param->parameters, param->signal_name, param->object_path);
} else if (g_strcmp0(param->interface_name, BT_HAL_PLAYER_CONTROL_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name: BT_HAL_PLAYER_CONTROL_INTERFACE");
__bt_hal_handle_avrcp_ctrl_events(param->parameters, param->signal_name, param->object_path);
} else if (g_strcmp0(param->interface_name, BT_HAL_MEDIATRANSPORT_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name: BT_HAL_MEDIATRANSPORT_INTERFACE");
__bt_hal_handle_avrcp_transport_events(param->parameters, param->signal_name, param->object_path);
} else if (g_strcmp0(param->interface_name, BT_HAL_GATT_CHAR_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name: BT_HAL_GATT_CHAR_INTERFACE");
__bt_hal_handle_gatt_char_event(param->parameters, param->signal_name);
+ } else if (g_strcmp0(param->interface_name, BT_HAL_GATT_SERVICE_INTERFACE) == 0) {
+ DBG("Manager Event: Interface Name: BT_HAL_GATT_SERVICE_INTERFACE");
+ __bt_hal_handle_gatt_service_event(param->parameters, param->signal_name);
}
-
/* Free data */
g_free(param->sender_name);
g_free(param->object_path);
static int subs_property_id = -1;
static int subs_adapter_id = -1;
- INFO_C("+");
-
if (subscribe) {
if (subs_interface_added_id == -1) {
subs_interface_added_id = g_dbus_connection_signal_subscribe(conn,
}
}
- INFO_C("-");
return 0;
}
{
static int subs_device_id = -1;
- DBG("+");
if (conn == NULL)
return -1;
}
}
- DBG("-");
return 0;
}
{
static int subs_input_id = -1;
- DBG("+");
-
if (conn == NULL)
return -1;
}
}
- DBG("-");
-
return 0;
}
static int __bt_hal_register_gatt_subscribe_signal(GDBusConnection *conn,
int subscribe)
{
- static int subs_gatt_id = -1;
-
- DBG("+");
+ static int subs_gatt_char_id = -1;
+ static int subs_gatt_service_id = -1;
if (subscribe) {
- if (subs_gatt_id == -1) {
- subs_gatt_id = g_dbus_connection_signal_subscribe(conn,
+ if (subs_gatt_char_id == -1) {
+ subs_gatt_char_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_HAL_GATT_CHAR_INTERFACE,
NULL, NULL, NULL, 0,
__bt_hal_manager_event_filter,
NULL, NULL);
}
+ if (subs_gatt_service_id == -1) {
+ subs_gatt_service_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_HAL_GATT_SERVICE_INTERFACE,
+ NULL, NULL, NULL, 0,
+ __bt_hal_manager_event_filter,
+ NULL, NULL);
+ }
} else {
- if (subs_gatt_id == -1) {
+ if (subs_gatt_char_id == -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_gatt_char_id);
+ subs_gatt_char_id = -1;
+ }
+ if (subs_gatt_service_id == -1) {
g_dbus_connection_signal_unsubscribe(conn,
- subs_gatt_id);
- subs_gatt_id = -1;
+ subs_gatt_service_id);
+ subs_gatt_service_id = -1;
}
}
static int __bt_hal_register_service_event(GDBusConnection *g_conn, int event_type)
{
- DBG("+");
-
if (g_conn == NULL)
return BT_HAL_ERROR_INTERNAL;
manager_conn = NULL;
}
- DBG("-");
-
return BT_HAL_ERROR_INTERNAL;
}
/*TODO: Initialize Obexd Event receiver */
- /* Initialize event receiver for flight mode */
- _bt_hal_register_vconf_handler();
-
event_cb = cb;
- DBG("-");
return BT_HAL_ERROR_NONE;
}
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);
+ INFO("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");
gboolean gatt_connected = FALSE;
g_variant_get(value, "b", &gatt_connected);
+ INFO_C("Device property changed : GattConnected [%d]", gatt_connected);
+
char *address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
_bt_hal_convert_device_path_to_address(path, address);
- DBG("@@gatt_connected: %d", gatt_connected);
- DBG("@@address: %s", address);
- if (_bt_hal_check_gattc_is_existing(address) == TRUE) {
- DBG("GattConnected event will be handled on CLIENT side");
- _bt_hal_handle_gattc_connected_event(address, gatt_connected);
- } else {
- DBG("GattConnected event will be handled on SERVER side");
- _bt_hal_gatt_connected_state_event(gatt_connected, address);
- }
+ _bt_hal_gatt_connected_state_event(gatt_connected, address);
+ _bt_hal_handle_gattc_connected_event(address, gatt_connected);
g_free(address);
} else if (!g_strcmp0(key, "Paired")) {
gboolean paired = FALSE;
if (!event_cb) {
ERR("Bluetooth HAL event handler not registered");
- } else {
- DBG("Sending HAL_EV_BOND_STATE_CHANGED event");
+ } else
event_cb(HAL_EV_BOND_STATE_CHANGED, (void*)&ev, sizeof(ev));
- }
} else if (!g_strcmp0(key, "LegacyPaired")) {
DBG("Device property changed : LegacyPaired");
} else if (!g_strcmp0(key, "Trusted")) {
DBG("Address: %s, TrustedProfiles: 0x%X", address, trust_val);
__bt_hal_send_device_trusted_profile_changed_event(trust_val, address);
} else {
- ERR("Unhandled Property:[%s]", key);
+ DBG("Unhandled Property:[%s]", key);
}
}
- DBG("-");
}
static void __bt_hal_dbus_device_found_properties(const char *device_path)
GDBusProxy *device_proxy;
GDBusConnection *conn;
GVariant *result;
- DBG("+");
if (!device_path) {
ERR("Invalid device path");
g_object_unref(device_proxy);
g_free(address);
-
- DBG("-");
}
static void __bt_hal_device_properties_lookup(GVariant *result, char *address)
(BT_HAL_STACK_UUID_SIZE * uuid_count),
uuids);
ev->num_props = num_props_tmp + 1;
- g_free(uuid_value);
+ g_strfreev(uuid_value);
}
g_variant_unref(tmp_value);
DBG("Send Device found event to HAL user, Num Prop [%d] total size [%zd]", ev->num_props, size);
event_cb(HAL_EV_DEVICE_FOUND, (void*) buf, size);
}
- DBG("-");
}
static void __bt_hal_send_device_acl_connection_state_event(int status, gboolean connected, const char *address)
{
- DBG("+");
struct hal_ev_acl_state_changed ev;
ev.status = status;
ERR("Bluetooth HAL event handler not registered");
else
event_cb(HAL_EV_ACL_STATE_CHANGED, &ev, sizeof(ev));
- DBG("-");
}
static void __bt_hal_send_device_le_connection_state_event(int status, gboolean connected, const char *address)
{
- DBG("+");
struct hal_ev_le_conn_state_changed ev;
ev.status = status;
ERR("Bluetooth HAL event handler not registered");
else
event_cb(HAL_EV_LE_CONN_STATE_CHANGED, &ev, sizeof(ev));
- 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 :
ERR("Bluetooth HAL event handler not registered");
else
event_cb(HAL_EV_DEVICE_TRUST_CHANGED, &ev, sizeof(ev));
- DBG("-");
}
static void __bt_hal_send_device_trusted_profile_changed_event(
uint32_t trust_val, const char *address)
{
struct hal_ev_device_trusted_profiles_changed ev;
- DBG("+");
_bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
ev.trust_val = trust_val;
ERR("Bluetooth HAL event handler not registered");
else
event_cb(HAL_EV_DEVICE_TRUSTED_PROFILES_CHANGED, &ev, sizeof(ev));
- DBG("-");
}
static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *member,
_bt_hal_convert_device_path_to_address(path, address);
DBG("Member: [%s]", member);
- ERR_C("Connected [%s] [%s]", !addr_type ? "BREDR" : "LE", address);
+ ERR_C("### Connected [%s] [%s]", !addr_type ? "BREDR" : "LE", address);
if (!addr_type)
__bt_hal_send_device_acl_connection_state_event(BT_STATUS_SUCCESS, TRUE, address);
else
address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
_bt_hal_convert_device_path_to_address(path, address);
- DBG("Member: [%s]", member);
+ ERR_C("### Disconnected [%s] [%d : %s] [%s] [%s]", !addr_type ? "BREDR" : "LE",
+ disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason), address, name);
- ERR_C("DisConnected [%s] [%s]", !addr_type ? "BREDR" : "LE", address);
- DBG("Disconnected Reason [%d : %s]", disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason));
- DBG("Name: %s", name);
if (!addr_type)
- __bt_hal_send_device_acl_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
+ __bt_hal_send_device_acl_connection_state_event(disc_reason, FALSE, address);
else
- __bt_hal_send_device_le_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
+ __bt_hal_send_device_le_connection_state_event(disc_reason, FALSE, address);
g_free(address);
} else if (strcasecmp(member, "ProfileStateChanged") == 0) {
int state = 0;
address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
_bt_hal_convert_device_path_to_address(path, address);
- DBG("Address: %s", address);
- DBG("Profile UUID: %s", profile_uuid);
- DBG("State: %d", state);
- if (strcmp(profile_uuid, HID_UUID) == 0) {
+ if (strncmp(profile_uuid, HID_UUID, strlen(HID_UUID)) == 0) {
DBG("HID Host Profile state: %d", state);
if (state == BT_HAL_PROFILE_STATE_CONNECTED)
__bt_hal_send_hid_connection_state_event(TRUE, address);
DBG("AVRCP Controller Profile state changed: BT_HAL_PROFILE_STATE_CONNECTING");
}
} else {
- DBG("Profile[%s] State changed status [%d] ", profile_uuid, state);
+ DBG("Profile [%s] State changed [%d] [%s] ", profile_uuid, state, address);
}
g_free(address);
g_free(profile_uuid);
address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
- DBG("Member: [%s]", member);
-
_bt_hal_convert_device_path_to_address(path, address);
g_variant_get(msg, "(q)", &mtu);
g_free(address);
} else if (strcasecmp(member, "AdvReport") == 0) {
- DBG("Member: [%s]", member);
__bt_hal_handle_adv_report(msg, path);
}
}
memcpy(ev->adv_data, buffer, data_len);
size += data_len;
- DBG("Send le scan result event to HAL, size: [%zd]", size);
gatt_event_cb(HAL_EV_GATT_CLIENT_SCAN_RESULT, buf, size);
g_variant_unref(value);
}
memset(buf, 0, sizeof(buf));
size = sizeof(*ev);
- DBG("Address: %s, mtu: %d", address, mtu);
-
ev->conn_id = _bt_get_remote_gatt_client_conn_id(address);
ev->mtu = mtu;
- DBG("Send GATT server mtu changed event to HAL, size: [%zd]", size);
gatt_event_cb(HAL_EV_GATT_SERVER_MTU_CHANGED, buf, size);
}
ev.state = HAL_AVRCP_CTRL_STATE_DISCONNECTED;
_bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
- if (!a2dp_sink_event_cb)
- ERR("AV event handler not registered");
+ if (!avrcp_ctrl_event_cb)
+ ERR("AVRCP controller handler not registered");
else
avrcp_ctrl_event_cb(HAL_EV_AVRCP_CTRL_CONN_STATE, &ev, sizeof(ev));
}
}
ev->num_attr = i;
- g_variant_iter_free(&iter);
return;
}
DBG("Property not handled");
}
}
-
- g_free((char *)property);
- g_variant_unref(value);
}
static void __bt_hal_handle_avrcp_transport_events(GVariant *msg, const char *member,
/* Send event to application */
avrcp_tg_event_cb(HAL_EV_AVRCP_TG_DELAY_CHANGE, &ev, sizeof(ev));
+ } else if ((strcasecmp(property, "Volume") == 0)) {
+ struct hal_ev_avrcp_tg_volume_changed ev;
+ uint16_t val;
+
+ memset(&ev, 0, sizeof(ev));
+ _bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
+
+ val = g_variant_get_uint16(value);
+ DBG("Value : %d", val);
+ ev.volume = val;
+
+ /* Send event to application */
+ avrcp_tg_event_cb(HAL_EV_AVRCP_TG_VOLUME_CHANGE, &ev, sizeof(ev));
} else {
DBG("Property not handled");
}
}
-
- DBG("-");
- g_free((char *)property);
- g_variant_unref(value);
}
/* A2DP Src Role(Remote:Sink) Events */
static void __bt_hal_send_av_connection_state_event(gboolean connected, const char *address)
{
- DBG("+");
struct hal_ev_a2dp_conn_state ev;
if (connected == TRUE)
/* A2DP Sink Role(Remote:Source) Events */
static void __bt_hal_send_a2dp_sink_connection_state_event(gboolean connected, const char *address)
{
- DBG("+");
struct hal_ev_a2dp_conn_state ev;
if (connected == TRUE)
static void __bt_hal_send_hf_audio_connection_state_event(gboolean connected,
const char *address)
{
- DBG("+");
struct hal_ev_handsfree_audio_state ev;
if (connected == TRUE)
static void __bt_hal_send_hf_connection_state_event(gboolean connected,
const char *address)
{
- DBG("+");
struct hal_ev_handsfree_conn_state ev;
if (connected == TRUE)