tests: bluetooth: Expand TBS testing
Add more server side tests Add more client side tests Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
This commit is contained in:
parent
6fd7b3bac6
commit
89751f31c9
4 changed files with 659 additions and 40 deletions
|
@ -66,6 +66,9 @@ CONFIG_BT_CSIP_SET_COORDINATOR_TEST_SAMPLE_DATA=y
|
||||||
# Telephone bearer service
|
# Telephone bearer service
|
||||||
CONFIG_BT_TBS=y
|
CONFIG_BT_TBS=y
|
||||||
CONFIG_BT_TBS_CLIENT=y
|
CONFIG_BT_TBS_CLIENT=y
|
||||||
|
CONFIG_BT_TBS_CLIENT_MAX_CALLS=4
|
||||||
|
CONFIG_BT_TBS_MAX_CALLS=4
|
||||||
|
CONFIG_BT_TBS_SUPPORTED_FEATURES=3
|
||||||
|
|
||||||
# Media control
|
# Media control
|
||||||
CONFIG_MCTL=y
|
CONFIG_MCTL=y
|
||||||
|
|
|
@ -11,17 +11,32 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
static struct bt_conn_cb conn_callbacks;
|
||||||
extern enum bst_result_t bst_result;
|
extern enum bst_result_t bst_result;
|
||||||
static volatile bool bt_init;
|
|
||||||
static volatile bool discovery_complete;
|
|
||||||
static volatile bool is_gtbs_found;
|
|
||||||
static volatile bool read_complete;
|
|
||||||
static volatile bool call_placed;
|
|
||||||
static volatile uint8_t call_state;
|
static volatile uint8_t call_state;
|
||||||
static volatile uint8_t call_index;
|
static volatile uint8_t call_index;
|
||||||
static volatile uint8_t tbs_count;
|
static volatile uint8_t tbs_count;
|
||||||
|
|
||||||
|
CREATE_FLAG(bt_init);
|
||||||
|
CREATE_FLAG(is_connected);
|
||||||
|
CREATE_FLAG(discovery_complete);
|
||||||
|
CREATE_FLAG(is_gtbs_found);
|
||||||
|
CREATE_FLAG(read_complete);
|
||||||
|
CREATE_FLAG(call_placed);
|
||||||
|
CREATE_FLAG(call_terminated);
|
||||||
|
CREATE_FLAG(provider_name);
|
||||||
CREATE_FLAG(ccid_read_flag);
|
CREATE_FLAG(ccid_read_flag);
|
||||||
|
CREATE_FLAG(signal_strength);
|
||||||
|
CREATE_FLAG(technology);
|
||||||
|
CREATE_FLAG(status_flags);
|
||||||
|
CREATE_FLAG(signal_interval);
|
||||||
|
CREATE_FLAG(call_accepted);
|
||||||
|
CREATE_FLAG(bearer_uci);
|
||||||
|
CREATE_FLAG(uri_list);
|
||||||
|
CREATE_FLAG(current_calls);
|
||||||
|
CREATE_FLAG(uri_inc);
|
||||||
|
CREATE_FLAG(term_reason);
|
||||||
|
|
||||||
static void tbs_client_call_states_cb(struct bt_conn *conn, int err,
|
static void tbs_client_call_states_cb(struct bt_conn *conn, int err,
|
||||||
uint8_t index, uint8_t call_count,
|
uint8_t index, uint8_t call_count,
|
||||||
|
@ -31,8 +46,7 @@ static void tbs_client_call_states_cb(struct bt_conn *conn, int err,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printk("%s\n", __func__);
|
printk("Index %u\n", __func__, index);
|
||||||
printk("Index %u\n", index);
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
FAIL("Call could not read call states (%d)\n", err);
|
FAIL("Call could not read call states (%d)\n", err);
|
||||||
return;
|
return;
|
||||||
|
@ -56,12 +70,14 @@ static void tbs_client_read_bearer_provider_name(struct bt_conn *conn, int err,
|
||||||
printk("Bearer name pointer: %p\n", value);
|
printk("Bearer name pointer: %p\n", value);
|
||||||
printk("Bearer name: %s\n", value);
|
printk("Bearer name: %s\n", value);
|
||||||
read_complete = true;
|
read_complete = true;
|
||||||
|
SET_FLAG(provider_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tbs_client_discover_cb(struct bt_conn *conn, int err,
|
static void tbs_client_discover_cb(struct bt_conn *conn, int err,
|
||||||
uint8_t count, bool gtbs_found)
|
uint8_t count, bool gtbs_found)
|
||||||
{
|
{
|
||||||
printk("%s\n", __func__);
|
printk("%s\n", __func__);
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
FAIL("TBS_CLIENT could not be discovered (%d)\n", err);
|
FAIL("TBS_CLIENT could not be discovered (%d)\n", err);
|
||||||
return;
|
return;
|
||||||
|
@ -93,27 +109,233 @@ static void tbs_client_read_ccid_cb(struct bt_conn *conn, int err,
|
||||||
SET_FLAG(ccid_read_flag);
|
SET_FLAG(ccid_read_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tbs_client_originate_call_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint8_t call_index)
|
||||||
|
{
|
||||||
|
printk("%s %u:\n", __func__, call_index);
|
||||||
|
call_placed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_hold_call_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint8_t call_index)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Client hold call error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Call index: %u\n", __func__, inst_index,
|
||||||
|
call_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_retrieve_call_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint8_t call_index)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Client retrieve call error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Call index: %u\n", __func__, inst_index,
|
||||||
|
call_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_technology_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint32_t value)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Client bearer technology error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Technology: %u\n", __func__, inst_index,
|
||||||
|
technology);
|
||||||
|
|
||||||
|
SET_FLAG(technology);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_signal_strength_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint32_t value)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Client signal strength error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u, Strength: %u\n", __func__, inst_index,
|
||||||
|
signal_strength);
|
||||||
|
|
||||||
|
SET_FLAG(signal_strength);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_signal_interval_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint32_t value)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Client signal interval error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Interval: %u\n", __func__, inst_index, value);
|
||||||
|
|
||||||
|
SET_FLAG(signal_interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_status_flags_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint32_t value)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Status flags error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Flags: %u\n", __func__, inst_index,
|
||||||
|
status_flags);
|
||||||
|
|
||||||
|
SET_FLAG(status_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_terminate_call_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index, uint8_t call_index)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Terminate call error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Call index: %u\n", __func__, inst_index,
|
||||||
|
call_index);
|
||||||
|
|
||||||
|
SET_FLAG(call_terminated);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_accept_call_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index, uint8_t call_index)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Accept call error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Call index: %u\n", __func__, inst_index,
|
||||||
|
call_index);
|
||||||
|
|
||||||
|
SET_FLAG(call_accepted);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_bearer_uci_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
const char *value)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Bearer UCI error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u UCI: %u\n", __func__, inst_index, value);
|
||||||
|
|
||||||
|
SET_FLAG(bearer_uci);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_uri_list_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index, const char *value)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("URI list error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u URI list: %u\n", __func__, inst_index,
|
||||||
|
uri_list);
|
||||||
|
|
||||||
|
SET_FLAG(uri_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_current_calls_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
uint8_t call_count,
|
||||||
|
const struct bt_tbs_client_call *calls)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Current calls error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s Instance: %u Call count: %u\n", __func__, inst_index,
|
||||||
|
call_count);
|
||||||
|
|
||||||
|
SET_FLAG(current_calls);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_call_uri_cb(struct bt_conn *conn, int err,
|
||||||
|
uint8_t inst_index,
|
||||||
|
const char *value)
|
||||||
|
{
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Incoming URI error: (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Incoming URI callback\n");
|
||||||
|
printk("%s Instance: %u URI: %u\n", __func__, inst_index, value);
|
||||||
|
|
||||||
|
SET_FLAG(uri_inc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_client_term_reason_cb(struct bt_conn *conn,
|
||||||
|
int err, uint8_t inst_index,
|
||||||
|
uint8_t call_index,
|
||||||
|
uint8_t reason)
|
||||||
|
{
|
||||||
|
printk("%s Instance: %u Reason: %u\n", __func__, inst_index, reason);
|
||||||
|
|
||||||
|
SET_FLAG(term_reason);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct bt_tbs_client_cb tbs_client_cbs = {
|
static const struct bt_tbs_client_cb tbs_client_cbs = {
|
||||||
.discover = tbs_client_discover_cb,
|
.discover = tbs_client_discover_cb,
|
||||||
.originate_call = NULL,
|
.originate_call = tbs_client_originate_call_cb,
|
||||||
.terminate_call = NULL,
|
.terminate_call = tbs_client_terminate_call_cb,
|
||||||
.hold_call = NULL,
|
.hold_call = tbs_client_hold_call_cb,
|
||||||
.accept_call = NULL,
|
.accept_call = tbs_client_accept_call_cb,
|
||||||
.retrieve_call = NULL,
|
.retrieve_call = tbs_client_retrieve_call_cb,
|
||||||
.bearer_provider_name = tbs_client_read_bearer_provider_name,
|
.bearer_provider_name = tbs_client_read_bearer_provider_name,
|
||||||
.bearer_uci = NULL,
|
.bearer_uci = tbs_client_bearer_uci_cb,
|
||||||
.technology = NULL,
|
.technology = tbs_client_technology_cb,
|
||||||
.uri_list = NULL,
|
.uri_list = tbs_client_uri_list_cb,
|
||||||
.signal_strength = NULL,
|
.signal_strength = tbs_client_signal_strength_cb,
|
||||||
.signal_interval = NULL,
|
.signal_interval = tbs_client_signal_interval_cb,
|
||||||
.current_calls = NULL,
|
.current_calls = tbs_client_current_calls_cb,
|
||||||
.ccid = tbs_client_read_ccid_cb,
|
.ccid = tbs_client_read_ccid_cb,
|
||||||
.status_flags = NULL,
|
.status_flags = tbs_client_status_flags_cb,
|
||||||
.call_uri = NULL,
|
.call_uri = tbs_client_call_uri_cb,
|
||||||
.call_state = tbs_client_call_states_cb,
|
.call_state = tbs_client_call_states_cb,
|
||||||
.termination_reason = NULL
|
.termination_reason = tbs_client_term_reason_cb
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void connected(struct bt_conn *conn, uint8_t err)
|
||||||
|
{
|
||||||
|
char addr[BT_ADDR_LE_STR_LEN];
|
||||||
|
|
||||||
|
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
|
||||||
|
|
||||||
|
if (err != 0) {
|
||||||
|
bt_conn_unref(default_conn);
|
||||||
|
FAIL("Failed to connect to %s (%u)\n", addr, err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Connected to %s\n", addr);
|
||||||
|
is_connected = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void bt_ready(int err)
|
static void bt_ready(int err)
|
||||||
{
|
{
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
|
@ -124,6 +346,11 @@ static void bt_ready(int err)
|
||||||
bt_init = true;
|
bt_init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct bt_conn_cb conn_callbacks = {
|
||||||
|
.connected = connected,
|
||||||
|
.disconnected = disconnected,
|
||||||
|
};
|
||||||
|
|
||||||
static void test_ccid(void)
|
static void test_ccid(void)
|
||||||
{
|
{
|
||||||
if (is_gtbs_found) {
|
if (is_gtbs_found) {
|
||||||
|
@ -157,6 +384,82 @@ static void test_ccid(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_signal_strength(uint8_t index)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
UNSET_FLAG(signal_strength);
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
|
||||||
|
err = bt_tbs_client_read_signal_strength(default_conn, index);
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Read signal strength failed (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WAIT_FOR_FLAG(signal_strength);
|
||||||
|
|
||||||
|
printk("Client read signal strength test success\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_technology(uint8_t index)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
UNSET_FLAG(technology);
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
|
||||||
|
err = bt_tbs_client_read_technology(default_conn, index);
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Read technology failed (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WAIT_FOR_FLAG(technology);
|
||||||
|
|
||||||
|
printk("Client read technology test success\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_status_flags(uint8_t index)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
UNSET_FLAG(status_flags);
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
|
||||||
|
err = bt_tbs_client_read_status_flags(default_conn, index);
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Read status flags failed (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WAIT_FOR_FLAG(status_flags);
|
||||||
|
|
||||||
|
printk("Client read status flags test success\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_signal_interval(uint8_t index)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
UNSET_FLAG(signal_interval);
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
|
||||||
|
err = bt_tbs_client_read_signal_interval(default_conn, index);
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Read signal interval failed (%d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WAIT_FOR_FLAG(signal_interval);
|
||||||
|
|
||||||
|
printk("Client signal interval test success\n");
|
||||||
|
}
|
||||||
|
|
||||||
static void test_main(void)
|
static void test_main(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
@ -170,6 +473,7 @@ static void test_main(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bt_conn_cb_register(&conn_callbacks);
|
||||||
bt_tbs_client_register_cb(&tbs_client_cbs);
|
bt_tbs_client_register_cb(&tbs_client_cbs);
|
||||||
|
|
||||||
WAIT_FOR_COND(bt_init);
|
WAIT_FOR_COND(bt_init);
|
||||||
|
@ -184,7 +488,7 @@ static void test_main(void)
|
||||||
|
|
||||||
printk("Advertising successfully started\n");
|
printk("Advertising successfully started\n");
|
||||||
|
|
||||||
WAIT_FOR_COND(flag_connected);
|
WAIT_FOR_COND(is_connected);
|
||||||
|
|
||||||
tbs_client_err = bt_tbs_client_discover(default_conn, true);
|
tbs_client_err = bt_tbs_client_discover(default_conn, true);
|
||||||
if (tbs_client_err) {
|
if (tbs_client_err) {
|
||||||
|
@ -231,14 +535,20 @@ static void test_main(void)
|
||||||
WAIT_FOR_COND(call_state == BT_TBS_CALL_STATE_ACTIVE);
|
WAIT_FOR_COND(call_state == BT_TBS_CALL_STATE_ACTIVE);
|
||||||
|
|
||||||
printk("Reading bearer provider name\n");
|
printk("Reading bearer provider name\n");
|
||||||
|
UNSET_FLAG(provider_name);
|
||||||
err = bt_tbs_client_read_bearer_provider_name(default_conn, index);
|
err = bt_tbs_client_read_bearer_provider_name(default_conn, index);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
FAIL("Read bearer provider name failed (%d)\n", err);
|
FAIL("Read bearer provider name failed (%d)\n", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
test_ccid();
|
test_ccid();
|
||||||
|
|
||||||
WAIT_FOR_COND(read_complete);
|
WAIT_FOR_COND(read_complete);
|
||||||
|
|
||||||
|
test_signal_strength(index);
|
||||||
|
test_technology(index);
|
||||||
|
test_status_flags(index);
|
||||||
|
test_signal_interval(index);
|
||||||
|
|
||||||
PASS("TBS_CLIENT Passed\n");
|
PASS("TBS_CLIENT Passed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +568,6 @@ struct bst_test_list *test_tbs_client_install(struct bst_test_list *tests)
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
struct bst_test_list *test_tbs_client_install(struct bst_test_list *tests)
|
struct bst_test_list *test_tbs_client_install(struct bst_test_list *tests)
|
||||||
{
|
{
|
||||||
return tests;
|
return tests;
|
||||||
|
|
|
@ -10,24 +10,31 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
extern enum bst_result_t bst_result;
|
extern enum bst_result_t bst_result;
|
||||||
static volatile bool call_placed;
|
static uint8_t call_index;
|
||||||
static volatile bool call_held;
|
static volatile uint8_t call_state;
|
||||||
static volatile bool call_id;
|
|
||||||
|
CREATE_FLAG(is_connected);
|
||||||
|
CREATE_FLAG(call_placed);
|
||||||
|
CREATE_FLAG(call_held);
|
||||||
|
CREATE_FLAG(call_id);
|
||||||
|
CREATE_FLAG(call_terminated);
|
||||||
|
CREATE_FLAG(call_accepted);
|
||||||
|
CREATE_FLAG(call_retrieved);
|
||||||
|
CREATE_FLAG(call_joined);
|
||||||
|
|
||||||
static void tbs_hold_call_cb(struct bt_conn *conn, uint8_t call_index)
|
static void tbs_hold_call_cb(struct bt_conn *conn, uint8_t call_index)
|
||||||
{
|
{
|
||||||
if (call_index == call_id) {
|
if (call_index == call_id) {
|
||||||
call_held = true;
|
SET_FLAG(call_held);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tbs_originate_call_cb(struct bt_conn *conn, uint8_t call_index,
|
static bool tbs_originate_call_cb(struct bt_conn *conn, uint8_t call_index,
|
||||||
const char *caller_id)
|
const char *caller_id)
|
||||||
{
|
{
|
||||||
printk("Placing call to remote with id %u to %s\n",
|
printk("Placing call to remote with id %u to %s\n", call_index, caller_id);
|
||||||
call_index, caller_id);
|
|
||||||
call_id = call_index;
|
call_id = call_index;
|
||||||
call_placed = true;
|
SET_FLAG(call_placed);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,16 +43,281 @@ static bool tbs_authorize_cb(struct bt_conn *conn)
|
||||||
return conn == default_conn;
|
return conn == default_conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tbs_terminate_call_cb(struct bt_conn *conn, uint8_t call_index,
|
||||||
|
uint8_t reason)
|
||||||
|
{
|
||||||
|
printk("Terminating call with id %u reason: %u", call_index, reason);
|
||||||
|
SET_FLAG(call_terminated);
|
||||||
|
UNSET_FLAG(call_placed);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_accept_call_cb(struct bt_conn *conn, uint8_t call_index)
|
||||||
|
{
|
||||||
|
printk("Accepting call with index %u\n", call_index);
|
||||||
|
SET_FLAG(call_accepted);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_retrieve_call_cb(struct bt_conn *conn, uint8_t call_index)
|
||||||
|
{
|
||||||
|
printk("Retrieve call with index %u\n", call_index);
|
||||||
|
SET_FLAG(call_retrieved);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_join_calls_cb(struct bt_conn *conn,
|
||||||
|
uint8_t call_index_count,
|
||||||
|
const uint8_t *call_indexes)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < sizeof(call_indexes); i++) {
|
||||||
|
printk("Call index: %u joined\n", call_indexes[i]);
|
||||||
|
}
|
||||||
|
SET_FLAG(call_joined);
|
||||||
|
}
|
||||||
|
|
||||||
static struct bt_tbs_cb tbs_cbs = {
|
static struct bt_tbs_cb tbs_cbs = {
|
||||||
.originate_call = tbs_originate_call_cb,
|
.originate_call = tbs_originate_call_cb,
|
||||||
.terminate_call = NULL,
|
.terminate_call = tbs_terminate_call_cb,
|
||||||
.hold_call = tbs_hold_call_cb,
|
.hold_call = tbs_hold_call_cb,
|
||||||
.accept_call = NULL,
|
.accept_call = tbs_accept_call_cb,
|
||||||
.retrieve_call = NULL,
|
.retrieve_call = tbs_retrieve_call_cb,
|
||||||
.join_calls = NULL,
|
.join_calls = tbs_join_calls_cb,
|
||||||
.authorize = tbs_authorize_cb,
|
.authorize = tbs_authorize_cb,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void connected(struct bt_conn *conn, uint8_t err)
|
||||||
|
{
|
||||||
|
char addr[BT_ADDR_LE_STR_LEN];
|
||||||
|
|
||||||
|
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
|
||||||
|
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Failed to connect to %s (%u)\n", addr, err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Connected to %s\n", addr);
|
||||||
|
|
||||||
|
default_conn = bt_conn_ref(conn);
|
||||||
|
SET_FLAG(is_connected);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct bt_conn_cb conn_callbacks = {
|
||||||
|
.connected = connected,
|
||||||
|
.disconnected = disconnected,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int test_provider_name(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
err = bt_tbs_set_bearer_provider_name(0, "BabblesimTBS");
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not set bearer provider name: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Set bearer provider name test success\n");
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_set_signal_strength(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
err = bt_tbs_set_signal_strength(0, 6);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not set bearer provider name: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Set signal strength test success\n");
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_set_bearer_technology(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
err = bt_tbs_set_bearer_technology(0, BT_TBS_TECHNOLOGY_GSM);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not set bearer technology: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Set bearer technology test success\n");
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_set_status_flags(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
err = bt_tbs_set_status_flags(0, 3);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not set status flags: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Set status flags test success\n");
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_answer_terminate(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
printk("Placing call\n");
|
||||||
|
err = bt_tbs_originate(0, "tel:000000000001", &call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not originate call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Answering call\n");
|
||||||
|
err = bt_tbs_remote_answer(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not accept call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Terminating call\n");
|
||||||
|
err = bt_tbs_terminate(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not terminate call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Test answer & terminate successful\n");
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_hold_retrieve(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
err = bt_tbs_originate(0, "tel:000000000001", &call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not originate call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bt_tbs_remote_answer(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not accept call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Holding call\n");
|
||||||
|
err = bt_tbs_hold(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not terminate call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Retrieving call\n");
|
||||||
|
err = bt_tbs_retrieve(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not retrieve call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Terminating call\n");
|
||||||
|
err = bt_tbs_terminate(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not terminate call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Hold & retrieve test sucessfull\n");
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_join(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
uint8_t call_indexes[2];
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
printk("Placing first call\n");
|
||||||
|
err = bt_tbs_originate(0, "tel:000000000001", &call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not originate first call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Answering first call\n");
|
||||||
|
err = bt_tbs_remote_answer(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not answer first call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
printk("First call answered\n");
|
||||||
|
|
||||||
|
call_indexes[0] = (uint8_t)call_index;
|
||||||
|
|
||||||
|
printk("Placing second call\n");
|
||||||
|
err = bt_tbs_originate(0, "tel:000000000002", &call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not originate second call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Answering second call\n");
|
||||||
|
err = bt_tbs_remote_answer(call_index);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not answer second call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
printk("Second call answered\n");
|
||||||
|
|
||||||
|
call_indexes[1] = (uint8_t)call_index;
|
||||||
|
|
||||||
|
printk("Joining calls\n");
|
||||||
|
err = bt_tbs_join(2, call_indexes);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not join calls: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bt_tbs_terminate(call_indexes[0]);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not terminate first call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bt_tbs_terminate(call_indexes[1]);
|
||||||
|
if (err != BT_TBS_RESULT_CODE_SUCCESS) {
|
||||||
|
FAIL("Could not terminate second call: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("Join calls test succesfull\n");
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_tbs_server_only(void)
|
||||||
|
{
|
||||||
|
test_answer_terminate();
|
||||||
|
test_hold_retrieve();
|
||||||
|
test_join();
|
||||||
|
test_provider_name();
|
||||||
|
test_set_signal_strength();
|
||||||
|
test_set_bearer_technology();
|
||||||
|
test_set_status_flags();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_main(void)
|
static void test_main(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
@ -58,6 +330,7 @@ static void test_main(void)
|
||||||
|
|
||||||
printk("Audio Client: Bluetooth initialized\n");
|
printk("Audio Client: Bluetooth initialized\n");
|
||||||
|
|
||||||
|
bt_conn_cb_register(&conn_callbacks);
|
||||||
bt_tbs_register_cb(&tbs_cbs);
|
bt_tbs_register_cb(&tbs_cbs);
|
||||||
|
|
||||||
err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, device_found);
|
err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, device_found);
|
||||||
|
@ -68,7 +341,7 @@ static void test_main(void)
|
||||||
|
|
||||||
printk("Scanning successfully started\n");
|
printk("Scanning successfully started\n");
|
||||||
|
|
||||||
WAIT_FOR_FLAG(flag_connected);
|
WAIT_FOR_COND(is_connected);
|
||||||
|
|
||||||
WAIT_FOR_COND(call_placed);
|
WAIT_FOR_COND(call_placed);
|
||||||
|
|
||||||
|
@ -94,10 +367,32 @@ static void test_main(void)
|
||||||
}
|
}
|
||||||
printk("Remote retrieved %u\n", call_id);
|
printk("Remote retrieved %u\n", call_id);
|
||||||
|
|
||||||
PASS("TBS passed\n");
|
PASS("TBS Passed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tbs_test_server_only(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = bt_enable(NULL);
|
||||||
|
|
||||||
|
if (err != 0) {
|
||||||
|
FAIL("Bluetooth init failed (err %d)\n", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
test_tbs_server_only();
|
||||||
|
|
||||||
|
PASS("TBS server tests passed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct bst_test_instance test_tbs[] = {
|
static const struct bst_test_instance test_tbs[] = {
|
||||||
|
{
|
||||||
|
.test_id = "tbs_test_server_only",
|
||||||
|
.test_post_init_f = test_init,
|
||||||
|
.test_tick_f = test_tick,
|
||||||
|
.test_main_f = tbs_test_server_only
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.test_id = "tbs",
|
.test_id = "tbs",
|
||||||
.test_post_init_f = test_init,
|
.test_post_init_f = test_init,
|
||||||
|
|
|
@ -5,15 +5,27 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
SIMULATION_ID="tbs_ccp"
|
|
||||||
VERBOSITY_LEVEL=2
|
|
||||||
|
|
||||||
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
|
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
|
||||||
|
|
||||||
|
SIMULATION_ID="tbs_ccp"
|
||||||
|
VERBOSITY_LEVEL=2
|
||||||
EXECUTE_TIMEOUT=20
|
EXECUTE_TIMEOUT=20
|
||||||
|
|
||||||
cd ${BSIM_OUT_PATH}/bin
|
cd ${BSIM_OUT_PATH}/bin
|
||||||
|
|
||||||
|
printf "\n\n==== Running TBS Server Only (API) test ====n\n"
|
||||||
|
|
||||||
|
Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \
|
||||||
|
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=tbs_test_server_only -rs=23
|
||||||
|
|
||||||
|
# Simulation time should be larger than the WAIT_TIME in common.h
|
||||||
|
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
|
||||||
|
-D=1 -sim_length=60e6 $@
|
||||||
|
|
||||||
|
wait_for_background_jobs
|
||||||
|
|
||||||
|
printf "\n\n==== Running TBS server & client tests ====n\n"
|
||||||
|
|
||||||
Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \
|
Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \
|
||||||
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=tbs -rs=23
|
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=tbs -rs=23
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue