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.models;
013
014import java.util.HashMap;
015
016import com.digi.xbee.api.utils.HexUtils;
017
018/**
019 * Enumerates the different hardware versions of the XBee devices.
020 */
021public enum HardwareVersionEnum {
022
023        // Enumeration entries
024        X09_009(0x01, "X09-009"),
025        X09_019(0x02, "X09-019"),
026        XH9_009(0x03, "XH9-009"),
027        XH9_019(0x04, "XH9-019"),
028        X24_009(0x05, "X24-009"),
029        X24_019(0x06, "X24-019"),
030        X09_001(0x07, "X09-001"),
031        XH9_001(0x08, "XH9-001"),
032        X08_004(0x09, "X08-004"),
033        XC09_009(0x0A, "XC09-009"),
034        XC09_038(0x0B, "XC09-038"),
035        X24_038(0x0C, "X24-038"),
036        X09_009_TX(0x0D, "X09-009-TX"),
037        X09_019_TX(0x0E, "X09-019-TX"),
038        XH9_009_TX(0x0F, "XH9-009-TX"),
039        XH9_019_TX(0x10, "XH9-019-TX"),
040        X09_001_TX(0x11, "X09-001-TX"),
041        XH9_001_TX(0x12, "XH9-001-TX"),
042        XT09B_XXX(0x13, "XT09B-xxx (Attenuator version)"),
043        XT09_XXX(0x14, "XT09-xxx"),
044        XC08_009(0x15, "XC08-009"),
045        XC08_038(0x16, "XC08-038"),
046        XB24_AXX_XX(0x17, "XB24-Axx-xx"),
047        XBP24_AXX_XX(0x18, "XBP24-Axx-xx"),
048        XB24_BXIX_XXX(0x19, "XB24-BxIx-xxx and XB24-Z7xx-xxx"),
049        XBP24_BXIX_XXX(0x1A, "XBP24-BxIx-xxx and XBP24-Z7xx-xxx"),
050        XBP09_DXIX_XXX(0x1B, "XBP09-DxIx-xxx Digi Mesh"),
051        XBP09_XCXX_XXX(0x1C, "XBP09-XCxx-xxx: S3 XSC Compatibility"),
052        XBP08_DXXX_XXX(0x1D, "XBP08-Dxx-xxx 868MHz"),
053        XBP24B(0x1E, "XBP24B: Low cost ZB PRO and PLUS S2B"),
054        XB24_WF(0x1F, "XB24-WF: XBee 802.11 (Redpine module)"),
055        AMBER_MBUS(0x20, "??????: M-Bus module made by Amber"),
056        XBP24C(0x21, "XBP24C: XBee PRO SMT Ember 357 S2C PRO"),
057        XB24C(0x22, "XB24C: XBee SMT Ember 357 S2C"),
058        XSC_GEN3(0x23, "XSC_GEN3: XBP9 XSC 24 dBm"),
059        SRD_868_GEN3(0x24, "SDR_868_GEN3: XB8 12 dBm"),
060        ABANDONATED(0x25, "Abandonated"),
061        SMT_900LP(0x26, "900LP (SMT): 900LP on 'S8 HW'"),
062        WIFI_ATHEROS(0x27, "WiFi Atheros (TH-DIP) XB2S-WF"),
063        SMT_WIFI_ATHEROS(0x28, "WiFi Atheros (SMT) XB2B-WF"),
064        SMT_475LP(0x29, "475LP (SMT): Beta 475MHz"),
065        XBEE_CELL_TH(0x2A, "XBee-Cell (TH): XBee Cellular"),
066        XLR_MODULE(0x2B, "XLR Module"),
067        XB900HP_NZ(0x2C, "XB900HP (New Zealand): XB9 NZ HW/SW"),
068        XBP24C_TH_DIP(0x2D, "XBP24C (TH-DIP): XBee PRO DIP"),
069        XB24C_TH_DIP(0x2E, "XB24C (TH-DIP): XBee DIP"),
070        XLR_BASEBOARD(0x2F, "XLR Baseboard");
071        
072        // Variables
073        private final int value;
074        
075        private final String description;
076        
077        private final static HashMap<Integer, HardwareVersionEnum> lookupTable = new HashMap<Integer, HardwareVersionEnum>();
078        
079        static {
080                for (HardwareVersionEnum hv:values())
081                        lookupTable.put(hv.getValue(), hv);
082        }
083        
084        /**
085         * Class constructor. Instantiates a new {@code HardwareVersion} 
086         * enumeration entry with the given parameters.
087         * 
088         * @param value Hardware version numeric value 
089         * @param description Hardware version description.
090         */
091        private HardwareVersionEnum(int value, String description) {
092                this.value = value;
093                this.description = description;
094        }
095        
096        /**
097         * Returns the Hardware version numeric value.
098         * 
099         * @return The hardware version numeric value.
100         */
101        public int getValue() {
102                return value;
103        }
104        
105        /**
106         * Returns the hardware version description.
107         * 
108         * @return The hardware version description.
109         */
110        public String getDescription() {
111                return description;
112        }
113        
114        /**
115         * Returns the {@code HardwareVersionEnum} associated to the given 
116         * numeric value.
117         * 
118         * @param value Numeric value of the {@code HardwareVersionEnum} to 
119         *              retrieve.
120         * 
121         * @return The {@code HardwareVersionEnum} associated to the given numeric 
122         *         value, {@code null} if there is not any 
123         *         {@code HardwareVersionEnum} associated to that value.
124         */
125        public static HardwareVersionEnum get(int value) {
126                return lookupTable.get(value);
127        }
128        
129        /*
130         * (non-Javadoc)
131         * @see java.lang.Enum#toString()
132         */
133        @Override
134        public String toString() {
135                return HexUtils.byteToHexString((byte)value) + ": " + description;
136        }
137}