Bluetooth Connector

When you try to use the standard method to connect your app to a bluetooth device, for example a bluetooth thermal printer, this process takes some seconds. While your app is waiting for a answer from the printer - until the BluetoothClient1.Connect block returns a positive or negative result - your app freezes and the user is not able to interact with the user interface.

The solution to this problem is an extension called Bluetooth Connector and provides an asynchronous method for connecting the printer in the background so that the app doesn't freeze anymore. After the process has finished, an event is raised that notifies you whether the connection has been established successfully.

Blocks

The Bluetooth Connector uses a built-in Bluetooth Client component to establish a connection. To connect, set your BluetoothClient component and the Address of the device and then call ConnectAsynch. When the process has finished after some seconds, the ConnectAsynchFinished event is raised and tells you whether the device isConnected.


EXAMPLE OF USAGE

Don't use multiple screens

Beware of using multiple screens! Unfortunately, in App Inventor the bluetooth connection gets lost every time you switch between screens. The Bluetooth Connector extension can't prevent the connection from getting lost. The solution to this would be to use virtual screens, i.e. hidden vertical arrangements on a single screen.