Skip to content

Commit

Permalink
fixing connection issues with ganglion native and brainalive (#644)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
  • Loading branch information
Andrey1994 committed Jul 1, 2023
1 parent 289d287 commit 67d08c7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
26 changes: 19 additions & 7 deletions src/board_controller/brainalive/brainalive.cpp
Expand Up @@ -105,14 +105,26 @@ int BrainAlive::prepare_session ()
simpleble_adapter_scan_stop (brainalive_adapter);
if (res == (int)BrainFlowExitCodes::STATUS_OK)
{
if (simpleble_peripheral_connect (brainalive_peripheral) == SIMPLEBLE_SUCCESS)
// for safety
for (int i = 0; i < 3; i++)
{
safe_logger (spdlog::level::info, "Connected to BrainAlive Device");
}
else
{
safe_logger (spdlog::level::err, "Failed to connect to BrainAlive Device");
res = (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
if (simpleble_peripheral_connect (brainalive_peripheral) == SIMPLEBLE_SUCCESS)
{
safe_logger (spdlog::level::info, "Connected to BrainAlive Device");
res = (int)BrainFlowExitCodes::STATUS_OK;
break;
}
else
{
safe_logger (
spdlog::level::warn, "Failed to connect to BrainAlive Device: {}/3", i);
res = (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
#ifdef _WIN32
Sleep (1000);
#else
sleep (1);
#endif
}
}
}
else
Expand Down
25 changes: 18 additions & 7 deletions src/board_controller/openbci/ganglion_native.cpp
Expand Up @@ -117,14 +117,25 @@ int GanglionNative::prepare_session ()
simpleble_adapter_scan_stop (ganglion_adapter);
if (res == (int)BrainFlowExitCodes::STATUS_OK)
{
if (simpleble_peripheral_connect (ganglion_peripheral) == SIMPLEBLE_SUCCESS)
// for safety
for (int i = 0; i < 3; i++)
{
safe_logger (spdlog::level::info, "Connected to GanglionNative Device");
}
else
{
safe_logger (spdlog::level::err, "Failed to connect to GanglionNative Device");
res = (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
if (simpleble_peripheral_connect (ganglion_peripheral) == SIMPLEBLE_SUCCESS)
{
safe_logger (spdlog::level::info, "Connected to Ganglion Device");
res = (int)BrainFlowExitCodes::STATUS_OK;
break;
}
else
{
safe_logger (spdlog::level::warn, "Failed to connect to Ganglion Device: {}/3", i);
res = (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
#ifdef _WIN32
Sleep (1000);
#else
sleep (1);
#endif
}
}
}
else
Expand Down

0 comments on commit 67d08c7

Please sign in to comment.