cancel
Showing results for 
Search instead for 
Did you mean: 

HCI_DISCONNECTION_COMPLETE_EVT_CODE always returning reason 0x13

WRosé.1
Associate II

Hi! I have a peripheral that calls

aci_gap_terminate(BleApplicationContext.BleApplicationContext_legacy.connectionHandle, HCI_AUTHENTICATION_FAILURE_ERR_CODE)

aci_gap_terminate(BleApplicationContext.BleApplicationContext_legacy.connectionHandle, HCI_AUTHENTICATION_FAILURE_ERR_CODE)

itself it receives the HCI_CONNECTION_TERMINATED_BY_LOCAL_HOST_ERR_CODE reason in disconnect which I guess makes sense.

But the central that it disconnects from will always receive the

HCI_REMOTE_USER_TERMINATED_CONNECTION_ERR_CODE 0x13

 case HCI_DISCONNECTION_COMPLETE_EVT_CODE:
      {
        /* USER CODE BEGIN EVT_DISCONN_COMPLETE */
        cc = (hci_disconnection_complete_event_rp0 *) event_pckt->data;
        /* USER CODE END EVT_DISCONN_COMPLETE */
        handleNotification.Reason = cc->Reason;
 
        APP_DBG_MSG("\r\n\r** DISCONNECTION EVENT WITH SERVER reason: %x  status: %x \n\r", cc->Reason, cc->Status);
}

Reason will always be 0x13 and status 0x00

The devices are flashed with the latest ble binaries

stm32wb1x_BLE_Stack_full_fw.bin

And are using the libs

STM32Cube_FW_WB_V1.14.0

Best regards Wallentin

3 REPLIES 3
Remy ISSALYS
ST Employee

Hello,

The behavior that you observe seems to be good. The peripheral send aci_gap_terminate command to terminate the connection so itself it receives the HCI_CONNECTION_TERMINATED_BY_LOCAL_HOST_ERR_CODE reason and the central received HCI_REMOTE_USER_TERMINATED_CONNECTION_ERR_CODE reason because the disconnection is sent by the peripheral (e.g the remote device).

Best Regards

WRosé.2
Associate II

Hey,

I understand that the HCI_CONNECTION_TERMINATED_BY_LOCAL_HOST_ERR_CODE should be the reason at the peripheral side but because I send the

HCI_AUTHENTICATION_FAILURE_ERR_CODE as the reason when using aci_gap_terminate

The central should receive that reason (0x05) as I understand? How else should the central know why the peripheral disconnected?

Remy ISSALYS
ST Employee

Hello,

Since STM32CubeWB v1.16.0, the disconnection reason used in aci_gap_terminate command is propagated on remote side.

The allowed remote reason values are:

  • Authentication Failure error code (0x05)
  • Remote User Terminated Connection (0x13)
  • Remote Device Terminated Connection due to Low Resources (0x14)
  • Remote Device Terminated Connection due to Power Off (0x15)
  • Unsupported Remote Feature error code (0x1A)
  • Unacceptable Connection Parameters error code (0x3B).

Best Regards