MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / read_data

Method read_data

src/board_controller/aavaa/aavaa_v3.cpp:471–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471void AAVAAv3::read_data (
472 simpleble_uuid_t service, simpleble_uuid_t characteristic, const uint8_t *data, size_t size)
473{
474 safe_logger (spdlog::level::trace, "received {} number of bytes", size);
475
476 if (!is_streaming)
477 {
478 if (data[1] == 64)
479 { // when the first byte is @
480 std::string temp (reinterpret_cast<const char *> (data), size);
481 device_status = temp.substr (1);
482 safe_logger (spdlog::level::trace, "received a status string {} ", device_status);
483 }
484 else
485 {
486 safe_logger (spdlog::level::trace, "received a string with start byte {} {} {} {} {}",
487 data[0], data[1], data[2], data[3], data[4]);
488 }
489 return;
490 }
491
492 int num_rows = board_descr["default"]["num_rows"];
493
494 std::vector<int> eeg_channels = board_descr["default"]["eeg_channels"];
495
496 if (size == 244)
497 {
498 data += 3;
499 size -= 3;
500 Incoming_BLE_Data_Buffer.insert (Incoming_BLE_Data_Buffer.end (), data, data + size);
501 }
502 else if (size > 1)
503 {
504 ++data;
505 --size;
506 Incoming_BLE_Data_Buffer.insert (Incoming_BLE_Data_Buffer.end (), data, data + size);
507 }
508
509 while ((int)Incoming_BLE_Data_Buffer.size () >= SIZE_OF_DATA_FRAME)
510 {
511 if (Incoming_BLE_Data_Buffer[0] != START_BYTE)
512 {
513 Incoming_BLE_Data_Buffer.pop_front (); // discard data, we have half a frame here
514 continue;
515 }
516
517 uint8_t *data_frame = new uint8_t[SIZE_OF_DATA_FRAME];
518 for (int i = 0; i < SIZE_OF_DATA_FRAME; ++i)
519 {
520 data_frame[i] = Incoming_BLE_Data_Buffer.front ();
521 Incoming_BLE_Data_Buffer.pop_front ();
522 }
523
524 if (data_frame[SIZE_OF_DATA_FRAME - 1] != END_BYTE)
525 {
526 safe_logger (
527 spdlog::level::warn, "Wrong End Byte: {}", data_frame[SIZE_OF_DATA_FRAME - 1]);
528 continue;

Callers 1

aavaa_read_notificationsFunction · 0.45

Calls 3

cast_16bit_to_int32Function · 0.85
get_timestampFunction · 0.85
whatMethod · 0.80

Tested by

no test coverage detected