diff --git a/src/main/java/de/games/nanoleaf/server/NanoleafServer.java b/src/main/java/de/games/nanoleaf/server/NanoleafServer.java new file mode 100644 index 0000000..893a108 --- /dev/null +++ b/src/main/java/de/games/nanoleaf/server/NanoleafServer.java @@ -0,0 +1,54 @@ +package de.games.nanoleaf.server; + +import java.util.List; + +import io.github.rowak.nanoleafapi.util.NanoleafDeviceMeta; +import io.github.rowak.nanoleafapi.util.NanoleafSetup; + +/** + * https://github.com/amybytes/nanoleaf-api + * + */ + +public class NanoleafServer { + + List m_nanoleafDeviceList = null; + public List getNanoleafDeviceList() { return m_nanoleafDeviceList; } + + public NanoleafServer() { + + int timeout = 2000; + + /* + * 192.168.178.138 Nanoleaf 4D + * + * 192.168.178.139 Nanoleaf Canvas P17 + */ + + try { + m_nanoleafDeviceList = NanoleafSetup.findNanoleafDevices(timeout); + + System.out.println("Nano Devices: " + m_nanoleafDeviceList.size()); + + NanoleafDeviceMeta meta = null; + + if (getNanoleafDeviceList().size() > 0) { + meta = getNanoleafDeviceList().get(0); + String accessToken = NanoleafSetup.createAccessToken(meta.getHostName(), meta.getPort()); + + System.out.println("accessToken: " + accessToken); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + public static void main(String[] args) { + new NanoleafServer(); + + } + +}