HCI Unexpected Event Code
SDK version: 3.4.1
I'm trying to implement stop/start of the Bluetooth SDK. Normally, the first startup of the SDK (running all the various *_init() functions, etc) works without issue. To stop the SDK, I disconnect any active connections and disable BLE advertising. Then to restart, I perform a hardware reset, and then do all the normal application initialization. However, I am regularly seeing errors after this restart, such as the following:
hci_api_execute_dloc_write(): unexpected event_code 0x10
What does this mean? Is hardware reset not enough to reset the module? I did have to introduce some hacks to get the SDK to reset, but I don't see how this affects the module during re-initialization.
I can confirm that after a hardware reset PAN1026 is in the same state as after a cold boot, so the same initialization sequence will work.
As you already noticed, the software environment must be "reset" as well. This includes non-SDK parts such as the state of the UART (Rx buffer) but also SDK parts, for example all global variables which are "auto initialized" to 0 (and are located in the bss segment) or initialized by the compiler to some other value.
From my understanding this kind of "software reset" is not available by design in the SDK. If you really want this behavior, you need to make sure to set all SDK variables to their default values.
I will report this to Toshiba and suggest that this should be implemented in the SDK correctly.