{BT_GATT_REGISTER_APPLICATION, "BT_GATT_REGISTER_APPLICATION"},
{BT_GATT_REGISTER_SERVICE, "BT_GATT_REGISTER_SERVICE"},
{BT_GATT_SEND_RESPONSE, "BT_GATT_SEND_RESPONSE"},
+ {BT_GATT_SERVER_READ_PHY, "BT_GATT_SERVER_READ_PHY"},
+ {BT_GATT_SERVER_SET_PHY, "BT_GATT_SERVER_SET_PHY"},
+ {BT_GATT_CLIENT_READ_PHY, "BT_GATT_CLIENT_READ_PHY"},
+ {BT_GATT_CLIENT_SET_PHY, "BT_GATT_CLIENT_SET_PHY"},
{BT_LE_IPSP_INIT, "BT_LE_IPSP_INIT"},
{BT_LE_IPSP_DEINIT, "BT_LE_IPSP_DEINIT"},
{BT_LE_IPSP_CONNECT, "BT_LE_IPSP_CONNECT"},
}
}
+static void _bt_get_phy_info(GVariant *parameters, bluetooth_le_phy_info_t *phy_info, int *result)
+{
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+ int tx_phy;
+ int rx_phy;
+ int status;
+
+ BT_DBG("BT_GATT_SERVER_PHY_UPDATED");
+ g_variant_get(parameters, "(i&siii)", result, &address, &tx_phy, &rx_phy, &status);
+
+ BT_DBG("Result [%d] Address [%s] TX_PHY [%d] RX_PHY[%d] status [%d]",
+ *result, address, tx_phy, rx_phy, status);
+
+ _bt_convert_addr_string_to_type(dev_address.addr, address);
+
+ memset(phy_info, 0x00, sizeof(bluetooth_le_phy_info_t));
+ memcpy(phy_info->device_address.addr,
+ dev_address.addr, BLUETOOTH_ADDRESS_LENGTH);
+
+ phy_info->tx_phy = tx_phy;
+ phy_info->rx_phy = rx_phy;
+ phy_info->status = status;
+}
+
void __bt_device_event_filter(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
_bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_DISCONNECTED,
result, &dev_address,
event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_SERVER_PHY_UPDATED) == 0) {
+ bluetooth_le_phy_info_t phy_info;
+
+ _bt_get_phy_info(parameters, &phy_info, &result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_PHY_UPDATED,
+ result, &phy_info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_SERVER_PHY_READ) == 0) {
+ bluetooth_le_phy_info_t phy_info;
+
+ _bt_get_phy_info(parameters, &phy_info, &result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_PHY_READ,
+ result, &phy_info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_CLIENT_PHY_UPDATED) == 0) {
+ bluetooth_le_phy_info_t phy_info;
+
+ _bt_get_phy_info(parameters, &phy_info, &result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_PHY_UPDATED,
+ result, &phy_info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_CLIENT_PHY_READ) == 0) {
+ bluetooth_le_phy_info_t phy_info;
+
+ _bt_get_phy_info(parameters, &phy_info, &result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_PHY_READ,
+ result, &phy_info,
+ event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_GATT_REQ_ATT_MTU_CHANGED) == 0) {
const char *address = NULL;
bluetooth_device_address_t dev_address = { {0} };
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
+
+BT_EXPORT_API int bluetooth_gatt_client_read_phy(const bluetooth_device_address_t *device_address)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GATT_CLIENT_READ_PHY,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result != BLUETOOTH_ERROR_NONE)
+ BT_INFO("GATT Client Read PHY failed result [%d]", result);
+ else
+ BT_INFO("GATT Client Read PHY successful");
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_gatt_client_set_phy(const bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INFO("Set PHY: Tx[%d], Rx[%d], Phy_options[%d]", tx_phy, rx_phy, phy_options);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+ g_array_append_vals(in_param2, &tx_phy, sizeof(int));
+ g_array_append_vals(in_param3, &rx_phy, sizeof(int));
+ g_array_append_vals(in_param4, &phy_options, sizeof(int));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GATT_CLIENT_SET_PHY,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result != BLUETOOTH_ERROR_NONE)
+ BT_INFO("GATT Client Set PHY failed result [%d]", result);
+ else
+ BT_INFO("GATT Client Set PHY successful");
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
bluetooth_characteristic_info_free(chr_info);
}
}
+
+BT_EXPORT_API int bluetooth_gatt_server_read_phy(const bluetooth_device_address_t *device_address)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GATT_SERVER_READ_PHY,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result != BLUETOOTH_ERROR_NONE)
+ BT_INFO("GATT Server Read PHY failed result [%d]", result);
+ else
+ BT_INFO("GATT Server Read PHY successful");
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_gatt_server_set_phy(const bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INFO("Set PHY: Tx[%d], Rx[%d], Phy_options[%d]", tx_phy, rx_phy, phy_options);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+ g_array_append_vals(in_param2, &tx_phy, sizeof(int));
+ g_array_append_vals(in_param3, &rx_phy, sizeof(int));
+ g_array_append_vals(in_param4, &phy_options, sizeof(int));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GATT_SERVER_SET_PHY,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result != BLUETOOTH_ERROR_NONE)
+ BT_INFO("GATT Server Set PHY failed result [%d]", result);
+ else
+ BT_INFO("GATT Server Set PHY successful");
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
EVENT(OAL_EVENT_GATTS_IND_CONFIRM) /* gatts Indiction confirmation from remote client */\
EVENT(OAL_EVENT_GATTS_NOTIFICATION) /* gatts Notification from remote client */\
EVENT(OAL_EVENT_GATTS_MTU_CHANGED) /* gatts MTU changed */\
+ EVENT(OAL_EVENT_GATTS_PHY_UPDATED) /* gatts PHY UPDATED event */\
+ EVENT(OAL_EVENT_GATTS_PHY_READ) /* gatts PHY READ event */\
+ EVENT(OAL_EVENT_GATTC_PHY_UPDATED) /* gattc PHY UPDATED event */\
+ EVENT(OAL_EVENT_GATTC_PHY_READ) /* gattc PHY READ event */\
EVENT(OAL_EVENT_GATTC_REGISTRATION) /* gattc Registration Confirmed */\
EVENT(OAL_EVENT_GATTC_CONNECTION_COMPLETED) /* gattc connection completed */\
EVENT(OAL_EVENT_GATTC_DISCONNECTION_COMPLETED) /* gattc disconnection */\
int mtu_size;
} event_gatts_mtu_changed_t;
+typedef struct{
+ int conn_id;
+ int tx_phy;
+ int rx_phy;
+ int status;
+} event_gatts_phy_updated_t;
+
+typedef struct{
+ int conn_id;
+ int tx_phy;
+ int rx_phy;
+ int status;
+} event_gatts_phy_read_t;
+
+typedef struct{
+ int conn_id;
+ int tx_phy;
+ int rx_phy;
+ int status;
+} event_gattc_phy_updated_t;
+
+typedef struct{
+ int conn_id;
+ int tx_phy;
+ int rx_phy;
+ int status;
+} event_gattc_phy_read_t;
+
typedef struct {
int server_inst;
} event_ble_adv_status;
result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
break;
}
+ case BT_GATT_SERVER_READ_PHY: {
+ bluetooth_device_address_t address = { {0} };
+
+ sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_gatt_server_read_phy(&address);
+ break;
+ }
+ case BT_GATT_SERVER_SET_PHY: {
+ bluetooth_device_address_t address = { {0} };
+ int tx_phy;
+ int rx_phy;
+ int phy_options;
+
+ sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &tx_phy, sizeof(int));
+ __bt_service_get_parameters(in_param3,
+ &rx_phy, sizeof(int));
+ __bt_service_get_parameters(in_param4,
+ &phy_options, sizeof(int));
+
+ result = _bt_gatt_server_set_phy(&address, tx_phy, rx_phy, phy_options);
+ break;
+ }
+ case BT_GATT_CLIENT_READ_PHY: {
+ bluetooth_device_address_t address = { {0} };
+
+ sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_gatt_client_read_phy(&address);
+ break;
+ }
+ case BT_GATT_CLIENT_SET_PHY: {
+ bluetooth_device_address_t address = { {0} };
+ int tx_phy;
+ int rx_phy;
+ int phy_options;
+
+ sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &tx_phy, sizeof(int));
+ __bt_service_get_parameters(in_param3,
+ &rx_phy, sizeof(int));
+ __bt_service_get_parameters(in_param4,
+ &phy_options, sizeof(int));
+
+ result = _bt_gatt_client_set_phy(&address, tx_phy, rx_phy, phy_options);
+ break;
+ }
case BT_GET_ATT_MTU: {
bluetooth_device_address_t address = { {0} };
unsigned int mtu = 0;
case BT_GATT_SERVER_UPDATE_VALUE:
case BT_GATT_SERVER_DEREGISTER:
#endif
+ case BT_GATT_SERVER_READ_PHY:
+ case BT_GATT_SERVER_SET_PHY:
+ case BT_GATT_CLIENT_READ_PHY:
+ case BT_GATT_CLIENT_SET_PHY:
case BT_REQ_ATT_MTU:
case BT_PBAP_CONNECT:
case BT_PBAP_DISCONNECT:
/* Tizen Platform Specific */
case OAL_EVENT_GATTS_NOTIFICATION: /* gatts Notification changed event */\
case OAL_EVENT_GATTS_MTU_CHANGED: /* gatts MTU changed event */\
+ case OAL_EVENT_GATTS_PHY_UPDATED: /* gatts PHY UPDATED event */\
+ case OAL_EVENT_GATTS_PHY_READ: /* gatts PHY READ event */\
if (adapter_gatt_cb)
adapter_gatt_cb(event_type, event_data);
if (adapter_le_cb)
case OAL_EVENT_GATTC_NOTIFY_DATA:
case OAL_EVENT_GATTC_CONNECTION_COMPLETED:
case OAL_EVENT_GATTC_REGISTRATION:
+ case OAL_EVENT_GATTC_PHY_UPDATED: /* gattc PHY UPDATED event */\
+ case OAL_EVENT_GATTC_PHY_READ: /* gattc PHY READ event */\
if (adapter_gatt_cb)
adapter_gatt_cb(event_type, event_data);
if (adapter_le_cb)
case BLUETOOTH_EVENT_GATT_SERVER_ATT_MTU_CHANGED:
signal = BT_GATT_SERVER_ATT_MTU_CHANGED;
break;
+ case BLUETOOTH_EVENT_GATT_SERVER_PHY_UPDATED:
+ signal = BT_GATT_SERVER_PHY_UPDATED;
+ BT_INFO_C("### PHY UPDATED Event [GATT server]");
+ break;
+ case BLUETOOTH_EVENT_GATT_SERVER_PHY_READ:
+ signal = BT_GATT_SERVER_PHY_READ;
+ BT_INFO_C("### PHY READ Event [GATT server]");
+ break;
+ case BLUETOOTH_EVENT_GATT_CLIENT_PHY_UPDATED:
+ signal = BT_GATT_CLIENT_PHY_UPDATED;
+ BT_INFO_C("### PHY UPDATED Event [GATT client]");
+ break;
+ case BLUETOOTH_EVENT_GATT_CLIENT_PHY_READ:
+ signal = BT_GATT_CLIENT_PHY_READ;
+ BT_INFO_C("### PHY READ Event [GATT client]");
+ break;
#ifndef GATT_DIRECT
case BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED:
signal = BT_GATT_VALUE_CHANGED;
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;
int client_id);
int _bt_request_att_mtu(bluetooth_device_address_t *device_address, unsigned int mtu);
+int _bt_gatt_server_read_phy(bluetooth_device_address_t *address);
+int _bt_gatt_server_set_phy(bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options);
+int _bt_gatt_client_read_phy(bluetooth_device_address_t *address);
+int _bt_gatt_client_set_phy(bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options);
+
+
#ifndef __INTEGRATE_GATT_INFO__
struct gatt_server_info_t *_bt_find_remote_gatt_server_info(char *address);
#else
BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED, /** <GATT Client service change event */
BLUETOOTH_EVENT_GATT_SERVER_ACQUIRE_WRITE, /** <GATT Characteristic/Descriptor Value change event */
BLUETOOTH_EVENT_GATT_SERVER_ACQUIRE_NOTIFY,
+ BLUETOOTH_EVENT_GATT_SERVER_PHY_READ, /**<Local Gatt Server PHY Read event */
+ BLUETOOTH_EVENT_GATT_SERVER_PHY_UPDATED, /**<Local Gatt Server PHY Updated event */
+ BLUETOOTH_EVENT_GATT_CLIENT_PHY_READ, /**<Gatt Client PHY Read event */
+ BLUETOOTH_EVENT_GATT_CLIENT_PHY_UPDATED, /**<Gatt Client PHY Updated event */
BLUETOOTH_EVENT_AG_CONNECTED = BLUETOOTH_EVENT_AUDIO_BASE, /**<AG service connected event*/
BLUETOOTH_EVENT_AG_DISCONNECTED, /**<AG service disconnected event*/
BLUETOOTH_EVENT_AG_SPEAKER_GAIN, /**<Speaker gain request event*/
unsigned int status; /** < status of the MTU exchange */
} bluetooth_le_att_mtu_info_t;
+typedef struct {
+ bluetooth_device_address_t device_address; /**< device address */
+ int tx_phy; /** < tx_phy set for the gatt connection */
+ int rx_phy; /** < rx_phy set for the gatt connection */
+ int status; /** < status of the PHY */
+} bluetooth_le_phy_info_t;
+
/**
* structure to hold the paired device information
*/
unsigned int *mtu);
/**
+ * @fn int bluetooth_gatt_server_read_phy(const bluetooth_device_address_t *device_address)
+ * @brief Gets the PHY values set for a connection.
+ *
+ * This function is a asynchronous call. The updated PHYs are notified
+ * through callback event.
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ * BLUETOOTH_ERROR_INVALID_PARAM - Parameter is not valid \n
+ *
+ * @exception None
+ * @param[in] address - remote device address value.
+ *
+ * @remark None
+ */
+int bluetooth_gatt_server_read_phy(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_gatt_server_set_phy(const bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options)
+ * @brief Request a change of the PHY values.
+ *
+ * This function is a asynchronous call. The updated PHYs are notified
+ * through callback event.
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ * BLUETOOTH_ERROR_INVALID_PARAM - Parameter is not valid \n
+ *
+ * @exception None
+ * @param[in] address - remote device address value.
+ * @param[in] tx_phy The preferred sender PHY
+ * @param[in] rx_phy The preferred receiver PHY
+ * @param[in] phy_options The preferred coding to use when transmitting on LE CODED PHY
+ *
+ * @remark None
+ */
+int bluetooth_gatt_server_set_phy(const bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options);
+
+/**
+ * @fn int bluetooth_gatt_client_read_phy(const bluetooth_device_address_t *device_address)
+ * @brief Gets the PHY values set for a connection.
+ *
+ * This function is a asynchronous call. The updated PHYs are notified
+ * through callback event.
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ * BLUETOOTH_ERROR_INVALID_PARAM - Parameter is not valid \n
+ *
+ * @exception None
+ * @param[in] address - remote device address value.
+ *
+ * @remark None
+ */
+int bluetooth_gatt_client_read_phy(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_gatt_client_set_phy(const bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options)
+ * @brief Request a change of the PHY values.
+ *
+ * This function is a asynchronous call. The updated PHYs are notified
+ * through callback event.
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ * BLUETOOTH_ERROR_INVALID_PARAM - Parameter is not valid \n
+ *
+ * @exception None
+ * @param[in] address - remote device address value.
+ * @param[in] tx_phy The preferred sender PHY
+ * @param[in] rx_phy The preferred receiver PHY
+ * @param[in] phy_options The preferred coding to use when transmitting on LE CODED PHY
+ *
+ * @remark None
+ */
+int bluetooth_gatt_client_set_phy(const bluetooth_device_address_t *device_address,
+ int tx_phy, int rx_phy, int phy_options);
+
+/**
* @fn int bluetooth_get_device_ida(const bluetooth_device_address_t *device_rpa,
* bluetooth_device_address_t *id_address)
* @brief Gets the Identity address of remote device.
BT_GATT_SERVER_SEND_INDICATION,
BT_GATT_SERVER_UPDATE_VALUE,
BT_GATT_SERVER_DEREGISTER,
+ BT_GATT_SERVER_READ_PHY,
+ BT_GATT_SERVER_SET_PHY,
+ BT_GATT_CLIENT_READ_PHY,
+ BT_GATT_CLIENT_SET_PHY,
//#endif
BT_LE_IPSP_INIT = BT_FUNC_IPSP_BASE,
BT_LE_IPSP_DEINIT,
#define BT_GATT_REQ_ATT_MTU_CHANGED "GattReqAttMtuChanged"
#define BT_GATT_SERVER_ATT_MTU_CHANGED "GattServerAttMtuChanged"
+#define BT_GATT_SERVER_PHY_UPDATED "GattServerPhyUpdated"
+#define BT_GATT_SERVER_PHY_READ "GattServerPhyRead"
+#define BT_GATT_CLIENT_PHY_UPDATED "GattClientPhyUpdated"
+#define BT_GATT_CLIENT_PHY_READ "GattClientPhyRead"
#define BT_GATT_CHAR_VAL_CHANGED "GattCharValueChanged"
#ifdef GATT_NO_RELAY
#define BT_GATT_BLUEZ_CHAR_VAL_CHANGED "GattValueChanged"