Skip to content

Commit

Permalink
Revert "Don't disable bluetooth in dongle mode"
Browse files Browse the repository at this point in the history
This reverts commit 2cdfdf6.
  • Loading branch information
nisargjhaveri committed Mar 15, 2024
1 parent 2cdfdf6 commit c009830
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
26 changes: 6 additions & 20 deletions aa_wireless_dongle/package/aawg/src/aawgd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,16 @@

int main(void) {
Logger::instance()->info("AA Wireless Dongle\n");
Logger::instance()->info("Connection Strategy: %d\n", Config::instance()->getConnectionStrategy());

// Global init
std::optional<std::thread> ueventThread = UeventMonitor::instance().start();
UsbManager::instance().init();
BluetoothHandler::instance().init();

ConnectionStrategy connectionStrategy = Config::instance()->getConnectionStrategy();
if (connectionStrategy == ConnectionStrategy::DONGLE_MODE) {
BluetoothHandler::instance().powerOn();
}

while (true) {
Logger::instance()->info("Connection Strategy: %d\n", connectionStrategy);

// Per connection setup and processing
if (connectionStrategy == ConnectionStrategy::USB_FIRST) {
if (Config::instance()->getConnectionStrategy() == ConnectionStrategy::USB_FIRST) {
Logger::instance()->info("Waiting for the accessory to connect first\n");
UsbManager::instance().enableDefaultAndWaitForAccessory();
}
Expand All @@ -36,22 +30,14 @@ int main(void) {
return 1;
}

if (connectionStrategy != ConnectionStrategy::DONGLE_MODE) {
BluetoothHandler::instance().powerOn();
}

BluetoothHandler::instance().connectDevice();
BluetoothHandler::instance().connect();

proxyThread->join();

BluetoothHandler::instance().powerOff();
UsbManager::instance().disableGadget();

if (connectionStrategy != ConnectionStrategy::DONGLE_MODE) {
BluetoothHandler::instance().powerOff();

// sleep for a couple of seconds before retrying
sleep(2);
}
// sleep for a couple of seconds before retrying
sleep(2);
}

ueventThread->join();
Expand Down
7 changes: 2 additions & 5 deletions aa_wireless_dongle/package/aawg/src/bluetoothHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ void BluetoothHandler::stopAdvertising() {
}

void BluetoothHandler::connectDevice() {
if (!m_adapter) {
return;
}

DBus::ManagedObjects objects = getBluezObjects();

std::vector<std::string> device_paths;
Expand Down Expand Up @@ -240,13 +236,14 @@ void BluetoothHandler::init() {
}
}

void BluetoothHandler::powerOn() {
void BluetoothHandler::connect() {
if (!m_adapter) {
return;
}

setPower(true);
setPairable(true);
connectDevice();
}

void BluetoothHandler::powerOff() {
Expand Down
4 changes: 2 additions & 2 deletions aa_wireless_dongle/package/aawg/src/bluetoothHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class BluetoothHandler {
static BluetoothHandler& instance();

void init();
void connectDevice();
void powerOn();
void connect();
void powerOff();

private:
Expand All @@ -27,6 +26,7 @@ class BluetoothHandler {
void setPower(bool on);
void setPairable(bool pairable);
void exportProfiles();
void connectDevice();

void startAdvertising();
void stopAdvertising();
Expand Down

0 comments on commit c009830

Please sign in to comment.