Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions build/make/Engine.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ INCLUDES := $(INCLUDES) \
-I$(INCDIR) \
-I$(INCDIR)/brainflow/utils \
-I$(INCDIR)/brainflow/board_controller \
-I$(INCDIR)/brainflow/third_party/json \
-I../../src \
-I../../priv/src \
-I$(SRCDIR) \
Expand Down
2 changes: 1 addition & 1 deletion deps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Open-Source Third Party Software included in this repository.

| Name | Version | Link | Remarks |
|---------------------|----------|-------------------------------------------------------|-----------------------------------------|
| brainflow | 4.0.1 | https://github.com/brainflow-dev/brainflow | Brainflow |
| brainflow | 5.7.0 | https://github.com/brainflow-dev/brainflow | Brainflow |
| double-conversion | 3.1.5 | https://github.com/google/double-conversion | Binary-Decimal Conversion |
| dspfilters | ?.?.? | | |
| easing | ?.?.? | http://robertpenner.com/easing/ | Easing Functions |
Expand Down
29 changes: 23 additions & 6 deletions deps/build/make/brainflow-boardcontroller.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,37 @@ INCLUDES := $(INCLUDES) \
-I$(INCDIR)/json \
-I$(INCDIR)/unicorn \
-I$(INCDIR)/brainflow/board_controller \
-I$(INCDIR)/brainflow/board_controller/ant_neuro \
-I$(INCDIR)/brainflow/board_controller/emotibit \
-I$(INCDIR)/brainflow/board_controller/enophone \
-I$(INCDIR)/brainflow/board_controller/freeeeg32 \
-I$(INCDIR)/brainflow/board_controller/gtec \
-I$(INCDIR)/brainflow/board_controller/ironbci \
-I$(INCDIR)/brainflow/board_controller/mit \
-I$(INCDIR)/brainflow/board_controller/mentalab \
-I$(INCDIR)/brainflow/board_controller/muse \
-I$(INCDIR)/brainflow/board_controller/neuromd \
-I$(INCDIR)/brainflow/board_controller/neurosity \
-I$(INCDIR)/brainflow/board_controller/openbci \
-I$(INCDIR)/brainflow/board_controller/oymotion \
-I$(INCDIR)/brainflow/ganglion-bglib \
-I$(INCDIR)/brainflow/gforcesdkcxx-wrapper \
-I$(INCDIR)/brainflow/utils
-I$(INCDIR)/brainflow/utils \
-I$(INCDIR)/brainflow/utils/bluetooth \
-I$(INCDIR)/brainflow/third_party/
CXXFLAGS := $(CXXFLAGS) -std=c++14
LINKFLAGS := $(LINKFLAGS)
LINKPATH := $(LINKPATH)
LINKLIBS := $(LINKLIBS)
OBJS = freeeeg32/freeeeg32.o \
OBJS = ant_neuro/ant_neuro.o \
emotibit/emotibit.o \
enophone/enophone.o \
freeeeg32/freeeeg32.o \
gtec/unicorn_board.o \
ironbci/ironbci.o \
mit/fascia.o \
mentalab/explore.o \
muse/muse.o \
muse/muse_bled.o \
neuromd/brainbit.o \
neuromd/brainbit_bled.o \
neuromd/callibri.o \
neuromd/callibri_ecg.o \
neuromd/callibri_eeg.o \
Expand All @@ -44,15 +55,21 @@ OBJS = freeeeg32/freeeeg32.o \
openbci/cyton_daisy_wifi.o \
openbci/cyton_wifi.o \
openbci/galea.o \
openbci/galea_serial.o \
openbci/ganglion.o \
openbci/ganglion_native.o \
openbci/ganglion_wifi.o \
openbci/openbci_serial_board.o \
openbci/openbci_wifi_shield_board.o \
oymotion/gforce_dual.o \
oymotion/gforce_pro.o \
board.o \
ble_lib_board.o \
board_controller.o \
board_info_getter.o \
board.o \
brainflow_boards.o \
bt_lib_board.o \
dyn_lib_board.o \
file_streamer.o \
multicast_streamer.o \
playback_file_board.o \
Expand Down
3 changes: 2 additions & 1 deletion deps/build/make/brainflow-datahandler.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ INCLUDES := $(INCLUDES) \
-I$(INCDIR)/fft \
-I$(INCDIR)/wavelib \
-I$(INCDIR)/brainflow/data_handler \
-I$(INCDIR)/brainflow/utils
-I$(INCDIR)/brainflow/utils \
-I$(INCDIR)/brainflow/third_party/kissfft
CXXFLAGS := $(CXXFLAGS) -std=c++14
LINKFLAGS := $(LINKFLAGS)
LINKPATH := $(LINKPATH)
Expand Down
12 changes: 5 additions & 7 deletions deps/build/make/brainflow-ml.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ INCLUDES := $(INCLUDES) \
-I$(INCDIR)/libsvm \
-I$(INCDIR)/json \
-I$(INCDIR)/brainflow/ml \
-I$(INCDIR)/brainflow/ml/onnx \
-I$(INCDIR)/brainflow/third_party/onnxruntime/build/native/include \
-I$(INCDIR)/brainflow/utils
CXXFLAGS := $(CXXFLAGS) -std=c++14
LINKFLAGS := $(LINKFLAGS)
LINKPATH := $(LINKPATH)
LINKLIBS := $(LINKLIBS)
OBJS = generated/focus_dataset.o \
generated/lda_model.o \
generated/regression_model.o \
OBJS = generated/mindfulness_model.o \
base_classifier.o \
concentration_knn_classifier.o \
concentration_lda_classifier.o \
concentration_regression_classifier.o \
concentration_svm_classifier.o \
dyn_lib_classifier.o \
mindfulness_classifier.o \
ml_module.o

