コード例 #1
0
ファイル: MQTTHandler.java プロジェクト: fluppie/knx2mqtt
 void processMessage(String topic, MqttMessage msg) {
   L.fine("Received " + msg + " to " + topic);
   topic = topic.substring(topicPrefix.length(), topic.length());
   if (topic.startsWith("set/")) processSetGet(topic.substring(4), msg, true);
   else if (topic.startsWith("get/")) processSetGet(topic.substring(4), msg, false);
   else L.warning("Ignored message " + msg + " to unknown topic " + topic);
 }
コード例 #2
0
ファイル: MQTTHandler.java プロジェクト: fluppie/knx2mqtt
 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);
 }