调用ble_gap_disconnect() doesn't work

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5 posts / 0 new
Last post
Ulf Söderberg
Offline
Last seen:4 months 1 day ago
加入:2014-02-14 20:16
调用ble_gap_disconnect() doesn't work

I'm developing firmware for a BLE peripheral using the DA14681 and am having trouble getting the ble_gap_disconnect function to work.
The firmware is a bridge between USB HID and BLE where the device is working as a BLE peripheral.

One of the requirements on the firmware is that it should be possible to disconnect a connected smartphone app.

When I call the ble_gap_disconnect function with the connection index of the current connection, nothing happens. There is no disconnection done.

How can this be?

Device:
MT_dialog
Offline
Last seen:2 months 2 weeks ago
工作人员
加入:2015-06-08 11:34
Hi Ulf Soderberg,

Hi Ulf Soderberg,

Can you see the command being send over the air via a sniffer ? Are you able to get one of the messages that declare the completion of the disconnection procedure BLE_EVT_GAP_DISCONNECTED or BLE_EVT_GAP_DISCONNECT_FAILED ?

Thanks MT_dialog

Ulf Söderberg
Offline
Last seen:4 months 1 day ago
加入:2014-02-14 20:16
I have not used a sniffer yet

I have not used a sniffer yet.
I don't see the BLE_EVT_GAP_DISCONNECTED being caught by the switch statement, and there is no case for the BLE_EVT_GAP_DISCONNECT_FAILED event.
I added the following lines in the default case and by setting a breakpoint I could see the BLE_EVT_GAP_DISCONNECT_FAILED event arriving.


default:
if (hdr->evt_code == BLE_EVT_GAP_DISCONNECT_FAILED) {
fff = 1; // variable defined above this code snippet. A breakpoint was set on this line
}
ble_handle_event_default(hdr);
break;

So, what's with the BLE_EVT_GAP_DISCONNECT_FAILED then?

Ulf Söderberg
Offline
Last seen:4 months 1 day ago
加入:2014-02-14 20:16
我调试后一点

我调试后一点found the problem. Turned out that the "reason" parameter was wrong.

By changing
ble_gap_disconnect(peer_conn_idx, BLE_HCI_ERROR_CON_TERM_BY_LOCAL_HOST);
to
ble_gap_disconnect(peer_conn_idx, BLE_HCI_ERROR_REMOTE_USER_TERM_CON);
it know works ok.

MT_dialog
Offline
Last seen:2 months 2 weeks ago
工作人员
加入:2015-06-08 11:34
Hi Ulf Soderberg,

Hi Ulf Soderberg,

Thanks for the indication.

Best Regards MT_dialog