Skip to content

Commit

Permalink
Do not compile BLE companion if not used
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmicro committed Aug 19, 2023
1 parent 0f13a05 commit 72aa546
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions include/services/OswServiceTaskBLECompanion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define OSW_SERVICE_COMPANION_H

#ifndef OSW_EMULATOR
#if SERVICE_BLE_COMPANION == 1
#include <BLECharacteristic.h>
#include <BLEDevice.h>
#include <osw_hal.h>
Expand Down Expand Up @@ -42,5 +43,6 @@ class OswServiceTaskBLECompanion : public OswServiceTask {
friend class NotificationCallback;
};

#endif
#endif
#endif
2 changes: 1 addition & 1 deletion include/services/OswServiceTasks.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "osw_service.h"

class OswServiceTaskBLECompanion;
class OswServiceTaskExample;
class OswServiceTaskMemMonitor;
class OswServiceTaskNotifier;
Expand All @@ -10,6 +9,7 @@ class OswServiceTaskWebserver;
#endif
namespace OswServiceAllTasks {
#if SERVICE_BLE_COMPANION == 1
class OswServiceTaskBLECompanion;
extern OswServiceTaskBLECompanion bleCompanion;
#endif
// extern OswServiceTaskExample example;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#if defined(GPS_EDITION) || defined(GPS_EDITION_ROTATED)
#include "./apps/main/map.h"
#endif
#include "./services/OswServiceTaskBLECompanion.h"
#include "services/OswServiceTaskBLECompanion.h"
#include "services/OswServiceTaskMemMonitor.h"
#include "services/OswServiceTasks.h"
#ifdef OSW_FEATURE_WIFI
Expand Down
13 changes: 7 additions & 6 deletions src/services/OswServiceTaskBLECompanion.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#ifndef OSW_EMULATOR

#if SERVICE_BLE_COMPANION == 1
#ifdef OSW_FEATURE_WIFI
#error "The RAM on all current OSW models is not big enough to hold both WiFi AND Bluetooth stacks during runtime. This WILL lead to a crash. Please only use one of these features simultaneously!"
#endif

#include "./services/OswServiceTaskBLECompanion.h"
#include "osw_hal.h"

Expand All @@ -11,12 +17,6 @@
#include <string.h>
#include "config_defaults.h"

#ifdef OSW_FEATURE_WIFI
#if SERVICE_BLE_COMPANION == 1
#error "The RAM on all current OSW models is not big enough to hold both WiFi AND Bluetooth stacks during runtime. This WILL lead to a crash. Please only use one of these features simultaneously!"
#endif
#endif

class NotificationCallback: public BLECharacteristicCallbacks {
public:
NotificationCallback(OswServiceTaskBLECompanion* comp) {
Expand Down Expand Up @@ -94,4 +94,5 @@ void OswServiceTaskBLECompanion::loop() {
void OswServiceTaskBLECompanion::stop() {
OswServiceTask::stop();
}
#endif
#endif

0 comments on commit 72aa546

Please sign in to comment.