Skip to content

Commit 73f097f

Browse files
committed
Include BLE stuff only for boards which support BLE
1 parent 28f24b9 commit 73f097f

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/Arduino_BHY2Host.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "Arduino_BHY2Host.h"
22

33
#include "EslovHandler.h"
4-
#include "BLEHandler.h"
54
#include "sensors/SensorManager.h"
65

76
Arduino_BHY2Host::Arduino_BHY2Host() :
@@ -20,10 +19,17 @@ bool Arduino_BHY2Host::begin(bool passthrough, NiclaWiring niclaConnection)
2019
_passthrough = passthrough;
2120
_wiring = niclaConnection;
2221
if (niclaConnection == NICLA_VIA_BLE) {
22+
#ifdef __BHY2_HOST_BLE_SUPPORTED__
2323
if (_debug) {
2424
_debug->println("NICLA_VIA_BLE selected");
2525
}
2626
return bleHandler.begin();
27+
#else
28+
if (_debug) {
29+
_debug->println("Unsupported board!");
30+
}
31+
return false;
32+
#endif
2733
}
2834
if (niclaConnection == NICLA_AS_SHIELD) {
2935
eslovHandler.niclaAsShield();
@@ -34,7 +40,9 @@ bool Arduino_BHY2Host::begin(bool passthrough, NiclaWiring niclaConnection)
3440
void Arduino_BHY2Host::update()
3541
{
3642
if (_wiring == NICLA_VIA_BLE) {
43+
#ifdef __BHY2_HOST_BLE_SUPPORTED__
3744
bleHandler.update();
45+
#endif
3846
} else {
3947
if (_passthrough){
4048
eslovHandler.update();
@@ -57,7 +65,9 @@ void Arduino_BHY2Host::update(unsigned long ms)
5765
void Arduino_BHY2Host::configureSensor(SensorConfigurationPacket& config)
5866
{
5967
if (_wiring == NICLA_VIA_BLE) {
68+
#ifdef __BHY2_HOST_BLE_SUPPORTED__
6069
bleHandler.writeConfigPacket(config);
70+
#endif
6171
} else {
6272
eslovHandler.writeConfigPacket(config);
6373
}
@@ -70,7 +80,9 @@ void Arduino_BHY2Host::configureSensor(uint8_t sensorId, float sampleRate, uint3
7080
config.sampleRate = sampleRate;
7181
config.latency = latency;
7282
if (_wiring == NICLA_VIA_BLE) {
83+
#ifdef __BHY2_HOST_BLE_SUPPORTED__
7384
bleHandler.writeConfigPacket(config);
85+
#endif
7486
} else {
7587
eslovHandler.writeConfigPacket(config);
7688
}
@@ -115,7 +127,9 @@ void Arduino_BHY2Host::debug(Stream &stream)
115127
{
116128
_debug = &stream;
117129
eslovHandler.debug(stream);
130+
#ifdef __BHY2_HOST_BLE_SUPPORTED__
118131
bleHandler.debug(stream);
132+
#endif
119133
}
120134

121135
Arduino_BHY2Host BHY2Host;

src/Arduino_BHY2Host.h

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
#include "sensors/SensorID.h"
1616

17+
#if defined(ARDUINO_PORTENTA_H7) || defined(ARDUINO_SAMD_MKRWIFI1010)
18+
#define __BHY2_HOST_BLE_SUPPORTED__
19+
#include "BLEHandler.h"
20+
#endif
21+
1722
enum NiclaWiring {
1823
NICLA_VIA_ESLOV = 0,
1924
NICLA_AS_SHIELD,

src/BLEHandler.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#include "Arduino_BHY2Host.h"
2+
3+
#ifdef __BHY2_HOST_BLE_SUPPORTED__
4+
15
#include "BLEHandler.h"
26
#include "sensors/SensorManager.h"
37

@@ -193,3 +197,5 @@ void BLEHandler::debug(Stream &stream)
193197
}
194198

195199
BLEHandler bleHandler;
200+
201+
#endif //__BHY2_HOST_BLE_SUPPORTED__

src/BLEHandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ class BLEHandler {
2929

3030
extern BLEHandler bleHandler;
3131

32-
#endif
32+
#endif

0 commit comments

Comments
 (0)