@Override public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception { if (topic.equals("Likaci/MqttMap")) { String msg = new String(mqttMessage.getPayload()); JSONObject json = new JSONObject(msg); if (!json.getString("id").equals(id)) { Point p = (Point) GeometryEngine.project( new Point(json.getDouble("x"), json.getDouble("y")), SpatialReference.create(4326), SpatialReference.create(3857)); layer.removeAll(); SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol( Color.parseColor("#763382"), 15, SimpleMarkerSymbol.STYLE.DIAMOND); layer.addGraphic(new Graphic(p, markerSymbol)); TextSymbol textSymbol = new TextSymbol( 15, json.getString("id"), Color.parseColor("#763382"), TextSymbol.HorizontalAlignment.CENTER, TextSymbol.VerticalAlignment.MIDDLE); textSymbol.setOffsetY(-15); layer.addGraphic(new Graphic(p, textSymbol)); } } }
private void processSetGet(String namePart, MqttMessage msg, boolean set) { if (msg.isRetained()) { L.finer("Ignoring retained message " + msg + " to " + namePart); return; } // Now translate the topic into a group address GroupAddressInfo gai = GroupAddressManager.getGAInfoForName(namePart); if (gai == null) { L.warning( "Unable to translate name " + namePart + " into a group address, ignoring message " + msg); return; } L.fine("Name " + namePart + " translates to GA " + gai.address); String data = new String(msg.getPayload(), StandardCharsets.UTF_8); if (set) KNXConnector.doGroupWrite(gai.address, data, gai); else KNXConnector.doGroupRead(gai.address, data, gai); }