001/**
002 * Copyright (c) 2014 Digi International Inc.,
003 * All rights not expressly granted are reserved.
004 *
005 * This Source Code Form is subject to the terms of the Mozilla Public
006 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
007 * You can obtain one at http://mozilla.org/MPL/2.0/.
008 *
009 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
010 * =======================================================================
011 */
012package com.digi.xbee.api;
013
014import com.digi.xbee.api.exceptions.TimeoutException;
015import com.digi.xbee.api.exceptions.XBeeException;
016import com.digi.xbee.api.models.AssociationIndicationStatus;
017import com.digi.xbee.api.models.XBee16BitAddress;
018import com.digi.xbee.api.models.XBee64BitAddress;
019import com.digi.xbee.api.models.XBeeProtocol;
020
021/**
022 * This class represents a remote ZigBee device.
023 * 
024 * @see RemoteXBeeDevice
025 * @see RemoteDigiMeshDevice
026 * @see RemoteDigiPointDevice
027 * @see RemoteRaw802Device
028 */
029public class RemoteZigBeeDevice extends RemoteXBeeDevice {
030
031        /**
032         * Class constructor. Instantiates a new {@code RemoteZigBeeDevice} object 
033         * with the given local {@code ZigBeeDevice} which contains the connection 
034         * interface to be used.
035         * 
036         * @param localXBeeDevice The local ZigBee device that will behave as 
037         *                        connection interface to communicate with this 
038         *                        remote ZigBee device.
039         * @param addr64 The 64-bit address to identify this remote ZigBee device.
040         * 
041         * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true}.
042         * @throws NullPointerException if {@code localXBeeDevice == null} or
043         *                              if {@code addr64 == null}.
044         * 
045         * @see com.digi.xbee.api.models.XBee64BitAddress
046         */
047        public RemoteZigBeeDevice(ZigBeeDevice localXBeeDevice, XBee64BitAddress addr64) {
048                super(localXBeeDevice, addr64);
049        }
050        
051        /**
052         * Class constructor. Instantiates a new {@code RemoteZigBeeDevice} object 
053         * with the given local {@code XBeeDevice} which contains the connection 
054         * interface to be used.
055         * 
056         * @param localXBeeDevice The local XBee device that will behave as 
057         *                        connection interface to communicate with this 
058         *                        remote ZigBee device.
059         * @param addr64 The 64-bit address to identify this remote ZigBee device.
060         * 
061         * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true} or 
062         *                                  if {@code localXBeeDevice.getXBeeProtocol() != XBeeProtocol.ZIGBEE}.
063         * @throws NullPointerException if {@code localXBeeDevice == null} or
064         *                              if {@code addr64 == null}.
065         * 
066         * @see com.digi.xbee.api.models.XBee64BitAddress
067         */
068        public RemoteZigBeeDevice(XBeeDevice localXBeeDevice, XBee64BitAddress addr64) {
069                super(localXBeeDevice, addr64);
070                
071                // Verify the local device has ZigBee protocol.
072                if (localXBeeDevice.getXBeeProtocol() != XBeeProtocol.ZIGBEE)
073                        throw new IllegalArgumentException("The protocol of the local XBee device is not " + XBeeProtocol.ZIGBEE.getDescription() + ".");
074        }
075        
076        /**
077         * Class constructor. Instantiates a new {@code RemoteZigBeeDevice} object 
078         * with the given local {@code XBeeDevice} which contains the connection 
079         * interface to be used.
080         * 
081         * @param localXBeeDevice The local XBee device that will behave as 
082         *                        connection interface to communicate with this 
083         *                        remote ZigBee device.
084         * @param addr64 The 64-bit address to identify this remote ZigBee device.
085         * @param addr16 The 16-bit address to identify this remote ZigBee device. 
086         *               It might be {@code null}.
087         * @param ni The node identifier of this remote ZigBee device. It might be 
088         *           {@code null}.
089         * 
090         * @throws IllegalArgumentException if {@code localXBeeDevice.isRemote() == true} or 
091         *                                  if {@code localXBeeDevice.getXBeeProtocol() != XBeeProtocol.ZIGBEE}.
092         * @throws NullPointerException if {@code localXBeeDevice == null} or
093         *                              if {@code addr64 == null}.
094         * 
095         * @see com.digi.xbee.api.models.XBee16BitAddress
096         * @see com.digi.xbee.api.models.XBee64BitAddress
097         */
098        public RemoteZigBeeDevice(XBeeDevice localXBeeDevice, XBee64BitAddress addr64, 
099                        XBee16BitAddress addr16, String ni) {
100                super(localXBeeDevice, addr64, addr16, ni);
101                
102                // Verify the local device has ZigBee protocol.
103                if (localXBeeDevice.getXBeeProtocol() != XBeeProtocol.ZIGBEE)
104                        throw new IllegalArgumentException("The protocol of the local XBee device is not " + XBeeProtocol.ZIGBEE.getDescription() + ".");
105        }
106        
107        /*
108         * (non-Javadoc)
109         * @see com.digi.xbee.api.AbstractXBeeDevice#getXBeeProtocol()
110         */
111        @Override
112        public XBeeProtocol getXBeeProtocol() {
113                return XBeeProtocol.ZIGBEE;
114        }
115        
116        /*
117         * (non-Javadoc)
118         * @see com.digi.xbee.api.AbstractXBeeDevice#getAssociationIndicationStatus()
119         */
120        @Override
121        public AssociationIndicationStatus getAssociationIndicationStatus() throws TimeoutException, XBeeException {
122                return super.getAssociationIndicationStatus();
123        }
124        
125        /*
126         * (non-Javadoc)
127         * @see com.digi.xbee.api.AbstractXBeeDevice#forceDisassociate()
128         */
129        @Override
130        public void forceDisassociate() throws TimeoutException, XBeeException {
131                super.forceDisassociate();
132        }
133}