-
Notifications
You must be signed in to change notification settings - Fork 8k
Bluetooth: Classic: GOEP: Support multiple OBEX sessions #95057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluetooth: Classic: GOEP: Support multiple OBEX sessions #95057
Conversation
067dc9d
to
ce37142
Compare
subsys/bluetooth/host/classic/obex.c
Outdated
break; | ||
case BT_UUID_SIZE_32: | ||
uuid->uuid.type = BT_UUID_TYPE_32; | ||
uuid->u32.val = sys_get_be16(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sys_get_be32(data);?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
b6618ee
to
fe5c811
Compare
* Before returning the callback, @ref bt_goep::transport_ops should be initialized with | ||
* valid address of type @ref bt_goep_transport_ops object. The field `mtu` of | ||
* @ref bt_obex::rx could be passed with valid value. Or set it to zero, the mtu will be | ||
* calculated according to @kconfig{CONFIG_BT_GOEP_L2CAP_MTU}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIG_BT_GOEP_RFCOMM_MTU
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
/** The OBEX packet header length for PUT and GET request and response. */ | ||
#define BT_OBEX_HDR_LEN 3 | ||
|
||
/** The max PDU data length of OBEX pachet. */ | ||
#define BT_OBEX_PDU_LEN(mopl) ((mopl) - BT_OBEX_HDR_LEN) | ||
|
||
/** The header length of the OBEX header body/end body. */ | ||
#define BT_OBEX_HDR_LEN_OF_HEADER_BODY 3 | ||
|
||
/** The max remaining length of the buffer if the adding header is body/end body. | ||
* | ||
* It is used to calculate the max sending length when adding the header body data. | ||
* @code{.c} | ||
* uint16_t len = BT_OBEX_PDU_LEN(mopl); | ||
* | ||
* len = MIN(len - buf->len, net_buf_tailroom(buf)); | ||
* if (len > BT_OBEX_HDR_LEN_OF_HEADER_BODY) { | ||
* len = BT_OBEX_DATA_LEN_OF_HEADER_BODY(len); | ||
* Calling bt_obex_add_header_body() or bt_obex_add_header_end_body() | ||
* ... | ||
* } | ||
* @endcode | ||
* | ||
* @param len The max remaining length. | ||
*/ | ||
#define BT_OBEX_DATA_LEN_OF_HEADER_BODY(len) ((len) - BT_OBEX_HDR_LEN_OF_HEADER_BODY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the usage of the MACROs in shell\bip.c of #95534 I think it is not easy-to-use by users. I suggest to pass mopl
and size_t *add_len
to add_header
APIs, then the API only put as much data as possible to net buf and return the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is created here b15aeec
} | ||
|
||
if (!obex->server_ops->connect) { | ||
if (server->ops->connect == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (server->ops->connect == NULL) { | |
if (server->ops == NULL || server->ops->connect == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not needed. The server->ops
has been checked in bt_obex_server_register().
} | ||
|
||
if (!obex->server_ops->disconnect) { | ||
if (server->ops->disconnect == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
|
||
if (!obex->server_ops->put) { | ||
if (server->ops->put == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
|
||
if (!obex->server_ops->get) { | ||
if (server->ops->get == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
|
||
if (!obex->server_ops->setpath) { | ||
if (server->ops->setpath == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
|
||
if (!obex->server_ops->action) { | ||
if (server->ops->action == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
|
||
if (!obex->server_ops->abort) { | ||
if (server->ops->abort == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
|
||
int bt_obex_connect(struct bt_obex *obex, uint16_t mopl, struct net_buf *buf) | ||
int bt_obex_server_register(struct bt_obex_server *server, const struct bt_uuid_128 *uuid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int bt_obex_server_register(struct bt_obex_server *server, const struct bt_uuid_128 *uuid) | |
int bt_obex_server_register(struct bt_obex* obex, struct bt_obex_server *server, const struct bt_uuid_128 *uuid) |
Then application don't needs to set server->obex
. and highlight that the registering is for the obex
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the doxygen comments to the function. And also checked the server->obex
in the function.
fe5c811
to
7d5b771
Compare
7d5b771
to
3955c88
Compare
Split the structure `struct bt_obex` into two parts. Part 1 `struct bt_obex`, it is the common part and shared by all OBEX sessions which share the same one transport. Part 2 `struct bt_obex_server` and `struct bt_obex_client`. The `struct bt_obex_server` is used to manage the OBEX session of server role. The `struct bt_obex_client` is used to manage the OBEX session of client role. Add function `bt_obex_server_register()` to register the OBEX server with specific uuid. Add function `bt_obex_server_unregister()` to unregister the OBEX server. Add function `bt_obex_make_uuid()` to make UUID. Signed-off-by: Lyle Zhu <[email protected]>
Set the MOPL of RX and TX to `BT_OBEX_MIN_MTU` when registering OBEX server. Set the TX MOPL to `BT_OBEX_MIN_MTU` when sending OBEX connection request. Check if the MOPL of client exceeds MTU of transport when server receives the connection request. Check if the MOPL of server exceeds MTU of transport when client receives the connection response. Signed-off-by: Lyle Zhu <[email protected]>
3955c88
to
893e6ad
Compare
|
Split the structure
struct bt_obex
into two parts.Part 1
struct bt_obex
, it is the common part and shared by all OBEX sessions which share the same one transport.Part 2
struct bt_obex_session
, it is the dedicated part for each OBEX session.Add function
bt_obex_register()
to register the OBEX server with specific uuid.Add function
bt_obex_unregister()
to unregister the OBEX server.