Skip to content

Commit 1600a56

Browse files
committed
thread: deprecate some IPv6 methods in other device classes
- This is done because IPv6 was included in AbstractXBeeDevice to reuse code. - Fixed some typos in IPDevice. - Fixed minor issues in some unit tests. Signed-off-by: Héctor González <hector.gonzalez@digi.com>
1 parent b8075f8 commit 1600a56

14 files changed

+386
-14
lines changed

library/src/main/java/com/digi/xbee/api/CellularDevice.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
* @see Raw802Device
5050
* @see WiFiDevice
5151
* @see ZigBeeDevice
52+
* @see ThreadDevice
5253
*
5354
* @since 1.2.0
5455
*/

library/src/main/java/com/digi/xbee/api/DigiMeshDevice.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import android.content.Context;
1919

20+
import java.net.Inet6Address;
21+
2022
import com.digi.xbee.api.connection.IConnectionInterface;
2123
import com.digi.xbee.api.connection.android.AndroidUSBPermissionListener;
2224
import com.digi.xbee.api.connection.serial.SerialPortParameters;
@@ -34,14 +36,18 @@
3436
* This class represents a local DigiMesh device.
3537
*
3638
* @see XBeeDevice
37-
* @see CellularDevice
39+
* @see DigiMeshDevice
3840
* @see DigiPointDevice
3941
* @see Raw802Device
4042
* @see WiFiDevice
4143
* @see ZigBeeDevice
44+
* @see ThreadDevice
4245
*/
4346
public class DigiMeshDevice extends XBeeDevice {
4447

48+
// Constants
49+
private static final String OPERATION_EXCEPTION = "Operation not supported in DigiMesh protocol.";
50+
4551
/**
4652
* Class constructor. Instantiates a new {@code DigiMeshDevice} object in the
4753
* given port name and baud rate.
@@ -424,4 +430,35 @@ public void sendExplicitDataAsync(XBee64BitAddress address, int sourceEndpoint,
424430
int profileID, byte[] data) throws XBeeException {
425431
super.sendExplicitDataAsync(address, sourceEndpoint, destEndpoint, clusterID, profileID, data);
426432
}
433+
434+
/**
435+
* @deprecated DigiMesh protocol does not have an associated IPv6 address.
436+
*/
437+
@Override
438+
public Inet6Address getIPv6Address() {
439+
// DigiMesh protocol does not have IPv6 address.
440+
return null;
441+
}
442+
443+
/**
444+
* @deprecated Operation not supported in DigiMesh protocol. This method
445+
* will raise an {@link UnsupportedOperationException}.
446+
*/
447+
@Override
448+
public Inet6Address getIPv6DestinationAddress()
449+
throws TimeoutException, XBeeException {
450+
// Not supported in DigiMesh.
451+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
452+
}
453+
454+
/**
455+
* @deprecated Operation not supported in DigiMesh protocol. This method
456+
* will raise an {@link UnsupportedOperationException}.
457+
*/
458+
@Override
459+
public void setIPv6DestinationAddress(Inet6Address ipv6Address)
460+
throws TimeoutException, XBeeException {
461+
// Not supported in DigiMesh.
462+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
463+
}
427464
}

library/src/main/java/com/digi/xbee/api/DigiPointDevice.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import android.content.Context;
1919

20+
import java.net.Inet6Address;
21+
2022
import com.digi.xbee.api.connection.IConnectionInterface;
2123
import com.digi.xbee.api.connection.android.AndroidUSBPermissionListener;
2224
import com.digi.xbee.api.connection.serial.SerialPortParameters;
@@ -35,14 +37,18 @@
3537
* This class represents a local DigiPoint device.
3638
*
3739
* @see XBeeDevice
38-
* @see CellularDevice
40+
* @see DigiPointDevice
3941
* @see DigiMeshDevice
4042
* @see Raw802Device
4143
* @see WiFiDevice
4244
* @see ZigBeeDevice
45+
* @see ThreadDevice
4346
*/
4447
public class DigiPointDevice extends XBeeDevice {
4548

49+
// Constants
50+
private static final String OPERATION_EXCEPTION = "Operation not supported in DigiPoint protocol.";
51+
4652
/**
4753
* Class constructor. Instantiates a new {@code DigiPointDevice} object in the
4854
* given port name and baud rate.
@@ -428,4 +434,35 @@ public void sendExplicitDataAsync(XBee64BitAddress address64Bit, XBee16BitAddres
428434
int destEndpoint, int clusterID, int profileID, byte[] data) throws XBeeException {
429435
super.sendExplicitDataAsync(address64Bit, address16Bit, sourceEndpoint, destEndpoint, clusterID, profileID, data);
430436
}
437+
438+
/**
439+
* @deprecated DigiPoint protocol does not have an associated IPv6 address.
440+
*/
441+
@Override
442+
public Inet6Address getIPv6Address() {
443+
// DigiPoint protocol does not have IPv6 address.
444+
return null;
445+
}
446+
447+
/**
448+
* @deprecated Operation not supported in DigiPoint protocol. This method
449+
* will raise an {@link UnsupportedOperationException}.
450+
*/
451+
@Override
452+
public Inet6Address getIPv6DestinationAddress()
453+
throws TimeoutException, XBeeException {
454+
// Not supported in DigiPoint.
455+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
456+
}
457+
458+
/**
459+
* @deprecated Operation not supported in DigiPoint protocol. This method
460+
* will raise an {@link UnsupportedOperationException}.
461+
*/
462+
@Override
463+
public void setIPv6DestinationAddress(Inet6Address ipv6Address)
464+
throws TimeoutException, XBeeException {
465+
// Not supported in DigiPoint.
466+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
467+
}
431468
}

