Retransmit changes to keep clients in sync
This commit is contained in:
parent
75f79fcd90
commit
09711d12d0
2 changed files with 7 additions and 3 deletions
|
@ -3,10 +3,13 @@
|
|||
|
||||
class BluetoothLEDCallback : public BLECharacteristicCallbacks {
|
||||
JsonLightControl *_lightControl;
|
||||
std::string _json;
|
||||
|
||||
void onWrite(BLECharacteristic *characteristic) {
|
||||
std::string value = characteristic->getValue();
|
||||
_lightControl->action(value);
|
||||
_json = characteristic->getValue();
|
||||
_lightControl->action(_json);
|
||||
characteristic->setValue(_json);
|
||||
characteristic->indicate();
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -26,11 +26,12 @@ public:
|
|||
|
||||
void init() {
|
||||
BLEDevice::init(_serviceName);
|
||||
//BLEDevice::setMTU(517);
|
||||
_server = BLEDevice::createServer();
|
||||
_service = _server->createService(SERVICE_UUID);
|
||||
_server->setCallbacks(new BLEAdvertisingRestartCallback());
|
||||
|
||||
_characteristic = _service->createCharacteristic(CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE);
|
||||
_characteristic = _service->createCharacteristic(CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_INDICATE);
|
||||
_characteristic->setCallbacks(_callbacks);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue