Skip to content
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: OBEX enablement #83781

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

lylezhu2012
Copy link
Contributor

@lylezhu2012 lylezhu2012 commented Jan 10, 2025

  • Bluetooth: GOEP: Enable GOEP feature

Add a Kconfig BT_GOEP to control the GOEP feature.

Implement the GOEP protocol and transport, both for GOEP 1.1 and GOEP 2.x.

For GOEP transport, OBEX over RFCOMM, and OBEX over L2CAP are supported.

For GOEP protocol, put, get, abort, setpath, and action are supported. And only one operation can be processed at the same time. The feature Reliable Session is unsupported.

  • Bluetooth: GOEP: Improve the MTU configuration

The MTU of the GOEP should be not less than 255. So, if the transport is RFCOMM, the CONFIG_BT_BUF_ACL_RX_SIZE should be not less than 264.
It includes,

  • 255 bytes for the minimum MTU of GOEP,
  • 4 bytes for L2CAP Header,
  • 5 bytes for RFCOMM header and FCS.

And if the transport is L2CAP, the CONFIG_BT_BUF_ACL_RX_SIZE should be not less than 259.
It includes,

  • 255 bytes for the minimum MTU of GOEP,
  • 4 bytes for L2CAP Header.

Add Kconfig BT_GOEP_RFCOMM_MTU to configure the maximum size for RFCOMM transport. The range of BT_GOEP_RFCOMM_MTU is [264, BT_RFCOMM_L2CAP_MTU]. And the GOEP MTU via RFCOMM transport should be in the range [255, (BT_GOEP_RFCOMM_MTU-9)].

Add Kconfig BT_GOEP_L2CAP_MTU to configure the maximum size for L2CAP transport. The range of BT_GOEP_L2CAP_MTU is [259, BT_BUF_ACL_RX_SIZE]. And the GOEP MTU via L2CAP transport should be in the range [255, (BT_GOEP_L2CAP_MTU-4)].

  • Bluetooth: shell: Add transport commands for GOEP

Add commands for GOEP to test transport features.

Add commands for transport over RFCOMM, including register-rfcomm, connect-rfcomm, and disconnect-rfcomm.

Add commands for transport over L2CAP, including register-l2cap, connect-l2cap, and disconnect-l2cap.

  • Bluetooth: shell: Add OBEX commands for GOEP

Add commands for GOEP to test OBEX features.

Add command alloc-buf and release-buf to allocate and release TX buffer.

Add command set add-header to add the OBEX headers to allocated TX buffer.

Add command set client to send OBEX client requests with allocated TX buffer.

Add command set server to send OBEX responses with allocated TX buffer.

  • Bluetooth: OBEX: Check if the added string is valid

There are types of string can be added by using OBEX adding header function bt_obex_add_header_*(). One is byte sequence. Another is null terminated Unicode text.

Add a function bt_obex_string_is_valid() to check if the added string is valid. And add a function bt_obex_unicode_is_valid() dedicated to check Unicode string.

@jhedberg
Copy link
Member

Another massive PR? :)

@lylezhu2012 I think the L2CAP and RFCOMM improvements could at least be split out into their own PRs. That way I think we can make faster progress with getting functionality merged incrementally.

@lylezhu2012
Copy link
Contributor Author

Another massive PR? :)

Actually, my PR only implements basic goep/obex operations, but goep and obex define too many concepts.

@lylezhu2012 I think the L2CAP and RFCOMM improvements could at least be split out into their own PRs. That way I think we can make faster progress with getting functionality merged incrementally.

Well, I will remove all other layers changes from this PR. And make small PR for these changes.

@hermabe hermabe removed their request for review January 10, 2025 08:38
@lylezhu2012
Copy link
Contributor Author

lylezhu2012 commented Jan 10, 2025

Split out the changes and create other 4 PRs, #83783, #83785, #83786, and #83787.

But the changes are not removed from current PR to avoid the building issue.

@Thalley Thalley removed their request for review January 10, 2025 09:29
@lylezhu2012 lylezhu2012 force-pushed the obex_enablement branch 4 times, most recently from 1dfaefe to e4a2256 Compare January 13, 2025 03:44
@sjanc sjanc removed their request for review January 13, 2025 07:30
@kartben
Copy link
Collaborator

kartben commented Jan 13, 2025

test failure is unrelated and will be fixed with #83907

