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 broadcast content and scan reply settings failed, returning 0x12 #526

Open
3 tasks done
xiezhuangwei opened this issue Oct 30, 2024 · 8 comments
Open
3 tasks done

Comments

@xiezhuangwei
Copy link

xiezhuangwei commented Oct 30, 2024

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

能正常设置广播数据和扫描回复数据

Actual behavior (suspected bug)

Image_20241030105036

设置广播数据或者扫描回复数据失败

Error logs or terminal output

linxu这边的日志:
# 
# hcitool -i hci0 cmd 0x08 0x0009 0A 09 09 49 50 43 5F 65 30 64 30
< HCI Command: ogf 0x08, ocf 0x0009, plen 11
  0A 09 09 49 50 43 5F 65 30 64 30 
> HCI Event: 0x0e plen 4
  01 09 20 12 
# 
# hcitool -i hci0 cmd 0x08 0x0008 15 02 01 06 11 ff 11 68 10 00 0c cf 89 28 13 c
4 00 00 19 00 00 00
< HCI Command: ogf 0x08, ocf 0x0008, plen 22
  15 02 01 06 11 FF 11 68 10 00 0C CF 89 28 13 C4 00 00 19 00 
  00 00 
> HCI Event: 0x0e plen 4
  01 08 20 12 
------------------------------------------


wifi端日志:
xzw esp_vhci_host_send_packet 
xzw hci_driver_vhci_tx 
xzw hci_driver_vhci_host_tx 
xzw hci_transport_packet_rx 
xzw hci_transport_controller_packet_rx 
xzw tx len 26: [ 8 20 16 15 2 1 6 11 ff 11 68 10 0 c cf 89 28 13 c4 0 0 19 0 0 0 0 ]
xzw hci_transport_controller_packet_rx 
xzw hci_transport_controller_evt_tx
xzw hci_driver_vhci_tx 
xzw hci_driver_vhci_controller_tx 
xzw hci_driver_vhci_controller_tx type 4
xzw C2H data[0 0 0 0 20 12 6 11 ff 11]
xzw hci_transport_packet_rx 
xzw hci_transport_host_packet_rx 
xzw hci_driver_vhci_host_recv_cb 
xzw host_rcv_pkt
xzw process_tx_pkt 
xzw r_ble_hci_trans_hs_cmd_tx ret 0


### Steps to reproduce the behavior

启动蓝牙,重置蓝牙,设置scan resp,设置adv数据
hciconfig hci0 up
hcitool -i hci0 cmd 0x03 0x0003
hcitool -i hci0 cmd 0x08 0x0009 0A 09 09 49 50 43 5F 65 30 64 30
hcitool -i hci0 cmd 0x08 0x0008 15 02 01 06 11 ff 11 68 10 00 0c cf 89 28 13 c4 00 00 19 00 00 00

### Project release version

最新master

### System architecture

other (details in Additional context)

### Operating system

Linux

### Operating system version

linux

### Shell

sh

### Additional context

_No response_
@mantriyogesh
Copy link
Collaborator

The ESP-Hosted is responsible to transfer the bluetooth messages from controller to stack and return path.

Are you facing any kind of message drop for bluetooth in this case?
If not, this is not ESP-Hosted bug.

If this is not ESP-Hosted bug, and if it is urgent, I would suggest checking your BlueZ configuration and the commands fired are supported and cross check with BlueZ support channel https://github.com/bluez/bluez/issues

From the logs shared, I can confirm there is no issue in ESP-Hosted as such.

@mantriyogesh
Copy link
Collaborator

Hello again,

Can you please attach all the logs and git commit version used:

  1. esp monitor or minicom log
  2. host dmesg log from system bootup
  3. host commands run and their outputs
  4. sudo btmon log (to be started before loading the kernel module for complete logs)

possibly:

  1. git commits used in esp-hosted for esp and host side, also idf
  2. sdkconfig used at esp

we will try re-assess if the issue is at esp-hosted. we can also try to get internal bt team help (high turnover time), possibly, if it is not esp-hosted issue, just as help and not as support.

@mantriyogesh
Copy link
Collaborator

Just to be sure, @xiezhuangwei

Can you reproduce this on your native laptop, if it works with this?

