|
6 | 6 | #include "timestamp.h" |
7 | 7 |
|
8 | 8 | // common constants |
9 | | -#define BRAINALIVE_PACKET_SIZE 46 |
| 9 | +#define BRAINALIVE_PACKET_SIZE 224 |
10 | 10 |
|
11 | 11 | // info about services and chars |
12 | 12 | #define START_BYTE 0x0A |
@@ -206,11 +206,11 @@ int BrainAlive::start_stream (int buffer_size, const char *streamer_params) |
206 | 206 | int res = prepare_for_acquisition (buffer_size, streamer_params); |
207 | 207 | if (res == (int)BrainFlowExitCodes::STATUS_OK) |
208 | 208 | { |
209 | | - res = config_board ("0a8000000d"); |
| 209 | + res = config_board ("0a8100000d"); |
210 | 210 | } |
211 | 211 | if (res == (int)BrainFlowExitCodes::STATUS_OK) |
212 | 212 | { |
213 | | - safe_logger (spdlog::level::debug, "Start command Send 0x8000000d"); |
| 213 | + safe_logger (spdlog::level::debug, "Start command Send 250sps"); |
214 | 214 | is_streaming = true; |
215 | 215 | } |
216 | 216 |
|
@@ -303,10 +303,11 @@ int BrainAlive::config_board (std::string config) |
303 | 303 | uint8_t command[5]; |
304 | 304 | size_t len = config.size (); |
305 | 305 | command[0] = 0x0a; |
306 | | - command[1] = config[2] << 4; |
| 306 | + command[1] = 0x81; // it is hardcoded for now only |
307 | 307 | command[2] = 0x00; |
308 | 308 | command[3] = 0x00; |
309 | 309 | command[4] = 0x0d; |
| 310 | + safe_logger (spdlog::level::trace, config[2]); |
310 | 311 | if (simpleble_peripheral_write_command (brainalive_peripheral, write_characteristics.first, |
311 | 312 | write_characteristics.second, command, sizeof (command)) != SIMPLEBLE_SUCCESS) |
312 | 313 | { |
@@ -340,7 +341,7 @@ void BrainAlive::adapter_1_on_scan_found ( |
340 | 341 | } |
341 | 342 | else |
342 | 343 | { |
343 | | - if (strncmp (peripheral_identified, "BrainAlive", 10) == 0) |
| 344 | + if (strncmp (peripheral_identified, "ADS_TES", 7) == 0) |
344 | 345 | { |
345 | 346 | found = true; |
346 | 347 | } |
@@ -375,18 +376,15 @@ void BrainAlive::read_data (simpleble_uuid_t service, simpleble_uuid_t character |
375 | 376 | return; |
376 | 377 | } |
377 | 378 |
|
378 | | - if ((data[0] == START_BYTE) && (data[45] == STOP_BYTE)) |
| 379 | + for (int i = 0; i < (int)size; i += 32) |
379 | 380 | { |
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) * |
385 | 385 | 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]; |
390 | 388 | push_package (&eeg_data[0]); |
391 | 389 | } |
392 | 390 | } |
0 commit comments