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 DigiMesh device. 027 * 028 * @see RemoteDigiPointDevice 029 * @see RemoteRaw802Device 030 * @see RemoteThreadDevice 031 * @see RemoteXBeeDevice 032 * @see RemoteZigBeeDevice 033 */ 034public class RemoteDigiMeshDevice extends RemoteXBeeDevice { 035 036 // Constants 037 private static final String OPERATION_EXCEPTION = "Operation not supported in DigiMesh protocol."; 038 039 /** 040 * Class constructor. Instantiates a new {@code RemoteDigiMeshDevice} object 041 * with the given local {@code DigiMeshDevice} which contains the connection 042 * interface to be used. 043 * 044 * @param localXBeeDevice The local DigiMesh device that will behave as 045 * connection interface to communicate with this 046 * remote DigiMesh device. 047 * @param addr64 The 64-bit address to identify this remote DigiMesh device. 048 * 049 * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true}. 050 * @throws NullPointerException if {@code localXBeeDevice == null} or 051 * if {@code addr64 == null}. 052 * 053 * @see com.digi.xbee.api.models.XBee64BitAddress 054 */ 055 public RemoteDigiMeshDevice(DigiMeshDevice localXBeeDevice, XBee64BitAddress addr64) { 056 super(localXBeeDevice, addr64); 057 } 058 059 /** 060 * Class constructor. Instantiates a new {@code RemoteDigiMeshDevice} object 061 * with the given local {@code XBeeDevice} which contains the connection 062 * interface to be used. 063 * 064 * @param localXBeeDevice The local XBee device that will behave as 065 * connection interface to communicate with this 066 * remote DigiMesh device. 067 * @param addr64 The 64-bit address to identify this remote DigiMesh device. 068 * 069 * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true} or 070 * if {@code localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_MESH}. 071 * @throws NullPointerException if {@code localXBeeDevice == null} or 072 * if {@code addr64 == null}. 073 * 074 * @see com.digi.xbee.api.models.XBee64BitAddress 075 */ 076 public RemoteDigiMeshDevice(AbstractXBeeDevice localXBeeDevice, XBee64BitAddress addr64) { 077 super(localXBeeDevice, addr64); 078 079 // Verify the local device has DigiMesh protocol. 080 if (localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_MESH) 081 throw new IllegalArgumentException("The protocol of the local XBee device is not " + XBeeProtocol.DIGI_MESH.getDescription() + "."); 082 } 083 084 /** 085 * Class constructor. Instantiates a new {@code RemoteDigiMeshDevice} object 086 * with the given local {@code XBeeDevice} which contains the connection 087 * interface to be used. 088 * 089 * @param localXBeeDevice The local XBee device that will behave as 090 * connection interface to communicate with this 091 * remote DigiMesh device. 092 * @param addr64 The 64-bit address to identify this remote DigiMesh device. 093 * @param id The node identifier of this remote DigiMesh device. It might 094 * be {@code null}. 095 * 096 * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true} or 097 * if {@code localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_MESH}. 098 * @throws NullPointerException if {@code localXBeeDevice == null} or 099 * if {@code addr64 == null}. 100 * 101 * @see com.digi.xbee.api.models.XBee64BitAddress 102 */ 103 public RemoteDigiMeshDevice(AbstractXBeeDevice localXBeeDevice, XBee64BitAddress addr64, String id) { 104 super(localXBeeDevice, addr64, null, id); 105 106 // Verify the local device has DigiMesh protocol. 107 if (localXBeeDevice.getXBeeProtocol() != XBeeProtocol.DIGI_MESH) 108 throw new IllegalArgumentException("The protocol of the local XBee device is not " + XBeeProtocol.DIGI_MESH.getDescription() + "."); 109 } 110 111 /* 112 * (non-Javadoc) 113 * @see com.digi.xbee.api.AbstractXBeeDevice#getXBeeProtocol() 114 */ 115 @Override 116 public XBeeProtocol getXBeeProtocol() { 117 return XBeeProtocol.DIGI_MESH; 118 } 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 } 150}