mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-04 14:14:17 -04:00
Add Nanoleaf support
This commit is contained in:
committed by
Adam Honse
parent
7faa3b4875
commit
79b49873ec
40
Controllers/NanoleafController/NanoleafControllerDetect.cpp
Normal file
40
Controllers/NanoleafController/NanoleafControllerDetect.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "Detector.h"
|
||||
#include "RGBController_Nanoleaf.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
/*----------------------------------------------------------------------------------------*\
|
||||
| |
|
||||
| DetectNanoleafControllers |
|
||||
| |
|
||||
| Connect to paired Nanoleaf devices |
|
||||
| |
|
||||
\*----------------------------------------------------------------------------------------*/
|
||||
|
||||
void DetectNanoleafControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices");
|
||||
|
||||
if(nanoleaf_settings.contains("devices"))
|
||||
{
|
||||
for(json::const_iterator it = nanoleaf_settings["devices"].begin(); it != nanoleaf_settings["devices"].end(); ++it)
|
||||
{
|
||||
const json& device = it.value();
|
||||
|
||||
if(device.contains("ip") && device.contains("port") && device.contains("auth_token"))
|
||||
{
|
||||
try
|
||||
{
|
||||
RGBController_Nanoleaf* rgb_controller = new RGBController_Nanoleaf(device["ip"], device["port"], device["auth_token"]);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
LOG_DEBUG("[Nanoleaf] Could not connect to device at %s:%s using auth_token %s", device["ip"], device["port"], device["auth_token"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* DetectNanoleafControllers() */
|
||||
|
||||
REGISTER_DETECTOR("Nanoleaf", DetectNanoleafControllers);
|
||||
Reference in New Issue
Block a user