handle_stack_msg gatt_le_event_cb;
+/* Advertising filter_policy */
+static int adv_filter_policy;
+
/* Forward declarations */
static gboolean __bt_hal_is_factory_test_mode(void);
static void __bt_hal_free_le_adv_slot(void);
static gboolean __bt_hal_adv_event_cb(gpointer param);
+
#ifdef TIZEN_BT_HAL
/* Enable LE Adapter */
int _bt_hal_le_enable(void)
return _bt_hal_dbus_disable_le();
}
+void _bt_hal_set_filter_policy_param(int filter_policy)
+{
+ adv_filter_policy = filter_policy;
+}
+
int _bt_hal_set_le_static_random_address(uint8_t enable)
{
DBG("+");
adv_type == BT_HAL_ADV_NON_CONNECTABLE)
return BT_STATUS_UNSUPPORTED;
+ if (adv_filter_policy < 0 || adv_filter_policy > 3) {
+ ERR("Invalid filter policy, Setting the filter policy to default");
+ adv_filter_policy = BT_HAL_ADV_FILTER_POLICY_DEFAULT;
+ }
min = min_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("(uuuuii)", min, max,
- BT_HAL_ADV_FILTER_POLICY_DEFAULT, adv_type,
+ adv_filter_policy, adv_type,
tx_power, slot_id), G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (error) {
int _bt_hal_le_disable(void);
+void _bt_hal_set_filter_policy_param(int filter_policy);
+
int _bt_hal_set_le_static_random_address(uint8_t enable);
#endif
chnl_map, tx_power, timeout_s);
}
+static bt_status_t gatt_server_set_filter_policy(int filter_policy)
+{
+ CHECK_BTGATT_INIT();
+ DBG("+");
+ /* Send the Filter policy parameter to LE Module */
+ _bt_hal_set_filter_policy_param(filter_policy);
+ return BT_STATUS_SUCCESS;
+}
static bt_status_t gatt_server_multi_adv_set_inst_data(btgatt_adv_param_setup_t adv_param_setup)
{
.set_adv_data = gatt_server_set_adv_data,
.multi_adv_enable = gatt_server_multi_adv_enable,
.multi_adv_update = gatt_server_multi_adv_update,
+ .set_filter_policy = gatt_server_set_filter_policy,
.multi_adv_set_inst_data = gatt_server_multi_adv_set_inst_data,
.multi_adv_disable = gatt_server_multi_adv_disable,
.get_att_mtu = gatt_server_get_mtu_size,
bt_status_t (*multi_adv_update)(int server_if, int min_interval, int max_interval, int adv_type,
int chnl_map, int tx_power, int timeout_s);
+ /* Set the filter_policy value in the HAL Layer */
+ bt_status_t (*set_filter_policy)(int filter_policy);
+
/* Setup the data for the specified instance */
bt_status_t (*multi_adv_set_inst_data)(btgatt_adv_param_setup_t adv_param_setup);
int adv_type, int chnl_map, int tx_power, int timeout_s);
/**
+ * @brief Set Advertising filter policy for a advertiser
+ *
+ * @param filter_policy Type of policy to be used for a particular advertiser.
+ *
+ * @return OAL_STATUS_SUCCESS on success.
+ *
+ * @pre Adapter must be enabled with adapter_enable()
+ */
+oal_status_t adapter_ble_set_filter_policy(int filter_policy);
+
+/**
* @brief Enable Multi Advertising on specific Instance ID
*
* @param instance_id Multi advertising slot ID initialized by stack
int tx_power, int timeout_s);
/**
+ * @brief sets the filter policy for a particular advertiser in HAL layer.
+ */
+oal_status_t gatts_set_filter_policy(int filter_policy);
+
+/**
* @brief Sets the the Multiple Advertising Data
*
* @remarks The Multiple advertising data will be set.
return OAL_STATUS_SUCCESS;
}
+oal_status_t adapter_ble_set_filter_policy(int filter_policy)
+{
+ int ret = OAL_STATUS_SUCCESS;
+
+ CHECK_OAL_INITIALIZED();
+ API_TRACE();
+
+ BT_DBG("Filter policy applied is [%d]", filter_policy);
+
+ ret = gatts_set_filter_policy(filter_policy);
+
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("gatts_set_filter_policy: [%d]", ret);
+ return ret;
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
oal_status_t adapter_ble_multi_adv_update(int Ins_id, int min_intv, int max_intv,
int adv_type, int chnl_map, int tx_power, int timeout_s)
{
return OAL_STATUS_SUCCESS;
}
+oal_status_t gatts_set_filter_policy(int filter_policy)
+{
+ int ret = OAL_STATUS_SUCCESS;
+
+ CHECK_OAL_GATT_ENABLED();
+
+ /* send the filter_policy value to the HAL Layer */
+ ret = gatt_api->server->set_filter_policy(filter_policy);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("set_filter_policy failed: %d",ret);
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
oal_status_t gatts_multi_adv_update(int instance_id,
int min_intv, int max_intv,
int adv_type, int chnl_map,
}
if (enable) {
+ /* Set the Advertising filter policy Parameter in HAL */
+ result = adapter_ble_set_filter_policy(params->filter_policy);
+
+ if (result != OAL_STATUS_SUCCESS){
+ BT_ERR("OAL API adapter_ble_set_filter_policy Fail %d", result);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
/* Set Advertising parameters to Stack */
result = adapter_ble_multi_adv_update(server_instance, params->interval_min, params->interval_max,
params->type, BT_ADV_DEFAULT_CHANNEL_MAP, params->tx_power_level, BT_ADV_DEFAULT_TIMEOUT);