Disabling BLE and Detecting Failures

You can always disable the BLE interface by calling ble.disable. Like, ble.enable, this is an asynchronous method. Your app needs to detect when the BLE actually turns off.

Here is the first, blocking, example using bt.enabled:

** Tibbo Basic **

bt.disable
while bt.enabled<>NO
wend
sys.debugprint("BLE is now disabled\r\n")

Here is the second, non-blocking, example using on_bt_event:

** Tibbo Basic **

...
 bt.disable
end sub

sub on_bt_event(bt_event as enum pl_bt_events)
 select case bt_event
 case PL_BT_EVENT_CONNECTED:

 case PL_BT_EVENT_DISCONNECTED:

 case PL_BT_EVENT_ENABLED:

 case PL_BT_EVENT_DISABLED:
         sys.debugprint("BLE is now disabled\r\n")
 end select
end sub

The on_bt_event(PL_BT_EVENT_DISABLED) is also generated if the WA2000 is disconnected, powered down, malfunctions, or is put in reset.