File tree Expand file tree Collapse file tree 2 files changed +37
-14
lines changed Expand file tree Collapse file tree 2 files changed +37
-14
lines changed Original file line number Diff line number Diff line change @@ -105,14 +105,26 @@ int BrainAlive::prepare_session ()
105
105
simpleble_adapter_scan_stop (brainalive_adapter);
106
106
if (res == (int )BrainFlowExitCodes::STATUS_OK)
107
107
{
108
- if (simpleble_peripheral_connect (brainalive_peripheral) == SIMPLEBLE_SUCCESS)
108
+ // for safety
109
+ for (int i = 0 ; i < 3 ; i++)
109
110
{
110
- safe_logger (spdlog::level::info, " Connected to BrainAlive Device" );
111
- }
112
- else
113
- {
114
- safe_logger (spdlog::level::err, " Failed to connect to BrainAlive Device" );
115
- res = (int )BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
111
+ if (simpleble_peripheral_connect (brainalive_peripheral) == SIMPLEBLE_SUCCESS)
112
+ {
113
+ safe_logger (spdlog::level::info, " Connected to BrainAlive Device" );
114
+ res = (int )BrainFlowExitCodes::STATUS_OK;
115
+ break ;
116
+ }
117
+ else
118
+ {
119
+ safe_logger (
120
+ spdlog::level::warn, " Failed to connect to BrainAlive Device: {}/3" , i);
121
+ res = (int )BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
122
+ #ifdef _WIN32
123
+ Sleep (1000 );
124
+ #else
125
+ sleep (1 );
126
+ #endif
127
+ }
116
128
}
117
129
}
118
130
else
Original file line number Diff line number Diff line change @@ -117,14 +117,25 @@ int GanglionNative::prepare_session ()
117
117
simpleble_adapter_scan_stop (ganglion_adapter);
118
118
if (res == (int )BrainFlowExitCodes::STATUS_OK)
119
119
{
120
- if (simpleble_peripheral_connect (ganglion_peripheral) == SIMPLEBLE_SUCCESS)
120
+ // for safety
121
+ for (int i = 0 ; i < 3 ; i++)
121
122
{
122
- safe_logger (spdlog::level::info, " Connected to GanglionNative Device" );
123
- }
124
- else
125
- {
126
- safe_logger (spdlog::level::err, " Failed to connect to GanglionNative Device" );
127
- res = (int )BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
123
+ if (simpleble_peripheral_connect (ganglion_peripheral) == SIMPLEBLE_SUCCESS)
124
+ {
125
+ safe_logger (spdlog::level::info, " Connected to Ganglion Device" );
126
+ res = (int )BrainFlowExitCodes::STATUS_OK;
127
+ break ;
128
+ }
129
+ else
130
+ {
131
+ safe_logger (spdlog::level::warn, " Failed to connect to Ganglion Device: {}/3" , i);
132
+ res = (int )BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
133
+ #ifdef _WIN32
134
+ Sleep (1000 );
135
+ #else
136
+ sleep (1 );
137
+ #endif
138
+ }
128
139
}
129
140
}
130
141
else
You can’t perform that action at this time.
0 commit comments