@mantriyogesh
Copy link
Collaborator

The commands you have sent are responded with invalid commands (0x12) So check your full scenario first if it works on native laptop bluetooth, first.

@xiezhuangwei
Copy link
Author

Serial-COM6-15_47_00.log
Serial-COM22-15_46_59.log
Serial-COM22-15_46_59.log是主控的日志,里面包含了命令运行,dmesg
Serial-COM6-15_47_00.log是WiFi的,有打印出主控下发的数据

@xiezhuangwei
Copy link
Author

异常的
hcitool -i hci0 cmd 0x08 0x0008 15 02 01 06 11 ff 11 68 10 00 0c cf 89 28 13 c4 00 00 19 00 00 00
hcitool -i hci0 cmd 0x08 0x0009 0A 09 09 49 50 43 5F 65 30 64 30

正常可以设置的。发现不需要的数据要补0,底层wifi才没报0x12错误
hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 06 11 ff 11 68 10 00 0c cf 89 28 13 c4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
hcitool -i hci0 cmd 0x08 0x0009 1e 09 09 49 50 43 5F 65 30 64 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

@mantriyogesh
Copy link
Collaborator

I note the difference of '0x19' in your first command. is it intentional

@mantriyogesh
Copy link
Collaborator

Length issue discussion

Pure esp32-c3 testing

The bluetooth team tested with following

31 #if CONFIG_EXAMPLE_EXTENDED_ADV
32 static uint8_t ext_adv_pattern_1[] = {
33     0x02, 0x01, 0x06,
34     0x11, 0XFF, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'p', 'e', 'f', 'e', 'q',
35 };
36 #endif

in bleprph esp-idf example with pure esp32-c3 and it is working fine.

ESP-Hosted testing

So I had cross checked on latest master of esp-hosted FG,

It is again working fine at our place.

Log at Raspberry Pi
kysoh@raspberrypi:~ $ hciconfig
hci0:	Type: Primary  Bus: SPI
	BD Address: 40:4C:CA:4A:A8:52  ACL MTU: 517:10  SCO MTU: 0:0
	UP RUNNING
	RX bytes:288 acl:0 sco:0 events:56 errors:0
	TX bytes:303 acl:0 sco:0 commands:0 errors:0

kysoh@raspberrypi:~ $ sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 06 11 ff 11 68 10 00 0c cf 89 28 13 c4 00 00 19 00 00 00 00 00 00 00 00 00 00 00 00 00
< HCI Command: ogf 0x08, ocf 0x0008, plen 32
  1E 02 01 06 11 FF 11 68 10 00 0C CF 89 28 13 C4 00 00 19 00
  00 00 00 00 00 00 00 00 00 00 00 00
> HCI Event: 0x0e plen 4
  01 08 20 0C
kysoh@raspberrypi:~ $ sudo hcitool -i hci0 cmd 0x08 0x0008 15 02 01 06 11 ff 11 68 10 00 0c cf 89 28 13 c4 00 00 19 00 00 00
< HCI Command: ogf 0x08, ocf 0x0008, plen 22
  15 02 01 06 11 FF 11 68 10 00 0C CF 89 28 13 C4 00 00 19 00
  00 00
> HCI Event: 0x0e plen 4
  01 08 20 0C
kysoh@raspberrypi:~ $ hciconfig
hci0:	Type: Primary  Bus: SPI
	BD Address: 40:4C:CA:4A:A8:52  ACL MTU: 517:10  SCO MTU: 0:0
	UP RUNNING
	RX bytes:300 acl:0 sco:0 events:60 errors:0
	TX bytes:363 acl:0 sco:0 commands:0 errors:0

In any case, you check your commands are correct. hcitool needs specific understanding of the commands.

Further, The Bluetooth messages could also be tracked to and fro using traces at:

Hosted debug logs

Slave

ESP_LOG_BUFFER_HEXDUMP("bt_rx", payload, payload_len, ESP_LOG_INFO);

ESP_LOG_BUFFER_HEXDUMP("bt_tx", data, len, ESP_LOG_INFO);

Host

esp_hex_dump_dbg("bt_tx: ", skb->data, len);

esp_hex_dump_dbg("bt_rx: ", skb->data, len);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants