2 *******************************************************************
4 * Copyright 2015 Intel Corporation.
6 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 package org.iotivity.base;
25 import java.security.InvalidParameterException;
26 import java.util.EnumSet;
28 public enum OcConnectivityType {
29 /** use when defaults are ok. */
32 /** IPv4 and IPv6, including 6LoWPAN.*/
33 CT_ADAPTER_IP (1 << 16),
35 /** GATT over Bluetooth LE.*/
36 CT_ADAPTER_GATT_BTLE (1 << 17),
38 /** RFCOMM over Bluetooth EDR.*/
39 CT_ADAPTER_RFCOMM_BTEDR (1 << 18),
41 /** Remote Access over XMPP.*/
42 CT_ADAPTER_REMOTE_ACCESS(1 << 19),
45 CT_ADAPTER_TCP(1 << 20),
48 CT_ADAPTER_NFC(1 << 21),
50 /** Insecure transport is the default (subject to change).*/
52 /** secure the transport path.*/
53 CT_FLAG_SECURE (1 << 4),
55 /** IPv4 & IPv6 autoselection is the default.*/
57 /** IP adapter only.*/
58 CT_IP_USE_V6 (1 << 5),
60 /** IP adapter only.*/
61 CT_IP_USE_V4 (1 << 6),
63 /** Link-Local multicast is the default multicast scope for IPv6.
64 * These are placed here to correspond to the IPv6 address bits.*/
66 /** IPv6 Interface-Local scope(loopback).*/
67 CT_SCOPE_INTERFACE (0x1),
69 /** IPv6 Link-Local scope (default).*/
72 /** IPv6 Realm-Local scope.*/
75 /** IPv6 Admin-Local scope.*/
78 /** IPv6 Site-Local scope.*/
81 /** IPv6 Organization-Local scope.*/
84 /** IPv6 Global scope.*/
85 CT_SCOPE_GLOBAL (0xE),
90 private OcConnectivityType(int value) {
94 public int getValue() {
98 public static EnumSet<OcConnectivityType> convertToEnumSet(int value) {
99 EnumSet<OcConnectivityType> typeSet = null;
101 for (OcConnectivityType v : values()) {
102 if (0 != (value & v.getValue())) {
103 if (null == typeSet) {
104 typeSet = EnumSet.of(v);
111 if (null == typeSet || typeSet.isEmpty()) {
112 throw new InvalidParameterException("Unexpected OcConnectivityType value:" + value);
118 public static OcConnectivityType getInstance(int caTransportAdapter) {
119 switch (caTransportAdapter) {
121 return CT_ADAPTER_IP;
123 return CT_ADAPTER_GATT_BTLE;
125 return CT_ADAPTER_RFCOMM_BTEDR;
127 return CT_ADAPTER_REMOTE_ACCESS;
129 return CT_ADAPTER_TCP;