Search in sources :

Example 1 with IoTDiscoveryManager

use of org.jivesoftware.smackx.iot.discovery.IoTDiscoveryManager in project Smack by igniterealtime.

the class IoTDiscoveryIntegrationTest method checkPrerequisites.

static void checkPrerequisites(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, TestNotPossibleException {
    IoTDiscoveryManager discoveryManager = IoTDiscoveryManager.getInstanceFor(connection);
    Jid registry = discoveryManager.findRegistry();
    if (registry == null) {
        throw new TestNotPossibleException("Could not find IoT Registry");
    }
}
Also used : TestNotPossibleException(org.igniterealtime.smack.inttest.TestNotPossibleException) Jid(org.jxmpp.jid.Jid) IoTDiscoveryManager(org.jivesoftware.smackx.iot.discovery.IoTDiscoveryManager)

Example 2 with IoTDiscoveryManager

use of org.jivesoftware.smackx.iot.discovery.IoTDiscoveryManager 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;
}
Also used : ThingMomentaryReadOutResult(org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutResult) ThingMomentaryReadOutRequest(org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest) IoTDiscoveryManager(org.jivesoftware.smackx.iot.discovery.IoTDiscoveryManager) ThingState(org.jivesoftware.smackx.iot.discovery.ThingState) IntField(org.jivesoftware.smackx.iot.data.element.IoTDataField.IntField) IntField(org.jivesoftware.smackx.iot.data.element.IoTDataField.IntField) IoTDataField(org.jivesoftware.smackx.iot.data.element.IoTDataField) Thing(org.jivesoftware.smackx.iot.Thing)

Aggregations

IoTDiscoveryManager (org.jivesoftware.smackx.iot.discovery.IoTDiscoveryManager)2 TestNotPossibleException (org.igniterealtime.smack.inttest.TestNotPossibleException)1 Thing (org.jivesoftware.smackx.iot.Thing)1 ThingMomentaryReadOutRequest (org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest)1 ThingMomentaryReadOutResult (org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutResult)1 IoTDataField (org.jivesoftware.smackx.iot.data.element.IoTDataField)1 IntField (org.jivesoftware.smackx.iot.data.element.IoTDataField.IntField)1 ThingState (org.jivesoftware.smackx.iot.discovery.ThingState)1 Jid (org.jxmpp.jid.Jid)1