ifeq ($(TARGET_ARCH),x86)
Expand Down
5 changes: 3 additions & 2 deletions deps/build/make/brainflow.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@ OBJS = cpp-package/board_shim.o \
cpp-package/data_filter.o \
cpp-package/ml_model.o \
utils/broadcast_client.o \
utils/broadcast_server.o \
utils/data_buffer.o \
utils/libftdi_serial.o \
utils/multicast_client.o \
utils/multicast_server.o \
utils/os_serial.o \
utils/os_serial_ioctl.o \
utils/os_serial.o \
utils/serial.o \
utils/socket_client_tcp.o \
utils/socket_client_udp.o \
utils/socket_server_tcp.o \
utils/socket_server_udp.o \
utils/timestamp.o

ifeq ($(TARGET_ARCH),x86)
DEFINES := $(DEFINES)
endif
Expand Down
43 changes: 43 additions & 0 deletions deps/include/brainflow/board_controller/ant_neuro/ant_neuro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include <string>
#include <thread>

#include "board.h"

#if defined __linux__ || defined _WIN32
// required to dont link ant neuro sdk
#define EEGO_SDK_BIND_DYNAMIC

#include <eemagine/sdk/amplifier.h>
#include <eemagine/sdk/stream.h>
#endif


class AntNeuroBoard : public Board
{

#if defined __linux__ || defined _WIN32
private:
volatile bool keep_alive;
bool initialized;
std::thread streaming_thread;
std::string ant_neuro_lib_path;
eemagine::sdk::amplifier *amp;
eemagine::sdk::stream *stream;
int sampling_rate;

void read_thread ();
#endif


public:
AntNeuroBoard (int board_id, struct BrainFlowInputParams params);
~AntNeuroBoard ();

int prepare_session ();
int start_stream (int buffer_size, const char *streamer_params);
int stop_stream ();
int release_session ();
int config_board (std::string config, std::string &response);
};
67 changes: 67 additions & 0 deletions deps/include/brainflow/board_controller/ble_lib_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

#include <mutex>

#include "board.h"
#include "board_controller.h"
#include "runtime_dll_loader.h"
#include "simpleble_c/types.h"


