!7 lib 1400324 // Eclipse Paho (MQTT) import org.eclipse.paho.client.mqttv3.*; cmodule MQTTSubscriberSpike > DynPrintLog { switchable S topic = "iot_data"; transient MqttClient client; start-thread { client = new MqttClient("tcp://localhost:1883", MqttClient.generateClientId()); client.setCallback(new MyCallback); client.connect(); client.subscribe(topic); print("Connected & subscribed to " + topic); } void cleanMeUp_mqtt ctex { if (client != null) { client.disconnect(); client.close(); } } class MyCallback implements MqttCallback { public void connectionLost(Throwable throwable) enter { print("Connection to MQTT broker lost!"); } public void messageArrived(S s, MqttMessage mqttMessage) enter { print("Message received: "+ fromUtf8(mqttMessage.getPayload())); } public void deliveryComplete(IMqttDeliveryToken token) enter { print("Delivery complete: " + token); } } }