powered by Jive Software

How to receive Packet payload that is shown in Debugger

Hello,

I’m trying to communicate with a Logitech Harmony Hub which is responding to XMPP packets. I’m successful in sending packages to the hub, which is resulting in the raw XML response below shown in the Debugger window.

<iq id="yWLpX-3" type="get">
  <oa xmlns='connect.logitech.com' mime='vnd.logitech.connect/vnd.logitech.pair'
                    errorcode='200' errorstring='OK'>ELEMENT_AS_CDATA</oa>
</iq>

How do I parse the CDATA-encapsulated response?

If you’re curious, here is a documentation of how the communication with the hub should work: https://github.com/jterrace/pyharmony/blob/master/PROTOCOL.md

I’m using Smack 3.4.1. Same behaviour with Smack 3.2.1

Best regards

Matthias

(Remark to board administrators: Your software is crashing when I try to cite an XML-document with CDATA included)

I got it on my own by implementing the following IQProvider:

public class HarmonyHubResponseIQProvider implements IQProvider{

public IQ parseIQ(XmlPullParser parser) throws Exception {

String errorCode = parser.getAttributeValue(null, “errorcode”);

String errorMessage = parser.getAttributeValue(null, “errorstring”);

String content = parser.nextText();

return new HarmonyHubResponseIQ(errorCode, errorMessage, content);

}

}

Nice use case for Smack.

Did you already wrote a PacketProvider for ‘oa’ with the ‘connect.logitech.com’ namespace? If so, please show us the code.

This is more a XPP3 question. I would expect to be able to retrieve the content of the ‘oa’ element with ‘getText()’.