Skip to content

Commit

Permalink
Fix radio config endpoint (#373)
Browse files Browse the repository at this point in the history
* Use correct constant for number of remote configs

* rename route: /radio_configs -> /remote_configs, as this is what is being listed.  radio configs are lower level.
  • Loading branch information
sidoh authored Jan 6, 2019
1 parent 60c924c commit 2a7ff6d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ If you want to wire up your own LED on a pin, such as on D2/GPIO4, put a wire fr
1. `POST /firmware`. OTA firmware update.
1. `GET /settings`. Gets current settings as JSON.
1. `PUT /settings`. Patches settings (e.g., doesn't overwrite keys that aren't present). Accepts a JSON blob in the body.
1. `GET /radio_configs`. Get a list of supported radio configs (aka `device_type`s).
1. `GET /remote_configs`. Get a list of supported remote configs (aka `device_type`s).
1. `GET /gateway_traffic(/:device_type)?`. Starts an HTTP long poll. Returns any Milight traffic it hears. Useful if you need to know what your Milight gateway/remote ID is. Since protocols for RGBW/CCT are different, specify one of `rgbw`, `cct`, or `rgb_cct` as `:device_type. The path `/gateway_traffic` without a `:device_type` will sniff for all protocols simultaneously.
1. `PUT /gateways/:device_id/:device_type/:group_id`. Controls or sends commands to `:group_id` from `:device_id`. Accepts a JSON blob. The schema is documented below in the _Bulb commands_ section.
1. `GET /gateways/:device_id/:device_type/:group_id`. Returns a JSON blob describing the state of the the provided group.
Expand Down
4 changes: 2 additions & 2 deletions lib/WebServer/MiLightHttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void MiLightHttpServer::begin() {
server.onAuthenticated("/settings", HTTP_GET, [this]() { serveSettings(); });
server.onAuthenticated("/settings", HTTP_PUT, [this]() { handleUpdateSettings(); });
server.onAuthenticated("/settings", HTTP_POST, [this]() { handleUpdateSettingsPost(); }, handleUpdateFile(SETTINGS_FILE));
server.onAuthenticated("/radio_configs", HTTP_GET, [this]() { handleGetRadioConfigs(); });
server.onAuthenticated("/remote_configs", HTTP_GET, [this]() { handleGetRadioConfigs(); });

server.onAuthenticated("/gateway_traffic", HTTP_GET, [this]() { handleListenGateway(NULL); });
server.onPatternAuthenticated("/gateway_traffic/:type", HTTP_GET, [this](const UrlTokenBindings* b) { handleListenGateway(b); });
Expand Down Expand Up @@ -133,7 +133,7 @@ void MiLightHttpServer::handleGetRadioConfigs() {
DynamicJsonBuffer buffer;
JsonArray& arr = buffer.createArray();

for (size_t i = 0; i < MiLightRadioConfig::NUM_CONFIGS; i++) {
for (size_t i = 0; i < MiLightRemoteConfig::NUM_REMOTES; i++) {
const MiLightRemoteConfig* config = MiLightRemoteConfig::ALL_REMOTES[i];
arr.add(config->name);
}
Expand Down

0 comments on commit 2a7ff6d

Please sign in to comment.