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 018import java.util.HashMap; 019 020import com.digi.xbee.api.utils.HexUtils; 021 022/** 023 * Enumerates the different association indication status for the Wi-Fi 024 * protocol. 025 * 026 * @since 1.2.0 027 */ 028public enum WiFiAssociationIndicationStatus { 029 030 // Enumeration entries 031 SUCCESSFULLY_JOINED(0x00, "Successfully joined to access point."), 032 INITIALIZING(0x01, "Initialization in progress."), 033 INITIALIZED(0x02, "Initialized, but not yet scanning."), 034 DISCONNECTING(0x13, "Disconnecting from access point."), 035 SSID_NOT_CONFIGURED(0x23, "SSID not configured"), 036 INVALID_KEY(0x24, "Encryption key invalid (NULL or invalid length)."), 037 JOIN_FAILED(0x27, "SSID found, but join failed."), 038 WAITING_FOR_AUTH(0x40, "Waiting for WPA or WPA2 authentication."), 039 WAITING_FOR_IP(0x41, "Joined to a network and waiting for IP address."), 040 SETTING_UP_SOCKETS(0x42, "Joined to a network and IP configured. Setting up listening sockets."), 041 SCANNING_FOR_SSID(0xFF, "Scanning for the configured SSID."); 042 043 // Variables 044 private final int value; 045 046 private final String description; 047 048 private final static HashMap<Integer, WiFiAssociationIndicationStatus> lookupTable = new HashMap<Integer, WiFiAssociationIndicationStatus>(); 049 050 static { 051 for (WiFiAssociationIndicationStatus associationIndicationStatus:values()) 052 lookupTable.put(associationIndicationStatus.getValue(), associationIndicationStatus); 053 } 054 055 /** 056 * Class constructor. Instantiates a new 057 * {@code WiFiAssociationIndicationStatus} enumeration entry with the 058 * given parameters. 059 * 060 * @param value Wi-Fi association indication status value. 061 * @param description Wi-Fi association indication status description. 062 */ 063 WiFiAssociationIndicationStatus(int value, String description) { 064 this.value = value; 065 this.description = description; 066 } 067 068 /** 069 * Returns the Wi-Fi association indication status value. 070 * 071 * @return The Wi-Fi association indication status value. 072 */ 073 public int getValue() { 074 return value; 075 } 076 077 /** 078 * Returns the Wi-Fi association indication status description. 079 * 080 * @return The Wi-Fi association indication status description. 081 */ 082 public String getDescription() { 083 return description; 084 } 085 086 /** 087 * Returns the {@code WiFiAssociationIndicationStatus} associated to 088 * the given value. 089 * 090 * @param value Value of the Wi-Fi association indication status to 091 * retrieve. 092 * 093 * @return The Wi-Fi association indication status of the associated 094 * value, {@code null} if it could not be found in the table. 095 */ 096 public static WiFiAssociationIndicationStatus get(int value) { 097 return lookupTable.get(value); 098 } 099 100 /* 101 * (non-Javadoc) 102 * @see java.lang.Enum#toString() 103 */ 104 @Override 105 public String toString() { 106 return HexUtils.byteToHexString((byte)value) + ": " + description; 107 } 108}