Installation#
The library comes prebuilt in the BrainAccess SDK, one archive per platform:
Platform |
Archive |
Requirements |
|---|---|---|
Windows x64 |
|
Windows 10 or newer with Bluetooth LE |
Linux x86-64 |
|
glibc 2.28 or newer, |
Linux arm64 (64-bit Raspberry Pi OS) |
|
glibc 2.28 or newer, |
macOS 11 or newer, Apple silicon and Intel |
|
Bluetooth permission for the application |
Unpack it anywhere. Every archive has the same layout:
Path |
Contents |
|---|---|
|
The C headers. Include |
|
Linux: |
|
Windows only: |
|
The Examples and a CMake project that builds them against the SDK. |
|
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.dllin 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.0installed aslibbacore.so.4(the name the executable asks for), found through an rpath such as$ORIGINorLD_LIBRARY_PATH.- macOS
libbacore.4.0.0.dylibinstalled aslibbacore.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_indexselects 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 inba_ble_device::mac_address. The application, or the terminal it is started from, needs Bluetooth permission (System Settings › Privacy & Security › Bluetooth); an application bundle declaresNSBluetoothAlwaysUsageDescriptionin itsInfo.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#
Insert a Bluetooth adapter if the computer has none built in.
Turn on the BrainAccess device.
Find its name with
ba_core_scan()or the operating system’s Bluetooth settings. The name, such asBA MINI 018, is also printed on the back of the device.Pass that name to
ba_eeg_manager_connect(); see Examples.