Knowledge Base

SimpleHMI: Android, Bluetooth and Connection

PLEASE IGNORE THIS PAGE

This page belongs logically much later in the tutorial, but makes a very important point that you need to be aware of.

With Android and Bluetooth, there is no certainty as to when a device is actually connected or not. Put another way, you can walk up to a machine fitted for SimpleHMI via Bluetooth at any time and connect to it (if you know the pairing password).

When SimpleHMI gets connected via Bluetooth, it automatically sends a Connected event to the SPLat. This is used in your program to redraw the SimpleHMI home screen.

If you are programming for SimpleHMI your program must be able to handle a Connected event at absolutely any time without doing anything dangerous.

The easy way to handle the Connected event is simply to paint the home screen. You must either design your system so this is always safe, or keep track of the state of the system and select which screen to paint accordingly (probably using a Branch instruction).

SimpleHMI in Android sends Connected events when it first connects and when it reconnects after being re-launched. In Android reverting to a “running” app actually re-launches it. This includes when the screen is turned on after being off.