Installation#

The library comes prebuilt in the BrainAccess SDK, one archive per platform:

Platform

Archive

Requirements

Windows x64

BrainAccessSDK-4.0.0-win_amd64.zip

Windows 10 or newer with Bluetooth LE

Linux x86-64

BrainAccessSDK-4.0.0-linux_x86_64.tar.gz

glibc 2.28 or newer, libdbus-1.so.3, libstdc++, BlueZ

Linux arm64 (64-bit Raspberry Pi OS)

BrainAccessSDK-4.0.0-linux_aarch64.tar.gz

glibc 2.28 or newer, libdbus-1.so.3, libstdc++, BlueZ

macOS 11 or newer, Apple silicon and Intel

BrainAccessSDK-4.0.0-macos_universal.tar.gz

Bluetooth permission for the application

Unpack it anywhere. Every archive has the same layout:

Path

Contents

include/

The C headers. Include bacore.h and eeg_manager.h; they pull in the others.

lib/

Linux: libbacore.so.4.0.0 with the links libbacore.so.4 and libbacore.so. macOS: libbacore.4.0.0.dylib with the links libbacore.4.dylib and libbacore.dylib. Windows: bacore.lib, the import library to link against.

bin/

Windows only: bacore.dll, signed by NEUROTECHNOLOGY UAB.

examples/

The Examples and a CMake project that builds them against the SDK.

python_api/

The BrainAccess Python API for this platform; see Python API.

Building an application#

With CMake, describe the library as an imported target, as examples/CMakeLists.txt does, and link it. Set BACORE_SDK to the unpacked folder:

add_library(bacore SHARED IMPORTED)
set_target_properties(bacore PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${BACORE_SDK}/include")
if (WIN32)
    set_target_properties(bacore PROPERTIES
        IMPORTED_LOCATION "${BACORE_SDK}/bin/bacore.dll"
        IMPORTED_IMPLIB "${BACORE_SDK}/lib/bacore.lib")
elseif (APPLE)
    set_target_properties(bacore PROPERTIES IMPORTED_LOCATION "${BACORE_SDK}/lib/libbacore.dylib")
else ()
    set_target_properties(bacore PROPERTIES IMPORTED_LOCATION "${BACORE_SDK}/lib/libbacore.so")
endif ()

target_link_libraries(my_app PRIVATE bacore)

Or from the command line, with SDK the unpacked folder:

Linux and macOS
$ cc app.c -I SDK/include -L SDK/lib -lbacore -Wl,-rpath,"$PWD/SDK/lib" -o app
Windows (Visual Studio developer prompt)
> cl app.c /I SDK\include SDK\lib\bacore.lib
> copy SDK\bin\bacore.dll .

Check at start-up that the loaded library matches the headers you built with:

const ba_version expected = {4, 0, 0};
if (!ba_is_version_compatible(&expected, ba_core_get_version()))
{
    /* major or minor version differs */
}

Shipping an application#

Ship the library with your application, where the system loader finds it:

Windows

bacore.dll in the folder of the executable. The C runtime is linked into the DLL, so no Visual C++ redistributable is needed.

Linux

libbacore.so.4.0.0 installed as libbacore.so.4 (the name the executable asks for), found through an rpath such as $ORIGIN or LD_LIBRARY_PATH.

macOS

libbacore.4.0.0.dylib installed as libbacore.4.dylib. Its install name is @rpath/libbacore.4.dylib, so the executable needs an rpath to its folder, for example @executable_path/../Frameworks.

Platform notes#

Linux

The Bluetooth service (bluetoothd) must be running and the adapter powered on (bluetoothctl power on). With several controllers, sBACORE_Config_t::adapter_index selects one; it is ignored on Windows and macOS, which use the system default.

macOS

The library is signed by NEUROTECHNOLOGY UAB but not notarized. If the archive was downloaded with a web browser, macOS refuses to load it until the quarantine flag is removed from the unpacked folder:

$ xattr -dr com.apple.quarantine BrainAccessSDK-4.0.0-macos_universal

CoreBluetooth does not reveal device MAC addresses: ba_core_scan() reports the 36-character UUID CoreBluetooth identifies the device by in ba_ble_device::mac_address. The application, or the terminal it is started from, needs Bluetooth permission (System Settings › Privacy & Security › Bluetooth); an application bundle declares NSBluetoothAlwaysUsageDescription in its Info.plist.

Python API#

python_api/ holds the brainaccess Python package for the same platform, built on this library; it is also published on PyPI. Install it with pip, for example on Linux x86-64:

$ pip install python_api/brainaccess-4.0.0-py3-none-manylinux_2_28_x86_64.whl

Connecting a device#

  1. Insert a Bluetooth adapter if the computer has none built in.

  2. Turn on the BrainAccess device.

  3. Find its name with ba_core_scan() or the operating system’s Bluetooth settings. The name, such as BA MINI 018, is also printed on the back of the device.

  4. Pass that name to ba_eeg_manager_connect(); see Examples.