Skip to content

Commit

Permalink
Move Ganglion BLE connection parameters definitions to header
Browse files Browse the repository at this point in the history
  • Loading branch information
philippitts committed Aug 3, 2023
1 parent 4579b82 commit 016c66c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
10 changes: 2 additions & 8 deletions src/board_controller/openbci/ganglion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "custom_cast.h"
#include "ganglion.h"
#include "ganglion_types.h"
#include "get_dll_dir.h"


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<char *> (params.mac_address.c_str ());
connection_params.firmware = 2;

Expand Down
1 change: 1 addition & 0 deletions src/board_controller/openbci/ganglion_bglib/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ namespace GanglionLib
INVALID_MAC_ADDR_ERROR = 17,
PORT_OPEN_ERROR = 18
};

struct ConnectionParameters
{
char *mac_address;
uint8_t firmware;
};
}
5 changes: 0 additions & 5 deletions src/board_controller/openbci/ganglion_bglib/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/board_controller/openbci/ganglion_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> lk (m);
ganglion_peripheral = peripheral;
{
std::lock_guard<std::mutex> lk (m);
ganglion_peripheral = peripheral;
}
cv.notify_one ();
}
else
Expand Down

0 comments on commit 016c66c

Please sign in to comment.