001/**
002 * Copyright 2017, 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.models;
017
018/**
019 * Enumerates the different working modes of the XBee device. The operating 
020 * mode establishes the way a user communicates with an XBee device through 
021 * its serial interface.
022 */
023public enum OperatingMode {
024
025        // Enumeration types
026        AT(0, "AT mode"),
027        API(1, "API mode"),
028        API_ESCAPE(2, "API mode with escaped characters"),
029        UNKNOWN(3, "Unknown");
030        
031        // Variables
032        private final int id;
033        
034        private final String name;
035        
036        /**
037         * Class constructor. Instantiates a new {@code OperatingMode} enumeration 
038         * entry with the given parameters.
039         * 
040         * @param id Operating mode ID.
041         * @param name Operating mode name.
042         */
043        private OperatingMode(int id, String name) {
044                this.id = id;
045                this.name = name;
046        }
047        
048        /**
049         * Returns the operating mode ID.
050         * 
051         * @return Operating mode ID.
052         */
053        public int getID() {
054                return id;
055        }
056        
057        /**
058         * Returns the operating mode name.
059         * 
060         * @return Operating mode name.
061         */
062        public String getName() {
063                return name;
064        }
065        
066        /*
067         * (non-Javadoc)
068         * @see java.lang.Enum#toString()
069         */
070        @Override
071        public String toString() {
072                return name;
073        }
074}