Skip to content

Commit

Permalink
Bluetooth: RFCOMM: Add a argument server to bt_rfcomm_server.accept
Browse files Browse the repository at this point in the history
In current implementation, the `accept` cannot be identified if the
same one `accept` callback is passed by the upper layer.

Similar with `accept` of `bt_l2cap_server.accept`, add a parameter
`server` to the `bt_rfcomm_server.accept` callback.

Signed-off-by: Lyle Zhu <[email protected]>

Bluetooth: HFP_HF: Add a argument `server` to rfcomm_accept()

Since a new argument `server` is added by `bt_rfcomm_server.accept`,
add a argument `server` to function rfcomm_accept() to avoid building
issue.

Signed-off-by: Lyle Zhu <[email protected]>

Bluetooth: Shell: Add a argument `server` to rfcomm_accept()

Since a new argument `server` is added by `bt_rfcomm_server.accept`,
add a argument `server` to function rfcomm_accept() to avoid building
issue.

Signed-off-by: Lyle Zhu <[email protected]>
  • Loading branch information
lylezhu2012 committed Jan 10, 2025
1 parent a4006e4 commit 38bff67
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/zephyr/bluetooth/classic/rfcomm.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ struct bt_rfcomm_server {
* authorization.
*
* @param conn The connection that is requesting authorization
* @param server Pointer to the server structure this callback relates to
* @param dlc Pointer to received the allocated dlc
*
* @return 0 in case of success or negative value in case of error.
*/
int (*accept)(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc);
int (*accept)(struct bt_conn *conn, struct bt_rfcomm_server *server,
struct bt_rfcomm_dlc **dlc);

struct bt_rfcomm_server *_next;
};
Expand Down
3 changes: 2 additions & 1 deletion subsys/bluetooth/host/classic/hfp_hf.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,8 @@ static void hfp_hf_sent(struct bt_rfcomm_dlc *dlc, int err)
LOG_DBG("DLC %p sent cb (err %d)", dlc, err);
}

static int bt_hfp_hf_accept(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc)
static int bt_hfp_hf_accept(struct bt_conn *conn, struct bt_rfcomm_server *server,
struct bt_rfcomm_dlc **dlc)
{
int i;
static struct bt_rfcomm_dlc_ops ops = {
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/classic/rfcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session
return NULL;
}

if (server->accept(session->br_chan.chan.conn, &dlc) < 0) {
if (server->accept(session->br_chan.chan.conn, server, &dlc) < 0) {
LOG_DBG("Incoming connection rejected");
return NULL;
}
Expand Down
3 changes: 2 additions & 1 deletion subsys/bluetooth/host/classic/shell/rfcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ static struct bt_rfcomm_dlc rfcomm_dlc = {
.mtu = 30,
};

static int rfcomm_accept(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc)
static int rfcomm_accept(struct bt_conn *conn, struct bt_rfcomm_server *server,
struct bt_rfcomm_dlc **dlc)
{
shell_print(ctx_shell, "Incoming RFCOMM conn %p", conn);

Expand Down

0 comments on commit 38bff67

Please sign in to comment.