Home/Support/Support Forum/The protocol of the local XBee device is not 802.15.4

The protocol of the local XBee device is not 802.15.4

0 votes
I am currently using a ConnectPort X2 802.15.4 / Ethernet gateway as my local XBee device. I am attempting to reach it using RealPort to control remote XBee devices. The remote device at this time is a Series 1 XBee connected with a Sparkfun Explorer Board to a seperate computer. I am attempting to write a Java application that reattempts connections after a failure.

Currently, I am encountering:
Exception in thread "Thread-17" java.lang.IllegalArgumentException: The protocol of the local XBee device is not 802.15.4. at com.digi.xbee.api.RemoteRaw802Device.<init>(RemoteRaw802Device.java:125) at com.digi.xbee.api.connection.DataReader.packetReceived(DataReader.java:453) at com.digi.xbee.api.connection.DataReader.run(DataReader.java:336)

This error seems simple, in that a comparison is failing. However, it is occuring when I attempt to open the connection to my local device.The protocol is "unknown" before calling this method, and after a successful connection the protocol is 802.15.4 (as one would expect from a 802.15.4 gateway). What part of establishing the connection and reading it's parameters am I not doing? It is my understanding that the open method should read this information for me, why would it cause an exception in this way?

The second error, which I believe to be related to the first, is that at some points during testing, the local device begins to report that it is in AT mode, which according to XCTU is incorrect. The error for this other exception is included, but as the first error occurs more commonly, and does not stop execution, I suspect it is a symptom rather than a cause.

In short, what could change the protocol reported by the gateway?

Apologies for the poorly commented and incomplete code. Several aspects, such as the requests instance variable are not made use of at this juncture.

Any help is appreciated.
package com.digi.xbee.controlPoint; import com.digi.xbee.api.RemoteXBeeDevice; import com.digi.xbee.api.XBeeDevice; import com.digi.xbee.api.exceptions.InterfaceNotOpenException; import com.digi.xbee.api.exceptions.TimeoutException; import com.digi.xbee.api.exceptions.XBeeException; import com.digi.xbee.api.io.IOLine; import com.digi.xbee.api.io.IOValue; import com.digi.xbee.api.models.XBee64BitAddress; import java.util.concurrent.ConcurrentLinkedQueue; public class XBee_Tactile_CP extends Tactile_Control_Point implements Runnable { public static final byte PR_DEFAULT = (byte)0xFE; private XBeeDevice local; private RemoteXBeeDevice remote; private final String ID; private Control_Point_Status status; private ConcurrentLinkedQueue<String> requests; public XBee_Tactile_CP(String ID, String localPort, int BAUD_RATE, String remoteAddress) { this.ID = ID; local = new XBeeDevice(localPort, BAUD_RATE); remote = new RemoteXBeeDevice(local, new XBee64BitAddress(remoteAddress)); status = Control_Point_Status.NORMAL; requests = new ConcurrentLinkedQueue<>(); } /*These methods control the DIO pins of the local XBee. For brevity, they have been omitted, all XBee interaction within them is done through setDigitalPin*/ private void deactivateSelect(byte [] pins), deactivate(), & activateSelect(byte [] pins), setDigitalPin(byte pin, boolean set) /*Method which makes several attempts to change DIO pins before aborting and declaring a timeout occurred*/ private void setDigitalInput(int pin, boolean high, int attempts) throws TimeoutException, XBeeException { if(attempts < 1) throw new TimeoutException(); byte [] map = {0x10, 0x08, 0x04, 0x02, 0x01}; if(pin > map.length || pin < 0) throw new IndexOutOfBoundsException(); try { byte [] pullup = local.getParameter("PR"); if(high) pullup[0] |= map[pin]; else pullup[0] &= ~map[pin]; local.setParameter("PR", pullup); } catch(TimeoutException e) { this.setDigitalInput(pin, high, attempts - 1); } } /* En/Disable of IO passing is done with startSamples(byte msb, byte lsb) and stopSamples() with local.setParameter("IR", /*byte[]*/); */ public void close() { stopSamples(); deactivate(); local.close(); status = Control_Point_Status.CLOSED; } private boolean open() { try { local.open(); local.readDeviceInfo(); remote.readDeviceInfo(); status = Control_Point_Status.NORMAL; return true; } //Catch statements omitted: set status, return false } protected void init() { local.setReceiveTimeout(5000); if(local.isOpen()) { try { local.readDeviceInfo(); } catch(XBeeException e) { status = Control_Point_Status.ERROR; return; } status = Control_Point_Status.NORMAL; deactivate(); byte[] defaultEnabledPins = {0}; activateSelect(defaultEnabledPins); stopSamples(); } else { if (open()) { status = Control_Point_Status.NORMAL; deactivate(); byte [] defaultEP = {0}; activateSelect(defaultEP); stopSamples(); } else { status = Control_Point_Status.CLOSED; } } } /*Performs 4 operations: 1.Attempts to initialize devices, with each error waiting a longer period before reattempting After a threshold, gives up. 2.Demonstrates that the remote device behaves as expected when connection is lost by briefly starting then stopping sample transmission. 3.Performs a series of changes on the digital input that is sent via direct line passing 4.Tear-down*/ public void run() { open(); int wait = 500, attempts = 0; double maxWaitTime = 3e7; while(status != Control_Point_Status.NORMAL) { try { Thread.sleep(wait); } catch(InterruptedException e) { e.printStackTrace(); } if(wait > maxWaitTime) { return; } else { wait += (attempts * 10 * attempts); attempts++; } init(); } byte [] iopin = {4}; activateSelect(iopin); startSamples((byte)0x00, (byte)0x64); try { Thread.sleep(500); stopSamples(); deactivateSelect(iopin); Thread.sleep(1000); startSamples((byte)0x00, (byte) 0x64); for(i = 5; i > 0; i--) { activateSelect(iopin); Thread.sleep(1000); deactivateSelect(iopin); Thread.sleep(1000); } } catch(InterruptedException e) { e.printStackTrace(); } close(); } public static void main(String[] args) { for(int i = 1; i < 100; i++) { String id = "Control Point " + i; XBee_Tactile_CP cp = new XBee_Tactile_CP(id, "COM3", 115200, "0013A20040D82615"); Thread cpt = new Thread(cp); cpt.setName(id); cpt.start(); try { cpt.join(); Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } } }
asked Jun 12, 2015 in RF Solutions and XBee by GJBrown New to the Community (3 points)
edited Jun 11, 2015 by GJBrown

Please log in or register to answer this question.

1 Answer

0 votes
Could you be in advertantly setting the AP command to a value of 0?
answered Sep 3, 2015 by mvut Veteran of the Digi Community (15,108 points)