Example #1
0
 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);
 }
Example #2
0
 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);
 }