void _bt_hal_set_advertising_status(int slot_id, gboolean mode)
{
- DBG("Advertising enabled [%s] server_slot [%d]", mode ? "TRUE" : "FALSE", slot_id);
bt_hal_adv_event_data_t *event;
- int adv_slot_id = -1;
+ int adv_slot_id = slot_id;
+ int server_if = 0;
- if (le_adv_slot == NULL)
- return;
+ server_if = bt_hal_gatts_get_server_if(slot_id);
- adv_slot_id = bt_hal_gatts_get_adv_slot_id(slot_id);
- if (adv_slot_id < 0)
+ DBG("Advertising enabled [%s] server_slot [%d] server_if[%d]", mode ? "TRUE" : "FALSE", slot_id, server_if);
+
+ if (le_adv_slot == NULL)
return;
le_adv_slot[adv_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->server_if = slot_id;
+
+ event->server_if = server_if;
event->status = BT_STATUS_SUCCESS;
/* To be removed later when we completely descope Legacy Adv concept */
if (mode == false ) {
DBG("release the adv_slot");
- bt_hal_gatts_release_adv_slot(slot_id);
+ bt_hal_gatts_release_adv_slot(server_if);
}
__bt_hal_adv_event_cb((gpointer)event);
}
ret = g_dbus_proxy_call_sync(proxy, "SetAdvertising",
- g_variant_new("(bi)", enable, server_if),
+ g_variant_new("(bi)", enable, adv_slot_id),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
guint32 min = 0;
guint32 max = 0;
bt_hal_adv_event_data_t *event;
+ int slot_id = 0;
proxy = _bt_hal_get_adapter_proxy();
min = min_interval / BT_HAL_ADV_INTERVAL_SPLIT;
max = max_interval / BT_HAL_ADV_INTERVAL_SPLIT;
+ slot_id = bt_hal_gatts_allocate_adv_slot_by_server_if(server_if);
+
ret = g_dbus_proxy_call_sync(proxy, "SetAdvertisingParameters",
g_variant_new("(uuuuii)", min, max,
BT_HAL_ADV_FILTER_POLICY_DEFAULT, adv_type,
- tx_power, server_if), G_DBUS_CALL_FLAGS_NONE,
+ tx_power, slot_id), G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (error) {
ERR("SetAdvertisingParameters Fail: %s", error->message);
bt_hal_adv_event_data_t *event;
int length = 0;
int i;
+ int slot_id = 0;
/* Parse data according to Bluez Interface */
if (__bt_hal_is_factory_test_mode()) {
if (proxy == NULL)
return BT_STATUS_FAIL;
+ slot_id = bt_hal_gatts_allocate_adv_slot_by_server_if(adv_param_setup.server_if);
+
memset(&adv_data, 0, 31);
/* Service UUID */
if (adv_param_setup.set_scan_rsp == 0) {
/* Set Advertising data to stack */
ret = g_dbus_proxy_call_sync(proxy, "SetAdvertisingData",
- g_variant_new("(@ayi)", temp, adv_param_setup.server_if),
+ g_variant_new("(@ayi)", temp, slot_id),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
} else {
/* Set Scan response data to stack */
ret = g_dbus_proxy_call_sync(proxy, "SetScanRespData",
- g_variant_new("(@ayi)", temp, adv_param_setup.server_if),
+ g_variant_new("(@ayi)", temp, slot_id),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
}
return NULL;
}
+static struct hal_gatts_server_register_info_t * bt_hal_gatts_find_server_register_info_by_slot_id(int adv_slot_id)
+{
+ DBG("+");
+
+ GSList *l;
+ struct hal_gatts_server_register_info_t *info = NULL;
+
+ for (l = hal_gatts_server_register_list; l != NULL; l = g_slist_next(l)) {
+ info = (struct hal_gatts_server_register_info_t *)l->data;
+ if (info == NULL) {
+ continue;
+ }
+
+ if (info->adv_slot_id == adv_slot_id) {
+ DBG("gatt server register found");
+ return info;
+ }
+ }
+
+ return NULL;
+}
+
static struct hal_gatts_server_register_info_t * bt_hal_gatts_add_server_app(bt_uuid_t *app_uuid)
{
DBG("+");
return 0;
}
+int bt_hal_gatts_allocate_adv_slot_by_server_if(int server_if)
+{
+ CHECK_BTGATT_INIT();
+
+ int ret = -1;
+
+ struct hal_gatts_server_register_info_t *server_register_info = NULL;
+
+ DBG("server_if: [%d]", server_if);
+
+ server_register_info = bt_hal_gatts_find_server_register_info(server_if);
+ if (server_register_info == NULL) {
+ DBG("gatt server is not registered");
+ return -1;
+ }
+
+ DBG("gatt server:[%d], adv_slot:[%d]", server_register_info->server_if, server_register_info->adv_slot_id);
+
+ if (server_register_info->adv_slot_id < 0 ) {
+ DBG("adv_slot is not assigned to server:[%d] \n", server_if);
+
+ ret = bt_hal_gatts_allocate_adv_slot(server_register_info);
+ if (ret < 0) {
+ DBG("failed to get adv_slot");
+ return -1;
+ }
+ }
+
+ return server_register_info->adv_slot_id;
+}
+
void bt_hal_gatts_release_adv_slot(int server_if)
{
struct hal_gatts_server_register_info_t *server_register_info = NULL;
return server_register_info->adv_slot_id;
}
+int bt_hal_gatts_get_server_if(int slot_id)
+{
+ struct hal_gatts_server_register_info_t *server_register_info = NULL;
+
+ server_register_info = bt_hal_gatts_find_server_register_info_by_slot_id(slot_id);
+ if (server_register_info == NULL) {
+ DBG("failed to get server_register_info");
+ return -1;
+ }
+
+ return server_register_info->server_if;
+}
+
static bt_status_t gatt_server_multi_adv_enable(int server_if)
{
CHECK_BTGATT_INIT();