Browse Source

Allow changing color via REST request

fastled
Xose Pérez 7 years ago
parent
commit
53d7890a85
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      code/espurna/light.ino

+ 19
- 0
code/espurna/light.ino View File

@ -158,6 +158,24 @@ void lightMQTTCallback(unsigned int type, const char * topic, const char * paylo
} }
//------------------------------------------------------------------------------
// REST API
//------------------------------------------------------------------------------
void lightSetupAPI() {
// API entry points (protected with apikey)
apiRegister("/api/color", "color",
[](char * buffer, size_t len) {
snprintf(buffer, len, "%s", lightColor().c_str());
},
[](const char * payload) {
lightColor(payload, true, mqttForward());
}
);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// SETUP // SETUP
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -181,6 +199,7 @@ void lightSetup() {
lightColorRetrieve(); lightColorRetrieve();
mqttRegister(lightMQTTCallback); mqttRegister(lightMQTTCallback);
lightSetupAPI();
} }


Loading…
Cancel
Save