Skip to content

Commit

Permalink
packets: increase the upper limit of the packet RSSI value from 100 t…
Browse files Browse the repository at this point in the history
…o 255

This was causing the library to throw an exception when the local module
received data packets from remotes that were too far.

Signed-off-by: Ruben Moral <ruben.moral@digi.com>
  • Loading branch information
rubenmoral committed Oct 15, 2018
1 parent 6d46906 commit dd61eff
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class RX16IOPacket extends XBeeAPIPacket {
* @throws IllegalArgumentException if {@code payload[0] != APIFrameType.RX_16.getValue()} or
* if {@code payload.length < }{@value #MIN_API_PAYLOAD_LENGTH} or
* if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code payload == null}.
Expand Down Expand Up @@ -117,7 +117,7 @@ public static RX16IOPacket createPacket(byte[] payload) {
* @param rfData Received RF data.
*
* @throws IllegalArgumentException if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code sourceAddress16 == null}.
Expand All @@ -130,8 +130,8 @@ public RX16IOPacket(XBee16BitAddress sourceAddress16, int rssi, int receiveOptio

if (sourceAddress16 == null)
throw new NullPointerException("16-bit source address cannot be null.");
if (rssi < 0 || rssi > 100)
throw new IllegalArgumentException("RSSI value must be between 0 and 100.");
if (rssi < 0 || rssi > 255)
throw new IllegalArgumentException("RSSI value must be between 0 and 255.");
if (receiveOptions < 0 || receiveOptions > 255)
throw new IllegalArgumentException("Receive options value must be between 0 and 255.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class RX16Packet extends XBeeAPIPacket {
* @throws IllegalArgumentException if {@code payload[0] != APIFrameType.RX_16.getValue()} or
* if {@code payload.length < }{@value #MIN_API_PAYLOAD_LENGTH} or
* if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code payload == null}.
Expand Down Expand Up @@ -118,7 +118,7 @@ public static RX16Packet createPacket(byte[] payload) {
* @param rfData Received RF data.
*
* @throws IllegalArgumentException if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code sourceAddress16 == null}.
Expand All @@ -131,8 +131,8 @@ public RX16Packet(XBee16BitAddress sourceAddress16, int rssi, int receiveOptions

if (sourceAddress16 == null)
throw new NullPointerException("16-bit source address cannot be null.");
if (rssi < 0 || rssi > 100)
throw new IllegalArgumentException("RSSI value must be between 0 and 100.");
if (rssi < 0 || rssi > 255)
throw new IllegalArgumentException("RSSI value must be between 0 and 255.");
if (receiveOptions < 0 || receiveOptions > 255)
throw new IllegalArgumentException("Receive options value must be between 0 and 255.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class RX64IOPacket extends XBeeAPIPacket {
* @throws IllegalArgumentException if {@code payload[0] != APIFrameType.RX_64.getValue()} or
* if {@code payload.length < }{@value #MIN_API_PAYLOAD_LENGTH} or
* if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code payload == null}.
Expand Down Expand Up @@ -117,7 +117,7 @@ public static RX64IOPacket createPacket(byte[] payload) {
* @param rfData Received RF data.
*
* @throws IllegalArgumentException if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code sourceAddress64 == null}.
Expand All @@ -130,8 +130,8 @@ public RX64IOPacket(XBee64BitAddress sourceAddress64, int rssi, int receiveOptio

if (sourceAddress64 == null)
throw new NullPointerException("64-bit source address cannot be null.");
if (rssi < 0 || rssi > 100)
throw new IllegalArgumentException("RSSI value must be between 0 and 100.");
if (rssi < 0 || rssi > 255)
throw new IllegalArgumentException("RSSI value must be between 0 and 255.");
if (receiveOptions < 0 || receiveOptions > 255)
throw new IllegalArgumentException("Receive options value must be between 0 and 255.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class RX64Packet extends XBeeAPIPacket {
* @throws IllegalArgumentException if {@code payload[0] != APIFrameType.RX_64.getValue()} or
* if {@code payload.length < }{@value #MIN_API_PAYLOAD_LENGTH} or
* if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code payload == null}.
Expand Down Expand Up @@ -118,7 +118,7 @@ public static RX64Packet createPacket(byte[] payload) {
* @param rfData Received RF data.
*
* @throws IllegalArgumentException if {@code rssi < 0} or
* if {@code rssi > 100} or
* if {@code rssi > 255} or
* if {@code receiveOptions < 0} or
* if {@code receiveOptions > 255}.
* @throws NullPointerException if {@code sourceAddress64 == null}.
Expand All @@ -131,8 +131,8 @@ public RX64Packet(XBee64BitAddress sourceAddress64, int rssi, int receiveOptions

if (sourceAddress64 == null)
throw new NullPointerException("64-bit source address cannot be null.");
if (rssi < 0 || rssi > 100)
throw new IllegalArgumentException("RSSI value must be between 0 and 100.");
if (rssi < 0 || rssi > 255)
throw new IllegalArgumentException("RSSI value must be between 0 and 255.");
if (receiveOptions < 0 || receiveOptions > 255)
throw new IllegalArgumentException("Receive options value must be between 0 and 255.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,19 @@ public final void testCreateRX16IOPacket16BitAddressNull() {
/**
* Test method for {@link com.digi.xbee.api.packet.raw.RX16IOPacket#RX16IOPacket(XBee16BitAddress, int, int, byte[])}.
*
* <p>Construct a new RX16 IO packet but with a RSSI bigger than 100.
* <p>Construct a new RX16 IO packet but with a RSSI bigger than 255.
* This must throw an {@code IllegalArgumentException}.</p>
*/
@Test
public final void testCreateRX16IOPacketRssiBiggerThan100() {
public final void testCreateRX16IOPacketRssiBiggerThan255() {
// Setup the resources for the test.
XBee16BitAddress source16Addr = new XBee16BitAddress("D817");
int rssi = 725;
int rssi = 256;
int options = 40;
byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX16IOPacket(source16Addr, rssi, options, data);
Expand All @@ -360,7 +360,7 @@ public final void testCreateRX16IOPacketRssiNegative() {
byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX16IOPacket(source16Addr, rssi, options, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,19 @@ public final void testCreateRX16Packet16BitAddressNull() {
/**
* Test method for {@link com.digi.xbee.api.packet.raw.RX16Packet#RX16Packet(XBee16BitAddress, int, int, byte[])}.
*
* <p>Construct a new RX16 packet but with a RSSI bigger than 100.
* <p>Construct a new RX16 packet but with a RSSI bigger than 255.
* This must throw an {@code IllegalArgumentException}.</p>
*/
@Test
public final void testCreateRX16PacketRssiBiggerThan100() {
public final void testCreateRX16PacketRssiBiggerThan255() {
// Setup the resources for the test.
XBee16BitAddress source16Addr = new XBee16BitAddress("D817");
int rssi = 725;
int rssi = 256;
int options = 40;
byte[] data = new byte[]{0x68, 0x6F, 0x6C, 0x61};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX16Packet(source16Addr, rssi, options, data);
Expand All @@ -284,7 +284,7 @@ public final void testCreateRX16PacketRssiNegative() {
byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX16Packet(source16Addr, rssi, options, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,19 @@ public final void testCreateRX64IOPacket16BitAddressNull() {
/**
* Test method for {@link com.digi.xbee.api.packet.raw.RX64IOPacket#RX64IOPacket(XBee64BitAddress, int, int, byte[])}.
*
* <p>Construct a new RX64 IO packet but with a RSSI bigger than 100.
* <p>Construct a new RX64 IO packet but with a RSSI bigger than 255.
* This must throw an {@code IllegalArgumentException}.</p>
*/
@Test
public final void testCreateRX64IOPacketRssiBiggerThan100() {
public final void testCreateRX64IOPacketRssiBiggerThan255() {
// Setup the resources for the test.
XBee64BitAddress source64Addr = new XBee64BitAddress("0013A2004032D9AB");
int rssi = 725;
int rssi = 256;
int options = 40;
byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX64IOPacket(source64Addr, rssi, options, data);
Expand All @@ -363,7 +363,7 @@ public final void testCreateRX64IOPacketRssiNegative() {
byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX64IOPacket(source64Addr, rssi, options, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,19 @@ public final void testCreateRX64Packet16BitAddressNull() {
/**
* Test method for {@link com.digi.xbee.api.packet.raw.RX64Packet#RX64Packet(XBee64BitAddress, int, int, byte[])}.
*
* <p>Construct a new RX64 packet but with a RSSI bigger than 100.
* <p>Construct a new RX64 packet but with a RSSI bigger than 255.
* This must throw an {@code IllegalArgumentException}.</p>
*/
@Test
public final void testCreateRX64PacketRssiBiggerThan100() {
public final void testCreateRX64PacketRssiBiggerThan255() {
// Setup the resources for the test.
XBee64BitAddress source64Addr = new XBee64BitAddress("0013A2004032D9AB");
int rssi = 725;
int rssi = 256;
int options = 40;
byte[] data = new byte[]{0x68, 0x6F, 0x6C, 0x61};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX64Packet(source64Addr, rssi, options, data);
Expand All @@ -284,7 +284,7 @@ public final void testCreateRX64PacketRssiNegative() {
byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};

exception.expect(IllegalArgumentException.class);
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 100.")));
exception.expectMessage(is(equalTo("RSSI value must be between 0 and 255.")));

// Call the method under test that should throw a NullPointerException.
new RX64Packet(source64Addr, rssi, options, data);
Expand Down

0 comments on commit dd61eff

Please sign in to comment.