Search in sources :

Example 11 with RemoteXBeeDevice

use of com.digi.xbee.api.RemoteXBeeDevice in project JMRI by JMRI.

the class XBeeNodeTest method testGetPreferedNameAsGlobalAddress.

@Test
public void testGetPreferedNameAsGlobalAddress() {
    // Mock the remote device.
    RemoteXBeeDevice rd = Mockito.mock(RemoteXBeeDevice.class);
    Mockito.when(rd.getXBeeProtocol()).thenReturn(XBeeProtocol.UNKNOWN);
    Mockito.when(rd.getNodeID()).thenReturn("");
    Mockito.when(rd.get64BitAddress()).thenReturn(new XBee64BitAddress("0013A20040A04D2D"));
    Mockito.when(rd.get16BitAddress()).thenReturn(new XBee16BitAddress("FFFE"));
    byte[] pan = { (byte) 0x00, (byte) 0x42 };
    byte[] uad = { (byte) 0xFF, (byte) 0xFE };
    byte[] gad = { (byte) 0x00, (byte) 0x13, (byte) 0xA2, (byte) 0x00, (byte) 0x40, (byte) 0xA0, (byte) 0x4D, (byte) 0x2D };
    XBeeNode node = new XBeeNode(pan, uad, gad);
    tc.registerNode(node);
    node.setXBee(rd);
    Assert.assertEquals("Global Address Name", "00 13 A2 00 40 A0 4D 2D ", node.getPreferedName());
}
Also used : XBee64BitAddress(com.digi.xbee.api.models.XBee64BitAddress) RemoteXBeeDevice(com.digi.xbee.api.RemoteXBeeDevice) XBee16BitAddress(com.digi.xbee.api.models.XBee16BitAddress) Test(org.junit.Test)

Aggregations

RemoteXBeeDevice (com.digi.xbee.api.RemoteXBeeDevice)11 XBee16BitAddress (com.digi.xbee.api.models.XBee16BitAddress)9 XBee64BitAddress (com.digi.xbee.api.models.XBee64BitAddress)9 Test (org.junit.Test)6 XBeeNode (jmri.jmrix.ieee802154.xbee.XBeeNode)3 TimeoutException (com.digi.xbee.api.exceptions.TimeoutException)2 XBeeException (com.digi.xbee.api.exceptions.XBeeException)2 WindowEvent (java.awt.event.WindowEvent)2 AbstractStreamPortController (jmri.jmrix.AbstractStreamPortController)1 XBeeConnectionMemo (jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo)1 XBeeTrafficController (jmri.jmrix.ieee802154.xbee.XBeeTrafficController)1 Element (org.jdom2.Element)1