class BLELibBoard : public Board
{

private:
static DLLLoader *dll_loader;
static std::mutex mutex;

protected:
static bool init_dll_loader ();
// common
void simpleble_free (void *handle);
// adapter
size_t simpleble_adapter_get_count (void);
bool simpleble_adapter_is_bluetooth_enabled (void);
simpleble_adapter_t simpleble_adapter_get_handle (size_t index);
void simpleble_adapter_release_handle (simpleble_adapter_t handle);
simpleble_err_t simpleble_adapter_scan_for (simpleble_adapter_t handle, int timeout_ms);
simpleble_err_t simpleble_adapter_scan_start (simpleble_adapter_t handle);
simpleble_err_t simpleble_adapter_scan_stop (simpleble_adapter_t handle);
simpleble_err_t simpleble_adapter_set_callback_on_scan_start (
simpleble_adapter_t handle, void (*) (simpleble_adapter_t, void *), void *);
simpleble_err_t simpleble_adapter_set_callback_on_scan_stop (
simpleble_adapter_t handle, void (*) (simpleble_adapter_t, void *), void *);
simpleble_err_t simpleble_adapter_set_callback_on_scan_updated (simpleble_adapter_t handle,
void (*) (simpleble_adapter_t, simpleble_peripheral_t, void *), void *);
simpleble_err_t simpleble_adapter_set_callback_on_scan_found (simpleble_adapter_t handle,
void (*) (simpleble_adapter_t, simpleble_peripheral_t, void *), void *);
// peripheral
char *simpleble_peripheral_address (simpleble_peripheral_t handle);
char *simpleble_peripheral_identifier (simpleble_peripheral_t handle);
void simpleble_peripheral_release_handle (simpleble_peripheral_t handle);
simpleble_err_t simpleble_peripheral_connect (simpleble_peripheral_t handle);
simpleble_err_t simpleble_peripheral_disconnect (simpleble_peripheral_t handle);
size_t simpleble_peripheral_services_count (simpleble_peripheral_t handle);
simpleble_err_t simpleble_peripheral_services_get (
simpleble_peripheral_t handle, size_t index, simpleble_service_t *services);
simpleble_err_t simpleble_peripheral_write_request (simpleble_peripheral_t handle,
simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data,
size_t data_length);
simpleble_err_t simpleble_peripheral_write_command (simpleble_peripheral_t handle,
simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data,
size_t data_length);
simpleble_err_t simpleble_peripheral_notify (simpleble_peripheral_t handle,
simpleble_uuid_t service, simpleble_uuid_t characteristic,
void (*) (simpleble_uuid_t, simpleble_uuid_t, uint8_t *, size_t, void *), void *);
simpleble_err_t simpleble_peripheral_unsubscribe (
simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic);
size_t simpleble_peripheral_manufacturer_data_count (simpleble_peripheral_t handle);
simpleble_err_t simpleble_peripheral_manufacturer_data_get (simpleble_peripheral_t handle,
size_t index, simpleble_manufacturer_data_t *manufacturer_data);
simpleble_err_t simpleble_peripheral_is_connected (
simpleble_peripheral_t handle, bool *connected);

public:
BLELibBoard (int board_id, struct BrainFlowInputParams params);
virtual ~BLELibBoard ();
};
43 changes: 28 additions & 15 deletions deps/include/brainflow/board_controller/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cmath>
#include <deque>
#include <limits>
#include <map>
#include <string>

#include "board_controller.h"
Expand All @@ -24,7 +25,7 @@ class Board
static std::shared_ptr<spdlog::logger> board_logger;
static JNIEnv *java_jnienv; // nullptr unless on java
static int set_log_level (int log_level);
static int set_log_file (char *log_file);
static int set_log_file (const char *log_file);

virtual ~Board ()
{
Expand All @@ -36,21 +37,30 @@ class Board
Board (int board_id, struct BrainFlowInputParams params)
{
skip_logs = false;
db = NULL;
streamer = NULL;
this->board_id = board_id;
this->params = params;
try
{
board_descr = boards_struct.brainflow_boards_json["boards"][std::to_string (board_id)];
}
catch (json::exception &e)
{
safe_logger (spdlog::level::err, e.what ());
}
}
virtual int prepare_session () = 0;
virtual int start_stream (int buffer_size, char *streamer_params) = 0;
virtual int start_stream (int buffer_size, const char *streamer_params) = 0;
virtual int stop_stream () = 0;
virtual int release_session () = 0;
virtual int config_board (std::string config, std::string &response) = 0;

int get_current_board_data (int num_samples, double *data_buf, int *returned_samples);
int get_board_data_count (int *result);
int get_board_data (int data_count, double *data_buf);
int insert_marker (double value);
int get_current_board_data (
int num_samples, int preset, double *data_buf, int *returned_samples);
int get_board_data_count (int preset, int *result);
int get_board_data (int data_count, int preset, double *data_buf);
int insert_marker (double value, int preset);
int add_streamer (const char *streamer_params, int preset);
int delete_streamer (const char *streamer_params, int preset);

// Board::board_logger should not be called from destructors, to ensure that there are safe log
// methods Board::board_logger still available but should be used only outside destructors
Expand Down Expand Up @@ -81,21 +91,24 @@ class Board
}

protected:
DataBuffer *db;
std::map<int, DataBuffer *> dbs;
std::map<int, std::vector<Streamer *>> streamers;
bool skip_logs;
int board_id;
struct BrainFlowInputParams params;
Streamer *streamer;
json board_descr;
SpinLock lock;
std::deque<double> marker_queue;
std::map<int, std::deque<double>> marker_queues;

int prepare_for_acquisition (int buffer_size, char *streamer_params);
int prepare_for_acquisition (int buffer_size, const char *streamer_params);
void free_packages ();
void push_package (double *package);
void push_package (double *package, int preset = (int)BrainFlowPresets::DEFAULT_PRESET);
std::string preset_to_string (int preset);
int preset_to_int (std::string preset);
int parse_streamer_params (const char *streamer_params, std::string &streamer_type,
std::string &streamer_dest, std::string &streamer_mods);

private:
int prepare_streamer (char *streamer_params);
// reshapes data from DataBuffer format where all channels are mixed to linear buffer
void reshape_data (int data_count, const double *buf, double *output_buf);
void reshape_data (int data_count, int preset, const double *buf, double *output_buf);
};
Loading