Skip to content

Commit

Permalink
add get_firmware_version command to ganglion boards (#686)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
  • Loading branch information
Andrey1994 committed Nov 15, 2023
1 parent 70b378c commit f9329c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/board_controller/openbci/ganglion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Ganglion::Ganglion (struct BrainFlowInputParams params)
is_valid = true;
}
use_mac_addr = (params.mac_address.empty ()) ? false : true;
firmware = 0;
is_streaming = false;
keep_alive = false;
initialized = false;
Expand Down Expand Up @@ -554,6 +555,11 @@ void Ganglion::decompress_firmware_2 (

int Ganglion::config_board (std::string config, std::string &response)
{
if (config == "get_firmware_version")
{
response = std::to_string (firmware);
return (int)BrainFlowExitCodes::STATUS_OK;
}
const char *conf = config.c_str ();
safe_logger (spdlog::level::debug, "Trying to config Ganglion with {}", conf);
// need to pause, config and restart. I have no idea why it doesnt work if I restart it inside
Expand Down
2 changes: 1 addition & 1 deletion src/board_controller/openbci/ganglion_bglib/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace GanglionLib
std::deque<struct GanglionLib::GanglionData> data_queue;
SpinLock lock;
volatile bd_addr connect_addr;
volatile uint8 firmware = 2;
volatile uint8 firmware = 0;
volatile uint8 connection = -1;
volatile uint16 ganglion_handle_start = 0;
volatile uint16 ganglion_handle_end = 0;
Expand Down
8 changes: 8 additions & 0 deletions src/board_controller/openbci/ganglion_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ GanglionNative::GanglionNative (struct BrainFlowInputParams params)
is_streaming = false;
start_command = "b";
stop_command = "s";
firmware = 0;
}

GanglionNative::~GanglionNative ()
Expand Down Expand Up @@ -316,6 +317,13 @@ int GanglionNative::release_session ()

int GanglionNative::config_board (std::string config, std::string &response)
{
// todo do smth to unify available commands
// and make them more or less standard between devices
if (config == "get_firmware_version")
{
response = std::to_string (firmware);
return (int)BrainFlowExitCodes::STATUS_OK;
}
return config_board (config);
}

Expand Down

0 comments on commit f9329c3

Please sign in to comment.