{
gatt_le_event_cb = NULL;
}
+
+/*add/remove remote device address from white list*/
+int _bt_hal_adapter_le_set_white_list(bt_bdaddr_t *device_address, bt_dev_addr_type_t address_type, bool is_add)
+{
+ GDBusProxy *proxy;
+ char address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
+ GError *error = NULL;
+ GVariant *ret;
+
+ if (address_type != BLUETOOTH_HAL_DEVICE_PUBLIC_ADDRESS &&
+ address_type != BLUETOOTH_HAL_DEVICE_RANDOM_ADDRESS)
+ return BT_STATUS_PARM_INVALID;
+
+ _bt_hal_convert_addr_type_to_string(address, device_address->address);
+
+ proxy = _bt_hal_get_adapter_proxy();
+ if (proxy == NULL)
+ return BT_STATUS_FAIL;
+ if (is_add)
+ ret = g_dbus_proxy_call_sync(proxy, "AddDeviceWhiteList",
+ g_variant_new("(su)", address, address_type),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, &error);
+ else
+ ret = g_dbus_proxy_call_sync(proxy, "RemoveDeviceWhiteList",
+ g_variant_new("(su)", address, address_type),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, &error);
+
+ if (error) {
+ if (is_add)
+ ERR("RemoveDeviceWhiteList Fail: %s", error->message);
+ else
+ ERR("AddDeviceWhiteList Fail: %s", error->message);
+ g_clear_error(&error);
+ return BT_STATUS_FAIL;
+ }
+
+ if (ret)
+ g_variant_unref(ret);
+ if (is_add)
+ INFO("Device Added to white list");
+ else
+ INFO("Device Removed from white list");
+ return BT_STATUS_SUCCESS;
+}
int _bt_hal_le_init(void);
void _bt_hal_le_deinit(void);
+
+int _bt_hal_adapter_le_set_white_list(bt_bdaddr_t *device_address, bt_dev_addr_type_t address_type, bool is_add);
#ifdef __cplusplus
}
#endif /* __cplusplus */
.set_le_static_random_address = _bt_hal_set_le_static_random_address,
.set_hal_adapter_request_state = set_hal_adapter_request_state,
.set_hal_le_request_state = set_hal_le_request_state,
+ .adapter_le_set_white_list = _bt_hal_adapter_le_set_white_list,
#endif
};
BT_DISC_ROLE_DUAL
} bt_disc_role_type_t;
+/**
+* This is Bluetooth device address type
+*/
+typedef enum {
+ BLUETOOTH_HAL_DEVICE_PUBLIC_ADDRESS = 0x00,
+ BLUETOOTH_HAL_DEVICE_RANDOM_ADDRESS
+} bt_dev_addr_type_t;
+
/** Bluetooth Trusted Profiles */
typedef enum {
BT_TRUSTED_PROFILE_PBAP = 1,
*/
int (*set_hal_le_request_state)(int enable);
+ /*
+ * adds/removes the remote device address to/from the white list
+ */
+ int (*adapter_le_set_white_list)(bt_bdaddr_t *device_address, bt_dev_addr_type_t address_type, bool is_add);
#endif
} bt_interface_t;
* @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
*/
oal_status_t is_advertising(void);
+
+/**
+ * @brief Add/removes device to/from whitelist
+ *
+ * @param remote device address
+ * @param remote device address type
+ * @param whether to add/remove from white list
+ *
+ * @details adds/removes device to/from controller's white list.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ */
+oal_status_t adapter_set_white_list(bt_address_t* device_address, int address_type, bool is_add);
#ifdef __cplusplus
}
#endif /* __cplusplus */
return ret;
}
+oal_status_t adapter_set_white_list(bt_address_t *device_address, int address_type, bool is_add)
+{
+ int ret;
+ bdstr_t bdstr;
+
+ CHECK_OAL_INITIALIZED();
+ API_TRACE();
+
+ BT_INFO("BT remote device Address: %s", bdt_bd2str(device_address, &bdstr));
+
+ ret = blued_api->adapter_le_set_white_list((bt_bdaddr_t*)device_address, address_type, is_add);
+ if (ret != BT_STATUS_SUCCESS) {
+ if(is_add)
+ BT_ERR("Add to White List Failed: [%s]",status2string(ret));
+ else
+ BT_ERR("Remove from White List Failed: [%s]",status2string(ret));
+ }
+ ret = convert_to_oal_status(ret);
+ return ret;
+}
+
static void cb_adapter_properties(bt_status_t status,
int num_properties,
bt_property_t *properties)
return FALSE;
}
+int _bt_set_white_list(bluetooth_device_address_t *device_address, int address_type, bool is_add)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ if (__bt_is_factory_test_mode()) {
+ if(is_add)
+ BT_ERR("Unable to add to white list in factory binary !!");
+ else
+ BT_ERR("Unable to remove white list in factory binary !!");
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+ }
+
+ BT_CHECK_PARAMETER(device_address, return);
+
+ if(_bt_adapter_get_status() != BT_ACTIVATED ){
+ BT_ERR("Bluetooth adapter is disabled");
+ return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+ }
+
+ result = adapter_set_white_list((bt_address_t*)device_address, address_type, is_add);
+ if (result != OAL_STATUS_SUCCESS) {
+ if(is_add)
+ BT_ERR("Add to White List Failed %d", result);
+ else
+ BT_ERR("Remove from white list Failed %d", result);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ return result;
+}
/*************************************** LE Scan APIs *********************************************/
return result;
}
-
result = _bt_set_authorization(&address, authorize);
break;
}
+ case BT_ADD_WHITE_LIST: {
+ bluetooth_device_address_t address = { {0} };
+ int address_type = 0;
+ bool is_add = true;
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &address_type, sizeof(int));
+ result = _bt_set_white_list(&address, address_type, is_add);
+ break;
+ }
+ case BT_REMOVE_WHITE_LIST: {
+ bluetooth_device_address_t address = { {0} };
+ int address_type = 0;
+ bool is_add = false;
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &address_type, sizeof(int));
+ result = _bt_set_white_list(&address, address_type, is_add);
+ break;
+ }
case BT_IS_DEVICE_CONNECTED: {
bluetooth_device_address_t address = { {0} };
gboolean connected = FALSE;
int _bt_set_le_static_random_address(gboolean is_enable);
+int _bt_set_white_list(bluetooth_device_address_t *device_address, int address_type, bool is_add);
#ifdef __cplusplus
}
#endif /* __cplusplus */