Skip to content

Commit

Permalink
tests: Bluetooth: has: Add test Preset Changed Offline Behavior
Browse files Browse the repository at this point in the history
Verify that a HAS Server IUT sends changed characteristic notifications
or indications when the Lower Tester reconnects.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
  • Loading branch information
MariuszSkamra committed Aug 31, 2023
1 parent b9b0e5b commit cfd265c
Show file tree
Hide file tree
Showing 7 changed files with 516 additions and 10 deletions.
1 change: 1 addition & 0 deletions subsys/bluetooth/audio/has_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct bt_has_cp_read_preset_rsp {
struct bt_has_cp_preset_changed {
uint8_t change_id;
uint8_t is_last;
uint8_t additional_params[0];
} __packed;

struct bt_has_cp_generic_update {
Expand Down
1 change: 1 addition & 0 deletions tests/bsim/bluetooth/audio/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ CONFIG_BT_BAP_BROADCAST_ASSISTANT=y

# Hearing Access
CONFIG_BT_HAS=y
CONFIG_BT_HAS_PRESET_COUNT=3
CONFIG_BT_HAS_CLIENT=y
CONFIG_BT_HAS_FEATURES_NOTIFIABLE=y

Expand Down
12 changes: 12 additions & 0 deletions tests/bsim/bluetooth/audio/src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern enum bst_result_t bst_result;
struct bt_conn *default_conn;
atomic_t flag_connected;
atomic_t flag_conn_updated;
bt_security_t security_level;

const struct bt_data ad[AD_SIZE] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR))
Expand Down Expand Up @@ -91,6 +92,7 @@ void disconnected(struct bt_conn *conn, uint8_t reason)
default_conn = NULL;
UNSET_FLAG(flag_connected);
UNSET_FLAG(flag_conn_updated);
security_level = BT_SECURITY_L1;
}

static void conn_param_updated_cb(struct bt_conn *conn, uint16_t interval, uint16_t latency,
Expand All @@ -102,10 +104,20 @@ static void conn_param_updated_cb(struct bt_conn *conn, uint16_t interval, uint1
SET_FLAG(flag_conn_updated);
}

static void security_changed_cb(struct bt_conn *conn, bt_security_t level, enum bt_security_err err)
{
printk("Security changed: %p level %d err %d\n", conn, level, err);

if (err == BT_SECURITY_ERR_SUCCESS) {
security_level = level;
}
}

BT_CONN_CB_DEFINE(conn_callbacks) = {
.connected = connected,
.disconnected = disconnected,
.le_param_updated = conn_param_updated_cb,
.security_changed = security_changed_cb,
};

void test_tick(bs_time_t HW_device_time)
Expand Down
1 change: 1 addition & 0 deletions tests/bsim/bluetooth/audio/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ extern const struct bt_data ad[AD_SIZE];
extern struct bt_conn *default_conn;
extern atomic_t flag_connected;
extern atomic_t flag_conn_updated;
extern bt_security_t security_level;

void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
struct net_buf_simple *ad);
Expand Down
Loading

0 comments on commit cfd265c

Please sign in to comment.