Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on: [pull_request]

jobs:
ci:
runs-on: ubuntu-latest
name: CI for Pull Request
steps:
- name: Checkout the source code
uses: actions/checkout@v3
with:
path: src/src

- name: CI
uses: tedd-an/bzcafe@main
with:
task: ci
base_folder: src
space: user
github_token: ${{ secrets.ACTION_TOKEN }}
email_token: ${{ secrets.EMAIL_TOKEN }}
patchwork_token: ${{ secrets.PATCHWORK_TOKEN }}
patchwork_user: ${{ secrets.PATCHWORK_USER }}

26 changes: 26 additions & 0 deletions .github/workflows/code_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Code Scan

on:
schedule:
- cron: "40 7 * * FRI"

jobs:
code-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout the source
uses: actions/checkout@v2
with:
fetch-depth: 0
path: src
- name: Code Scan
uses: BluezTestBot/action-code-scan@main
with:
src_path: src
github_token: ${{ secrets.GITHUB_TOKEN }}
email_token: ${{ secrets.EMAIL_TOKEN }}
- uses: actions/upload-artifact@v2
with:
name: scan_report
path: scan_report.tar.gz

43 changes: 43 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Sync

on:
schedule:
- cron: "*/30 * * * *"

jobs:
sync_repo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master

- name: Sync Repo
uses: tedd-an/bzcafe@main
with:
task: sync
upstream_repo: 'https://git.kernel.org/pub/scm/bluetooth/bluez.git'
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Cleanup PR
uses: tedd-an/bzcafe@main
with:
task: cleanup
github_token: ${{ secrets.ACTION_TOKEN }}

sync_patchwork:
needs: sync_repo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Sync Patchwork
uses: tedd-an/bzcafe@main
with:
task: patchwork
space: user
github_token: ${{ secrets.ACTION_TOKEN }}
email_token: ${{ secrets.EMAIL_TOKEN }}
patchwork_token: ${{ secrets.PATCHWORK_TOKEN }}
patchwork_user: ${{ secrets.PATCHWORK_USER }}

2 changes: 2 additions & 0 deletions doc/mgmt-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ Read Controller Information Command
19 Connected Isochronous Stream - Peripheral
20 Isochronous Broadcaster
21 Synchronized Receiver
22 LL Privacy

This command generates a Command Complete event on success or
a Command Status event on failure.
Expand Down Expand Up @@ -3429,6 +3430,7 @@ Get Device Flags Command

0 Remote Wakeup enabled
1 Device Privacy Mode enabled
2 Address Resolution enabled