library/src/main/java/com/digi/xbee/api/IPDevice.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.digi.xbee.api;
1717

1818
import java.net.Inet4Address;
19+
import java.net.Inet6Address;
1920
import java.net.UnknownHostException;
2021

2122
import android.content.Context;
@@ -144,7 +145,7 @@ protected IPDevice(String port, SerialPortParameters serialPortParameters) {
144145
}
145146

146147
/**
147-
* Class constructor. Instantiates a new {@code DigiMeshDevice} object for
148+
* Class constructor. Instantiates a new {@code IPDevice} object for
148149
* Android with the given parameters.
149150
*
150151
* @param context The Android context.
@@ -166,7 +167,7 @@ protected IPDevice(Context context, int baudRate) {
166167
}
167168

168169
/**
169-
* Class constructor. Instantiates a new {@code DigiMeshDevice} object for
170+
* Class constructor. Instantiates a new {@code IPDevice} object for
170171
* Android with the given parameters.
171172
*
172173
* @param context The Android context.
@@ -191,7 +192,7 @@ protected IPDevice(Context context, int baudRate, AndroidUSBPermissionListener p
191192
}
192193

193194
/**
194-
* Class constructor. Instantiates a new {@code DigiMeshDevice} object for
195+
* Class constructor. Instantiates a new {@code IPDevice} object for
195196
* Android with the given parameters.
196197
*
197198
* <p>This constructor uses the Digi Android Serial Port API based on the
@@ -218,7 +219,7 @@ protected IPDevice(Context context, String port, int baudRate) {
218219
}
219220

220221
/**
221-
* Class constructor. Instantiates a new {@code DigiMeshDevice} object for
222+
* Class constructor. Instantiates a new {@code IPDevice} object for
222223
* Android with the given parameters.
223224
*
224225
* <p>This constructor uses the Digi Android Serial Port API based on the
@@ -358,6 +359,34 @@ public Inet4Address getDestinationIPAddress() throws TimeoutException, XBeeExcep
358359
}
359360
}
360361

362+
/**
363+
* @deprecated This protocol does not have an associated IPv6 address.
364+
*/
365+
@Override
366+
public Inet6Address getIPv6Address() {
367+
return null;
368+
}
369+
370+
/**
371+
* @deprecated Operation not supported in this protocol. This method
372+
* will raise an {@link UnsupportedOperationException}.
373+
*/
374+
@Override
375+
public Inet6Address getIPv6DestinationAddress()
376+
throws TimeoutException, XBeeException {
377+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
378+
}
379+
380+
/**
381+
* @deprecated Operation not supported in this protocol. This method
382+
* will raise an {@link UnsupportedOperationException}.
383+
*/
384+
@Override
385+
public void setIPv6DestinationAddress(Inet6Address ipv6Address)
386+
throws TimeoutException, XBeeException {
387+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
388+
}
389+
361390
/**
362391
* @deprecated This protocol does not have an associated 16-bit address.
363392
*/

library/src/main/java/com/digi/xbee/api/Raw802Device.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import android.content.Context;
1919

