Move bluetooth management in to own classes
This commit is contained in:
parent
0432071759
commit
e1a279ee75
5 changed files with 73 additions and 39 deletions
23
src/BluetoothLEDCallback.cpp
Normal file
23
src/BluetoothLEDCallback.cpp
Normal 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;
|
||||
}
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue