001/* 002 * Copyright 2017-2019, Digi International Inc. 003 * 004 * This Source Code Form is subject to the terms of the Mozilla Public 005 * License, v. 2.0. If a copy of the MPL was not distributed with this 006 * file, you can obtain one at http://mozilla.org/MPL/2.0/. 007 * 008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 015 */ 016package com.digi.xbee.api; 017 018import java.net.Inet6Address; 019 020import com.digi.xbee.api.exceptions.TimeoutException; 021import com.digi.xbee.api.exceptions.XBeeException; 022import com.digi.xbee.api.models.XBee64BitAddress; 023import com.digi.xbee.api.models.XBeeProtocol; 024 025/** 026 * This class represents a remote DigiPoint device. 027 * 028 * @see RemoteDigiMeshDevice 029 * @see RemoteRaw802Device 030 * @see RemoteThreadDevice 031 * @see RemoteXBeeDevice 032 * @see RemoteZigBeeDevice 033 */ 034public class RemoteDigiPointDevice extends RemoteXBeeDevice { 035 036 // Constants 037 private static final String OPERATION_EXCEPTION = "Operation not supported in DigiPoint protocol."; 038 039 /** 040 * Class constructor. Instantiates a new {@code RemoteDigiPointDevice} object 041 * with the given local {@code DigiPointDevice} which contains the connection 042 * interface to be used. 043 * 044 * @param localXBeeDevice The local point-to-multipoint device that will behave as 045 * connection interface to communicate with this 046 * remote point-to-multipoint device. 047 * @param addr64 The 64-bit address to identify this remote point-to-multipoint 048 * device. 049 * 050 * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true}. 051 * @throws NullPointerException if {@code localXBeeDevice == null} or 052 * if {@code addr64 == null}. 053 * 054 * @see com.digi.xbee.api.models.XBee64BitAddress 055 */ 056 public RemoteDigiPointDevice(DigiPointDevice localXBeeDevice, XBee64BitAddress addr64) { 057 super(localXBeeDevice, addr64); 058 } 059 060 /** 061 * Class constructor. Instantiates a new {@code RemoteDigiPointDevice} object 062 * with the given local {@code XBeeDevice} which contains the connection 063 * interface to be used. 064 * 065 * @param localXBeeDevice The local XBee device that will behave as 066 * connection interface to communicate with this 067 * remote point-to-multipoint device. 068 * @param addr64 The 64-bit address to identify this remote point-to-multipoint 069 * device. 070 * 071 * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true} or 072 * if {@code localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_POINT}. 073 * @throws NullPointerException if {@code localXBeeDevice == null} or 074 * if {@code addr64 == null}. 075 * 076 * @see com.digi.xbee.api.models.XBee64BitAddress 077 */ 078 public RemoteDigiPointDevice(AbstractXBeeDevice localXBeeDevice, XBee64BitAddress addr64) { 079 super(localXBeeDevice, addr64); 080 081 // Verify the local device has point-to-multipoint protocol. 082 if (localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_POINT) 083 throw new IllegalArgumentException("The protocol of the local XBee device is not " + XBeeProtocol.DIGI_POINT.getDescription() + "."); 084 } 085 086 /** 087 * Class constructor. Instantiates a new {@code RemoteDigiPointDevice} object 088 * with the given local {@code XBeeDevice} which contains the connection 089 * interface to be used. 090 * 091 * @param localXBeeDevice The local XBee device that will behave as 092 * connection interface to communicate with this 093 * remote point-to-multipoint device. 094 * @param addr64 The 64-bit address to identify this remote point-to-multipoint 095 * device. 096 * @param id The node identifier of this remote point-to-multipoint device. 097 * It might be {@code null}. 098 * 099 * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true} or 100 * if {@code localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_POINT}. 101 * @throws NullPointerException if {@code localXBeeDevice == null} or 102 * if {@code addr64 == null}. 103 * 104 * @see com.digi.xbee.api.models.XBee64BitAddress 105 */ 106 public RemoteDigiPointDevice(AbstractXBeeDevice localXBeeDevice, XBee64BitAddress addr64, String id) { 107 super(localXBeeDevice, addr64, null, id); 108 109 // Verify the local device has point-to-multipoint protocol. 110 if (localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_POINT) 111 throw new IllegalArgumentException("The protocol of the local XBee device is not " + XBeeProtocol.DIGI_POINT.getDescription() + "."); 112 } 113 114 /* 115 * (non-Javadoc) 116 * @see com.digi.xbee.api.AbstractXBeeDevice#getXBeeProtocol() 117 */ 118 @Override 119 public XBeeProtocol getXBeeProtocol() { 120 return XBeeProtocol.DIGI_POINT; 121 } 122 123 /** 124 * @deprecated DigiPoint protocol does not have an associated IPv6 address. 125 */ 126 @Override 127 public Inet6Address getIPv6Address() { 128 // DigiPoint protocol does not have IPv6 address. 129 return null; 130 } 131 132 /** 133 * @deprecated Operation not supported in DigiPoint protocol. This method 134 * will raise an {@link UnsupportedOperationException}. 135 */ 136 @Override 137 public Inet6Address getIPv6DestinationAddress() 138 throws TimeoutException, XBeeException { 139 // Not supported in DigiPoint. 140 throw new UnsupportedOperationException(OPERATION_EXCEPTION); 141 } 142 143 /** 144 * @deprecated Operation not supported in DigiPoint protocol. This method 145 * will raise an {@link UnsupportedOperationException}. 146 */ 147 @Override 148 public void setIPv6DestinationAddress(Inet6Address ipv6Address) 149 throws TimeoutException, XBeeException { 150 // Not supported in DigiPoint. 151 throw new UnsupportedOperationException(OPERATION_EXCEPTION); 152 } 153}