BrainBit

So far we used SDK provided by BrainBit to work with device. This SDK is good, but it supports only Windows and MacOS. It doesn’t work on Linux OS and for devices like Raspberry Pi. We added support for all possible desktop OSes and devices like Raspberry Pi using BLED112 dongle.

Also, it can be useful for PCs without built in BLE support.

In terms of BrainFlow boards it is a new board with its own board id.

For developers

Often there is a need to develop additional dynamic libraries and load them in runtime for particular board.

For example OYMotion provides only C++ library, while we need plain C interface, for BGLIB we need to wrap BGLIB callbacks by additional library and so on.

To make it easier DynLibBoard was added as a base class.

template <int N>
class DynLibBoard : public Board
{

protected:
    volatile bool keep_alive;
    bool initialized;
    bool is_streaming;
    std::thread streaming_thread;
    std::mutex m;
    std::condition_variable cv;
    volatile int state;
    DLLLoader *dll_loader;

    virtual int call_init ();
    virtual int call_open ();
    virtual int call_close ();
    virtual int call_start ();
    virtual int call_stop ();
    virtual int call_release ();
    virtual int call_config (char *config);

    virtual void read_thread ();
    virtual std::string get_lib_name () = 0;


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

    virtual int prepare_session ();
    virtual int start_stream (int buffer_size, char *streamer_params);
    virtual int stop_stream ();
    virtual int release_session ();
    virtual int config_board (std::string config, std::string &response);
};

By default it calls the following methods from a library loaded in runtime:

SHARED_EXPORT int CALLING_CONVENTION initialize (void *param);
SHARED_EXPORT int CALLING_CONVENTION open_device (void *param);
SHARED_EXPORT int CALLING_CONVENTION stop_stream (void *param);
SHARED_EXPORT int CALLING_CONVENTION start_stream (void *param);
SHARED_EXPORT int CALLING_CONVENTION close_device (void *param);
SHARED_EXPORT int CALLING_CONVENTION get_data (void *param);
SHARED_EXPORT int CALLING_CONVENTION release (void *param);
SHARED_EXPORT int CALLING_CONVENTION config_device (void *param);

You can override such methods and customize them as you need. The only method which must be implemented in subclasses is virtual std::string get_lib_name () = 0;, it should return a full path to a library or it’s name(if library is in search path).

Use code for BrainBitBLED board or OYMotion boards as an example.