Other Parts Discussed in Thread: CC256XSTBTBLESW
Sometimes the controller get stuck in function "BSC_Shutdown" (see flow below).
This happens only sometimes, with no specific schema (~ 1 out of 20). The function "BSC_Shutdown" has some callbacks "HCITR_COMReconfigure" and "HCITR_COMClose", this funcations are called in case of success. In case of an error theis functions are not called and the controller stays forever in the function "BSC_Shutdown".
In case it stays there, the function "HCISendPacket" and "HCITR_COMDataCallback_UART" is called frequently.
I'm using the stack "CC256XSTBTBLESW_4.2.1.1" and the service pack V1.8 (CC256XB.h).
CloseStack flow:
/* First check to see if the Stack has been opened. */
if(StaticBluetoothStackID)
{
/* Cleanup GAP Service Module. */
if(GAPSInstanceID)
{
GAPS_Cleanup_Service(StaticBluetoothStackID, GAPSInstanceID);
}
/* Un-registered SPP LE Service. */
if(SPPLEServiceID)
{
GATT_Un_Register_Service(StaticBluetoothStackID, SPPLEServiceID);
SPPLEServiceID = 0;
}
/* Cleanup GATT Module. */
GATT_Cleanup(StaticBluetoothStackID);
/* Simply close the Stack */
BSC_Shutdown(StaticBluetoothStackID);
/* Free BTPSKRNL allocated memory. */
BTPS_DeInit();
Display(("Stack Shutdown."));
/* Free the Key List. */
FreeDeviceInfoList(&DeviceInfoList);
/* Flag that the Stack is no longer initialized. */
StaticBluetoothStackID = 0;
/* Flag success to the caller. */
ret_val = 0;
}
else
{
/* A valid Stack ID does not exist, inform to user. */
ret_val = UNABLE_TO_INITIALIZE_STACK;
}