stuffmatic / zephyr-ble-midi

A Zephyr implementation of the BLE-MIDI (MIDI over Bluetooth low energy) service specification.
MIT License
2 stars 1 forks source link

Immediate disconnect on connection issue #1

Closed paulmialane closed 4 days ago

paulmialane commented 5 months ago

Hello! I'm currently working with the Nordic XIAO BLE SENSE for a school project, and I'd like to use your project to implement Midi over BLE. I added an overlay file for my board in order to have 4 buttons, and some debugging messages.

However, I'm running into the following issues:

Thanks!

stuffmatic commented 4 months ago

Interesting. Lately, I've been developing with nRF Connect SDK and haven't checked vanilla Zephyr compatibility in a while. So I just tried building the sample app with Zephyr 3.3.0 for my nRF52840dk and it seems to work fine. I tried both with Bluetooth MIDI connect iOS app and the macOS Audio MIDI Setup app. Here's the log when connecting to the iOS app:

*** Booting Zephyr OS build zephyr-v3.3.0-1122-g29ac5d43817a ***
[00:00:00.380,310] <inf> bt_hci_core: hci_vs_init: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.380,340] <inf> bt_hci_core: hci_vs_init: HW Variant: nRF52x (0x0002)
[00:00:00.380,371] <inf> bt_hci_core: hci_vs_init: Firmware: Standard Bluetooth controller (0x00) Version 3.3 Build 99
[00:00:00.381,072] <inf> bt_hci_core: bt_dev_show_info: Identity: F0:BE:77:15:29:08 (random)
[00:00:00.381,103] <inf> bt_hci_core: bt_dev_show_info: HCI: version 5.4 (0x0d) revision 0x0000, manufacturer 0x05f1
[00:00:00.381,134] <inf> bt_hci_core: bt_dev_show_info: LMP: version 5.4 (0x0d) subver 0xffff
[00:00:00.381,164] <inf> ble_midi: ble_midi_init: Initialized BLE MIDI
[00:00:17.158,996] <inf> ble_midi: mtu_updated: MTU updated: tx 23, rx 23 (actual 23), setting tx_buf_max_size to 20
[00:00:17.159,057] <inf> ble_midi: on_connected: tx_running_status 0, tx_note_off_as_note_on 0
[00:00:17.159,088] <inf> ble_midi: on_connected: Got conn. interval 30 ms, requesting interval 7 ms with error 0
[00:00:17.577,148] <inf> ble_midi: mtu_updated: MTU updated: tx 23, rx 23 (actual 23), setting tx_buf_max_size to 20
[00:00:18.147,277] <inf> ble_midi: midi_read_cb: Got read request, responding with empty payload
[00:00:18.537,261] <inf> ble_midi: midi_ccc_cfg_changed: I/O characteristic notification enabled: 1
[00:00:18.537,292] <inf> ble_midi: on_service_availability_changed: BLE MIDI service available: 1
[00:00:18.745,269] <inf> ble_midi: le_param_updated: Conn. params changed: interval: 15 ms, latency: 0, timeout: 200
[00:00:22.182,037] <inf> ble_midi: le_param_updated: Conn. params changed: interval: 15 ms, latency: 0, timeout: 200

I just pushed a logging improvement so you can see the disconnect reason code in the log. Might give you a clue. And if you happen to have an nRF52840dk, it would be interesting to know if the unmodified sample app runs properly on that.

Just a guess, but judging from your log, the disconnect might be related to the central dropping the connection because it doesn't like the requested connection interval range (which currently sets both min and max to 7.5 ms). It would be interesting to see if using a larger max interval helps, for example setting INTERVAL_MAX to 0xc here.

Only my computer running under Ubuntu 23.10 and my Android smartphone can detect the board, but my friends running under Windows and MacOS can't. Do you know how to fix this?

The device won't advertise when connected, which means centrals won't be able to detect it. Did you perhaps forget to disconnect the device?