20+
import java.net.Inet6Address;
21+
2022
import com.digi.xbee.api.connection.IConnectionInterface;
2123
import com.digi.xbee.api.connection.android.AndroidUSBPermissionListener;
2224
import com.digi.xbee.api.connection.serial.SerialPortParameters;
@@ -39,13 +41,17 @@
3941
*
4042
* @see XBeeDevice
4143
* @see CellularDevice
42-
* @see DigiMeshDevice
44+
* @see 802.15.4Device
4345
* @see DigiPointDevice
4446
* @see WiFiDevice
4547
* @see ZigBeeDevice
48+
* @see ThreadDevice
4649
*/
4750
public class Raw802Device extends XBeeDevice {
4851

52+
// Constants
53+
private static final String OPERATION_EXCEPTION = "Operation not supported in 802.15.4 protocol.";
54+
4955
/**
5056
* Class constructor. Instantiates a new {@code Raw802Device} object in the
5157
* given port name and baud rate.
@@ -413,4 +419,35 @@ public void set16BitAddress(XBee16BitAddress xbee16BitAddress) throws TimeoutExc
413419
public AssociationIndicationStatus getAssociationIndicationStatus() throws TimeoutException, XBeeException {
414420
return super.getAssociationIndicationStatus();
415421
}
422+
423+
/**
424+
* @deprecated 802.15.4 protocol does not have an associated IPv6 address.
425+
*/
426+
@Override
427+
public Inet6Address getIPv6Address() {
428+
// 802.15.4 protocol does not have IPv6 address.
429+
return null;
430+
}
431+
432+
/**
433+
* @deprecated Operation not supported in 802.15.4 protocol. This method
434+
* will raise an {@link UnsupportedOperationException}.
435+
*/
436+
@Override
437+
public Inet6Address getIPv6DestinationAddress()
438+
throws TimeoutException, XBeeException {
439+
// Not supported in 802.15.4.
440+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
441+
}
442+
443+
/**
444+
* @deprecated Operation not supported in 802.15.4 protocol. This method
445+
* will raise an {@link UnsupportedOperationException}.
446+
*/
447+
@Override
448+
public void setIPv6DestinationAddress(Inet6Address ipv6Address)
449+
throws TimeoutException, XBeeException {
450+
// Not supported in 802.15.4.
451+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
452+
}
416453
}

library/src/main/java/com/digi/xbee/api/RemoteDigiMeshDevice.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*/
1616
package com.digi.xbee.api;
1717

18+
import java.net.Inet6Address;
19+
20+
import com.digi.xbee.api.exceptions.TimeoutException;
21+
import com.digi.xbee.api.exceptions.XBeeException;
1822
import com.digi.xbee.api.models.XBee64BitAddress;
1923
import com.digi.xbee.api.models.XBeeProtocol;
2024

@@ -25,9 +29,13 @@
2529
* @see RemoteDigiPointDevice
2630
* @see RemoteRaw802Device
2731
* @see RemoteZigBeeDevice
32+
* @see RemoteThreadDevice
2833
*/
2934
public class RemoteDigiMeshDevice extends RemoteXBeeDevice {
3035

36+
// Constants
37+
private static final String OPERATION_EXCEPTION = "Operation not supported in DigiMesh protocol.";
38+
3139
/**
3240
* Class constructor. Instantiates a new {@code RemoteDigiMeshDevice} object
3341
* with the given local {@code DigiMeshDevice} which contains the connection
@@ -108,4 +116,35 @@ public RemoteDigiMeshDevice(XBeeDevice localXBeeDevice, XBee64BitAddress addr64,
108116
public XBeeProtocol getXBeeProtocol() {
109117
return XBeeProtocol.DIGI_MESH;
110118
}
119+
120+
/**
121+
* @deprecated DigiMesh protocol does not have an associated IPv6 address.
122+
*/
123+
@Override
124+
public Inet6Address getIPv6Address() {
125+
// DigiMesh protocol does not have IPv6 address.
126+
return null;
127+
}
128+
129+
/**
130+
* @deprecated Operation not supported in DigiMesh protocol. This method
131+
* will raise an {@link UnsupportedOperationException}.
132+
*/
133+
@Override
134+
public Inet6Address getIPv6DestinationAddress()
135+
throws TimeoutException, XBeeException {
136+
// Not supported in DigiMesh.
137+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
138+
}
139+
140+
/**
141+
* @deprecated Operation not supported in DigiMesh protocol. This method
142+
* will raise an {@link UnsupportedOperationException}.
143+
*/
144+
@Override
145+
public void setIPv6DestinationAddress(Inet6Address ipv6Address)
146+
throws TimeoutException, XBeeException {
147+
// Not supported in DigiMesh.
148+
throw new UnsupportedOperationException(OPERATION_EXCEPTION);
149+
}
111150
}

0 commit comments

Comments
 (0)