pxt-calliope/docs/reference/bluetooth/on-bluetooth-disconnected.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR ()
* Accessibility changes
2017-09-07 13:42:08 -07:00

1.5 KiB
Executable File

On Bluetooth Disconnected

~hint

For another device like a smartphone to use any of the Bluetooth "services" which the @boardname@ has, it must first be paired with the @boardname@. Once paired, the other device may connect to the @boardname@ and exchange data relating to many of the @boardname@'s features.

~

This block starts an event handler which in this case will run when a device which is connected to your @boardname@ over Bluetooth disconnects.

You could use this event handler to display a letter "D" on the @boardname@ LED grid so you know that the Bluetooth connection has been closed.

bluetooth.onBluetoothDisconnected(() => {
});

Example: Displaying "D" when a Bluetooth connection to the @boardname@ is closed

bluetooth.onBluetoothDisconnected(() => {
    basic.showString("D");
});

Video - on Bluetooth disconnected

http://www.youtube.com/watch?v=HyBcsD9Eh6I

See also

About Bluetooth, @boardname@ Bluetooth profile overview , @boardname@ Bluetooth profile reference, Bluetooth on @boardname@ resources, Bluetooth SIG

bluetooth