@lylezhu2012 lylezhu2012 requested a review from makeshi January 14, 2025 05:03
@lylezhu2012 lylezhu2012 force-pushed the obex_enablement branch 2 times, most recently from 4c7feba to 2177c21 Compare January 14, 2025 12:45
@lylezhu2012 lylezhu2012 force-pushed the obex_enablement branch 2 times, most recently from 6ad4f54 to 8433ca6 Compare February 12, 2025 02:12
@lylezhu2012 lylezhu2012 force-pushed the obex_enablement branch 4 times, most recently from 11d4c7b to a31f46a Compare February 25, 2025 12:23
Add a Kconfig BT_GOEP to control the GOEP feature.

Implement the GOEP protocol and transport, both for GOEP 1.1 and GOEP
2.x.

For GOEP transport, OBEX over RFCOMM, and OBEX over L2CAP are
supported.

For GOEP protocol, `put`, `get`, `abort`, `setpath`, and `action` are
supported. And only one operation can be processed at the same time.
The feature `Reliable Session` is unsupported.

Signed-off-by: Lyle Zhu <[email protected]>
The MTU of the GOEP should be not less than 255. So, if the transport
is RFCOMM, the CONFIG_BT_BUF_ACL_RX_SIZE should be not less than 264.
It includes,
- 255 bytes for the minimum MTU of GOEP,
- 4 bytes for L2CAP Header,
- 5 bytes for RFCOMM header and FCS.

And if the transport is L2CAP, the CONFIG_BT_BUF_ACL_RX_SIZE should
be not less than 259.
It includes,
- 255 bytes for the minimum MTU of GOEP,
- 4 bytes for L2CAP Header.

Add Kconfig `BT_GOEP_RFCOMM_MTU` to configure the maximum size for
RFCOMM transport. The range of `BT_GOEP_RFCOMM_MTU` is
`[264, BT_RFCOMM_L2CAP_MTU]`. And the GOEP MTU via RFCOMM transport
should be in the range `[255, (BT_GOEP_RFCOMM_MTU-9)]`.

Add Kconfig `BT_GOEP_L2CAP_MTU` to configure the maximum size for
L2CAP transport. The range of `BT_GOEP_L2CAP_MTU` is
`[259, BT_BUF_ACL_RX_SIZE]`. And the GOEP MTU via L2CAP transport
should be in the range `[255, (BT_GOEP_L2CAP_MTU-4)]`.

Signed-off-by: Lyle Zhu <[email protected]>
Add commands for GOEP to test transport features.

Add commands for transport over RFCOMM, including `register-rfcomm`,
`connect-rfcomm`, and `disconnect-rfcomm`.

Add commands for transport over L2CAP, including `register-l2cap`,
`connect-l2cap`, and `disconnect-l2cap`.

Signed-off-by: Lyle Zhu <[email protected]>
Add commands for GOEP to test OBEX features.

Add command `alloc-buf` and `release-buf` to allocate and release TX
buffer.

Add command set `add-header` to add the OBEX headers to allocated TX
buffer.

Add command set `client` to send OBEX client requests with allocated
TX buffer.

Add command set `server` to send OBEX responses with allocated TX
buffer.

Signed-off-by: Lyle Zhu <[email protected]>
There are types of string can be added by using OBEX adding header
function bt_obex_add_header_*(). One is byte sequence. Another is null
terminated Unicode text.

Add a function bt_obex_string_is_valid() to check if the added string
is valid. And add a function bt_obex_unicode_is_valid() dedicated to
check Unicode string.

Signed-off-by: Lyle Zhu <[email protected]>
Add a structure `struct bt_obex_tlv` to pass/save the one TLV info.

Use a array of `struct bt_obex_tlv` as the set of all TLV-triplets.
Update the following functions to  support the feature, including
`bt_obex_add_header_app_param`, `bt_obex_add_header_auth_challenge`,
and `bt_obex_add_header_auth_rsp`.

Add a function `bt_obex_tlv_parse` to parse the encoded TLV-triplets.

Signed-off-by: Lyle Zhu <[email protected]>
Add a TLV array `tlvs` to keep the pending TLV data.

Update `app_param`, `auth_challenge`, and `auth_rsp` to set the one
TLV information each time. When the optional argument `last` set,
write the all pending TLVs to the tx buffer.

Signed-off-by: Lyle Zhu <[email protected]>
@jhedberg jhedberg changed the title Obex enablement Bluetooth: Classic: OBEX enablement Feb 26, 2025
According to the OBEX Version 1.5, the Name header could be a empty
string.

Update function `bt_obex_add_header_name` to support the case that the
length of name could be 0.

Update function `bt_obex_get_header_name` to support the case that the
name header is found but the name length is 0.

Signed-off-by: Lyle Zhu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants