I am trying to write a MATLAB GUI that uses the XBee-API interface to talk to an XBee wireless radio on board an Arduino. The GUI mostly does data collection and parses incoming packets.
I want to do an addPacketListener as defined in the Developer's Guide (see section "Receiving Packets") to wait for packets to process. In Java, this is how it would be done:
xbee.addPacketListener(new PacketListener() {
public void processResponse(XBeeResponse response) {
// handle the response
}
});
In MATLAB, I would do an addlistener() and set its callback to do my processing.
I don't know much at all about Java, so I was wondering if it's possible to set up the processResponse code a la MATLAB: can I do something like as follows:
function processResponse
#% do response here
end
>> xbee.addPacketListener(@processResponse)
I'm not sure if this made complete sense; basically what I'm trying to accomplish is to execute a callback once new packets are available for my XBee (which in Java is handled by addPacketListener).
processResponseand pass an instance of that class toaddPacketListener? I tried passing in a MATLAB object with a methodprocessResponseand got the following error:XB.addPacketListener(testclass) No method 'addPacketListener' with matching signature found for class 'com.rapplogic.xbee.api.XBee'