This command generates a Command Complete event on success
or a Command Status event on failure.
Expand Down
1 change: 1 addition & 0 deletions lib/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct mgmt_rp_read_index_list {
#define MGMT_SETTING_CIS_PERIPHERAL BIT(19)
#define MGMT_SETTING_ISO_BROADCASTER BIT(20)
#define MGMT_SETTING_ISO_SYNC_RECEIVER BIT(21)
#define MGMT_SETTING_LL_PRIVACY BIT(22)

#define MGMT_OP_READ_INFO 0x0004
struct mgmt_rp_read_info {
Expand Down
1 change: 1 addition & 0 deletions monitor/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -12999,6 +12999,7 @@ static const struct bitfield_data mgmt_settings_table[] = {
{ 19, "CIS Peripheral" },
{ 20, "ISO Broadcaster" },
{ 21, "Sync Receiver" },
{ 22, "LL Privacy" },
{}
};

Expand Down
21 changes: 14 additions & 7 deletions src/gatt-database.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ static void gap_car_read_cb(struct gatt_db_attribute *attrib,
device = btd_adapter_find_device_by_fd(bt_att_get_fd(att));
if (device)
value = btd_device_flags_enabled(device,
DEVICE_FLAG_ADDRESS_RESOLUTION);
DEVICE_FLAG_ADDRESS_RESOLUTION);
}

gatt_db_attribute_read_result(attrib, id, 0, &value, sizeof(value));
Expand Down Expand Up @@ -873,10 +873,13 @@ static void populate_gap_service(struct btd_gatt_database *database)
{
bt_uuid_t uuid;
struct gatt_db_attribute *service, *attrib;
bool ll_privacy = btd_adapter_has_settings(database->adapter,
MGMT_SETTING_LL_PRIVACY);

/* Add the GAP service */
bt_uuid16_create(&uuid, UUID_GAP);
service = gatt_db_add_service(database->db, &uuid, true, 7);
service = gatt_db_add_service(database->db, &uuid, true,
ll_privacy ? 7 : 5);

/*
* Device Name characteristic.
Expand All @@ -898,15 +901,19 @@ static void populate_gap_service(struct btd_gatt_database *database)
NULL, database);
gatt_db_attribute_set_fixed_length(attrib, 2);

/*
* Central Address Resolution characteristic.
*/
bt_uuid16_create(&uuid, GATT_CHARAC_CAR);
attrib = gatt_db_service_add_characteristic(service, &uuid,
/* Only enable Central Address Resolution if LL Privacy is supported */
if (ll_privacy) {
/*
* Central Address Resolution characteristic.
*/
bt_uuid16_create(&uuid, GATT_CHARAC_CAR);
attrib = gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ,
BT_GATT_CHRC_PROP_READ,
gap_car_read_cb,
NULL, database);
}

gatt_db_attribute_set_fixed_length(attrib, 1);

gatt_db_service_set_active(service, true);
Expand Down
60 changes: 37 additions & 23 deletions tools/mgmt-tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,7 @@ static const char set_ssp_invalid_param[] = { 0x02 };
static const char set_ssp_garbage_param[] = { 0x01, 0x00 };
static const char set_ssp_settings_param_1[] = { 0xc0, 0x00, 0x00, 0x00 };
static const char set_ssp_settings_param_2[] = { 0xc1, 0x00, 0x00, 0x00 };
static const char set_ssp_settings_param_3[] = { 0xc1, 0x00, 0x40, 0x00 };
static const char set_ssp_on_write_ssp_mode_param[] = { 0x01 };

static const struct generic_data set_ssp_on_success_test_1 = {
Expand Down Expand Up @@ -6077,8 +6078,8 @@ static const struct generic_data set_dev_id_power_off_on = {
.send_param = set_powered_on_param,
.send_len = sizeof(set_powered_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_ssp_settings_param_2,
.expect_len = sizeof(set_ssp_settings_param_2),
.expect_param = set_ssp_settings_param_3,
.expect_len = sizeof(set_ssp_settings_param_3),
.expect_settings_set = MGMT_SETTING_POWERED,
.expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE,
.expect_hci_param = write_eir_set_dev_id_success_1,
Expand All @@ -6094,8 +6095,8 @@ static const struct generic_data set_dev_id_ssp_off_on = {
.send_param = set_ssp_on_param,
.send_len = sizeof(set_ssp_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_ssp_settings_param_2,
.expect_len = sizeof(set_ssp_settings_param_2),
.expect_param = set_ssp_settings_param_3,
.expect_len = sizeof(set_ssp_settings_param_3),
.expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE,
.expect_hci_param = write_eir_set_dev_id_success_1,
.expect_hci_len = sizeof(write_eir_set_dev_id_success_1),
Expand Down Expand Up @@ -8214,13 +8215,17 @@ static const uint8_t set_ext_adv_data_test1[] = {
0x74, 0x65, 0x73, 0x74, 0x31, /* "test1" */
};

static const char set_powered_ext_adv_instance_settings_param[] = {
0x81, 0x02, 0x40, 0x00,
};

static const struct generic_data add_ext_advertising_success_pwron_data = {
.send_opcode = MGMT_OP_SET_POWERED,
.send_param = set_powered_on_param,
.send_len = sizeof(set_powered_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_powered_adv_instance_settings_param,
.expect_len = sizeof(set_powered_adv_instance_settings_param),
.expect_param = set_powered_ext_adv_instance_settings_param,
.expect_len = sizeof(set_powered_ext_adv_instance_settings_param),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
.expect_hci_param = set_ext_adv_data_test1,
.expect_hci_len = sizeof(set_ext_adv_data_test1),
Expand All @@ -8239,7 +8244,7 @@ static const struct generic_data add_ext_advertising_success_pwron_enabled = {
.send_param = set_powered_on_param,
.send_len = sizeof(set_powered_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_powered_adv_instance_settings_param,
.expect_param = set_powered_ext_adv_instance_settings_param,
.expect_len = sizeof(set_powered_adv_instance_settings_param),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
.expect_hci_param = set_ext_adv_on_set_adv_enable_param,
Expand All @@ -8256,13 +8261,15 @@ static const uint8_t set_ext_adv_data_txpwr[] = {
0x00, /* tx power */
};

static const char set_ext_adv_settings_param[] = { 0x81, 0x06, 0x40, 0x00 };

static const struct generic_data add_ext_advertising_success_4 = {
.send_opcode = MGMT_OP_SET_ADVERTISING,
.send_param = set_adv_on_param,
.send_len = sizeof(set_adv_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_adv_settings_param_2,
.expect_len = sizeof(set_adv_settings_param_2),
.expect_param = set_ext_adv_settings_param,
.expect_len = sizeof(set_ext_adv_settings_param),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
.expect_hci_param = set_ext_adv_data_txpwr,
.expect_hci_len = sizeof(set_ext_adv_data_txpwr),
Expand All @@ -8273,8 +8280,8 @@ static const struct generic_data add_ext_advertising_success_5 = {
.send_param = set_adv_off_param,
.send_len = sizeof(set_adv_off_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_powered_adv_instance_settings_param,
.expect_len = sizeof(set_powered_adv_instance_settings_param),
.expect_param = set_powered_ext_adv_instance_settings_param,
.expect_len = sizeof(set_powered_ext_adv_instance_settings_param),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
.expect_hci_param = set_ext_adv_data_test1,
.expect_hci_len = sizeof(set_ext_adv_data_test1),
Expand Down Expand Up @@ -8545,13 +8552,16 @@ static uint8_t preset_connectable_on_ext_adv_param[] = {
0x00, /* Scan req notification */
};

static const char set_connectable_settings_param_4[] = {
0x83, 0x02, 0x40, 0x00 };

static const struct generic_data add_ext_advertising_success_16 = {
.send_opcode = MGMT_OP_SET_CONNECTABLE,
.send_param = set_connectable_on_param,
.send_len = sizeof(set_connectable_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_connectable_settings_param_3,
.expect_len = sizeof(set_connectable_settings_param_3),
.expect_param = set_connectable_settings_param_4,
.expect_len = sizeof(set_connectable_settings_param_4),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
.expect_hci_param = preset_connectable_on_ext_adv_param,
.expect_hci_len = sizeof(preset_connectable_on_ext_adv_param),
Expand All @@ -8575,25 +8585,29 @@ static uint8_t preset_connectable_off_ext_adv_param[] = {
0x00, /* Scan req notification */
};

static const char set_le_settings_param_3[] = { 0x81, 0x02, 0x40, 0x00 };

static const struct generic_data add_ext_advertising_success_17 = {
.send_opcode = MGMT_OP_SET_CONNECTABLE,
.send_param = set_connectable_off_param,
.send_len = sizeof(set_connectable_off_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_le_settings_param_2,
.expect_len = sizeof(set_le_settings_param_2),
.expect_param = set_le_settings_param_3,
.expect_len = sizeof(set_le_settings_param_3),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
.expect_hci_param = preset_connectable_off_ext_adv_param,
.expect_hci_len = sizeof(preset_connectable_off_ext_adv_param),
};

static const char set_le_settings_param_off_1[] = { 0x81, 0x00, 0x40, 0x00 };

static const struct generic_data add_ext_advertising_le_off = {
.send_opcode = MGMT_OP_SET_LE,
.send_param = set_le_off_param,
.send_len = sizeof(set_le_off_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_le_settings_param_off,
.expect_len = sizeof(set_le_settings_param_off),
.expect_param = set_le_settings_param_off_1,
.expect_len = sizeof(set_le_settings_param_off_1),
.expect_alt_ev = MGMT_EV_ADVERTISING_REMOVED,
.expect_alt_ev_param = advertising_instance1_param,
.expect_alt_ev_len = sizeof(advertising_instance1_param),
Expand Down Expand Up @@ -8875,8 +8889,8 @@ static const struct generic_data multi_ext_advertising_add_no_power = {
.send_param = set_powered_on_param,
.send_len = sizeof(set_powered_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_powered_adv_instance_settings_param,
.expect_len = sizeof(set_powered_adv_instance_settings_param),
.expect_param = set_powered_ext_adv_instance_settings_param,
.expect_len = sizeof(set_powered_ext_adv_instance_settings_param),
.expect_hci_list = multi_ext_adv_add_2_advs_hci_cmds,
};

Expand Down Expand Up @@ -9403,8 +9417,8 @@ static const struct generic_data add_ext_advertising_conn_on_1m = {
.send_param = set_connectable_on_param,
.send_len = sizeof(set_connectable_on_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_connectable_settings_param_3,
.expect_len = sizeof(set_connectable_settings_param_3),
.expect_param = set_connectable_settings_param_4,
.expect_len = sizeof(set_connectable_settings_param_4),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
.expect_hci_param = preset_connectable_on_ext_pdu_adv_param,
.expect_hci_len = sizeof(preset_connectable_on_ext_pdu_adv_param),
Expand Down Expand Up @@ -9463,8 +9477,8 @@ static const struct generic_data add_ext_advertising_conn_off_1m = {
.send_param = set_connectable_off_param,
.send_len = sizeof(set_connectable_off_param),
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_le_settings_param_2,
.expect_len = sizeof(set_le_settings_param_2),
.expect_param = set_le_settings_param_3,
.expect_len = sizeof(set_le_settings_param_3),
.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
.expect_hci_param = preset_connectable_off_ext_1m_adv_param,
.expect_hci_len = sizeof(preset_connectable_off_ext_1m_adv_param),
Expand Down