Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleInitializing GatewayClient
linenumberstrue
// 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
languagejava
titleScanning for Devices (i.e. opening the permit join window)
linenumberstrue
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
languagejava
titleGetting the Properties of the Remote Device
linenumberstrue
final Device d = gw.getDevice("00244600000f1472_1");
d.getProperties();

Updating Properties

...

Conclusion

...