g_free(uuid_str);
}
+static struct gatt_server_info_t *__bt_find_remote_gatt_server_info_from_conn_id(int conn_id)
+{
+ GSList *l;
+ struct gatt_server_info_t *info = NULL;
+
+ for (l = gatt_server_info_list; l != NULL; l = g_slist_next(l)) {
+ info = (struct gatt_server_info_t*)l->data;
+ if (info == NULL)
+ continue;
+
+ if (info->connection_id == conn_id)
+ return info;
+ }
+ return NULL;
+}
+
int _bt_gatt_init(void)
{
const char *stack_name = NULL;
param);
}
+static void __bt_handle_gatt_phy_updated_event(event_gatts_phy_updated_t *event)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ struct gatt_client_info_t *conn_info = NULL;
+ GVariant *param = NULL;
+
+ conn_info = __bt_find_remote_gatt_client_info_from_conn_id(event->conn_id);
+ if (conn_info == NULL) {
+ BT_ERR("Can't find connection Information");
+ return;
+ }
+
+ BT_INFO("Got connection Info GATT client:[%s] TX_PHY:[%d], RX_PHY:[%d], Status:[%d]",
+ conn_info->addr, event->tx_phy, event->rx_phy, event->status);
+
+ param = g_variant_new("(isiii)",
+ result,
+ conn_info->addr,
+ event->tx_phy,
+ event->rx_phy,
+ event->status);
+
+ /* Send event to BT-API */
+ _bt_send_event(BT_GATT_SERVER_EVENT,
+ BLUETOOTH_EVENT_GATT_SERVER_PHY_UPDATED,
+ param);
+}
+
+static void __bt_handle_gatt_phy_read_event(event_gatts_phy_read_t *event)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ struct gatt_client_info_t *conn_info = NULL;
+ GVariant *param = NULL;
+
+ conn_info = __bt_find_remote_gatt_client_info_from_conn_id(event->conn_id);
+ if (conn_info == NULL) {
+ BT_ERR("Cant find connection Information");
+ return;
+ }
+
+ BT_INFO("Got connection Info GATT client:[%s] TX_PHY:[%d], RX_PHY:[%d], Status:[%d]",
+ conn_info->addr, event->tx_phy, event->rx_phy, event->status);
+
+ param = g_variant_new("(isiii)",
+ result,
+ conn_info->addr,
+ event->tx_phy,
+ event->rx_phy,
+ event->status);
+
+ /* Send event to BT-API */
+ _bt_send_event(BT_GATT_SERVER_EVENT,
+ BLUETOOTH_EVENT_GATT_SERVER_PHY_READ,
+ param);
+}
+
+static void __bt_handle_gatt_client_phy_updated_event(event_gattc_phy_updated_t *event)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ struct gatt_server_info_t *conn_info = NULL;
+ GVariant *param = NULL;
+
+ conn_info = __bt_find_remote_gatt_server_info_from_conn_id(event->conn_id);
+ if (conn_info == NULL) {
+ BT_ERR("Cant find connection Information");
+ return;
+ }
+
+ BT_INFO("Got connection Info GATT client:[%s] TX_PHY:[%d], RX_PHY:[%d], Status:[%d]",
+ conn_info->addr, event->tx_phy, event->rx_phy, event->status);
+
+ param = g_variant_new("(isiii)",
+ result,
+ conn_info->addr,
+ event->tx_phy,
+ event->rx_phy,
+ event->status);
+
+ /* Send event to BT-API */
+ _bt_send_event(BT_GATT_CLIENT_EVENT,
+ BLUETOOTH_EVENT_GATT_CLIENT_PHY_UPDATED,
+ param);
+}
+
+static void __bt_handle_gatt_client_phy_read_event(event_gattc_phy_read_t *event)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ struct gatt_server_info_t *conn_info = NULL;
+ GVariant *param = NULL;
+
+ conn_info = __bt_find_remote_gatt_server_info_from_conn_id(event->conn_id);
+ if (conn_info == NULL) {
+ BT_ERR("Cant find connection Information");
+ return;
+ }
+
+ BT_INFO("Got connection Info GATT client:[%s] TX_PHY:[%d], RX_PHY:[%d], Status:[%d]",
+ conn_info->addr, event->tx_phy, event->rx_phy, event->status);
+
+ param = g_variant_new("(isiii)",
+ result,
+ conn_info->addr,
+ event->tx_phy,
+ event->rx_phy,
+ event->status);
+
+ /* Send event to BT-API */
+ _bt_send_event(BT_GATT_CLIENT_EVENT,
+ BLUETOOTH_EVENT_GATT_CLIENT_PHY_READ,
+ param);
+}
+
static void __bt_gatt_event_handler(int event_type, gpointer event_data)
{
switch (event_type) {
__bt_handle_gatt_mtu_changed_event((event_gatts_mtu_changed_t *)event_data);
break;
}
+ case OAL_EVENT_GATTS_PHY_UPDATED: {
+ BT_INFO("OAL Event: GATT Server PHY Updated event callback");
+ __bt_handle_gatt_phy_updated_event((event_gatts_phy_updated_t *)event_data);
+ break;
+ }
+ case OAL_EVENT_GATTS_PHY_READ: {
+ BT_INFO("OAL Event: GATT Server PHY Read event callback");
+ __bt_handle_gatt_phy_read_event((event_gatts_phy_read_t *)event_data);
+ break;
+ }
+ case OAL_EVENT_GATTC_PHY_UPDATED: {
+ BT_INFO("OAL Event: GATT Client PHY Updated event callback");
+ __bt_handle_gatt_client_phy_updated_event((event_gattc_phy_updated_t *)event_data);
+ break;
+ }
+ case OAL_EVENT_GATTC_PHY_READ: {
+ BT_INFO("OAL Event: GATT Client PHY Read event callback");
+ __bt_handle_gatt_client_phy_read_event((event_gattc_phy_read_t *)event_data);
+ break;
+ }
case OAL_EVENT_GATTC_REGISTRATION: {
BT_INFO("OAL Event: GATT Client instance Registered");
__bt_handle_client_instance_registered((event_gattc_register_t *) event_data);
return BLUETOOTH_ERROR_NONE;
}
+int _bt_gatt_server_set_phy(bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options)
+{
+ struct gatt_client_info_t *conn_info = NULL;
+ char *addr = NULL;
+ int ret = OAL_STATUS_SUCCESS;
+
+ BT_INFO("Setting Preferred PHY");
+ addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
+ _bt_convert_addr_type_to_string(addr, device_address->addr);
+
+ /* Check if remote GATT Client is connected or not */
+ conn_info = _bt_find_remote_gatt_client_info(addr);
+ if (conn_info == NULL) {
+ BT_ERR("GATT Client is not yet connected...");
+ g_free(addr);
+ return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
+
+ // TODO: This code is commented as currently this API is not supported in OAL
+ //ret = gatts_set_preferred_phy(conn_info->connection_id, tx_phy, rx_phy, phy_options);
+
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("ret: %d", ret);
+ g_free(addr);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_free(addr);
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_gatt_server_read_phy(bluetooth_device_address_t *address)
+{
+ struct gatt_client_info_t *conn_info = NULL;
+ int ret = OAL_STATUS_SUCCESS;
+ char *addr = NULL;
+
+ BT_CHECK_PARAMETER(address, return);
+
+ addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
+ _bt_convert_addr_type_to_string(addr, address->addr);
+
+ BT_INFO("Read PHY for the server: address:[%s]", addr);
+
+ /* Check if remote GATT client is connected or not */
+ conn_info = _bt_find_remote_gatt_client_info(addr);
+ if (conn_info == NULL) {
+ BT_ERR("GATT Client is not yet connected..");
+ g_free(addr);
+ return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
+
+ // TODO: This code is commented as currently this API is not supported in OAL
+ //ret = gatts_read_phy(conn_info->connection_id);
+
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("ret: %d", ret);
+ g_free(addr);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_free(addr);
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_gatt_client_set_phy(bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options)
+{
+ struct gatt_server_info_t *conn_info = NULL;
+ char *addr = NULL;
+ int ret = OAL_STATUS_SUCCESS;
+
+ BT_INFO("Setting Preferred PHY");
+ addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
+ _bt_convert_addr_type_to_string(addr, device_address->addr);
+
+ /* Check if remote GATT server is connected or not */
+ conn_info = _bt_find_remote_gatt_server_info(addr);
+ if (conn_info == NULL) {
+ BT_ERR("GATT Server is not yet connected...");
+ g_free(addr);
+ return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
+
+ // TODO: This code is commented as currently this API is not supported in OAL
+ //ret = gattc_set_preferred_phy(conn_info->connection_id, tx_phy, rx_phy, phy_options);
+
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("ret: %d", ret);
+ g_free(addr);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_free(addr);
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_gatt_client_read_phy(bluetooth_device_address_t *address)
+{
+ struct gatt_server_info_t *conn_info = NULL;
+ int ret = OAL_STATUS_SUCCESS;
+ char *addr = NULL;
+
+ BT_CHECK_PARAMETER(address, return);
+
+ addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
+ _bt_convert_addr_type_to_string(addr, address->addr);
+
+ BT_INFO("Read PHY for the server: address:[%s]", addr);
+
+ /* Check if remote GATT server is connected or not */
+ conn_info = _bt_find_remote_gatt_server_info(addr);
+ if (conn_info == NULL) {
+ BT_ERR("GATT Server is not yet connected..");
+ g_free(addr);
+ return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
+
+ // TODO: This code is commented as currently this API is not supported in OAL
+ //ret = gattc_read_phy(conn_info->connection_id);
+
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("ret: %d", ret);
+ g_free(addr);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_free(addr);
+ return BLUETOOTH_ERROR_NONE;
+}
+
int _bt_request_att_mtu(bluetooth_device_address_t *device_address,
unsigned int mtu)
{
return NULL;
}
-
-static struct gatt_server_info_t *__bt_find_remote_gatt_server_info_from_conn_id(int conn_id)
-{
- GSList *l;
- struct gatt_server_info_t *info = NULL;
-
- for (l = gatt_server_info_list; l != NULL; l = g_slist_next(l)) {
- info = (struct gatt_server_info_t*)l->data;
- if (info == NULL)
- continue;
-
- if (info->connection_id == conn_id)
- return info;
- }
- return NULL;
-}
-
static bt_gatt_service_info_t* __bt_find_removed_service(bt_gatt_service_info_list_t *svc_list)
{
GSList *l;