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

Obex enablement #83781

Open
wants to merge 11 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

@@ -0,0 +1,1443 @@
/* obex.h - IrDA Oject Exchange Protocol handling */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IrDA suppose should be bluetooth?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full name of obex is IrDA Object Exchange Protocol.

#include <errno.h>
#include <stdbool.h>

#ifndef ZEPHYR_INCLUDE_BLUETOOTH_OBEX_H_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, the header guard should be placed at the very beginning of the header file, it should be before #include

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


/** Converts a OBEX response code to string.
*
* @return The string representation of the response code code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate typo "code"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

};

/** Converts a OBEX response code to string.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No @param doxygen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

In the function `bt_l2cap_br_server_register()`, the PSM cannot be
dynamic allocated. And only pre-set PSM is supported.

Improve the function `bt_l2cap_br_server_register()` to support the
dynamic PSM allocation if the passed PSM is zero.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
In the function `bt_rfcomm_server_register()`, the channel cannot be
dynamic allocated. And only pre-set channel is supported.

Improve the function `bt_rfcomm_server_register()` to support the
dynamic channel allocation if the passed channel is zero.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
The buffer `BT_RFCOMM_BUF_SIZE` is used to define the TX buffer size of
TX pool.

In current implementation, the TX buffer size of RFCOMM cannot be
calculated due to the macro `BT_RFCOMM_BUF_SIZE` is defined in internal
header file `rfcomm_internal.h`.

Move the macro `BT_RFCOMM_BUF_SIZE` form internal header file
`rfcomm_internal.h` to interface `rfcomm.h`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
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 <lyle.zhu@nxp.com>
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