Skip to main content, firmware, mac)

Initializes the imp004m’s Bluetooth sub-system and readies it for use


Device (from impOS™ 38)


Name Type Description
uart An imp UART object The imp UART bus connected to the module’s Bluetooth sub-system
firmware String or blob The Broadcom-proprietary firmware for the Bluetooth sub-system
mac String Optional override CYW43438 Bluetooth MAC address


A new bluetooth instance


This method initializes the imp004m’s Bluetooth sub-system and opens it for use. It returns an instance of the bluetooth class for you to use, so make sure you don’t allow the instance to go out of scope if you don’t want it to be automatically closed.

The uart parameter takes the imp UART bus which you have connected to the Bluetooth component of the imp004’s integrated Cypress CYW43438 communications chip. It will be taken over and configured by impOS and should not be used for other tasks while you have the bluetooth instance open — ie. until you call the bluetooth.close() method on the instance returned by this call.

Note It is possible to set the size of the selected UART’s receive buffer by calling uart.setrxfifosize() before you call A minimum receive buffer size of 1KB is imposed, so any buffer size smaller than this will be increased to 1KB by, but sizes greater than 1KB will be respected. If you do not call uart.setrxfifosize(), will set the receive buffer size to 1KB.

You must pass Cypress-proprietary radio firmware into the second parameter. This is then loaded into the CYW43438, which is restarted. The firmware is approximately 16KB in size, and you can choose to include it as a string in your application code, or as binary data stored on and read in from SPI flash. Indeed, you should note that a future implementation of this API will replace this parameter with a reference to a function in your application that will stream the firmware in from flash.

The required Bluetooth LE firmware is available as a Squirrel file stub here.

Note You will need to include the firmware in any subsequent call you make, for example after an earlier call to bluetooth.close().

To override the local bluetooth MAC address, pass an alternative address into the optional parameter mac. It must be provided as a 12-character lower-case hexadecimal string.

Example Code

const FIRMWARE = “...”;

// Set up BT on imp004m Breakout Board
bt <- null;
bt_uart <- hardware.uartFGJH;
bt_lpo_in <- hardware.pinE;
bt_reg_on <- hardware.pinJ;

// Boot up BT
bt_lpo_in.configure(DIGITAL_OUT, 0);
bt_reg_on.configure(DIGITAL_OUT, 1);

// Pregnant pause while BT boots...

local start = hardware.millis();

try {
    // Instantiate BT
    bt =, BT_FIRMWARE);
    server.log("BLE initialized after " + (hardware.millis() - start) + " ms");
} catch (err) {
    server.log("BLE failed after " + (hardware.millis() - start) + " ms");