From: Amit Purwar Date: Wed, 3 Jan 2018 10:59:53 +0000 (+0530) Subject: resolved the code rule warnings X-Git-Tag: submit/tizen/20180110.041217^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdb0a76b987d717fdd61a4b5d5c022cafbd0ba9e;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git resolved the code rule warnings Change-Id: I14806911d8adbf1b5fadb98bb89c6b2f6d955514 Signed-off-by: Amit Purwar Signed-off-by: DoHyun Pyun --- diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index 810edabf..c2812218 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -2963,7 +2963,7 @@ static void __bt_tds_event_filter(GDBusConnection *connection, g_variant_get(parameters, "(i&sn@ay)", &result, &address, &data_len, &var); data = (char *)g_variant_get_data(var); - if(data) { + if (data) { BT_DBG("Address [%s]", address); BT_DBG("Data len [%d]", data_len); @@ -2992,7 +2992,7 @@ static void __bt_tds_event_filter(GDBusConnection *connection, g_free(info->data); g_free(info); } - } + } g_variant_unref(var); } else if (strcasecmp(signal_name, BT_TDS_ACTIVATION_RESULT) == 0) { BT_DBG("TDS Control point Activation result"); @@ -3601,11 +3601,11 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data) case BT_HEADSET_EVENT: event_func = __bt_headset_event_filter; path = BT_HEADSET_PATH; - break; + break; case BT_NETWORK_EVENT: event_func = __bt_network_event_filter; path = BT_NETWORK_PATH; - break; + break; case BT_AVRCP_EVENT: event_func = __bt_avrcp_event_filter; path = BT_AVRCP_PATH; @@ -3678,7 +3678,7 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data) path = BT_HDP_DEVICE_PATH; break; #ifndef GATT_DIRECT - case BT_GATT_SERVER_EVENT: + case BT_GATT_SERVER_EVENT: event_func = __bt_gatt_server_event_filter; path = BT_GATT_SERVER_PATH; break; diff --git a/bt-oal/bluez_hal/inc/bt-hal-log.h b/bt-oal/bluez_hal/inc/bt-hal-log.h index 9f29a013..78d8544f 100644 --- a/bt-oal/bluez_hal/inc/bt-hal-log.h +++ b/bt-oal/bluez_hal/inc/bt-hal-log.h @@ -37,16 +37,16 @@ #define LOG_COLOR_PURPLE "\033[35m" #define DBG(fmt, args...) \ - SLOGD(fmt, ##args) + SLOGD(fmt, ##args) #define INFO(fmt, args...) \ - SLOGI(fmt, ##args) + SLOGI(fmt, ##args) #define ERR(fmt, args...) \ - SLOGE(fmt, ##args) + SLOGE(fmt, ##args) #define INFO_C(fmt, arg...) \ - SLOGI_IF(TRUE, LOG_COLOR_GREEN" "fmt" "LOG_COLOR_RESET, ##arg) + SLOGI_IF(TRUE, LOG_COLOR_GREEN" "fmt" "LOG_COLOR_RESET, ##arg) #define ERR_C(fmt, arg...) \ - SLOGI_IF(TRUE, LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg) + SLOGI_IF(TRUE, LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg) #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args) #define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args) diff --git a/bt-oal/bluez_hal/inc/bt-hal-msg.h b/bt-oal/bluez_hal/inc/bt-hal-msg.h index 1dd9e4a9..1bbbfb69 100644 --- a/bt-oal/bluez_hal/inc/bt-hal-msg.h +++ b/bt-oal/bluez_hal/inc/bt-hal-msg.h @@ -50,10 +50,10 @@ These properties have to added to HAL bt_property_type_t enums */ struct hal_prop_device_service_rec { - uint8_t uuid[16]; - uint16_t channel; - uint8_t name_len; - uint8_t name[]; + uint8_t uuid[16]; + uint16_t channel; + uint8_t name_len; + uint8_t name[]; } __attribute__((packed)); #define HAL_PROP_DEVICE_FRIENDLY_NAME 0x0a @@ -79,30 +79,30 @@ struct hal_prop_device_service_rec { #define HAL_PROP_DEVICE_IS_ALIAS_SET 0x19 struct hal_prop_device_info { - uint8_t version; - uint16_t sub_version; - uint16_t manufacturer; + uint8_t version; + uint16_t sub_version; + uint16_t manufacturer; } __attribute__((packed)); #define HAL_PROP_DEVICE_TIMESTAMP 0xFF #define HAL_EV_ADAPTER_STATE_CHANGED 0x00 struct hal_ev_adapter_state_changed { - uint8_t state; + uint8_t state; } __attribute__((packed)); struct hal_property { - uint8_t type; - uint16_t len; - uint8_t val[0]; + uint8_t type; + uint16_t len; + uint8_t val[0]; } __attribute__((packed)); #define HAL_EV_ADAPTER_PROPS_CHANGED 0x01 struct hal_ev_adapter_props_changed { - uint8_t status; - uint8_t num_props; - struct hal_property props[0]; + uint8_t status; + uint8_t num_props; + struct hal_property props[0]; } __attribute__((packed)); @@ -111,39 +111,39 @@ struct hal_ev_adapter_props_changed { #define HAL_EV_DISCOVERY_STATE_CHANGED 0x85 struct hal_ev_discovery_state_changed { - uint8_t state; + uint8_t state; } __attribute__((packed)); #define HAL_EV_REMOTE_DEVICE_PROPS 0x83 struct hal_ev_remote_device_props { - uint8_t status; - uint8_t bdaddr[6]; - uint8_t num_props; - struct hal_property props[0]; + uint8_t status; + uint8_t bdaddr[6]; + uint8_t num_props; + struct hal_property props[0]; } __attribute__((packed)); #define HAL_EV_DEVICE_FOUND 0x84 struct hal_ev_device_found { - uint8_t num_props; - struct hal_property props[0]; + uint8_t num_props; + struct hal_property props[0]; } __attribute__((packed)); /* Device callbacks */ #define HAL_EV_PIN_REQUEST 0x86 struct hal_ev_pin_request { - uint8_t bdaddr[6]; - uint8_t name[249]; - uint32_t class_of_dev; + uint8_t bdaddr[6]; + uint8_t name[249]; + uint32_t class_of_dev; } __attribute__((packed)); #define HAL_EV_SSP_REQUEST 0x87 struct hal_ev_ssp_request { - uint8_t bdaddr[6]; - uint8_t name[249]; - uint32_t class_of_dev; - uint8_t pairing_variant; - uint32_t passkey; + uint8_t bdaddr[6]; + uint8_t name[249]; + uint32_t class_of_dev; + uint8_t pairing_variant; + uint32_t passkey; } __attribute__((packed)); #define HAL_BOND_STATE_NONE 0 @@ -152,9 +152,9 @@ struct hal_ev_ssp_request { #define HAL_EV_BOND_STATE_CHANGED 0x88 struct hal_ev_bond_state_changed { - uint8_t status; - uint8_t bdaddr[6]; - uint8_t state; + uint8_t status; + uint8_t bdaddr[6]; + uint8_t state; } __attribute__((packed)); #define HAL_EV_AUTHORIZE_REQUEST 0x89 @@ -166,7 +166,7 @@ struct hal_ev_authorize_request { #ifdef TIZEN_BT_HAL #define HAL_EV_SOCK_AUTHORIZE_REQUEST 0x90 struct hal_ev_sock_conn_auth { - uint8_t uuid[16]; + uint8_t uuid[16]; uint8_t bdaddr[6]; } __attribute__((packed)); #endif //TIZEN_BT_HAL @@ -176,9 +176,9 @@ struct hal_ev_sock_conn_auth { #define HAL_EV_ACL_STATE_CHANGED 0x8A struct hal_ev_acl_state_changed { - uint8_t status; - uint8_t bdaddr[6]; - uint8_t state; + uint8_t status; + uint8_t bdaddr[6]; + uint8_t state; } __attribute__((packed)); #define HAL_DEVICE_TRUSTED 0x00 @@ -186,8 +186,8 @@ struct hal_ev_acl_state_changed { #define HAL_EV_DEVICE_TRUST_CHANGED 0x8B struct hal_ev_device_trust_state_changed { - uint8_t bdaddr[6]; - uint8_t trust; + uint8_t bdaddr[6]; + uint8_t trust; } __attribute__((packed)); #define BT_TRANSPORT_UNKNOWN 0x00 @@ -205,8 +205,8 @@ struct hal_ev_device_trust_state_changed { #define HAL_EV_HIDHOST_CONN_STATE 0x81 struct hal_ev_hidhost_conn_state { - uint8_t bdaddr[6]; - uint8_t state; + uint8_t bdaddr[6]; + uint8_t state; } __attribute__((packed)); #define HAL_EV_HIDHOST_INFO 0x82 @@ -274,7 +274,7 @@ struct hal_ev_sock_connect { #define HAL_EV_A2DP_CONN_STATE 0x8C struct hal_ev_a2dp_conn_state { uint8_t state; - uint8_t bdaddr[6]; + uint8_t bdaddr[6]; } __attribute__((packed)); #define HAL_AUDIO_SUSPEND 0x00 @@ -283,15 +283,15 @@ struct hal_ev_a2dp_conn_state { #define HAL_EV_A2DP_AUDIO_STATE 0x8D struct hal_ev_a2dp_audio_state { - uint8_t state; - uint8_t bdaddr[6]; + uint8_t state; + uint8_t bdaddr[6]; } __attribute__((packed)); #define HAL_EV_A2DP_AUDIO_CONFIG 0x8E struct hal_ev_a2dp_audio_config { - uint8_t bdaddr[6]; - uint32_t sample_rate; - uint8_t channel_count; + uint8_t bdaddr[6]; + uint32_t sample_rate; + uint8_t channel_count; } __attribute__((packed)); /* A2DP Sink Role connection*/ @@ -306,8 +306,8 @@ struct hal_ev_a2dp_audio_config { #define HAL_EV_HANDSFREE_CONN_STATE 0x91 struct hal_ev_handsfree_conn_state { - uint8_t state; - uint8_t bdaddr[6]; + uint8_t state; + uint8_t bdaddr[6]; } __attribute__((packed)); #define HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED 0x00 @@ -317,8 +317,8 @@ struct hal_ev_handsfree_conn_state { #define HAL_EV_HANDSFREE_AUDIO_STATE 0x92 struct hal_ev_handsfree_audio_state { - uint8_t state; - uint8_t bdaddr[6]; + uint8_t state; + uint8_t bdaddr[6]; } __attribute__((packed)); /* HDP HAL Events */ @@ -331,7 +331,7 @@ struct hal_ev_hdp_app_reg_state { #define HAL_EV_HDP_CONN_STATE 0x94 struct hal_ev_hdp_conn_state { uint16_t app_id; - uint8_t bdaddr[6]; + uint8_t bdaddr[6]; uint8_t mdep_index; uint16_t channel_id; uint8_t channel_state; @@ -442,46 +442,46 @@ struct hal_ev_avrcp_tg_player_property { /* LE-GATT */ #define HAL_EV_SERVER_INSTANCE_INITIALIZED 0xA4 struct hal_ev_server_instance_registered { - uint32_t status; - uint32_t server_instance; - uint8_t app_uuid[16]; + uint32_t status; + uint32_t server_instance; + uint8_t app_uuid[16]; } __attribute__((packed)); #define HAL_EV_MULTI_ADV_DATA_SET 0xA5 struct hal_ev_multi_adv_data_set { - uint8_t status; - uint8_t server_instance; + uint8_t status; + uint8_t server_instance; } __attribute__((packed)); #define HAL_EV_MULTI_ADV_ENABLE 0xA6 struct hal_ev_multi_adv_enable { - uint32_t status; - uint32_t server_instance; + uint32_t status; + uint32_t server_instance; } __attribute__((packed)); #define HAL_EV_MULTI_ADV_DISABLE 0xA7 struct hal_ev_multi_adv_disable { - uint32_t status; - uint32_t server_instance; + uint32_t status; + uint32_t server_instance; } __attribute__((packed)); #define HAL_EV_MULTI_ADV_UPDATE 0xA8 struct hal_ev_multi_adv_update { - uint32_t status; - uint32_t server_instance; + uint32_t status; + uint32_t server_instance; } __attribute__((packed)); #define HAL_EV_LEGACY_ADV_ENABLE 0xA9 struct hal_ev_legacy_adv_status { - uint32_t status; - uint32_t server_instance; + uint32_t status; + uint32_t server_instance; } __attribute__((packed)); #define HAL_EV_GATT_CLIENT_REGISTERED 0xAA struct hal_ev_gatt_client_registered { - uint32_t status; - uint32_t client_if; - uint8_t app_uuid[16]; + uint32_t status; + uint32_t client_if; + uint8_t app_uuid[16]; } __attribute__((packed)); #define HAL_EV_GATT_CLIENT_SCAN_RESULT 0xAC @@ -496,97 +496,97 @@ struct hal_ev_gatt_client_scan_result { #define HAL_EV_GATT_SERVICE_ADDED 0xAD struct hal_ev_gatt_service_added { - uint32_t status; - uint32_t server_instance; + uint32_t status; + uint32_t server_instance; uint8_t is_primary; uint8_t svc_uuid[16]; - uint32_t service_handle; + uint32_t service_handle; } __attribute__((packed)); #define HAL_EV_GATT_CHAR_ADDED 0xAE struct hal_ev_gatt_char_added { - uint32_t status; - uint32_t server_instance; - uint32_t service_handle; - uint32_t char_handle; + uint32_t status; + uint32_t server_instance; + uint32_t service_handle; + uint32_t char_handle; uint8_t char_uuid[16]; } __attribute__((packed)); #define HAL_EV_GATT_DESC_ADDED 0xAF struct hal_ev_gatt_desc_added { - uint32_t status; - uint32_t server_instance; - uint32_t service_handle; - uint32_t desc_handle; + uint32_t status; + uint32_t server_instance; + uint32_t service_handle; + uint32_t desc_handle; uint8_t desc_uuid[16]; } __attribute__((packed)); #define HAL_EV_GATT_SERVICE_STARTED 0xB0 struct hal_ev_gatt_service_started { - uint32_t status; - uint32_t server_instance; - uint32_t service_handle; + uint32_t status; + uint32_t server_instance; + uint32_t service_handle; } __attribute__((packed)); #define HAL_EV_GATT_SERVICE_DELETED 0xB1 struct hal_ev_gatt_service_deleted { - uint32_t status; - uint32_t server_instance; - uint32_t service_handle; + uint32_t status; + uint32_t server_instance; + uint32_t service_handle; } __attribute__((packed)); #define HAL_EV_GATT_SERVER_CONNECTED 0xB2 struct hal_ev_gatt_server_connected { - uint32_t conn_id; - uint32_t server_instance; - uint8_t connected; + uint32_t conn_id; + uint32_t server_instance; + uint8_t connected; uint8_t bdaddr[6]; } __attribute__((packed)); #define HAL_EV_GATT_READ_REQUESTED 0xB3 struct hal_ev_gatt_server_read_req { - uint32_t conn_id; - uint32_t trans_id; + uint32_t conn_id; + uint32_t trans_id; uint8_t bdaddr[6]; - uint32_t att_handle; - uint32_t offset; - uint8_t is_long; + uint32_t att_handle; + uint32_t offset; + uint8_t is_long; } __attribute__((packed)); #define HAL_EV_GATT_WRITE_REQUESTED 0xB4 struct hal_ev_gatt_server_write_req { - uint32_t conn_id; - uint32_t trans_id; + uint32_t conn_id; + uint32_t trans_id; uint8_t bdaddr[6]; - uint32_t att_handle; - uint32_t offset; - uint32_t length; - uint8_t need_rsp; - uint8_t is_prep; - uint8_t value[0]; + uint32_t att_handle; + uint32_t offset; + uint32_t length; + uint8_t need_rsp; + uint8_t is_prep; + uint8_t value[0]; } __attribute__((packed)); #define HAL_EV_GATT_INDICATE_CFM 0xB5 struct hal_ev_gatt_server_indicate_cfm { - uint32_t conn_id; - uint32_t trans_id; - uint32_t att_handle; + uint32_t conn_id; + uint32_t trans_id; + uint32_t att_handle; uint8_t bdaddr[6]; } __attribute__((packed)); #ifdef TIZEN_BT_HAL #define HAL_EV_GATT_NOTIFICATION_CHANGE 0xB6 struct hal_ev_gatt_server_notifcation_change { - uint32_t conn_id; - uint32_t trans_id; - uint32_t att_handle; + uint32_t conn_id; + uint32_t trans_id; + uint32_t att_handle; uint8_t notify; uint8_t bdaddr[6]; } __attribute__((packed)); #define HAL_EV_LE_STATE_CHANGED 0xB7 struct hal_ev_le_state_changed { - uint8_t state; + uint8_t state; } __attribute__((packed)); #endif /* TIZEN_BT_HAL */ @@ -595,15 +595,15 @@ struct hal_ev_le_state_changed { #define HAL_EV_LE_CONN_STATE_CHANGED 0xB8 struct hal_ev_le_conn_state_changed { - uint8_t status; - uint8_t bdaddr[6]; - uint8_t state; + uint8_t status; + uint8_t bdaddr[6]; + uint8_t state; } __attribute__((packed)); #define HAL_EV_DEVICE_TRUSTED_PROFILES_CHANGED 0xB9 struct hal_ev_device_trusted_profiles_changed { - uint8_t bdaddr[6]; - uint32_t trust_val; + uint8_t bdaddr[6]; + uint32_t trust_val; } __attribute__((packed)); #define HAL_RSSI_MONITORING_ENABLED 0x00 @@ -611,14 +611,14 @@ struct hal_ev_device_trusted_profiles_changed { #define HAL_EV_RSSI_MONITOR_STATE_CHANGED 0xBA struct hal_ev_rssi_monitor_state_changed { - uint8_t bdaddr[6]; + uint8_t bdaddr[6]; int32_t link_type; - uint8_t state; + uint8_t state; } __attribute__((packed)); #define HAL_EV_RSSI_ALERT_RECIEVED 0xBB struct hal_ev_rssi_alert_recieved { - uint8_t bdaddr[6]; + uint8_t bdaddr[6]; int32_t link_type; int32_t alert_type; int32_t rssi; @@ -626,7 +626,7 @@ struct hal_ev_rssi_alert_recieved { #define HAL_EV_RAW_RSSI_RECIEVED 0xBC struct hal_ev_raw_rssi_recieved { - uint8_t bdaddr[6]; + uint8_t bdaddr[6]; int32_t link_type; int32_t rssi; } __attribute__((packed)); diff --git a/bt-oal/bluez_hal/inc/bt-hal-utils.h b/bt-oal/bluez_hal/inc/bt-hal-utils.h index 793bd2e3..6fc235a8 100644 --- a/bt-oal/bluez_hal/inc/bt-hal-utils.h +++ b/bt-oal/bluez_hal/inc/bt-hal-utils.h @@ -39,8 +39,8 @@ static const char BT_BASE_UUID[BT_HAL_UUID_128] = { }; static const char BASE_UUID_CONVERTED[BT_HAL_UUID_128] = { - 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /** BT Profile Service UUID's */ diff --git a/bt-oal/bluez_hal/src/bt-hal-a2dp-sink-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-a2dp-sink-dbus-handler.c index fb5ffa5f..4f08b1bb 100644 --- a/bt-oal/bluez_hal/src/bt-hal-a2dp-sink-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-a2dp-sink-dbus-handler.c @@ -49,7 +49,7 @@ void _bt_hal_unregister_a2dp_sink_dbus_handler_cb() } static void __bt_a2dp_sink_connect_cb(GDBusProxy *proxy, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { GError *g_error = NULL; struct hal_ev_a2dp_conn_state ev; @@ -104,13 +104,13 @@ bt_status_t _bt_hal_dbus_handler_a2dp_sink_connect(bt_bdaddr_t *bd_addr) int ret; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -134,7 +134,7 @@ bt_status_t _bt_hal_dbus_handler_a2dp_sink_connect(bt_bdaddr_t *bd_addr) } static void __bt_a2dp_source_disconnect_cb(GDBusProxy *proxy, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { GError *g_error = NULL; struct hal_ev_a2dp_conn_state ev; @@ -190,13 +190,13 @@ bt_status_t _bt_hal_dbus_handler_a2dp_sink_disconnect(bt_bdaddr_t *bd_addr) int ret; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -235,13 +235,13 @@ bt_status_t _bt_hal_dbus_handler_enable_a2dp_sink(void) } gconn = _bt_hal_get_system_gconn(); - if(!gconn) { + if (!gconn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } adapter_path = _bt_hal_get_adapter_path(); - if(!adapter_path) { + if (!adapter_path) { ERR("adapter_path is NULL"); return BT_STATUS_FAIL; } diff --git a/bt-oal/bluez_hal/src/bt-hal-a2dp-sink.c b/bt-oal/bluez_hal/src/bt-hal-a2dp-sink.c index d7f6a123..dbe78298 100644 --- a/bt-oal/bluez_hal/src/bt-hal-a2dp-sink.c +++ b/bt-oal/bluez_hal/src/bt-hal-a2dp-sink.c @@ -68,23 +68,23 @@ static void __bt_hal_handle_a2dp_sink_audio_conn_state(void *buf, uint16_t len) static void __bt_hal_handle_a2dp_sink_events(int message, void *buf, uint16_t len) { - DBG("+"); - if (!interface_ready()) - return; - switch(message) { - case HAL_EV_A2DP_SOURCE_CONN_STATE: - DBG("Event: HAL_EV_A2DP_SOURCE_CONN_STATE"); - __bt_hal_handle_a2dp_sink_conn_state(buf, len); - break; - case HAL_EV_A2DP_AUDIO_STATE: - DBG("Event: HAL_EV_A2DP_AUDIO_STATE"); - __bt_hal_handle_a2dp_sink_audio_conn_state(buf, len); - break; - default: - DBG("Event Currently not handled!!"); - break; - } - DBG("-"); + DBG("+"); + if (!interface_ready()) + return; + switch (message) { + case HAL_EV_A2DP_SOURCE_CONN_STATE: + DBG("Event: HAL_EV_A2DP_SOURCE_CONN_STATE"); + __bt_hal_handle_a2dp_sink_conn_state(buf, len); + break; + case HAL_EV_A2DP_AUDIO_STATE: + DBG("Event: HAL_EV_A2DP_AUDIO_STATE"); + __bt_hal_handle_a2dp_sink_audio_conn_state(buf, len); + break; + default: + DBG("Event Currently not handled!!"); + break; + } + DBG("-"); } static bt_status_t init(btav_callbacks_t* callbacks) diff --git a/bt-oal/bluez_hal/src/bt-hal-adapter-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-adapter-dbus-handler.c index fff0e1c8..d3fdb56e 100644 --- a/bt-oal/bluez_hal/src/bt-hal-adapter-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-adapter-dbus-handler.c @@ -105,7 +105,7 @@ static gboolean __bt_hal_send_adapter_event(gpointer user_data) struct hal_ev_adapter_state_changed ev; gboolean *enable = (gboolean *)user_data; - if(*enable == TRUE) + if (*enable == TRUE) ev.state = HAL_POWER_ON; else ev.state = HAL_POWER_OFF; @@ -113,9 +113,9 @@ static gboolean __bt_hal_send_adapter_event(gpointer user_data) if (!event_cb) event_cb = _bt_get_adapter_event_cb(); - if (event_cb) { + if (event_cb) event_cb(HAL_EV_ADAPTER_STATE_CHANGED, &ev, sizeof(ev)); - } + g_free(enable); return false; } @@ -125,7 +125,7 @@ static gboolean __bt_hal_send_le_event(gpointer user_data) struct hal_ev_le_state_changed ev; gboolean *enable = (gboolean *)user_data; - if(*enable == TRUE) + if (*enable == TRUE) ev.state = HAL_POWER_ON; else ev.state = HAL_POWER_OFF; @@ -133,9 +133,9 @@ static gboolean __bt_hal_send_le_event(gpointer user_data) if (!event_cb) event_cb = _bt_get_adapter_event_cb(); - if (event_cb) { + if (event_cb) event_cb(HAL_EV_LE_STATE_CHANGED, &ev, sizeof(ev)); - } + g_free(enable); return false; @@ -151,16 +151,14 @@ int _bt_hal_dbus_enable_adapter(void) DBG("+"); int le_value = VCONFKEY_BT_LE_STATUS_OFF; - if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &le_value)) { + if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &le_value)) ERR("fail to get vconf key!"); - } - if(_bt_hal_get_adapter_powered_state(&powered) == BT_STATUS_FAIL) { + if (_bt_hal_get_adapter_powered_state(&powered) == BT_STATUS_FAIL) ERR("_bt_hal_get_adapter_powered_state failed"); - } /*if LE is enabled and bluez is UP , send event from here and return.*/ - if((le_value == VCONFKEY_BT_LE_STATUS_ON)&&(powered == 1)) { + if ((le_value == VCONFKEY_BT_LE_STATUS_ON) && (powered == 1)) { gboolean *user_data = g_new0(int, 1); *user_data = TRUE; g_idle_add(__bt_hal_send_adapter_event, (gpointer)user_data); @@ -254,15 +252,13 @@ int _bt_hal_dbus_enable_le(void) DBG("+"); - if (vconf_get_int(VCONFKEY_BT_STATUS, &adapter_value) != 0) { + if (vconf_get_int(VCONFKEY_BT_STATUS, &adapter_value) != 0) ERR("fail to get vconf key!"); - } - if(_bt_hal_get_adapter_powered_state(&powered) == BT_STATUS_FAIL) { + if (_bt_hal_get_adapter_powered_state(&powered) == BT_STATUS_FAIL) ERR("_bt_hal_get_adapter_powered_state failed"); - } - if((adapter_value == VCONFKEY_BT_STATUS_ON) && (powered == 1)) { + if ((adapter_value == VCONFKEY_BT_STATUS_ON) && (powered == 1)) { gboolean *user_data = g_new0(int, 1); *user_data = TRUE; g_idle_add(__bt_hal_send_le_event, (gpointer)user_data); @@ -316,11 +312,10 @@ int _bt_hal_dbus_disable_le(void) int adapter_value = VCONFKEY_BT_STATUS_OFF; DBG("+"); - if (vconf_get_int(VCONFKEY_BT_STATUS, &adapter_value) != 0) { + if (vconf_get_int(VCONFKEY_BT_STATUS, &adapter_value) != 0) ERR("fail to get vconf key!"); - } - if(adapter_value == VCONFKEY_BT_STATUS_ON) { + if (adapter_value == VCONFKEY_BT_STATUS_ON) { gboolean *user_data = g_new0(int, 1); *user_data = FALSE; g_idle_add(__bt_hal_send_le_event, (gpointer)user_data); @@ -485,15 +480,14 @@ static void ___bt_fill_le_supported_features(const char *item, { DBG("+"); - if (g_strcmp0(item, "adv_inst_max") == 0) { + if (g_strcmp0(item, "adv_inst_max") == 0) le_features[1] = atoi(value); - } else if (g_strcmp0(item, "rpa_offloading") == 0) { + else if (g_strcmp0(item, "rpa_offloading") == 0) le_features[2] = atoi(value); - } else if (g_strcmp0(item, "max_filter") == 0) { + else if (g_strcmp0(item, "max_filter") == 0) le_features[4] = atoi(value); - } else { + else DBG("No registered item"); - } /* * TODO: Need to check these usages for Bluez Case. In Bluedroid case, @@ -546,7 +540,7 @@ static gboolean __bt_adapter_all_properties_cb(gpointer user_data) DBG("@@Start parsing properties"); g_variant_get(result, "(a{sv})", &property_iter); while (g_variant_iter_loop(property_iter, "{sv}", &key, &value)) { - if(!g_strcmp0(key, "Address")) { + if (!g_strcmp0(key, "Address")) { uint8_t bdaddr[6]; address = (gchar *) g_variant_get_string(value, NULL); @@ -619,7 +613,7 @@ static gboolean __bt_adapter_all_properties_cb(gpointer user_data) char **uuid_value; int uuid_count = 0; gsize size1 = 0; - int i =0; + int i = 0; size1 = g_variant_get_size(value); int num_props_tmp = ev->num_props; if (size1 > 0) { @@ -774,7 +768,7 @@ int _bt_hal_get_adapter_powered_state(uint8_t *state) int ret = BT_STATUS_FAIL; /* Check Valid Adapter Path, followed by Adapter Powered state. - If any of these fails, adapter will be considered Disabled */ + If any of these fails, adapter will be considered Disabled */ adapter_path = _bt_hal_get_adapter_path(); if (adapter_path == NULL) { @@ -832,7 +826,7 @@ static gboolean __bt_adapter_discovery_timeout_cb(gpointer user_data) if (size > 2) { DBG("Send Adapter Properties changed event to HAL user," - " Num Prop [%d] total size [%d]",ev->num_props, size); + " Num Prop [%d] total size [%d]", ev->num_props, size); event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size); } done: @@ -928,7 +922,7 @@ static gboolean __bt_adapter_scan_mode_cb(gpointer user_data) if (size > 2) { DBG("Send Adapter Properties changed event to HAL user," - " Num Prop [%d] total size [%d]",ev->num_props, size); + " Num Prop [%d] total size [%d]", ev->num_props, size); event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size); } done: @@ -1060,7 +1054,7 @@ static gboolean __bt_adapter_local_version_cb(gpointer user_data) if (size > 2) { DBG("Send Adapter Properties changed event to HAL user," - " Num Prop [%d] total size [%d]",ev->num_props, size); + " Num Prop [%d] total size [%d]", ev->num_props, size); event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size); } done: @@ -1139,7 +1133,7 @@ static gboolean __bt_adapter_local_name_cb(gpointer user_data) strlen(name) + 1, name); ev->num_props++; - DBG("Device name [%s] property Num [%d]",name, ev->num_props); + DBG("Device name [%s] property Num [%d]", name, ev->num_props); if (!event_cb) event_cb = _bt_get_adapter_event_cb(); @@ -1150,7 +1144,7 @@ static gboolean __bt_adapter_local_name_cb(gpointer user_data) if (size > 2) { DBG("Send Adapter Properties changed event to HAL user," - " Num Prop [%d] total size [%d]",ev->num_props, size); + " Num Prop [%d] total size [%d]", ev->num_props, size); event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size); } done: @@ -1231,7 +1225,7 @@ static gboolean __bt_adapter_local_address_cb(gpointer user_data) sizeof(bdaddr), bdaddr); ev->num_props++; - DBG("Device address [%s] property Num [%d]",address, ev->num_props); + DBG("Device address [%s] property Num [%d]", address, ev->num_props); size += __bt_insert_hal_properties(buf + size, HAL_PROP_ADAPTER_ADDR, sizeof(bdaddr), bdaddr); @@ -1245,7 +1239,7 @@ static gboolean __bt_adapter_local_address_cb(gpointer user_data) if (size > 1) { DBG("Send Device found event to HAL user," - " Num Prop [%d] total size [%d]",ev->num_props, size); + " Num Prop [%d] total size [%d]", ev->num_props, size); event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size); } done: @@ -1290,11 +1284,10 @@ int _bt_hal_dbus_get_local_address(void) g_variant_get(result, "(v)", &temp); address = g_variant_dup_string(temp, NULL); - if (address) { + if (address) DBG("Address:%s", address); - } else { + else return BT_STATUS_FAIL; - } g_variant_unref(result); g_variant_unref(temp); @@ -1438,7 +1431,7 @@ static gboolean __is_device_paired(GVariantIter *item_iter) gchar *key; while (g_variant_iter_loop(item_iter, "{sv}", &key, &value)) { - if (NULL == key || g_strcmp0(key,"Paired")) + if (NULL == key || g_strcmp0(key, "Paired")) continue; paired = g_variant_get_boolean(value); @@ -1481,7 +1474,7 @@ static gboolean __bt_adapter_bonded_devices_cb(gpointer user_data) /* Parse the signature: {oa{sa{sv}}} */ while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path, &interface_iter)) { - if(object_path == NULL) + if (object_path == NULL) continue; while (g_variant_iter_loop(interface_iter, "{sa{sv}}", @@ -1522,7 +1515,7 @@ static gboolean __bt_adapter_bonded_devices_cb(gpointer user_data) if (size > 2) { DBG("Send Adapter properties changed event to HAL user," - " Num Prop [%d] total size [%d]",ev->num_props, size); + " Num Prop [%d] total size [%d]", ev->num_props, size); event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size); } done: diff --git a/bt-oal/bluez_hal/src/bt-hal-adapter-le.c b/bt-oal/bluez_hal/src/bt-hal-adapter-le.c index a901c7ac..a4899022 100644 --- a/bt-oal/bluez_hal/src/bt-hal-adapter-le.c +++ b/bt-oal/bluez_hal/src/bt-hal-adapter-le.c @@ -49,17 +49,17 @@ #include "bt-hal-gatt-server.h" typedef struct { - int adv_inst_max; - int rpa_offloading; - int max_filter; + int adv_inst_max; + int rpa_offloading; + int max_filter; } bt_adapter_le_feature_info_t; typedef struct { int initialized; gboolean is_multi_adv; /* To be removed once we complete descope Legacy Adv */ - int adv_handle; - gboolean is_advertising; - guint hold_timer_id; + int adv_handle; + gboolean is_advertising; + guint hold_timer_id; bt_uuid_t app_uuid; } bt_adapter_le_adv_slot_t; @@ -68,9 +68,9 @@ static bt_adapter_le_adv_slot_t *le_adv_slot = NULL; typedef struct { uint8_t event; - int server_if; - uint8_t status; - uint8_t data[31]; + int server_if; + uint8_t status; + uint8_t data[31]; } bt_hal_adv_event_data_t; /* Macros */ @@ -125,9 +125,9 @@ static void __bt_hal_free_le_adv_slot(void) if (le_adv_slot == NULL) return; - for (i = 0; i < le_feature_info.adv_inst_max; i++) { + for (i = 0; i < le_feature_info.adv_inst_max; i++) memset(&le_adv_slot[i], 0x00, sizeof(bt_adapter_le_adv_slot_t)); - } + g_free(le_adv_slot); le_adv_slot = NULL; } @@ -156,7 +156,7 @@ gboolean _bt_hal_is_advertising_in_slot(int slot) void _bt_hal_set_advertising_status(int slot_id, gboolean mode) { - DBG("Advertising enabled [%s] slot [%d]", mode? "TRUE": "FALSE", slot_id); + DBG("Advertising enabled [%s] slot [%d]", mode ? "TRUE" : "FALSE", slot_id); bt_hal_adv_event_data_t *event; if (le_adv_slot == NULL) @@ -165,7 +165,7 @@ void _bt_hal_set_advertising_status(int slot_id, gboolean mode) le_adv_slot[slot_id].is_advertising = mode; event = g_malloc0(sizeof(bt_hal_adv_event_data_t)); - event->event = mode? BT_HAL_MULTI_ADV_ENB_EVT: BT_HAL_MULTI_ADV_DISABLE_EVT; + event->event = mode ? BT_HAL_MULTI_ADV_ENB_EVT : BT_HAL_MULTI_ADV_DISABLE_EVT; event->server_if = slot_id; event->status = BT_STATUS_SUCCESS; /* To be removed later when we completely descope Legacy Adv concept */ @@ -401,7 +401,7 @@ static void __bt_hal_parse_uuid(int len, char *src, uint8_t *dest, int *length, dest[index+1] = 0x06; /* AD Type */ memcpy(&(dest[index + 2]), &src[12], byte_len); /* Update current type */ - prev_byte_len = byte_len; + prev_byte_len = byte_len; *length += 18; break; } @@ -420,19 +420,19 @@ static void __bt_hal_parse_uuid(int len, char *src, uint8_t *dest, int *length, static gboolean __bt_hal_is_factory_test_mode(void) { - int mode = 0; + int mode = 0; - if (vconf_get_bool(VCONFKEY_BT_DUT_MODE, &mode)) { - ERR("Get the DUT Mode fail"); - return TRUE; - } + if (vconf_get_bool(VCONFKEY_BT_DUT_MODE, &mode)) { + ERR("Get the DUT Mode fail"); + return TRUE; + } - if (mode != FALSE) { - INFO("DUT Test Mode !!"); - return TRUE; - } + if (mode != FALSE) { + INFO("DUT Test Mode !!"); + return TRUE; + } - return FALSE; + return FALSE; } static gboolean __bt_hal_adv_event_cb(gpointer param) @@ -448,7 +448,7 @@ static gboolean __bt_hal_adv_event_cb(gpointer param) return FALSE; } - switch(event->event) { + switch (event->event) { case BT_HAL_MULTI_ADV_ENB_EVT: { INFO("BLE Advertising enabled slot [%d]", event->server_if); struct hal_ev_multi_adv_enable ev; @@ -558,61 +558,61 @@ int _bt_hal_enable_advertising(int server_if, bool enable, bool is_multi_adv) } int _bt_hal_set_advertising_params(int server_if, int min_interval, - int max_interval,int adv_type, - int chnl_map, int tx_power, int timeout_s) + int max_interval, int adv_type, + int chnl_map, int tx_power, int timeout_s) { DBG("+"); GDBusProxy *proxy; - GVariant *ret; - GError *error = NULL; - guint32 min = 0; - guint32 max = 0; + GVariant *ret; + GError *error = NULL; + guint32 min = 0; + guint32 max = 0; bt_hal_adv_event_data_t *event; proxy = _bt_hal_get_adapter_proxy(); - if (proxy == NULL) + if (proxy == NULL) return BT_STATUS_FAIL; if (min_interval > max_interval || - min_interval < BT_HAL_ADV_INTERVAL_MIN || - max_interval > BT_HAL_ADV_INTERVAL_MAX) + min_interval < BT_HAL_ADV_INTERVAL_MIN || + max_interval > BT_HAL_ADV_INTERVAL_MAX) return BT_STATUS_PARM_INVALID; if (adv_type == BT_HAL_ADV_CONNECTABLE_DIRECT_HIGH || - adv_type == BT_HAL_ADV_CONNECTABLE_DIRECT_LOW || - adv_type == BT_HAL_ADV_NON_CONNECTABLE) - return BT_STATUS_UNSUPPORTED; + adv_type == BT_HAL_ADV_CONNECTABLE_DIRECT_LOW || + adv_type == BT_HAL_ADV_NON_CONNECTABLE) + return BT_STATUS_UNSUPPORTED; min = min_interval / BT_HAL_ADV_INTERVAL_SPLIT; - max = max_interval / BT_HAL_ADV_INTERVAL_SPLIT; + max = max_interval / BT_HAL_ADV_INTERVAL_SPLIT; ret = g_dbus_proxy_call_sync(proxy, "SetAdvertisingParameters", - g_variant_new("(uuuui)", min, max, - BT_HAL_ADV_FILTER_POLICY_DEFAULT, adv_type, - server_if), G_DBUS_CALL_FLAGS_NONE, - -1, NULL, &error); + g_variant_new("(uuuui)", min, max, + BT_HAL_ADV_FILTER_POLICY_DEFAULT, adv_type, + server_if), G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &error); if (error) { - ERR("SetAdvertisingParameters Fail: %s", error->message); - g_clear_error(&error); + ERR("SetAdvertisingParameters Fail: %s", error->message); + g_clear_error(&error); return BT_STATUS_FAIL; - } + } INFO("Set advertising data"); - if (ret) - g_variant_unref(ret); + if (ret) + g_variant_unref(ret); /* - * As we need to provide async callback to user from HAL, simply schedule a - * callback method which will carry actual result - */ + * As we need to provide async callback to user from HAL, simply schedule a + * callback method which will carry actual result + */ event = g_malloc0(sizeof(bt_hal_adv_event_data_t)); event->event = BT_HAL_MULTI_ADV_UPDATE_EVT; event->server_if = server_if; event->status = BT_STATUS_SUCCESS; - g_idle_add(__bt_hal_adv_event_cb, (gpointer)event); + g_idle_add(__bt_hal_adv_event_cb, (gpointer)event); return BT_STATUS_SUCCESS; } @@ -624,23 +624,23 @@ int _bt_hal_set_advertising_data(btgatt_adv_param_setup_t adv_param_setup) uint8_t adv_data[31]; int index = 0; GDBusProxy *proxy; - GError *error = NULL; - GVariant *ret = NULL; - GVariant *temp = NULL; - GVariantBuilder *builder; + GError *error = NULL; + GVariant *ret = NULL; + GVariant *temp = NULL; + GVariantBuilder *builder; bt_hal_adv_event_data_t *event; int length = 0; - int i; + int i; /* Parse data according to Bluez Interface */ if (__bt_hal_is_factory_test_mode()) { - ERR("Unable to set advertising data in factory binary !!"); - return BT_STATUS_UNSUPPORTED; - } + ERR("Unable to set advertising data in factory binary !!"); + return BT_STATUS_UNSUPPORTED; + } /* TODO: Check adapter and LE adapter status */ proxy = _bt_hal_get_adapter_proxy(); - if (proxy == NULL) + if (proxy == NULL) return BT_STATUS_FAIL; memset(&adv_data, 0, 31); @@ -715,15 +715,15 @@ int _bt_hal_set_advertising_data(btgatt_adv_param_setup_t adv_param_setup) /* Create Builder */ builder = g_variant_builder_new(G_VARIANT_TYPE("ay")); - for (i = 0; i < length; i++) - g_variant_builder_add(builder, "y", adv_data[i]); + for (i = 0; i < length; i++) + g_variant_builder_add(builder, "y", adv_data[i]); - temp = g_variant_new("ay", builder); - g_variant_builder_unref(builder); + temp = g_variant_new("ay", builder); + g_variant_builder_unref(builder); - DBG("####Adv data length [%d] Index [%d]", length, index); - for (i = 0; i < length; i++) - DBG("##Data[%d] [0x%x]", i, adv_data[i]); + DBG("####Adv data length [%d] Index [%d]", length, index); + for (i = 0; i < length; i++) + DBG("##Data[%d] [0x%x]", i, adv_data[i]); if (adv_param_setup.set_scan_rsp == 0) { /* Set Advertising data to stack */ @@ -739,28 +739,28 @@ int _bt_hal_set_advertising_data(btgatt_adv_param_setup_t adv_param_setup) -1, NULL, &error); } - if (error) { - ERR("SetAdvertisingData Fail: %s", error->message); - g_clear_error(&error); - return BT_STATUS_FAIL; - } + if (error) { + ERR("SetAdvertisingData Fail: %s", error->message); + g_clear_error(&error); + return BT_STATUS_FAIL; + } INFO("Set advertising data"); - if (ret) - g_variant_unref(ret); + if (ret) + g_variant_unref(ret); /* - * As we need to provide async callback to user from HAL, simply schedule a - * callback method which will carry actual result - */ + * As we need to provide async callback to user from HAL, simply schedule a + * callback method which will carry actual result + */ event = g_malloc0(sizeof(bt_hal_adv_event_data_t)); event->event = BT_HAL_MULTI_ADV_DATA_EVT; event->server_if = adv_param_setup.server_if; event->status = BT_STATUS_SUCCESS; memcpy(&event->data, adv_data, 31); - g_idle_add(__bt_hal_adv_event_cb, (gpointer)event); + g_idle_add(__bt_hal_adv_event_cb, (gpointer)event); - return BT_STATUS_SUCCESS; + return BT_STATUS_SUCCESS; } int _bt_hal_adapter_le_start_scan(void) diff --git a/bt-oal/bluez_hal/src/bt-hal-adapter-le.h b/bt-oal/bluez_hal/src/bt-hal-adapter-le.h index 1b3258c3..5676b6e6 100644 --- a/bt-oal/bluez_hal/src/bt-hal-adapter-le.h +++ b/bt-oal/bluez_hal/src/bt-hal-adapter-le.h @@ -62,7 +62,7 @@ void _bt_hal_free_server_slot(int slot_id); int _bt_hal_set_advertising_data(btgatt_adv_param_setup_t adv_param_setup); int _bt_hal_set_advertising_params(int server_if, int min_interval, - int max_interval, int adv_type, + int max_interval, int adv_type, int chnl_map, int tx_power, int timeout_s); int _bt_hal_enable_advertising(int server_if, bool enable, bool is_multi_adv); diff --git a/bt-oal/bluez_hal/src/bt-hal-agent.c b/bt-oal/bluez_hal/src/bt-hal-agent.c index 3b58d5d9..6f600f3c 100644 --- a/bt-oal/bluez_hal/src/bt-hal-agent.c +++ b/bt-oal/bluez_hal/src/bt-hal-agent.c @@ -73,8 +73,8 @@ #define BT_HAL_AGENT_SYSPOPUP_MAX_ATTEMPT 3 #define G_VARIANT_UNREF(variant) \ - g_variant_unref(variant); \ - variant = NULL + g_variant_unref(variant); \ + variant = NULL #define BT_HAL_MAX_EVENT_STR_LENGTH 50 static void *adapter_agent = NULL; @@ -93,7 +93,7 @@ static gboolean __bt_hal_passkey_request(GapAgentPrivate *agent, GDBusProxy *dev static gboolean __bt_hal_confirm_request(GapAgentPrivate *agent, GDBusProxy *device, guint passkey); static gboolean __bt_hal_authorize_request(GapAgentPrivate *agent, GDBusProxy *device, - const char *uuid); + const char *uuid); static gboolean __bt_hal_authorize_cancel_request(GapAgentPrivate *agent, const char *address); static gboolean __bt_hal_pairing_cancel_request(GapAgentPrivate *agent, const char *address); static GVariant *__bt_hal_service_getall(GDBusProxy *device, const char *interface); @@ -103,12 +103,12 @@ static inline void stack_trim(void); static gboolean __bt_hal_device_is_hid_keyboard(unsigned int dev_class); static int __bt_hal_device_generate_passkey(char *passkey, int size); static gboolean __bt_hal_device_is_auto_response(uint32_t dev_class, - const gchar *address, const gchar *name); + const gchar *address, const gchar *name); static gboolean __bt_hal_device_is_device_blacklisted(const char *address, const char *name); static gboolean __bt_hal_find_device_by_address_exactname(char *buffer, - const char *address); + const char *address); static gboolean __bt_hal_find_device_by_partial_name(char *buffer, - const char *partial_name); + const char *partial_name); static void __bt_hal_send_ssp_request_events(const gchar *address, const gchar *name, guint passkey, uint32_t cod, unsigned char variant); static void __bt_hal_send_authorize_request_event(const gchar *address, const char *uuid); @@ -401,7 +401,7 @@ static gboolean __bt_hal_pincode_request(GapAgentPrivate *agent, GDBusProxy *dev goto done; } - g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/ + g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/ tmp_value = g_variant_lookup_value(reply, "Class", G_VARIANT_TYPE_UINT32); g_variant_get(tmp_value, "u", &device_class); @@ -523,9 +523,9 @@ static gboolean __bt_hal_display_request(GapAgentPrivate *agent, GDBusProxy *dev goto done; } - g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/ + g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/ - tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING); + tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING); g_variant_get(tmp_value, "s", &address); G_VARIANT_UNREF(tmp_value); if (!address) { @@ -594,9 +594,9 @@ static gboolean __bt_hal_passkey_request(GapAgentPrivate *agent, GDBusProxy *dev goto done; } - g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/ + g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/ - tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING); + tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING); g_variant_get(tmp_value, "s", &address); G_VARIANT_UNREF(tmp_value); if (!address) { @@ -660,13 +660,13 @@ static gboolean __bt_hal_confirm_request(GapAgentPrivate *agent, GDBusProxy *dev NULL); goto done; } - g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/ + g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/ - tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING); + tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING); g_variant_get(tmp_value, "s", &address); G_VARIANT_UNREF(tmp_value); - tmp_value = g_variant_lookup_value (reply, "Name", G_VARIANT_TYPE_STRING); + tmp_value = g_variant_lookup_value(reply, "Name", G_VARIANT_TYPE_STRING); g_variant_get(tmp_value, "s", &name); G_VARIANT_UNREF(tmp_value); @@ -703,7 +703,7 @@ done: } static gboolean __bt_hal_authorize_request(GapAgentPrivate *agent, GDBusProxy *device, - const char *uuid) + const char *uuid) { const gchar *address; const gchar *name; @@ -721,9 +721,9 @@ static gboolean __bt_hal_authorize_request(GapAgentPrivate *agent, GDBusProxy *d goto done; } - g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/ + g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/ - tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING); + tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING); g_variant_get(tmp_value, "s", &address); G_VARIANT_UNREF(tmp_value); if (!address) { @@ -848,19 +848,19 @@ static gboolean __bt_hal_pairing_cancel_request(GapAgentPrivate *agent, const ch headed_plugin_info->headed_plugin->bt_destroy_popup_all(); __bt_hal_agent_release_memory(); - return TRUE; + return TRUE; } static gboolean __bt_hal_device_is_hid_keyboard(unsigned int dev_class) { switch ((dev_class & 0x1f00) >> 8) { - case 0x05: - switch ((dev_class & 0xc0) >> 6) { - case 0x01: - /* input-keyboard" */ - return TRUE; - } - break; + case 0x05: + switch ((dev_class & 0xc0) >> 6) { + case 0x01: + /* input-keyboard" */ + return TRUE; + } + break; } return FALSE; @@ -1031,47 +1031,47 @@ static gboolean __bt_hal_device_is_auto_response(uint32_t dev_class, return FALSE; switch ((dev_class & 0x1f00) >> 8) { - case 0x04: - switch ((dev_class & 0xfc) >> 2) { - case 0x01: - case 0x02: - /* Headset */ - is_headset = TRUE; - break; - case 0x06: - /* Headphone */ - is_headset = TRUE; - break; - case 0x0b: /* VCR */ - case 0x0c: /* Video Camera */ - case 0x0d: /* Camcorder */ - break; - default: - /* Other audio device */ - is_headset = TRUE; - break; - } + case 0x04: + switch ((dev_class & 0xfc) >> 2) { + case 0x01: + case 0x02: + /* Headset */ + is_headset = TRUE; + break; + case 0x06: + /* Headphone */ + is_headset = TRUE; + break; + case 0x0b: /* VCR */ + case 0x0c: /* Video Camera */ + case 0x0d: /* Camcorder */ break; - case 0x05: - switch (dev_class & 0xff) { - case 0x80: /* 0x80: Pointing device(Mouse) */ - is_mouse = TRUE; - break; - - case 0x40: /* 0x40: input device (BT keyboard) */ - - /* Get the LAP(Lower Address part) */ - g_strlcpy(lap_address, address, sizeof(lap_address)); - - /* Need to Auto pair the blacklisted Keyboard */ - if (__bt_hal_device_is_device_blacklisted(lap_address, name) != TRUE) { - DBG("Device is not black listed\n"); - return FALSE; - } else { - ERR("Device is black listed\n"); - return TRUE; - } + default: + /* Other audio device */ + is_headset = TRUE; + break; + } + break; + case 0x05: + switch (dev_class & 0xff) { + case 0x80: /* 0x80: Pointing device(Mouse) */ + is_mouse = TRUE; + break; + + case 0x40: /* 0x40: input device (BT keyboard) */ + + /* Get the LAP(Lower Address part) */ + g_strlcpy(lap_address, address, sizeof(lap_address)); + + /* Need to Auto pair the blacklisted Keyboard */ + if (__bt_hal_device_is_device_blacklisted(lap_address, name) != TRUE) { + DBG("Device is not black listed\n"); + return FALSE; + } else { + ERR("Device is black listed\n"); + return TRUE; } + } } if ((!is_headset) && (!is_mouse)) @@ -1126,29 +1126,29 @@ static void __bt_hal_agent_release_memory(void) static inline void stack_trim(void) { #ifdef STACK_FLUSH - unsigned int sp; - char buf[BUF_SIZE]; - FILE *file; - unsigned int stacktop; - int found = 0; - - asm volatile ("mov %0,sp " : "=r"(sp)); - - sprintf(buf, "/proc/%d/maps", getpid()); - file = fopen(buf, "r"); - while (fgets(buf, BUF_SIZE, file) != NULL) { - if (strstr(buf, "[stack]")) { - found = 1; - break; - } - } - fclose(file); - - if (found) { - sscanf(buf, "%x-", &stacktop); - if (madvise((void *)PAGE_ALIGN(stacktop), PAGE_ALIGN(sp) - stacktop, - MADV_DONTNEED) < 0) - perror("stack madvise fail"); - } + unsigned int sp; + char buf[BUF_SIZE]; + FILE *file; + unsigned int stacktop; + int found = 0; + + asm volatile ("mov %0,sp " : "=r"(sp)); + + sprintf(buf, "/proc/%d/maps", getpid()); + file = fopen(buf, "r"); + while (fgets(buf, BUF_SIZE, file) != NULL) { + if (strstr(buf, "[stack]")) { + found = 1; + break; + } + } + fclose(file); + + if (found) { + sscanf(buf, "%x-", &stacktop); + if (madvise((void *)PAGE_ALIGN(stacktop), PAGE_ALIGN(sp) - stacktop, + MADV_DONTNEED) < 0) + perror("stack madvise fail"); + } #endif } diff --git a/bt-oal/bluez_hal/src/bt-hal-agent.h b/bt-oal/bluez_hal/src/bt-hal-agent.h index ed1f4210..bf37383f 100644 --- a/bt-oal/bluez_hal/src/bt-hal-agent.h +++ b/bt-oal/bluez_hal/src/bt-hal-agent.h @@ -29,23 +29,23 @@ #include typedef enum { - BT_HAL_AGENT_EVENT_PIN_REQUEST, - BT_HAL_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST, - BT_HAL_AGENT_EVENT_PASSKEY_AUTO_ACCEPTED, - BT_HAL_AGENT_EVENT_PASSKEY_REQUEST, - BT_HAL_AGENT_EVENT_PASSKEY_DISPLAY_REQUEST, - BT_HAL_AGENT_EVENT_AUTHORIZE_REQUEST, - BT_HAL_AGENT_EVENT_CONFIRM_MODE_REQUEST, - BT_HAL_AGENT_EVENT_APP_CONFIRM_REQUEST, - BT_HAL_AGENT_EVENT_FILE_RECEIVED, - BT_HAL_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, - BT_HAL_AGENT_EVENT_SECURITY, - BT_HAL_AGENT_EVENT_TERMINATE, - BT_HAL_AGENT_EVENT_EXCHANGE_REQUEST, - BT_HAL_AGENT_EVENT_PBAP_REQUEST, - BT_HAL_AGENT_EVENT_MAP_REQUEST, - BT_HAL_AGENT_EVENT_SYSTEM_RESET_REQUEST, - BT_HAL_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE, + BT_HAL_AGENT_EVENT_PIN_REQUEST, + BT_HAL_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST, + BT_HAL_AGENT_EVENT_PASSKEY_AUTO_ACCEPTED, + BT_HAL_AGENT_EVENT_PASSKEY_REQUEST, + BT_HAL_AGENT_EVENT_PASSKEY_DISPLAY_REQUEST, + BT_HAL_AGENT_EVENT_AUTHORIZE_REQUEST, + BT_HAL_AGENT_EVENT_CONFIRM_MODE_REQUEST, + BT_HAL_AGENT_EVENT_APP_CONFIRM_REQUEST, + BT_HAL_AGENT_EVENT_FILE_RECEIVED, + BT_HAL_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, + BT_HAL_AGENT_EVENT_SECURITY, + BT_HAL_AGENT_EVENT_TERMINATE, + BT_HAL_AGENT_EVENT_EXCHANGE_REQUEST, + BT_HAL_AGENT_EVENT_PBAP_REQUEST, + BT_HAL_AGENT_EVENT_MAP_REQUEST, + BT_HAL_AGENT_EVENT_SYSTEM_RESET_REQUEST, + BT_HAL_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE, } bt_hal_agent_event_type_t; void* _bt_hal_create_agent(const char *path, gboolean adapter); diff --git a/bt-oal/bluez_hal/src/bt-hal-av-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-av-dbus-handler.c index c7236a6f..91e41e5e 100644 --- a/bt-oal/bluez_hal/src/bt-hal-av-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-av-dbus-handler.c @@ -49,7 +49,7 @@ void _bt_hal_unregister_av_dbus_handler_cb() } static void __bt_av_connect_cb(GDBusProxy *proxy, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { GError *g_error = NULL; struct hal_ev_a2dp_conn_state ev; @@ -105,13 +105,13 @@ bt_status_t _bt_hal_dbus_handler_av_connect(bt_bdaddr_t *bd_addr) GDBusConnection *conn; int ret; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -134,7 +134,7 @@ bt_status_t _bt_hal_dbus_handler_av_connect(bt_bdaddr_t *bd_addr) } static void __bt_av_disconnect_cb(GDBusProxy *proxy, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { GError *g_error = NULL; struct hal_ev_a2dp_conn_state ev; @@ -190,13 +190,13 @@ bt_status_t _bt_hal_dbus_handler_av_disconnect(bt_bdaddr_t *bd_addr) GDBusConnection *conn; int ret; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -235,13 +235,13 @@ bt_status_t _bt_hal_dbus_handler_enable_a2dp_source(void) } gconn = _bt_hal_get_system_gconn(); - if(!gconn) { + if (!gconn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } adapter_path = _bt_hal_get_adapter_path(); - if(!adapter_path) { + if (!adapter_path) { ERR("adapter_path is NULL"); return BT_STATUS_FAIL; } diff --git a/bt-oal/bluez_hal/src/bt-hal-av.c b/bt-oal/bluez_hal/src/bt-hal-av.c index 871b7e20..7cfa029e 100644 --- a/bt-oal/bluez_hal/src/bt-hal-av.c +++ b/bt-oal/bluez_hal/src/bt-hal-av.c @@ -72,7 +72,7 @@ static void __bt_hal_handle_av_events(int message, void *buf, uint16_t len) DBG("+"); if (!interface_ready()) return; - switch(message) { + switch (message) { case HAL_EV_A2DP_CONN_STATE: DBG("Event: HAL_EV_A2DP_CONN_STATE"); __bt_hal_handle_av_conn_state(buf, len); diff --git a/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl-dbus-handler.c index 79397ab6..5d063597 100644 --- a/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl-dbus-handler.c @@ -75,7 +75,7 @@ void _bt_hal_unregister_avrcp_ctrl_dbus_handler_cb() } static void __bt_avrcp_target_connect_cb(GDBusProxy *proxy, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { struct hal_ev_avrcp_ctrl_conn_state ev; char *address = user_data; @@ -124,13 +124,13 @@ bt_status_t _bt_hal_dbus_handler_avrcp_ctrl_connect(bt_bdaddr_t *bd_addr) int ret; GDBusConnection *conn; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -155,7 +155,7 @@ bt_status_t _bt_hal_dbus_handler_avrcp_ctrl_connect(bt_bdaddr_t *bd_addr) } static void __bt_avrcp_target_disconnect_cb(GDBusProxy *proxy, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { struct hal_ev_avrcp_ctrl_conn_state ev; char *address = user_data; @@ -206,13 +206,13 @@ bt_status_t _bt_hal_dbus_handler_avrcp_ctrl_disconnect(bt_bdaddr_t *bd_addr) int ret; GDBusConnection *conn; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -324,16 +324,16 @@ bt_status_t _bt_hal_dbus_handler_avrcp_ctrl_cmd(bt_bdaddr_t *bd_addr, uint8_t ke static const char *__bt_media_type_to_str(int type) { switch (type) { - case BTRC_PLAYER_ATTR_EQUALIZER: - return "Equalizer"; - case BTRC_PLAYER_ATTR_REPEAT: - return "Repeat"; - case BTRC_PLAYER_ATTR_SHUFFLE: - return "Shuffle"; - case BTRC_PLAYER_ATTR_SCAN: - return "Scan"; - default : - return NULL; + case BTRC_PLAYER_ATTR_EQUALIZER: + return "Equalizer"; + case BTRC_PLAYER_ATTR_REPEAT: + return "Repeat"; + case BTRC_PLAYER_ATTR_SHUFFLE: + return "Shuffle"; + case BTRC_PLAYER_ATTR_SCAN: + return "Scan"; + default: + return NULL; } return NULL; @@ -369,7 +369,7 @@ bt_status_t _bt_hal_dbus_handler_avrcp_ctrl_set_property(bt_bdaddr_t *bd_addr, u } proxy = _bt_hal_get_avrcp_ctrl_properties_proxy(bd_addr); - if(proxy == NULL) { + if (proxy == NULL) { ERR("Unable to allocate new proxy \n"); if (err) { ERR("%s", err->message); diff --git a/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl.c b/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl.c index 1455e54b..1711b01e 100644 --- a/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl.c +++ b/bt-oal/bluez_hal/src/bt-hal-avrcp-ctrl.c @@ -66,9 +66,9 @@ static bt_status_t avrcp_ctrl_set_player_app_setting_cmd(bt_bdaddr_t *bd_addr, int ret = BT_STATUS_SUCCESS; DBG(""); - for (i = 0; i < num_attrib; i++) { + for (i = 0; i < num_attrib; i++) ret = _bt_hal_dbus_handler_avrcp_ctrl_set_property(bd_addr, type[i], value[i]); - } + return ret; } @@ -91,25 +91,25 @@ btrc_play_status_t __get_play_status(int status) btrc_play_status_t play_status; play_status = BTRC_PLAYSTATE_ERROR; - switch(status) { - case BTRC_PLAYSTATE_STOPPED: - play_status = BTRC_PLAYSTATE_STOPPED; - break; - case BTRC_PLAYSTATE_PLAYING: - play_status = BTRC_PLAYSTATE_PLAYING; - break; - case BTRC_PLAYSTATE_PAUSED: - play_status = BTRC_PLAYSTATE_PAUSED; - break; - case BTRC_PLAYSTATE_FWD_SEEK: - play_status = BTRC_PLAYSTATE_FWD_SEEK; - break; - case BTRC_PLAYSTATE_REV_SEEK: - play_status = BTRC_PLAYSTATE_REV_SEEK; - break; - default : - DBG("Wrong play status received:"); - break; + switch (status) { + case BTRC_PLAYSTATE_STOPPED: + play_status = BTRC_PLAYSTATE_STOPPED; + break; + case BTRC_PLAYSTATE_PLAYING: + play_status = BTRC_PLAYSTATE_PLAYING; + break; + case BTRC_PLAYSTATE_PAUSED: + play_status = BTRC_PLAYSTATE_PAUSED; + break; + case BTRC_PLAYSTATE_FWD_SEEK: + play_status = BTRC_PLAYSTATE_FWD_SEEK; + break; + case BTRC_PLAYSTATE_REV_SEEK: + play_status = BTRC_PLAYSTATE_REV_SEEK; + break; + default: + DBG("Wrong play status received:"); + break; } return play_status; } @@ -182,44 +182,44 @@ static void __bt_hal_handle_avrcp_ctrl_track_changed_event(void *buf, uint16_t l static void __bt_hal_handle_avrcp_ctrl_event(int message, void *buf, uint16_t len) { - DBG("+"); - if (!interface_ready()) - return; - switch(message) { - case HAL_EV_AVRCP_CTRL_CONN_STATE: - DBG("Event: HAL_EV_AVRCP_CTRL_CONN_STATE"); - __bt_hal_handle_avrcp_ctrl_conn_state(buf, len); - break; - case HAL_EV_AVRCP_CTRL_PASS_THROUGH_RSP: - DBG("Event: HAL_EV_AVRCP_CTRL_PASS_THROUGH_RSP"); - __bt_hal_handle_avrcp_ctrl_pass_cmd_res_event(buf, len); - break; - case HAL_EV_AVRCP_CTRL_SET_PLAYER_APP_SETTING_RSP: - DBG("Event: HAL_EV_AVRCP_CTRL_SET_PLAYER_APP_SETTING_RSP"); - __bt_hal_handle_avrcp_ctrl_set_app_setting_res_event(buf, len); - break; - case HAL_EV_AVRCP_CTRL_PLAYER_APP_SETTING_CHANGED: - DBG("Event: HAL_EV_AVRCP_CTRL_PLAYER_APP_SETTING_CHANGED"); - __bt_hal_handle_avrcp_ctrl_player_setting_changed(buf, len); - break; - case HAL_EV_AVRCP_CTRL_TRACK_CHANGED: - DBG("Event: HAL_EV_AVRCP_CTRL_TRACK_CHANGED"); - __bt_hal_handle_avrcp_ctrl_track_changed_event(buf, len); - break; - case HAL_EV_AVRCP_CTRL_PLAY_POSITION_CHANGED: - DBG("Event: HAL_EV_AVRCP_CTRL_PLAY_POSITION_CHANGED"); - __bt_hal_handle_avrcp_ctrl_playposition_changed_event(buf, len); - break; - case HAL_EV_AVRCP_CTRL_PLAY_STATUS_CHANGED: - DBG("Event: HAL_EV_AVRCP_CTRL_PLAY_STATUS_CHANGED"); - __bt_hal_handle_avrcp_ctrl_playstatus_changed_event(buf, len); - break; - default: - DBG("Event Currently not handled!!"); - break; - } - - DBG("-"); + DBG("+"); + if (!interface_ready()) + return; + switch (message) { + case HAL_EV_AVRCP_CTRL_CONN_STATE: + DBG("Event: HAL_EV_AVRCP_CTRL_CONN_STATE"); + __bt_hal_handle_avrcp_ctrl_conn_state(buf, len); + break; + case HAL_EV_AVRCP_CTRL_PASS_THROUGH_RSP: + DBG("Event: HAL_EV_AVRCP_CTRL_PASS_THROUGH_RSP"); + __bt_hal_handle_avrcp_ctrl_pass_cmd_res_event(buf, len); + break; + case HAL_EV_AVRCP_CTRL_SET_PLAYER_APP_SETTING_RSP: + DBG("Event: HAL_EV_AVRCP_CTRL_SET_PLAYER_APP_SETTING_RSP"); + __bt_hal_handle_avrcp_ctrl_set_app_setting_res_event(buf, len); + break; + case HAL_EV_AVRCP_CTRL_PLAYER_APP_SETTING_CHANGED: + DBG("Event: HAL_EV_AVRCP_CTRL_PLAYER_APP_SETTING_CHANGED"); + __bt_hal_handle_avrcp_ctrl_player_setting_changed(buf, len); + break; + case HAL_EV_AVRCP_CTRL_TRACK_CHANGED: + DBG("Event: HAL_EV_AVRCP_CTRL_TRACK_CHANGED"); + __bt_hal_handle_avrcp_ctrl_track_changed_event(buf, len); + break; + case HAL_EV_AVRCP_CTRL_PLAY_POSITION_CHANGED: + DBG("Event: HAL_EV_AVRCP_CTRL_PLAY_POSITION_CHANGED"); + __bt_hal_handle_avrcp_ctrl_playposition_changed_event(buf, len); + break; + case HAL_EV_AVRCP_CTRL_PLAY_STATUS_CHANGED: + DBG("Event: HAL_EV_AVRCP_CTRL_PLAY_STATUS_CHANGED"); + __bt_hal_handle_avrcp_ctrl_playstatus_changed_event(buf, len); + break; + default: + DBG("Event Currently not handled!!"); + break; + } + + DBG("-"); } static bt_status_t init(btrc_ctrl_callbacks_t* callbacks) diff --git a/bt-oal/bluez_hal/src/bt-hal-avrcp-tg-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-avrcp-tg-dbus-handler.c index 68dd2b92..01a044b6 100644 --- a/bt-oal/bluez_hal/src/bt-hal-avrcp-tg-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-avrcp-tg-dbus-handler.c @@ -305,7 +305,7 @@ bt_status_t _bt_hal_dbus_handler_register_media_player(void) DBG("+"); conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -503,13 +503,13 @@ bt_status_t _bt_hal_dbus_handler_avrcp_tg_connect(bt_bdaddr_t *bd_addr) char *address; int ret; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -584,13 +584,13 @@ bt_status_t _bt_hal_dbus_handler_avrcp_tg_disconnect(bt_bdaddr_t *bd_addr) char *address; int ret; - if(!bd_addr) { + if (!bd_addr) { ERR("bd_addr is NULL, return"); return BT_STATUS_PARM_INVALID; } conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -651,7 +651,7 @@ bt_status_t _bt_hal_dbus_handler_avrcp_tg_play_status_changed(btrc_play_status_t DBG("+"); conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -674,7 +674,7 @@ bt_status_t _bt_hal_dbus_handler_avrcp_tg_play_pos_changed(uint32_t song_pos) DBG("+"); conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -700,7 +700,7 @@ bt_status_t _bt_hal_dbus_handler_avrcp_tg_app_setting_changed(btrc_player_settin DBG("+"); conn = _bt_hal_get_system_gconn(); - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } @@ -762,7 +762,7 @@ bt_status_t _bt_hal_dbus_handler_avrcp_tg_set_track_info( } conn = _bt_hal_get_system_gconn();; - if(!conn) { + if (!conn) { ERR("_bt_hal_get_system_gconn returned NULL, return"); return BT_STATUS_FAIL; } diff --git a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c index b8197e4f..3aeb35ae 100644 --- a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c +++ b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c @@ -59,8 +59,8 @@ static const bt_callbacks_t *bt_hal_cbacks = NULL; /* Forward declarations */ static void __bt_adapter_props_to_hal(bt_property_t *send_props, struct hal_property *prop, uint8_t num_props, uint16_t len); static void __bt_device_props_to_hal(bt_property_t *send_props, - struct hal_property *prop, uint8_t num_props, - uint16_t len); + struct hal_property *prop, uint8_t num_props, + uint16_t len); static void __bt_hal_handle_adapter_state_changed(void *buf, uint16_t len); static void __bt_hal_handle_adapter_property_changed(void *buf, uint16_t len); static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len); @@ -328,7 +328,7 @@ static int read_energy_info(void) } static int authorize_response(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id, - uint8_t authorize, uint8_t save_settings) + uint8_t authorize, uint8_t save_settings) { DBG("+"); return _bt_hal_device_authorize_response(bd_addr, service_id, authorize, save_settings); @@ -372,7 +372,7 @@ static int get_connected_link_rssi_strength(bt_bdaddr_t *bd_addr, uint32_t conn_ } static int enable_rssi_monitoring(bt_bdaddr_t *bd_addr, uint32_t conn_link_type, - int low_threshold, int in_range_threshold, int high_threshold) + int low_threshold, int in_range_threshold, int high_threshold) { DBG(""); return _bt_hal_device_enable_rssi_monitoring(bd_addr, conn_link_type, @@ -532,10 +532,10 @@ static void __bt_adapter_props_to_hal(bt_property_t *send_props, struct hal_prop switch (prop->type) { /* TODO: Add Adapter Properties */ - default: - send_props[i].len = prop->len; - send_props[i].val = prop->val; - break; + default: + send_props[i].len = prop->len; + send_props[i].val = prop->val; + break; } DBG("prop[%d]: %s", i, btproperty2str(&send_props[i])); @@ -550,8 +550,8 @@ static void __bt_adapter_props_to_hal(bt_property_t *send_props, struct hal_prop } static void __bt_device_props_to_hal(bt_property_t *send_props, - struct hal_property *prop, uint8_t num_props, - uint16_t len) + struct hal_property *prop, uint8_t num_props, + uint16_t len) { void *buf = prop; uint8_t i; @@ -716,54 +716,54 @@ static void __bt_hal_handle_bond_state_changed_event(void *buf, uint16_t len) static void __bt_hal_handle_device_acl_state_changed_event(void *buf, uint16_t len) { - struct hal_ev_acl_state_changed *ev = (struct hal_ev_acl_state_changed*)buf; - bt_bdaddr_t bd_addr; - DBG("+"); + struct hal_ev_acl_state_changed *ev = (struct hal_ev_acl_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]); + 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("ACL Status [0x%x]", ev->status); - DBG("ACL State [0x%x]", ev->state); + DBG("ACL Status [0x%x]", ev->status); + DBG("ACL State [0x%x]", ev->state); - if (!bt_hal_cbacks->acl_state_changed_cb) { - ERR("HAL User acl_state_changed_cb is not set!!"); - return; - } + if (!bt_hal_cbacks->acl_state_changed_cb) { + ERR("HAL User acl_state_changed_cb is not set!!"); + return; + } - bt_hal_cbacks->acl_state_changed_cb(ev->status, &bd_addr, ev->state); - DBG("-"); + bt_hal_cbacks->acl_state_changed_cb(ev->status, &bd_addr, ev->state); + DBG("-"); } static void __bt_hal_handle_device_le_conn_state_changed_event(void *buf, uint16_t len) { - struct hal_ev_acl_state_changed *ev = (struct hal_ev_acl_state_changed*)buf; - bt_bdaddr_t bd_addr; - DBG("+"); + struct hal_ev_acl_state_changed *ev = (struct hal_ev_acl_state_changed*)buf; + bt_bdaddr_t bd_addr; + DBG("+"); - memcpy(bd_addr.address, ev->bdaddr, 6); - /* BD address */ - DBG("Address: [%02X:%02X:%02X:%02X:%02X:%02X]", bd_addr.address[0], + memcpy(bd_addr.address, ev->bdaddr, 6); + /* BD address */ + DBG("Address: [%02X:%02X:%02X:%02X:%02X:%02X]", bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]); - DBG("LE conn Status [0x%x]", ev->status); - DBG("LE conn State [0x%x]", ev->state); + DBG("LE conn Status [0x%x]", ev->status); + DBG("LE conn State [0x%x]", ev->state); #ifdef TIZEN_BT_HAL - if (!bt_hal_cbacks->le_conn_state_changed_cb) { - ERR("HAL User le_conn_state_changed_cb is not set!!"); - return; - } + if (!bt_hal_cbacks->le_conn_state_changed_cb) { + ERR("HAL User le_conn_state_changed_cb is not set!!"); + return; + } - bt_hal_cbacks->le_conn_state_changed_cb(ev->status, &bd_addr, ev->state); + bt_hal_cbacks->le_conn_state_changed_cb(ev->status, &bd_addr, ev->state); #endif - DBG("-"); + DBG("-"); } static void __bt_hal_handle_authorize_request_event(void *buf, uint16_t len) @@ -881,28 +881,28 @@ 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) { - struct hal_ev_device_trust_state_changed *ev = (struct hal_ev_device_trust_state_changed*)buf; - bt_bdaddr_t bd_addr; - DBG("+"); + 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]); + 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); + 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; - } + 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("-"); + bt_hal_cbacks->device_trust_state_changed_cb(&bd_addr, ev->trust); + DBG("-"); } static void __bt_hal_handle_device_trusted_profiles_changed_event(void *buf, uint16_t len) @@ -935,8 +935,8 @@ static void __bt_handle_rssi_monitor_state_changed(void *buf, uint16_t len) DBG("+"); #ifdef TIZEN_BT_HAL - memcpy(bd_addr.address, ev->bdaddr, 6); - DBG("[0x%02X:%02X:%02X:%02X:%02X:%02X]", + memcpy(bd_addr.address, ev->bdaddr, 6); + DBG("[0x%02X:%02X:%02X:%02X:%02X:%02X]", bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]); @@ -955,8 +955,8 @@ static void __bt_handle_rssi_alert_recieved(void *buf, uint16_t len) DBG("+"); #ifdef TIZEN_BT_HAL - memcpy(bd_addr.address, ev->bdaddr, 6); - DBG("[0x%02X:%02X:%02X:%02X:%02X:%02X]", + memcpy(bd_addr.address, ev->bdaddr, 6); + DBG("[0x%02X:%02X:%02X:%02X:%02X:%02X]", bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]); @@ -975,8 +975,8 @@ static void __bt_handle_raw_rssi_recieved(void *buf, uint16_t len) DBG("+"); #ifdef TIZEN_BT_HAL - memcpy(bd_addr.address, ev->bdaddr, 6); - DBG("[0x%02X:%02X:%02X:%02X:%02X:%02X]", + memcpy(bd_addr.address, ev->bdaddr, 6); + DBG("[0x%02X:%02X:%02X:%02X:%02X:%02X]", bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]); @@ -991,84 +991,84 @@ static void __bt_handle_raw_rssi_recieved(void *buf, uint16_t len) static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len) { DBG("+"); - switch(message) { - case HAL_EV_ADAPTER_STATE_CHANGED: - DBG("Event: HAL_EV_ADAPTER_STATE_CHANGED"); - __bt_hal_handle_adapter_state_changed(buf, len); - break; - case HAL_EV_ADAPTER_PROPS_CHANGED: - DBG("Event: HAL_EV_ADAPTER_PROPS_CHANGED"); - __bt_hal_handle_adapter_property_changed(buf, len); - break; - case HAL_EV_DISCOVERY_STATE_CHANGED: - DBG("Event: HAL_EV_DISCOVERY_STATE_CHANGED"); - __bt_hal_handle_adapter_discovery_state_changed(buf, len); - break; - case HAL_EV_DEVICE_FOUND: - DBG("Event: HAL_EV_DEVICE_FOUND"); - __bt_hal_handle_device_found_event(buf, len); - break; - case HAL_EV_REMOTE_DEVICE_PROPS: - DBG("Event: HAL_EV_REMOTE_DEVICE_PROPS"); - __bt_hal_handle_remote_device_properties_event(buf, len); - break; - case HAL_EV_BOND_STATE_CHANGED: - DBG("Event: HAL_EV_BOND_STATE_CHANGED:"); - __bt_hal_handle_bond_state_changed_event(buf, len); - break; - case HAL_EV_ACL_STATE_CHANGED: - DBG("Event: HAL_ACL_STATE_CONNECTED or Disconnected"); - __bt_hal_handle_device_acl_state_changed_event(buf, len); - break; - case HAL_EV_LE_CONN_STATE_CHANGED: - DBG("Event: HAL_LE_CONN_STATE_CONNECTED or Disconnected"); - __bt_hal_handle_device_le_conn_state_changed_event(buf, len); - break; - case HAL_EV_SSP_REQUEST: - DBG("Event: HAL_EV_SSP_REQUEST"); - __bt_hal_handle_ssp_request_event(buf, len); - break; - case HAL_EV_PIN_REQUEST: - DBG("Event: HAL_EV_PIN_REQUEST"); - __bt_hal_handle_pin_request_event(buf, len); - break; - case HAL_EV_AUTHORIZE_REQUEST: - 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; + switch (message) { + case HAL_EV_ADAPTER_STATE_CHANGED: + DBG("Event: HAL_EV_ADAPTER_STATE_CHANGED"); + __bt_hal_handle_adapter_state_changed(buf, len); + break; + case HAL_EV_ADAPTER_PROPS_CHANGED: + DBG("Event: HAL_EV_ADAPTER_PROPS_CHANGED"); + __bt_hal_handle_adapter_property_changed(buf, len); + break; + case HAL_EV_DISCOVERY_STATE_CHANGED: + DBG("Event: HAL_EV_DISCOVERY_STATE_CHANGED"); + __bt_hal_handle_adapter_discovery_state_changed(buf, len); + break; + case HAL_EV_DEVICE_FOUND: + DBG("Event: HAL_EV_DEVICE_FOUND"); + __bt_hal_handle_device_found_event(buf, len); + break; + case HAL_EV_REMOTE_DEVICE_PROPS: + DBG("Event: HAL_EV_REMOTE_DEVICE_PROPS"); + __bt_hal_handle_remote_device_properties_event(buf, len); + break; + case HAL_EV_BOND_STATE_CHANGED: + DBG("Event: HAL_EV_BOND_STATE_CHANGED:"); + __bt_hal_handle_bond_state_changed_event(buf, len); + break; + case HAL_EV_ACL_STATE_CHANGED: + DBG("Event: HAL_ACL_STATE_CONNECTED or Disconnected"); + __bt_hal_handle_device_acl_state_changed_event(buf, len); + break; + case HAL_EV_LE_CONN_STATE_CHANGED: + DBG("Event: HAL_LE_CONN_STATE_CONNECTED or Disconnected"); + __bt_hal_handle_device_le_conn_state_changed_event(buf, len); + break; + case HAL_EV_SSP_REQUEST: + DBG("Event: HAL_EV_SSP_REQUEST"); + __bt_hal_handle_ssp_request_event(buf, len); + break; + case HAL_EV_PIN_REQUEST: + DBG("Event: HAL_EV_PIN_REQUEST"); + __bt_hal_handle_pin_request_event(buf, len); + break; + case HAL_EV_AUTHORIZE_REQUEST: + 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; #ifdef TIZEN_BT_HAL - case HAL_EV_SOCK_AUTHORIZE_REQUEST: - DBG("Event: HAL_EV_AUTHORIZE_REQUEST"); - __bt_hal_handle_socket_authorize_request_event(buf, len); - break; - case HAL_EV_LE_STATE_CHANGED: - DBG("Event: HAL_EV_LE_STATE_CHANGED"); - __bt_hal_handle_le_state_changed(buf, len); - break; + case HAL_EV_SOCK_AUTHORIZE_REQUEST: + DBG("Event: HAL_EV_AUTHORIZE_REQUEST"); + __bt_hal_handle_socket_authorize_request_event(buf, len); + break; + case HAL_EV_LE_STATE_CHANGED: + DBG("Event: HAL_EV_LE_STATE_CHANGED"); + __bt_hal_handle_le_state_changed(buf, len); + break; #endif - case HAL_EV_DEVICE_TRUSTED_PROFILES_CHANGED: - DBG("Event: HAL_EV_DEVICE_TRUST_CHANGED"); - __bt_hal_handle_device_trusted_profiles_changed_event(buf, len); - break; - case HAL_EV_RSSI_MONITOR_STATE_CHANGED: - DBG("Event: HAL_EV_RSSI_MONITOR_STATE_CHANGED"); - __bt_handle_rssi_monitor_state_changed(buf, len); - break; - case HAL_EV_RSSI_ALERT_RECIEVED: - DBG("Event: HAL_EV_RSSI_ALERT_RECIEVED"); - __bt_handle_rssi_alert_recieved(buf, len); - break; - case HAL_EV_RAW_RSSI_RECIEVED: - DBG("Event: HAL_EV_RAW_RSSI_RECIEVED"); - __bt_handle_raw_rssi_recieved(buf, len); - break; - default: - DBG("Event Currently not handled!!"); - break; + case HAL_EV_DEVICE_TRUSTED_PROFILES_CHANGED: + DBG("Event: HAL_EV_DEVICE_TRUST_CHANGED"); + __bt_hal_handle_device_trusted_profiles_changed_event(buf, len); + break; + case HAL_EV_RSSI_MONITOR_STATE_CHANGED: + DBG("Event: HAL_EV_RSSI_MONITOR_STATE_CHANGED"); + __bt_handle_rssi_monitor_state_changed(buf, len); + break; + case HAL_EV_RSSI_ALERT_RECIEVED: + DBG("Event: HAL_EV_RSSI_ALERT_RECIEVED"); + __bt_handle_rssi_alert_recieved(buf, len); + break; + case HAL_EV_RAW_RSSI_RECIEVED: + DBG("Event: HAL_EV_RAW_RSSI_RECIEVED"); + __bt_handle_raw_rssi_recieved(buf, len); + break; + default: + DBG("Event Currently not handled!!"); + break; } DBG("-"); } diff --git a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c index cd8466f0..c54ee3c7 100644 --- a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c +++ b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c @@ -104,7 +104,7 @@ GDBusConnection *_bt_hal_gdbus_get_system_gconn(void) if (system_gconn == NULL) { system_gconn = _bt_hal_gdbus_init_system_gconn(); - } else if (g_dbus_connection_is_closed(system_gconn)){ + } else if (g_dbus_connection_is_closed(system_gconn)) { local_system_gconn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); @@ -330,28 +330,24 @@ static GDBusProxy *__bt_hal_init_avrcp_ctrl_proxy(bt_bdaddr_t *bd_addr) if (system_conn == NULL) { system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL); - if (system_conn == NULL) { + if (system_conn == NULL) return NULL; - } } manager_proxy = _bt_hal_get_manager_proxy(); - if (manager_proxy == NULL) { + if (manager_proxy == NULL) return NULL; - } control_path = _bt_hal_get_control_device_path(bd_addr); - if (control_path == NULL) { + if (control_path == NULL) return NULL; - } proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, BT_HAL_BLUEZ_NAME, control_path, BT_HAL_PLAYER_CONTROL_INTERFACE, NULL, NULL); - if (proxy == NULL) { + if (proxy == NULL) return NULL; - } avrcp_ctrl_proxy = proxy; return proxy; @@ -360,7 +356,7 @@ static GDBusProxy *__bt_hal_init_avrcp_ctrl_proxy(bt_bdaddr_t *bd_addr) static GDBusConnection *__bt_hal_init_session_conn(void) { if (session_conn == NULL) - session_conn =g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + session_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); return session_conn; } @@ -429,13 +425,13 @@ GDBusProxy *_bt_hal_get_avrcp_ctrl_properties_proxy(bt_bdaddr_t *bd_addr) DBG("+"); control_path = _bt_hal_get_control_device_path(bd_addr); - if (control_path == NULL) { + if (control_path == NULL) return NULL; - } + DBG("control_path = %s", control_path); conn = _bt_hal_get_system_gconn(); - if(conn == NULL) { + if (conn == NULL) { ERR("FAIL to get system connection"); return NULL; } @@ -643,9 +639,8 @@ void _bt_hal_convert_device_path_to_address(const char *device_path, dev_addr += 4; g_strlcpy(address, dev_addr, sizeof(address)); - while ((pos = strchr(address, '_')) != NULL) { + while ((pos = strchr(address, '_')) != NULL) *pos = ':'; - } g_strlcpy(device_address, address, BT_HAL_ADDRESS_STRING_SIZE); } @@ -679,7 +674,7 @@ gboolean _bt_hal_uuid_is_standard(bt_uuid_t *p_uuid) } void _bt_hal_convert_uuid_string_to_type(unsigned char *uuid, - const char *device_uuid) + const char *device_uuid) { uint32_t uuid0, uuid4; uint16_t uuid1, uuid2, uuid3, uuid5; @@ -796,7 +791,7 @@ int _bt_hal_copy_utf8_string(char *dest, const char *src, unsigned int length) while (count > 0 && ((i + count) < length)) { dest[i++] = *p; p++; - count --; + count--; } p = next; } @@ -835,9 +830,8 @@ int _bt_hal_set_socket_non_blocking(int socket_fd) if (arg < 0) return -errno; - if (arg & O_NONBLOCK) { + if (arg & O_NONBLOCK) ERR("Already Non-blocking \n"); - } arg |= O_NONBLOCK; @@ -878,9 +872,8 @@ static char *__bt_hal_extract_device_path(GVariantIter *iter, char *address) if (object_path == NULL) return NULL; _bt_hal_convert_device_path_to_address(object_path, device_address); - if (g_strcmp0(address, device_address) == 0) { + if (g_strcmp0(address, device_address) == 0) return g_strdup(object_path); - } } return NULL; } @@ -1003,7 +996,7 @@ char *_bt_hal_convert_error_to_string(int error) char * _bt_hal_convert_disc_reason_to_string(int reason) { - switch(reason) { + switch (reason) { case 1: return "Link loss"; case 2: @@ -1416,7 +1409,7 @@ int _bt_hal_discover_services(char *address, char *uuid, void *cb, gpointer func INFO("No searched device"); adapter_proxy = _bt_hal_get_adapter_proxy(); - if(adapter_proxy == NULL) { + if (adapter_proxy == NULL) { ERR("adapter_proxy == NULL, return"); return BT_STATUS_FAIL; } @@ -1479,7 +1472,7 @@ int _bt_hal_cancel_discovers(char *address) GVariant *ret = NULL; INFO("No searched device"); adapter_proxy = _bt_hal_get_adapter_proxy(); - if(adapter_proxy == NULL) { + if (adapter_proxy == NULL) { ERR("adapter_proxy == NULL, return"); return BT_STATUS_FAIL; } @@ -1534,26 +1527,26 @@ int _bt_hal_discover_service_uuids(char *address, char *remote_uuid) GError *err = NULL; char **uuid_value = NULL; gsize size; - int i =0; + int i = 0; GVariant *value = NULL; GVariant *ret = NULL; int result = BT_STATUS_FAIL; DBG("+"); - if(remote_uuid == NULL) { + if (remote_uuid == NULL) { ERR("remote_uuid == NULL, return"); return BT_STATUS_FAIL; } gconn = _bt_hal_get_system_gconn(); - if(gconn == NULL) { + if (gconn == NULL) { ERR("gconn == NULL, return"); return BT_STATUS_FAIL; } object_path = _bt_hal_get_device_object_path(address); - if(object_path == NULL) { + if (object_path == NULL) { ERR("object_path == NULL, return"); return BT_STATUS_FAIL; } @@ -1561,7 +1554,7 @@ int _bt_hal_discover_service_uuids(char *address, char *remote_uuid) proxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE, NULL, BT_HAL_BLUEZ_NAME, object_path, BT_HAL_PROPERTIES_INTERFACE, NULL, &err); - if(proxy == NULL) { + if (proxy == NULL) { g_free(object_path); ERR("proxy == NULL, return"); return BT_STATUS_FAIL; @@ -1607,7 +1600,7 @@ int _bt_hal_discover_service_uuids(char *address, char *remote_uuid) if (temp_value) g_variant_unref(temp_value); - if(uuid_value) { + if (uuid_value) { for (i = 0; uuid_value[i] != NULL; i++) { DBG("Remote uuids %s, searched uuid: %s", uuid_value[i], remote_uuid); @@ -1632,8 +1625,8 @@ done: } int bt_hal_gatt_convert_prop2string( - bt_hal_gatt_characteristic_property_t properties, - char *char_properties[]) + bt_hal_gatt_characteristic_property_t properties, + char *char_properties[]) { int flag_count = 0; @@ -1699,42 +1692,42 @@ int bt_hal_gatt_convert_prop2string( } int bt_hal_gatt_convert_perm2string( - bt_hal_gatt_permission_t properties, - char *char_properties[]) + bt_hal_gatt_permission_t properties, + char *char_properties[]) { - int flag_count = 0; - - if (properties & BT_HAL_GATT_PERMISSION_READ) { - char_properties[flag_count] = g_strdup("read"); - flag_count++; - } - if (properties & BT_HAL_GATT_PERMISSION_WRITE) { - char_properties[flag_count] = g_strdup("write"); - flag_count++; - } - if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_READ) { - char_properties[flag_count] = g_strdup("encrypt-read"); - flag_count++; - } - if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_WRITE) { - char_properties[flag_count] = g_strdup("encrypt-write"); - flag_count++; - } - if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_READ) { - char_properties[flag_count] = g_strdup("encrypt-authenticated-read"); - flag_count++; - } - if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_WRITE) { - char_properties[flag_count] = g_strdup("encrypt-authenticated-write"); - flag_count++; - } - - if (flag_count == 0) { - char_properties[flag_count] = g_strdup("read"); - flag_count++; - } - - return flag_count; + int flag_count = 0; + + if (properties & BT_HAL_GATT_PERMISSION_READ) { + char_properties[flag_count] = g_strdup("read"); + flag_count++; + } + if (properties & BT_HAL_GATT_PERMISSION_WRITE) { + char_properties[flag_count] = g_strdup("write"); + flag_count++; + } + if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_READ) { + char_properties[flag_count] = g_strdup("encrypt-read"); + flag_count++; + } + if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_WRITE) { + char_properties[flag_count] = g_strdup("encrypt-write"); + flag_count++; + } + if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_READ) { + char_properties[flag_count] = g_strdup("encrypt-authenticated-read"); + flag_count++; + } + if (properties & BT_HAL_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_WRITE) { + char_properties[flag_count] = g_strdup("encrypt-authenticated-write"); + flag_count++; + } + + if (flag_count == 0) { + char_properties[flag_count] = g_strdup("read"); + flag_count++; + } + + return flag_count; } gboolean _bt_hal_is_service_enabled(const char *uuid) diff --git a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h index dd2febfd..aa7fcc5b 100644 --- a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h +++ b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h @@ -46,10 +46,10 @@ extern "C" { #define BT_HAL_MAX_DBUS_TIMEOUT 45000 #define BT_HAL_TIMEOUT_MESSAGE "Did not receive a reply. Possible causes include: " \ - "the remote application did not send a reply, " \ - "the message bus security policy blocked the reply, " \ - "the reply timeout expired, or the network connection " \ - "was broken." + "the remote application did not send a reply, " \ + "the message bus security policy blocked the reply, " \ + "the reply timeout expired, or the network connection " \ + "was broken." #define BT_HAL_ACCESS_DENIED_MSG "Rejected send message" #define BT_HAL_DISCOVERY_FINISHED_DELAY 200 @@ -115,364 +115,364 @@ extern "C" { #define BT_HAL_NAME_OWNER_CHANGED "NameOwnerChanged" #define BT_HAL_PROPERTIES_CHANGED "PropertiesChanged" -/** - * This is Bluetooth error code - */ + /** + * This is Bluetooth error code + */ #define BT_HAL_ERROR_BASE ((int)0) /**< Error code base */ #define BT_HAL_ERROR_NONE ((int)0) /**< No error #0 */ #define BT_HAL_ERROR_CANCEL ((int)BT_HAL_ERROR_BASE - 0x01) - /**< cancelled */ + /**< cancelled */ #define BT_HAL_ERROR_INVALID_CALLBACK ((int)BT_HAL_ERROR_BASE - 0x02) - /**< Callback error */ + /**< Callback error */ #define BT_HAL_ERROR_INVALID_PARAM ((int)BT_HAL_ERROR_BASE - 0x03) - /**< invalid paramerror */ + /**< invalid paramerror */ #define BT_HAL_ERROR_INVALID_DATA ((int)BT_HAL_ERROR_BASE - 0x04) - /**< invalid data error */ + /**< invalid data error */ #define BT_HAL_ERROR_MEMORY_ALLOCATION ((int)BT_HAL_ERROR_BASE - 0x05) - /**< Memory allocation error */ + /**< Memory allocation error */ #define BT_HAL_ERROR_OUT_OF_MEMORY ((int)BT_HAL_ERROR_BASE - 0x06) - /**< out of memory error */ + /**< out of memory error */ #define BT_HAL_ERROR_TIMEOUT ((int)BT_HAL_ERROR_BASE - 0x07) - /**< timeout error */ + /**< timeout error */ #define BT_HAL_ERROR_NO_RESOURCES ((int)BT_HAL_ERROR_BASE - 0x08) - /**< No resource error */ + /**< No resource error */ #define BT_HAL_ERROR_INTERNAL ((int)BT_HAL_ERROR_BASE - 0x09) - /**< internal error */ + /**< internal error */ #define BT_HAL_ERROR_NOT_SUPPORT ((int)BT_HAL_ERROR_BASE - 0x0a) - /**< Not supported error */ + /**< Not supported error */ #define BT_HAL_ERROR_DEVICE_NOT_ENABLED ((int)BT_HAL_ERROR_BASE - 0x0b) - /**< Operation is failed because - of not enabled BT Adapter */ + /**< Operation is failed because + of not enabled BT Adapter */ #define BT_HAL_ERROR_DEVICE_ALREADY_ENABLED ((int)BT_HAL_ERROR_BASE - 0x0c) - /**< Enabling is failed because of - already enabled BT Adapter */ + /**< Enabling is failed because of + already enabled BT Adapter */ #define BT_HAL_ERROR_DEVICE_BUSY ((int)BT_HAL_ERROR_BASE - 0x0d) - /**< Operation is failed because of - other on going operation */ + /**< Operation is failed because of + other on going operation */ #define BT_HAL_ERROR_ACCESS_DENIED ((int)BT_HAL_ERROR_BASE - 0x0e) - /**< access denied error */ + /**< access denied error */ #define BT_HAL_ERROR_MAX_CLIENT ((int)BT_HAL_ERROR_BASE - 0x0f) - /**< max client error */ + /**< max client error */ #define BT_HAL_ERROR_NOT_FOUND ((int)BT_HAL_ERROR_BASE - 0x10) - /**< not found error */ + /**< not found error */ #define BT_HAL_ERROR_SERVICE_SEARCH_ERROR ((int)BT_HAL_ERROR_BASE - 0x11) - /**< service search fail */ + /**< service search fail */ #define BT_HAL_ERROR_PARING_FAILED ((int)BT_HAL_ERROR_BASE - 0x12) - /**< pairing failed error */ + /**< pairing failed error */ #define BT_HAL_ERROR_NOT_PAIRED ((int)BT_HAL_ERROR_BASE - 0x13) - /**< Not paired error */ + /**< Not paired error */ #define BT_HAL_ERROR_SERVICE_NOT_FOUND ((int)BT_HAL_ERROR_BASE - 0x14) - /**< no service error */ + /**< no service error */ #define BT_HAL_ERROR_NOT_CONNECTED ((int)BT_HAL_ERROR_BASE - 0x15) - /**< no connection error */ + /**< no connection error */ #define BT_HAL_ERROR_ALREADY_CONNECT ((int)BT_HAL_ERROR_BASE - 0x16) - /**< alread connected error */ + /**< alread connected error */ #define BT_HAL_ERROR_CONNECTION_BUSY ((int)BT_HAL_ERROR_BASE - 0x17) - /**< connection busy error */ + /**< connection busy error */ #define BT_HAL_ERROR_CONNECTION_ERROR ((int)BT_HAL_ERROR_BASE - 0x18) - /**< connection error */ + /**< connection error */ #define BT_HAL_ERROR_MAX_CONNECTION ((int)BT_HAL_ERROR_BASE - 0x19) - /**< max connection error*/ + /**< max connection error*/ #define BT_HAL_ERROR_NOT_IN_OPERATION ((int)BT_HAL_ERROR_BASE - 0x1a) - /**< Not in operation */ + /**< Not in operation */ #define BT_HAL_ERROR_CANCEL_BY_USER ((int)BT_HAL_ERROR_BASE - 0x1b) - /**< Cancelled by user */ + /**< Cancelled by user */ #define BT_HAL_ERROR_REGISTRATION_FAILED ((int)BT_HAL_ERROR_BASE - 0x1c) - /**< Service record registration failed */ + /**< Service record registration failed */ #define BT_HAL_ERROR_IN_PROGRESS ((int)BT_HAL_ERROR_BASE - 0x1d) - /**< Operation in progress */ + /**< Operation in progress */ #define BT_HAL_ERROR_AUTHENTICATION_FAILED ((int)BT_HAL_ERROR_BASE - 0x1e) - /**< authentication failed error when paring*/ + /**< authentication failed error when paring*/ #define BT_HAL_ERROR_HOST_DOWN ((int)BT_HAL_ERROR_BASE - 0x1f) - /**< Remote host is down */ + /**< Remote host is down */ #define BT_HAL_ERROR_END_OF_DEVICE_LIST ((int)BT_HAL_ERROR_BASE - 0x20) - /**< End of device list */ + /**< End of device list */ #define BT_HAL_ERROR_AGENT_ALREADY_EXIST ((int)BT_HAL_ERROR_BASE - 0x21) - /**< Obex agent already exists */ + /**< Obex agent already exists */ #define BT_HAL_ERROR_AGENT_DOES_NOT_EXIST ((int)BT_HAL_ERROR_BASE - 0x22) - /**< Obex agent does not exist */ + /**< Obex agent does not exist */ #define BT_HAL_ERROR_ALREADY_INITIALIZED ((int)BT_HAL_ERROR_BASE - 0x23) - /**< Already initialized */ + /**< Already initialized */ #define BT_HAL_ERROR_PERMISSION_DEINED ((int)BT_HAL_ERROR_BASE - 0x24) - /**< Permission deined */ + /**< Permission deined */ #define BT_HAL_ERROR_ALREADY_DEACTIVATED ((int)BT_HAL_ERROR_BASE - 0x25) - /**< Nap already done */ + /**< Nap already done */ #define BT_HAL_ERROR_NOT_INITIALIZED ((int)BT_HAL_ERROR_BASE - 0x26) - /**< Not initialized */ + /**< Not initialized */ #define BT_HAL_ERROR_DEVICE_POLICY_RESTRICTION ((int)BT_HAL_ERROR_BASE - 0x27) - /**< Device Policy Restricted */ -/** -* Service class part of class of device returned from device discovery -*/ -typedef enum { - BT_HAL_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000, - BT_HAL_DEVICE_SERVICE_CLASS_POSITIONING = 0x010000, /**< */ - BT_HAL_DEVICE_SERVICE_CLASS_NETWORKING = 0x020000, /**< */ - BT_HAL_DEVICE_SERVICE_CLASS_RENDERING = 0x040000, /**< */ - BT_HAL_DEVICE_SERVICE_CLASS_CAPTURING = 0x080000, /**< */ - BT_HAL_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000, /**< */ - BT_HAL_DEVICE_SERVICE_CLASS_AUDIO = 0x200000, /**< */ - BT_HAL_DEVICE_SERVICE_CLASS_TELEPHONY = 0x400000, /**< */ - BT_HAL_DEVICE_SERVICE_CLASS_INFORMATION = 0x800000, /**< */ -} bt_hal_device_service_class_t; - -/** - * Major device mask (For device discovery) - */ -typedef enum { - BT_HAL_DEVICE_MAJOR_MASK_MISC = 0x00, - BT_HAL_DEVICE_MAJOR_MASK_COMPUTER = 0x0001, - BT_HAL_DEVICE_MAJOR_MASK_PHONE = 0x0002, - BT_HAL_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT = 0x0004, - BT_HAL_DEVICE_MAJOR_MASK_AUDIO = 0x0008, - BT_HAL_DEVICE_MAJOR_MASK_PERIPHERAL = 0x0010, - BT_HAL_DEVICE_MAJOR_MASK_IMAGING = 0x0020, - BT_HAL_DEVICE_MAJOR_MASK_WEARABLE = 0x0040, - BT_HAL_DEVICE_MAJOR_MASK_TOY = 0x0080, - BT_HAL_DEVICE_MAJOR_MASK_HEALTH = 0x0100, -} bt_hal_device_major_mask_t; - -/** - * Major device class (part of Class of Device) - */ -typedef enum { - BT_HAL_DEVICE_MAJOR_CLASS_MISC = 0x00, /**< Miscellaneous major device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_COMPUTER = 0x01, /**< Computer major device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_PHONE = 0x02, /**< Phone major device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT = 0x03, /**< LAN major device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_AUDIO = 0x04, /**< AUDIO major device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_PERIPHERAL = 0x05, /**< Peripheral major device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_IMAGING = 0x06, /**< Imaging major device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_WEARABLE = 0x07, /**< Wearable device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_TOY = 0x08, /**< Toy device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_HEALTH = 0x09, /**< Health device class*/ - BT_HAL_DEVICE_MAJOR_CLASS_UNCLASSIFIED = 0x1F /**< Unknown major device class*/ -} bt_hal_device_major_class_t; - - -typedef enum { - BT_HAL_DEVICE_MINOR_CLASS_UNCLASSIFIED = 0x00, /**< unclassified minor class */ - - /* About Computer Major class */ - BT_HAL_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION = 0x04, /**< desktop workstation - minor class */ - BT_HAL_DEVICE_MINOR_CLASS_SERVER_CLASS_COMPUTER = 0x08, /**< server minor class */ - BT_HAL_DEVICE_MINOR_CLASS_LAPTOP = 0x0C, /**< laptop minor class */ - BT_HAL_DEVICE_MINOR_CLASS_HANDHELD_PC_OR_PDA = 0x10, /**< PDA minor class */ - BT_HAL_DEVICE_MINOR_CLASS_PALM_SIZED_PC_OR_PDA = 0x14, /**< PALM minor class */ - BT_HAL_DEVICE_MINOR_CLASS_WEARABLE_COMPUTER = 0x18, /**< Wearable PC minor class */ - - /* About Phone Major class */ - BT_HAL_DEVICE_MINOR_CLASS_CELLULAR = 0x04, /**< Cellular minor class */ - BT_HAL_DEVICE_MINOR_CLASS_CORDLESS = 0x08, /**< cordless minor class */ - BT_HAL_DEVICE_MINOR_CLASS_SMART_PHONE = 0x0C, /**< smart phone minor class */ - BT_HAL_DEVICE_MINOR_CLASS_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10, - /**< voice gateway minor class */ - BT_HAL_DEVICE_MINOR_CLASS_COMMON_ISDN_ACCESS = 0x14, /**< ISDN minor class */ - - /* About LAN/Network Access Point Major class */ - BT_HAL_DEVICE_MINOR_CLASS_FULLY_AVAILABLE = 0x04, /**< Fully available minor class */ - BT_HAL_DEVICE_MINOR_CLASS_1_TO_17_PERCENT_UTILIZED = 0x20, /**< 1-17% utilized minor class */ - BT_HAL_DEVICE_MINOR_CLASS_17_TO_33_PERCENT_UTILIZED = 0x40, /**< 17-33% utilized minor class */ - BT_HAL_DEVICE_MINOR_CLASS_33_TO_50_PERCENT_UTILIZED = 0x60, /**< 33-50% utilized minor class */ - BT_HAL_DEVICE_MINOR_CLASS_50_to_67_PERCENT_UTILIZED = 0x80, /**< 50-67% utilized minor class */ - BT_HAL_DEVICE_MINOR_CLASS_67_TO_83_PERCENT_UTILIZED = 0xA0, /**< 67-83% utilized minor class */ - BT_HAL_DEVICE_MINOR_CLASS_83_TO_99_PERCENT_UTILIZED = 0xC0, /**< 83-99% utilized minor class */ - BT_HAL_DEVICE_MINOR_CLASS_NO_SERVICE_AVAILABLE = 0xE0, /**< No service available minor class */ - - /* About Audio/Video Major class */ - BT_HAL_DEVICE_MINOR_CLASS_HEADSET_PROFILE = 0x04, /**< Headset minor class */ - BT_HAL_DEVICE_MINOR_CLASS_HANDSFREE = 0x08, /**< Handsfree minor class*/ - - BT_HAL_DEVICE_MINOR_CLASS_MICROPHONE = 0x10, /**< Microphone minor class */ - BT_HAL_DEVICE_MINOR_CLASS_LOUD_SPEAKER = 0x14, /**< Loud Speaker minor class */ - BT_HAL_DEVICE_MINOR_CLASS_HEADPHONES = 0x18, /**< Headphones minor class */ - BT_HAL_DEVICE_MINOR_CLASS_PORTABLE_AUDIO = 0x1C, /**< Portable Audio minor class */ - BT_HAL_DEVICE_MINOR_CLASS_CAR_AUDIO = 0x20, /**< Car Audio minor class */ - BT_HAL_DEVICE_MINOR_CLASS_SET_TOP_BOX = 0x24, /**< Set top box minor class */ - BT_HAL_DEVICE_MINOR_CLASS_HIFI_AUDIO_DEVICE = 0x28, /**< Hifi minor class */ - BT_HAL_DEVICE_MINOR_CLASS_VCR = 0x2C, /**< VCR minor class */ - BT_HAL_DEVICE_MINOR_CLASS_VIDEO_CAMERA = 0x30, /**< Video Camera minor class */ - BT_HAL_DEVICE_MINOR_CLASS_CAM_CORDER = 0x34, /**< CAM Corder minor class */ - BT_HAL_DEVICE_MINOR_CLASS_VIDEO_MONITOR = 0x38, /**