2023-03-26 09:14 AM
I have interesting problem.
Custom PCB as master role using SDK 1.15.0.
Trying bonding procedure, I find an situatiotion where after ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE event, waiting 100ms (as in "BLE_HeartRateFreeRTOS_ANCS" example) (Ithink it is a mistake or error using that algorithm) and starting disconnect operation calling "aci_gap_terminate()" - the FW freeze and I newer receive an "HCI_DISCONNECTION_COMPLETE_EVT_CODE" event.
This log of bonding proc with trying disconnect after ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE like in "BLE_HeartRateFreeRTOS_ANCS" example :
-------------------------------------------------------------------------------
SCAN START: 1 use white_list: 0 result: 0
CONNECT BEGIN: 0
HCI_VENDOR: 0407
HCI_LE_META: 0001
CONNECTION_COMPLETE wit peer: 0000
Bonded=0 SMode=1 SLevel 1
HCI_VENDOR: 0C03
HCI_LE_META: 0007
HCI_VENDOR: 0C03
HCI_VENDOR: 0C10
HCI_ENCRYPTION_CHANGE: enabled: 0001 status: 0000
HCI_VENDOR: 0802
HCI_LE_META: 0003
HCI_VENDOR: 0401
ACI_GAP_PAIRING_COMPLETE: 0000 0000
Bonded=1 SMode=1 SLevel 2
SYS_EVT: 9204 //SHCI_SUB_EVT_NVM_START_WRITE
DISCONNECT BEGIN: 0 0 (!!! calling aci_gap_terminate() after 2 minutes timeout !!!)
----------/* !!! after 2 minutes !!! */----------
SYS_EVT: 9205 //SHCI_SUB_EVT_NVM_END_WRITE
SYS_EVT: 9204 //SHCI_SUB_EVT_NVM_START_WRITE
SYS_EVT: 9205 //SHCI_SUB_EVT_NVM_END_WRITE
-----------------------------------------------------------------------------------------
But when after ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE I continue connection with geting service, characteristics, descriptors and after that ytying to disconnect - its all ok.
LOG:
SCAN START: 1 use white_list: 0 result: 0
CONNECT BEGIN: 0
HCI_VENDOR: 0407
HCI_LE_META: 0001
CONNECTION_COMPLETE wit peer: 0000
Bonded=0 SMode=1 SLevel 1
HCI_VENDOR: 0C03
HCI_LE_META: 0007
HCI_VENDOR: 0C03
HCI_VENDOR: 0C10
HCI_ENCRYPTION_CHANGE: enabled: 0001 status: 0000
HCI_VENDOR: 0802
HCI_LE_META: 0003
HCI_VENDOR: 0401
ACI_GAP_PAIRING_COMPLETE: 0000 0000
Bonded=1 SMode=1 SLevel 2
SYS_EVT: 9204 //SHCI_SUB_EVT_NVM_START_WRITE
CMD_BLE_DISCOVERY_OWN_SERVICE /* begin discovery porc*/
SYS_EVT: 9205 /* WOW i dont need wait 2 minutes!! */
HCI_VENDOR: 0C05 ACI_ATT_FIND_BY_TYPE_VALUE_RESP_VSEVT_CODE
HCI_VENDOR: 0C11 ACI_GATT_ERROR_RESP_VSEVT_CODE
ACI_GATT_ERROR_RESP: 0006 001D 000A
HCI_VENDOR: 0C10 ACI_GATT_PROC_COMPLETE_VSEVT_CODE
CMD_BLE_DISCOVERY_ALL_CHARS
HCI_VENDOR: 0C06 ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE
HCI_VENDOR: 0C11 ACI_GATT_ERROR_RESP_VSEVT_CODE
ACI_GATT_ERROR_RESP: 0008 001B 000A
HCI_VENDOR: 0C10 ACI_GATT_PROC_COMPLETE_VSEVT_CODE
CMD_BLE_DISCOVERY_ALL_DESCS
HCI_VENDOR: 0C04 ACI_ATT_FIND_INFO_RESP_VSEVT_CODE
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C04
HCI_VENDOR: 0C10 ACI_GATT_PROC_COMPLETE_VSEVT_CODE
CMD_BLE_DISCOVERY_PARSE_CHARS
HCI_VENDOR: 0C10 ACI_GATT_PROC_COMPLETE_VSEVT_CODE
HCI_VENDOR: 0C10
HCI_VENDOR: 0C10
HCI_VENDOR: 0C10
DISCONNECT BEGIN: 0 0
HCI_DISCONNECTION_COMPLETE: 0016 /* BINGO */
-----------------------------------------------------------------------------
Thanks all who answer me.
2023-03-31 04:53 AM
Hello,
Yes, the BLE_HeartRateFreeRTOS_ANCS is working as expected. The following part of code inside ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE event can be removed, it's not more useful.
if (Peer_Bonded == 0x00)/* only for the first paring complete*/
{
APP_DBG_MSG("Term Connection for the first pairing complete to save bonding information !!! \n\r");
for (int loop=0;loop<10;loop++) /* */
{
/* hci_disconnection_complete_event event will be generated when the link is disconnected.
It is important to leave an 100 ms blank window before sending any new command (including system hardware reset), since immediately after @ref hci_disconnection_complete_event event, system could save important information in non volatile memory. */
int cnt = 1000000;
while(cnt--);
printf(".\n\r");
}
ret = aci_gap_terminate(BleApplicationContext.connection_handle, 0x13);
if (ret == BLE_STATUS_SUCCESS)
{
Notification.Evt_Opcode = ANCS_DISCONNECTING;
ANCS_App_Notification(&Notification);
}
}
Best Regards
2023-03-31 05:17 AM
Hello, Remy.
It`s ok, Remy, but the problem is there : if to call "aci_gap_terminate()" - the CPU2 is not fire any evens. The solution is: only reboot or continue the connection.
But sometimes it happens that when to call the "aci_gatt_disc_primary_service_by_uuid(...)", the same thing happens: there is no event from the CPU2.
Note: the function is NOT called in the interrupt handler (not in SVCCTL_App_Notification()), but in a separate thread with handler completion checks.
I think this is due to the fact that CPU2 sends the SHCI_SUB_EVT_NVM_START_WRITE and SHCI_SUB_EVT_NVM_STOP_WRITE events with a random delay.and there events erase or blocks another events.
Best Regards.
2023-04-07 11:14 AM
Hello,
If you try BLE_HeartRateFreeRTOS_ANCS example on STM32WB55 Nucleo board, do you see the same behavior?
Best Regards