Skip to content

Commit 1117602

Browse files
authored
Updated_Data_Formated_BrainAlive (#714)
* update brainalive format
1 parent 778993c commit 1117602

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

src/board_controller/brainalive/brainalive.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "timestamp.h"
77

88
// common constants
9-
#define BRAINALIVE_PACKET_SIZE 46
9+
#define BRAINALIVE_PACKET_SIZE 224
1010

1111
// info about services and chars
1212
#define START_BYTE 0x0A
@@ -206,11 +206,11 @@ int BrainAlive::start_stream (int buffer_size, const char *streamer_params)
206206
int res = prepare_for_acquisition (buffer_size, streamer_params);
207207
if (res == (int)BrainFlowExitCodes::STATUS_OK)
208208
{
209-
res = config_board ("0a8000000d");
209+
res = config_board ("0a8100000d");
210210
}
211211
if (res == (int)BrainFlowExitCodes::STATUS_OK)
212212
{
213-
safe_logger (spdlog::level::debug, "Start command Send 0x8000000d");
213+
safe_logger (spdlog::level::debug, "Start command Send 250sps");
214214
is_streaming = true;
215215
}
216216

@@ -303,10 +303,11 @@ int BrainAlive::config_board (std::string config)
303303
uint8_t command[5];
304304
size_t len = config.size ();
305305
command[0] = 0x0a;
306-
command[1] = config[2] << 4;
306+
command[1] = 0x81; // it is hardcoded for now only
307307
command[2] = 0x00;
308308
command[3] = 0x00;
309309
command[4] = 0x0d;
310+
safe_logger (spdlog::level::trace, config[2]);
310311
if (simpleble_peripheral_write_command (brainalive_peripheral, write_characteristics.first,
311312
write_characteristics.second, command, sizeof (command)) != SIMPLEBLE_SUCCESS)
312313
{
@@ -340,7 +341,7 @@ void BrainAlive::adapter_1_on_scan_found (
340341
}
341342
else
342343
{
343-
if (strncmp (peripheral_identified, "BrainAlive", 10) == 0)
344+
if (strncmp (peripheral_identified, "ADS_TES", 7) == 0)
344345
{
345346
found = true;
346347
}
@@ -375,18 +376,15 @@ void BrainAlive::read_data (simpleble_uuid_t service, simpleble_uuid_t character
375376
return;
376377
}
377378

378-
if ((data[0] == START_BYTE) && (data[45] == STOP_BYTE))
379+
for (int i = 0; i < (int)size; i += 32)
379380
{
380-
int32_t ppg_data[3] = {0};
381-
int32_t axl_data[3] = {0};
382-
double eeg_data[8] = {0};
383-
for (int i = 4, j = 0; i < 28; i += 3, j++)
384-
eeg_data[j] = (((data[i] << 16 | data[i + 1] << 8 | data[i + 2]) << 8) >> 8) *
381+
double eeg_data[9] = {0};
382+
for (int j = i + 4, k = 0; j < i + 28; j += 3, k++)
383+
{
384+
eeg_data[k] = (((data[j] << 16 | data[j + 1] << 8 | data[j + 2]) << 8) >> 8) *
385385
BRAINALIVE_EEG_SCALE_FACTOR / BRAINALIVE_EEG_GAIN_VALUE;
386-
for (int i = 28, j = 0; i < 37; i += 3, j++)
387-
ppg_data[j] = ((data[i] << 16 | data[i + 1] << 8 | data[i + 2]) & 0x7FFFF);
388-
for (int i = 37, j = 0; i < 43; i += 2, j++)
389-
axl_data[j] = ((data[i] << 8 | data[i + 1]) << 16) >> 16;
386+
}
387+
eeg_data[8] = data[i + 29];
390388
push_package (&eeg_data[0]);
391389
}
392390
}

0 commit comments

Comments
 (0)