Move bluetooth management in to own classes

This commit is contained in:
Robert Marshall 2021-07-30 09:31:42 +01:00
parent 0432071759
commit e1a279ee75
5 changed files with 73 additions and 39 deletions

View file

@ -0,0 +1,23 @@
#include "LED.cpp"
#include <BLEUtils.h>
class BluetoothLEDCallback : public BLECharacteristicCallbacks {
LED *_led;
void onWrite(BLECharacteristic *characteristic) {
std::string value = characteristic->getValue();
if (value.length() > 0) {
Serial.println(value.c_str());
if (value == "on")
_led->on();
else
_led->off();
}
}
public:
BluetoothLEDCallback(LED* led){
_led = led;
}
};