use of org.jivesoftware.smackx.iot.Thing in project Smack by igniterealtime.
the class IoT method actAsDataThing.
private static ThingState actAsDataThing(XMPPTCPConnection connection) throws XMPPException, SmackException, InterruptedException {
final String key = StringUtils.randomString(12);
final String sn = StringUtils.randomString(12);
Thing dataThing = Thing.builder().setKey(key).setSerialNumber(sn).setManufacturer("IgniteRealtime").setModel("Smack").setVersion("0.1").setMomentaryReadOutRequestHandler(new ThingMomentaryReadOutRequest() {
@Override
public void momentaryReadOutRequest(ThingMomentaryReadOutResult callback) {
IoTDataField.IntField field = new IntField("timestamp", (int) (System.currentTimeMillis() / 1000));
callback.momentaryReadOut(Collections.singletonList(field));
}
}).build();
IoTDiscoveryManager iotDiscoveryManager = IoTDiscoveryManager.getInstanceFor(connection);
ThingState state = IoTDiscoveryIntegrationTest.registerThing(iotDiscoveryManager, dataThing);
printStatus("SUCCESS: Thing registered:" + dataThing);
return state;
}
Aggregations