From 899f9678315b7da74817c30db740dcb46b2c5105 Mon Sep 17 00:00:00 2001 From: Philip Pitts <84428015+philippitts@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:16:30 -0400 Subject: [PATCH] Move Ganglion BLE connection parameters definitions to header --- src/board_controller/openbci/ganglion.cpp | 10 ++-------- .../openbci/ganglion_bglib/callbacks.cpp | 1 + .../openbci/ganglion_bglib/inc/ganglion_types.h | 7 +++++++ src/board_controller/openbci/ganglion_bglib/main.cpp | 5 ----- src/board_controller/openbci/ganglion_native.cpp | 6 ++++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/board_controller/openbci/ganglion.cpp b/src/board_controller/openbci/ganglion.cpp index c267d3294..8a10b2813 100644 --- a/src/board_controller/openbci/ganglion.cpp +++ b/src/board_controller/openbci/ganglion.cpp @@ -10,6 +10,7 @@ #include "custom_cast.h" #include "ganglion.h" +#include "ganglion_types.h" #include "get_dll_dir.h" @@ -397,7 +398,6 @@ void Ganglion::read_thread () } void Ganglion::decompress_firmware_3 ( - struct GanglionLib::GanglionData *data, float *last_data, double *acceleration) { int bits_per_num = 0; @@ -642,13 +642,7 @@ int Ganglion::call_open () safe_logger (spdlog::level::info, "search for {}", params.mac_address.c_str ()); - struct ConnectionParameters - { - char *mac_address; - uint8_t firmware; - }; - - ConnectionParameters connection_params; + GanglionLib::ConnectionParameters connection_params; connection_params.mac_address = const_cast (params.mac_address.c_str ()); connection_params.firmware = 2; diff --git a/src/board_controller/openbci/ganglion_bglib/callbacks.cpp b/src/board_controller/openbci/ganglion_bglib/callbacks.cpp index 3e23c7274..517351375 100644 --- a/src/board_controller/openbci/ganglion_bglib/callbacks.cpp +++ b/src/board_controller/openbci/ganglion_bglib/callbacks.cpp @@ -77,6 +77,7 @@ void ble_evt_gap_scan_response (const struct ble_msg_gap_scan_response_evt_t *ms GanglionLib::firmware = 3; } + // Check if the found device is the one specified by the serial_number parameter if (memcmp (msg->sender.addr, (uint8 *)GanglionLib::connect_addr.addr, sizeof (bd_addr)) == 0) { diff --git a/src/board_controller/openbci/ganglion_bglib/inc/ganglion_types.h b/src/board_controller/openbci/ganglion_bglib/inc/ganglion_types.h index c99cdc654..73ae4feb0 100644 --- a/src/board_controller/openbci/ganglion_bglib/inc/ganglion_types.h +++ b/src/board_controller/openbci/ganglion_bglib/inc/ganglion_types.h @@ -1,6 +1,7 @@ #pragma once #include "shared_export.h" +#include #include namespace GanglionLib @@ -86,4 +87,10 @@ namespace GanglionLib INVALID_MAC_ADDR_ERROR = 17, PORT_OPEN_ERROR = 18 }; + + struct ConnectionParameters + { + char *mac_address; + uint8_t firmware; + }; } \ No newline at end of file diff --git a/src/board_controller/openbci/ganglion_bglib/main.cpp b/src/board_controller/openbci/ganglion_bglib/main.cpp index d0ee59826..7f223e041 100644 --- a/src/board_controller/openbci/ganglion_bglib/main.cpp +++ b/src/board_controller/openbci/ganglion_bglib/main.cpp @@ -108,11 +108,6 @@ namespace GanglionLib exit_code = (int)CustomExitCodes::SYNC_ERROR; state = State::OPEN_CALLED; - struct ConnectionParameters - { - char *mac_address; - uint8_t firmware; - }; ConnectionParameters *connection_parameters = (ConnectionParameters *)param; char *mac_addr = connection_parameters->mac_address; diff --git a/src/board_controller/openbci/ganglion_native.cpp b/src/board_controller/openbci/ganglion_native.cpp index 55e421425..19ddbb954 100644 --- a/src/board_controller/openbci/ganglion_native.cpp +++ b/src/board_controller/openbci/ganglion_native.cpp @@ -445,8 +445,10 @@ void GanglionNative::adapter_1_on_scan_found ( if (found) { firmware = strncmp (peripheral_identified, "Ganglion 1.3", 12) == 0 ? 3 : 2; - std::lock_guard lk (m); - ganglion_peripheral = peripheral; + { + std::lock_guard lk (m); + ganglion_peripheral = peripheral; + } cv.notify_one (); } else