Add control from JSON payload
This commit is contained in:
parent
eacb06c0ae
commit
44b91c86f2
4 changed files with 48 additions and 25 deletions
|
@ -1,36 +1,17 @@
|
|||
#include "LED.cpp"
|
||||
#include "JsonLightControl.cpp"
|
||||
#include <BLEUtils.h>
|
||||
|
||||
class BluetoothLEDCallback : public BLECharacteristicCallbacks {
|
||||
LED *_seatingLeds, *_kitchenLeds;
|
||||
JsonLightControl *_lightControl;
|
||||
|
||||
void onWrite(BLECharacteristic *characteristic) {
|
||||
std::string value = characteristic->getValue();
|
||||
if (value.length() > 0) {
|
||||
Serial.println(value.c_str());
|
||||
if (value == "all on"){
|
||||
_seatingLeds->on();
|
||||
_kitchenLeds->on();
|
||||
}
|
||||
if (value == "all off"){
|
||||
_seatingLeds->off();
|
||||
_kitchenLeds->off();
|
||||
}
|
||||
if (value == "seating on")
|
||||
_seatingLeds->on();
|
||||
if (value == "kitchen on")
|
||||
_kitchenLeds->on();
|
||||
if (value == "seating off")
|
||||
_seatingLeds->off();
|
||||
if (value == "kitchen off")
|
||||
_kitchenLeds->off();
|
||||
}
|
||||
_lightControl->action(value);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
BluetoothLEDCallback(LED *seatingLeds, LED *kitchenLeds){
|
||||
_seatingLeds = seatingLeds;
|
||||
_kitchenLeds = kitchenLeds;
|
||||
BluetoothLEDCallback(JsonLightControl *lightControl){
|
||||
_lightControl = lightControl;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue