Skip to content

Totem BLE

RoboBoard X3 remote ESP32

Totem Library headers
// Control over Bluetooth
#include <TotemBLE.h>              // Discover Totem boards (scan)
#include <TotemMiniControlBoard.h> // Connect Mini Control Board
#include <TotemRoboBoardX3.h>      // Connect RoboBoard X3
#include <TotemRoboBoardX4.h>      // Connect RoboBoard X4

TotemBLE

TotemBLE is only used to discover available boards or validate them before connecting. For actual connection and control read specific board section MiniControlBoard, RoboBoard X3, RoboBoard X4.

Boards are able to represent themselves with customizable: name, color and model (type of robot). This information is available before BLE connection is established. Same information and functionality is available using Totem App.

#include <TotemBLE.h>
TotemBLE totemBLE;
// Board found event
void onScanResult(TotemScanResult result) {
  // Print discovered board information
  Serial.printf("Address: '%s', Type: %s, Name: %s, Color: %x\n",
    result.getAddress().c_str(), result.getType().c_str(), result.getName().c_str(), result.getColor());
}
void setup() {
  Serial.begin(115200);
  // Register result function
  totemBLE.addOnScanResult(onScanResult);
  // Start scan for available Totem Boards
  totemBLE.scan();
}
void loop() { }

Scan function

Begin BLE scan() and receive discovered results from addOnScanResult().

totemBLE.addOnScanResult(function)

Register function to receive discovered scan results TotemScanResult.
Parameter:
function - void onResult(TotemScanResult result)

status totemBLE.scan()

status totemBLE.scan(duration)

Start Bluetooth scan for Totem boards. Results will be received in function registered with addOnScanResult().
Parameter:
duration - amount of seconds to scan. [0] infinite.
Returns:
status - [true] scan is started, [false] failed to start.

totemBLE.stop()

Stop ongoing Bluetooth scan.

status totemBLE.isScanning()

Check if ongoing Bluetooth scan.
Returns:
status - [true] scanning, [false] not scanning.

totemBLE.wait()

Wait (block) until scan is stopped by duration or manually with stop().

TotemBLE totemBLE;
void setup() {
  totemBLE.scan();
  totemBLE.wait();
  // Code execution is held by "wait" function, until scan is stopped
}

Find function

Begin BLE scan looking for specific board. Result will be returned once discovered.

TotemScanResult totemBLE.findAny()

TotemScanResult totemBLE.findAny(name)

Discover any Totem board (block until found).
Parameter:
name - (optional) find board with matching name.
Returns:
TotemScanResult - scan result object.

TotemScanResult totemBLE.findMiniControlBoard()

TotemScanResult totemBLE.findRoboBoardX3()

TotemScanResult totemBLE.findRoboBoardX4()

TotemScanResult totemBLE.findMiniControlBoard(name)

TotemScanResult totemBLE.findRoboBoardX3(name)

TotemScanResult totemBLE.findRoboBoardX4(name)

Discover specific type of Totem board (block until found).
Parameter:
name - (optional) find board with matching name.
Returns:
TotemScanResult - scan result object.

TotemScanResult totemBLE.findAddress(address)

Discover Totem board matching Bluetooth address (block until found).
Parameter:
address - address Bluetooth address to find.
Returns:
TotemScanResult - scan result object.

TotemScanResult

address result.getAddress()

Get board Bluetooth address.
Returns:
address - String object containing address

name result.getName()

Get board name.
Returns:
name - String object containing name

color result.getColor()

Get board appearance color.
Returns:
color - 24-bit HEX color

color result.getModel()

Get board appearance identifier.
Note: Not used at the moment.
Returns:
color - 16-bit identifier

number result.getNumber()

Get board identification number.
Returns:
number - 8-bit id

type result.getType()

Get board type name.
Returns:
type - String of [Mini Control Board, RoboBoard X3, RoboBoard X4]

status result.isMiniControlBoard()

status result.isRoboBoardX3()

status result.isRoboBoardX4()

Is board of specific type.
Returns:
status - [true:false]