Skip to content

Commit 67e01df

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Shell: BR: Find HFP_HF records on HFP_AG side
Add a option `HFPHF` to find HFP HF SDP records from HFP AG side. Add a SDP records discovery parameter `discov_hfphf` for this option. Add a function `sdp_hfp_hf_user` to handle the discovery result. Signed-off-by: Lyle Zhu <[email protected]>
1 parent eba356d commit 67e01df

File tree

1 file changed

+62
-1
lines changed
  • subsys/bluetooth/host/classic/shell

1 file changed

+62
-1
lines changed

subsys/bluetooth/host/classic/shell/bredr.c

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,58 @@ static uint8_t sdp_hfp_ag_user(struct bt_conn *conn, struct bt_sdp_client_result
753753
return BT_SDP_DISCOVER_UUID_CONTINUE;
754754
}
755755

756+
static uint8_t sdp_hfp_hf_user(struct bt_conn *conn,
757+
struct bt_sdp_client_result *result,
758+
const struct bt_sdp_discover_params *params)
759+
{
760+
char addr[BT_ADDR_STR_LEN];
761+
uint16_t param, version;
762+
uint16_t features;
763+
int err;
764+
765+
conn_addr_str(conn, addr, sizeof(addr));
766+
767+
if (result && result->resp_buf) {
768+
bt_shell_print("SDP HFPHF data@%p (len %u) hint %u from remote %s",
769+
result->resp_buf, result->resp_buf->len, result->next_record_hint,
770+
addr);
771+
772+
/*
773+
* Focus to get BT_SDP_ATTR_PROTO_DESC_LIST attribute item to
774+
* get HFPHF Server Channel Number operating on RFCOMM protocol.
775+
*/
776+
err = bt_sdp_get_proto_param(result->resp_buf, BT_SDP_PROTO_RFCOMM, &param);
777+
if (err < 0) {
778+
bt_shell_error("Error getting Server CN, err %d", err);
779+
goto done;
780+
}
781+
bt_shell_print("HFPHF Server CN param 0x%04x", param);
782+
783+
err = bt_sdp_get_profile_version(result->resp_buf, BT_SDP_HANDSFREE_SVCLASS,
784+
&version);
785+
if (err < 0) {
786+
bt_shell_error("Error getting profile version, err %d", err);
787+
goto done;
788+
}
789+
bt_shell_print("HFP version param 0x%04x", version);
790+
791+
/*
792+
* Focus to get BT_SDP_ATTR_SUPPORTED_FEATURES attribute item to
793+
* get profile Supported Features mask.
794+
*/
795+
err = bt_sdp_get_features(result->resp_buf, &features);
796+
if (err < 0) {
797+
bt_shell_error("Error getting HFPHF Features, err %d", err);
798+
goto done;
799+
}
800+
bt_shell_print("HFPHF Supported Features param 0x%04x", features);
801+
} else {
802+
bt_shell_print("No SDP HFPHF data from remote %s", addr);
803+
}
804+
done:
805+
return BT_SDP_DISCOVER_UUID_CONTINUE;
806+
}
807+
756808
static uint8_t sdp_a2src_user(struct bt_conn *conn, struct bt_sdp_client_result *result,
757809
const struct bt_sdp_discover_params *params)
758810
{
@@ -816,6 +868,13 @@ static struct bt_sdp_discover_params discov_hfpag = {
816868
.pool = &sdp_client_pool,
817869
};
818870

871+
static struct bt_sdp_discover_params discov_hfphf = {
872+
.type = BT_SDP_DISCOVER_SERVICE_SEARCH_ATTR,
873+
.uuid = BT_UUID_DECLARE_16(BT_SDP_HANDSFREE_SVCLASS),
874+
.func = sdp_hfp_hf_user,
875+
.pool = &sdp_client_pool,
876+
};
877+
819878
static struct bt_sdp_discover_params discov_a2src = {
820879
.type = BT_SDP_DISCOVER_SERVICE_SEARCH_ATTR,
821880
.uuid = BT_UUID_DECLARE_16(BT_SDP_AUDIO_SOURCE_SVCLASS),
@@ -839,6 +898,8 @@ static int cmd_sdp_find_record(const struct shell *sh, size_t argc, char *argv[]
839898

840899
if (!strcmp(action, "HFPAG")) {
841900
discov = discov_hfpag;
901+
} else if (!strcmp(action, "HFPHF")) {
902+
discov = discov_hfphf;
842903
} else if (!strcmp(action, "A2SRC")) {
843904
discov = discov_a2src;
844905
} else {
@@ -963,7 +1024,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(br_cmds,
9631024
SHELL_CMD(l2cap, &l2cap_cmds, HELP_NONE, cmd_default_handler),
9641025
SHELL_CMD_ARG(oob, NULL, NULL, cmd_oob, 1, 0),
9651026
SHELL_CMD_ARG(pscan, NULL, "<value: on, off>", cmd_connectable, 2, 0),
966-
SHELL_CMD_ARG(sdp-find, NULL, "<HFPAG>", cmd_sdp_find_record, 2, 0),
1027+
SHELL_CMD_ARG(sdp-find, NULL, "<HFPAG, HFPHF>", cmd_sdp_find_record, 2, 0),
9671028
SHELL_SUBCMD_SET_END
9681029
);
9691030

0 commit comments

Comments
 (0)