...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// example of a lambda implementation of the DeviceEventListener parameter. final GatewayClient gw = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyS1"), (event) -> { System.out.println("Device Event: " + event.getStatus()); System.out.println("Device: " + event.getDevice().getID()); } ); |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
for (ConnectionInfo c: gw.getConnectionInfo()) { gw.scanForDevices(c, 30).thenAccept( status -> { System.out.println("Status for connection " + c.getValue() + " is " + status); }); } |
...
Note: You can close the permit join window by calling "scanForDevices" with 0 as the "duration" parameter.
Interacting with Devices
When a device joins the network, you should see a DeviceEvent. For example, the lambda we passed into GatewayClient should print something like the following:
Code Block |
---|
Device Event: ADD
Device ID: 00244600000f1472_1 |
"ADD" means a new device has been added to the network.
Getting Properties
You can use the Device API to request properties of the connected device.
LightDevice
...
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
final Device d = gw.getDevice("00244600000f1472_1");
d.getProperties(); |
Updating Properties
...
Conclusion
...