1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 #include "canetworkconfigurator.h"
24 #include "uarraylist.h"
26 #include "cainterfacecontroller.h"
30 static u_arraylist_t *gSelectedNetworkList = NULL;
32 CAResult_t CAAddNetworkType(uint32_t ConnectivityType)
34 if (gSelectedNetworkList == NULL)
36 OIC_LOG_V(DEBUG, TAG, "Create network list");
38 gSelectedNetworkList = u_arraylist_create();
41 switch (ConnectivityType)
45 #ifndef ETHERNET_ADAPTER
46 OIC_LOG_V(DEBUG, TAG, "Add network type(ETHERNET) - Not Supported");
47 return CA_NOT_SUPPORTED;
48 #endif /* ETHERNET_ADAPTER */
50 OIC_LOG_V(DEBUG, TAG, "Add network type(ETHERNET)");
51 u_arraylist_add(gSelectedNetworkList, &NETWORK_ETHERNET);
58 OIC_LOG_V(DEBUG, TAG, "Add network type(WIFI) - Not Supported");
59 return CA_NOT_SUPPORTED;
60 #endif /* WIFI_ADAPTER */
62 OIC_LOG_V(DEBUG, TAG, "Add network type(WIFI)");
63 u_arraylist_add(gSelectedNetworkList, &NETWORK_WIFI);
70 OIC_LOG_V(DEBUG, TAG, "Add network type(EDR) - Not Supported");
71 return CA_NOT_SUPPORTED;
72 #endif /* EDR_ADAPTER */
74 OIC_LOG_V(DEBUG, TAG, "Add network type(EDR)");
75 u_arraylist_add(gSelectedNetworkList, &NETWORK_EDR);
81 OIC_LOG_V(DEBUG, TAG, "Add network type(LE) - Not Supported");
82 return CA_NOT_SUPPORTED;
83 #endif /* LE_ADAPTER */
85 OIC_LOG_V(DEBUG, TAG, "Add network type(LE)");
86 u_arraylist_add(gSelectedNetworkList, &NETWORK_LE);
91 // start selected interface adapter
92 CAStartAdapter(ConnectivityType);
97 CAResult_t CARemoveNetworkType(uint32_t ConnectivityType)
99 if (gSelectedNetworkList == NULL)
101 OIC_LOG_V(DEBUG, TAG, "Selected network not found");
103 return CA_STATUS_FAILED;
106 switch (ConnectivityType)
110 #ifndef ETHERNET_ADAPTER
111 OIC_LOG_V(DEBUG, TAG, "Remove network type(ETHERNET) - Not Supported");
112 return CA_NOT_SUPPORTED;
115 OIC_LOG_V(DEBUG, TAG, "Remove network type(ETHERNET)");
116 u_arraylist_remove(gSelectedNetworkList, &NETWORK_ETHERNET);
117 #endif /* ETHERNET_ADAPTER */
123 OIC_LOG_V(DEBUG, TAG, "Remove network type(WIFI) - Not Supported");
124 return CA_NOT_SUPPORTED;
126 OIC_LOG_V(DEBUG, TAG, "Remove network type(WIFI)");
127 u_arraylist_remove(gSelectedNetworkList, &NETWORK_WIFI);
128 #endif /* WIFI_ADAPTER */
135 OIC_LOG_V(DEBUG, TAG, "Remove network type(EDR) - Not Supported");
136 return CA_NOT_SUPPORTED;
138 OIC_LOG_V(DEBUG, TAG, "Remove network type(EDR)");
139 u_arraylist_remove(gSelectedNetworkList, &NETWORK_EDR);
140 #endif /* EDR_ADAPTER */
147 OIC_LOG_V(DEBUG, TAG, "Remove network type(LE) - Not Supported");
148 return CA_NOT_SUPPORTED;
150 OIC_LOG_V(DEBUG, TAG, "Remove network type(LE)");
151 u_arraylist_remove(gSelectedNetworkList, &NETWORK_LE);
152 #endif /* LE_ADAPTER */
157 // stop selected interface adapter
158 CAStopAdapter(ConnectivityType);
163 u_arraylist_t* CAGetSelectedNetworkList()
165 if (gSelectedNetworkList == NULL)
167 OIC_LOG_V(DEBUG, TAG, "Selected network not found");
172 return gSelectedNetworkList;