Previous version of code misbehaves under containerized applications. In the first run of the application the Bluetooth enable pin is set, and hciattach called. On application restart (but not whole device reboot) hciattach will be killed, but the enable pin stays as it was. Then when running this code again on the start, Bluetooth enable fails and initialization times out. To prevent that to happen, if the Bluetooth enable is on, toggle it (disable then enable again)
to reset the hardware.
Previous version of code misbehaves under containerized applications. In the first run of the application the Bluetooth enable pin is set, and hciattach called. On application restart (but not whole device reboot) hciattach will be killed, but the enable pin stays as it was. Then when running this code again on the start, Bluetooth enable fails and initialization times out. To prevent that to happen, if the Bluetooth enable is on, toggle it (disable then enable again) to reset the hardware.