Creating and Using smartBASIC Applications

Reminder of default app

Please remember that the default application on the co-processor is the smartBASIC 'At Interface' app. More information about this application can be found in the following document.

Writing your smartBASIC application

smartBASIC code can be written in any text editor and must be saved with a .sb extension. Laird Connectivity provides a smartBASIC syntax highlighting file for Notepad++ and Textpad which will provide useful syntax highlighting.

Please refer to the following guides on smartBASIC core functionality and BL654 extensions to see the APIs available for your application.

Additionally, please note that there are many sample applications you can use as a starting point which can be found here:

Compiling your application

To compile your smartBASIC application you will need to utilize a program called UwTerminalX that is provided by Laird Connectivity. This runs on Windows, Linux, Mac, and Raspberry Pi. It cannot be run on the IG60 itself.

Releases of the UwTerminalX app can be found here:

Within the UwTerminalX program you can right click on the terminal window and select "XCompile". This will allow you to point to a .sb file that you would like to compile. The result will be a .uwc file which can then be loaded onto the BT 5 co-processor. This is covered in the following section.

Loading your compiled application onto the BT 5 co-processor

Once you have a .uwc file (a compiled .sb application) you can leverage a python script called 'btpa_utility' to load the application onto the BT 5 co-processor via the /dev/ttyS2 interface.

The python script can be found on GitHub at the following link.

Exiting an $autorun$ smartBASIC Application

There exist pre-defined GPIOs in the IG60 to control the BL654 module, which can be found under /sys/devices/platform/gpio:

  • bt_nautorun: If set to 0 (low) autorun is active and and $autorun$ application will start after power up/reset and if set to 1 (high) autorun will be disabled.
  • card_nreset: Setting to 0 (low) asserts BL654 reset and 1 (high) releases reset.

To exit an $autorun$ application nAUTORUN needs to be set high followed by a module reset.

echo 1 > /sys/devices/platform/gpio/bt_nautorun/value (disables autorun)
echo 0 > /sys/devices/platform/gpio/card_nreset/value (assert reset)
echo 1 > /sys/devices/platform/gpio/card_nreset/value (release reset)
echo 0 > /sys/devices/platform/gpio/bt_nautorun/value (re-enable autorun)

You should now be able to connect to the BL654 through e.g. microcom with access to the smartBASIC interactive mode:

microcom -s 115200 /dev/ttyS2

You can now use e.g. AT&F* to clear the flash file system before loading a new smartBASIC app to the module with the above Python script. (Note: CTRL-X will exit microcom).

Note: You can always check the current state of the above GPIOs with

cat /sys/devices/platform/gpio/.../value