bluetooth: fix Kconfig combination compilation issues#585
Conversation
f630c8c to
3337ab9
Compare
| bool "Serial Port Profile (SPP)" | ||
| default n | ||
| select BT_RFCOMM | ||
| select BT_RFCOMM |
There was a problem hiding this comment.
Done. Removed the duplicate select BT_RFCOMM line.
| g_a2dp_sink.offloading = msg->data.valuebool; | ||
| break; | ||
| case PROFILE_EVT_REMOTE_DETACH: { | ||
| #ifdef CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC |
There was a problem hiding this comment.
suggest do not add CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC within *c
There was a problem hiding this comment.
Done. Moved cookie fields out of #ifdef CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC in bluetooth.h so they are unconditionally available in bt_instance_t. Removed all ifdefs from .c files.
| g_a2dp_source.offloading = msg->data.valuebool; | ||
| break; | ||
| case PROFILE_EVT_REMOTE_DETACH: { | ||
| #ifdef CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC |
There was a problem hiding this comment.
Done. Same fix — cookie fields are now unconditional in bt_instance_t.
| @@ -0,0 +1,34 @@ | |||
| /**************************************************************************** | |||
| * Copyright (C) 2024 Xiaomi Corporation | |||
There was a problem hiding this comment.
Done. Fixed copyright year to 2026.
561f9fe to
9576771
Compare
| scanner_device_t* device; | ||
| uint32_t timestamp_ms; | ||
|
|
||
| #ifdef CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC |
There was a problem hiding this comment.
suggest do not add CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC in service cods, maybe it coudl be add in ipc code
gzh-terry
left a comment
There was a problem hiding this comment.
Additional note: l2cap_service.h declares l2cap_on_cid_allocated(bt_address_t* addr, uint16_t cid, uint16_t psm) but the implementation in l2cap_service.c has signature (addr, psm, cid) — parameter names are swapped between declaration and definition. This is a pre-existing bug but since this PR adds a new caller, it would be good to fix the header to match the implementation.
| sal_l2cap_channel_t* ch = find_channel_by_le_chan(BT_L2CAP_LE_CHAN(chan)); | ||
| if (!ch) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
bt_sal_l2cap_init() and bt_sal_l2cap_cleanup() are declared in the header and implemented here, but never called from anywhere (e.g., l2cap_service_init() does not call bt_sal_l2cap_init()). This is dead code. Either wire them into the service lifecycle or remove them.
There was a problem hiding this comment.
This is to prepare for implementing L2CAP socket communication later.
|
|
||
| *chan = &ch->le_chan.chan; | ||
|
|
||
| l2cap_on_cid_allocated(&ch->addr, ch->psm, 0); |
There was a problem hiding this comment.
bt_sal_l2cap_stop_listen_channel only marks in_use = false but the server remains registered in zblue (no bt_l2cap_server_unregister API exists). If the same PSM is listened again, bt_l2cap_server_register will fail because zblue still has it registered.
Suggestion: on re-listen, check if a server with the same PSM is already registered in zblue and reuse it instead of trying to register again.
|
|
||
| l2cap_on_channel_connected(&ch->addr, ¶m); | ||
| } | ||
|
|
There was a problem hiding this comment.
l2cap_on_cid_allocated is documented as "for client only" in handle_cid_allocated(). Calling it from l2cap_accept_cb (server-side accept) with cid=0 will:
- Fail to find any channel (searches
L2CAP_CHANNEL_ROLE_CLIENTonly) - Print a misleading error log: "record allocated CID: 0x0 failed!"
This call should be removed. For server-side channels, the CID is properly assigned later in l2cap_connected_cb → handle_channel_connected via param->local_cid.
| bt_status_t bt_sal_pan_disconnect(bt_address_t* addr); | ||
| bt_status_t bt_sal_pan_write(bt_address_t* addr, uint16_t protocol, | ||
| uint8_t* dst_addr, uint8_t* src_addr, | ||
| uint8_t* data, uint16_t length); |
There was a problem hiding this comment.
nit: dst_addr, src_addr, and data should all be const qualified. These are input-only parameters for a write/send operation — the callee should not modify them.
Same applies to bt_sal_l2cap_send_packet in sal_l2cap_interface.h — data should be const uint8_t*.
General principle: cross-layer payload pointers (app → framework → stack) that are informational/read-only should be const to express intent and catch accidental mutation at compile time.
| static sal_l2cap_channel_t g_channels[L2CAP_MAX_CHANNELS]; | ||
| static sal_l2cap_server_t g_servers[L2CAP_MAX_SERVERS]; |
There was a problem hiding this comment.
Are these arrays too large?
Can we allocate them when actually connected?
9576771 to
4d949d8
Compare
|
All review comments have been addressed in the latest push (commits b9363e9 and a21f41a): @chengkai15 — re: @gzh-terry — re: @gzh-terry — re: @gzh-terry — re:
@gzh-terry — re: @gzh-terry — re: @gzh-terry — re: |
…dapter bug: v/90629 sal_adapter_le_interface.c unconditionally accesses struct bt_keys members remote_csrk/local_csrk (only exist when CONFIG_BT_SIGNING is enabled) and references zblue_on_pairing_complete_ctkd (only declared under CONFIG_BT_SMP). This causes compilation failure in BLE-only configurations where SMP/SIGNING may not be enabled. Add appropriate ifdef guards. Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
bug: v/90631 sal_gatt_client_interface.c uses CONFIG_GATT_CLIENT_SERVICE_MAX, CONFIG_GATT_CLIENT_ELEMENT_MAX, and CONFIG_GATT_CLIENT_CHAR_PER_SERVICE_MAX as array sizes, but these Kconfig options depend on multiple configs being enabled simultaneously. In some config combinations they are undefined, causing compilation failure. Add #ifndef fallback defaults (20, 200, 100). Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
bug: v/90632 BLUETOOTH_SPP does not select BT_RFCOMM. When HFP (which normally brings in RFCOMM via its own select) is disabled but SPP remains enabled, RFCOMM is not compiled into the zblue library, causing undefined reference errors for bt_rfcomm_dlc_connect, bt_rfcomm_server_register, etc. Add explicit select BT_RFCOMM to the BLUETOOTH_SPP menuconfig. Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
…rement bug: v/90633 bt_cs.h declares bt_cs_start_distance_measurement with const parameter but the implementation in bt_cs.c and the interface typedef in cs_service.h omit const, causing -Wdiscarded-qualifiers warnings and potential build failure with -Werror. Align implementation and interface with the header declaration. Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
bug: v/90634 When CONFIG_BLUETOOTH_L2CAP is enabled, l2cap_service.c references sal_l2cap_interface.h and bt_sal_l2cap_* functions which were never implemented, causing fatal compilation error. Implement the SAL L2CAP interface header and zblue-based implementation supporting channel listen, connect, disconnect, and data send operations. Add build rules to Makefile. Channels and servers are dynamically allocated via calloc/free to minimize BSS footprint when L2CAP connections are idle. Server entries are kept allocated after stop_listen since zblue has no unregister API, and reused on re-listen for the same PSM. Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
bug: v/90635 When CONFIG_BLUETOOTH_PAN is enabled, pan_service.c references sal_pan_interface.h and bt_sal_pan_* functions which were never implemented, causing fatal compilation error. Add SAL PAN interface header and zblue-based stub implementation that returns BT_STATUS_NOT_SUPPORTED (BNEP not yet available in zblue). Add build rules to Makefile. Input-only pointer parameters (dst_addr, src_addr, data) are const qualified to express intent and prevent accidental mutation. Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
bug: v/90636 When CONFIG_BLUETOOTH_FRAMEWORK_LOCAL is enabled (no socket IPC), several compilation errors occur: - bt_instance_t cookie fields are guarded by SOCKET_IPC ifdef but referenced unconditionally in service code. Move cookie fields out of the ifdef so they are always available. - scan_manager.c calls bt_socket_server_is_busy() which only exists when SOCKET_IPC is enabled. Add ifdef guard around the call. Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
a21f41a to
fb31f0d
Compare
Summary
Test plan
Related JIRAs
v/90625, v/90629, v/90631, v/90632, v/90633, v/90634, v/90635, v/90636
Signed-off-by: huangyulong3 huangyulong3@xiaomi.com