#include "uarraylist.h"
#include "logger.h"
-#define TAG "CA_NW_CONFIG"
+#define TAG "OIC_CA_NW_CONFIG"
static u_arraylist_t *g_selectedNetworkList = NULL;
-static uint32_t NETWORK_IP = CA_ADAPTER_IP;
+
+#ifdef EDR_ADAPTER
static uint32_t NETWORK_RFCOMM = CA_ADAPTER_RFCOMM_BTEDR;
+#endif
+
+#ifdef LE_ADAPTER
static uint32_t NETWORK_GATT = CA_ADAPTER_GATT_BTLE;
+#endif
+
+#ifdef IP_ADAPTER
+static uint32_t NETWORK_IP = CA_ADAPTER_IP;
+#endif
+
+#ifdef NFC_ADAPTER
+static uint32_t NETWORK_NFC = CA_ADAPTER_NFC;
+#endif
#ifdef RA_ADAPTER
static uint32_t NETWORK_RA = CA_ADAPTER_REMOTE_ACCESS;
#endif
-#ifdef CI_ADAPTER
-static uint32_t NETWORK_CI = CA_ADAPTER_CLOUD_INTERFACE;
+#ifdef TCP_ADAPTER
+static uint32_t NETWORK_TCP = CA_ADAPTER_TCP;
#endif
CAResult_t CAAddNetworkType(CATransportAdapter_t transportType)
{
- OIC_LOG(DEBUG, TAG, "IN");
if (NULL == g_selectedNetworkList)
{
OIC_LOG(DEBUG, TAG, "Create network list");
{
case CA_ADAPTER_IP:
#ifndef IP_ADAPTER
- OIC_LOG(DEBUG, TAG, "Add network type(IP) - Not Supported");
return CA_NOT_SUPPORTED;
-#endif /* IP_ADAPTER */
+#else
- OIC_LOG(DEBUG, TAG, "Add network type(IP)");
if (u_arraylist_contains(g_selectedNetworkList, &NETWORK_IP))
{
goto exit;
}
res = u_arraylist_add(g_selectedNetworkList, &NETWORK_IP);
+
break;
+#endif // IP_ADAPTER
case CA_ADAPTER_RFCOMM_BTEDR:
#ifndef EDR_ADAPTER
- OIC_LOG(DEBUG, TAG, "Add network type(EDR) - Not Supported");
return CA_NOT_SUPPORTED;
-#endif /* EDR_ADAPTER */
+#else
- OIC_LOG(DEBUG, TAG, "Add network type(EDR)");
if (u_arraylist_contains(g_selectedNetworkList, &NETWORK_RFCOMM))
{
goto exit;
}
res = u_arraylist_add(g_selectedNetworkList, &NETWORK_RFCOMM);
+
break;
+#endif // EDR_ADAPTER
case CA_ADAPTER_GATT_BTLE:
#ifndef LE_ADAPTER
- OIC_LOG(DEBUG, TAG, "Add network type(LE) - Not Supported");
return CA_NOT_SUPPORTED;
-#endif /* LE_ADAPTER */
+#else
- OIC_LOG(DEBUG, TAG, "Add network type(LE)");
if (u_arraylist_contains(g_selectedNetworkList, &NETWORK_GATT))
{
goto exit;
}
res = u_arraylist_add(g_selectedNetworkList, &NETWORK_GATT);
+
break;
+#endif // LE_ADAPTER
#ifdef RA_ADAPTER
case CA_ADAPTER_REMOTE_ACCESS:
- OIC_LOG(DEBUG, TAG, "Add network type(RA)");
if (u_arraylist_contains(g_selectedNetworkList, &NETWORK_RA))
{
goto exit;
}
res = u_arraylist_add(g_selectedNetworkList, &NETWORK_RA);
break;
-#endif /* RA_ADAPTER */
+#endif // RA_ADAPTER
+
+#ifdef TCP_ADAPTER
+ case CA_ADAPTER_TCP:
+
+ if (u_arraylist_contains(g_selectedNetworkList, &NETWORK_TCP))
+ {
+ goto exit;
+ }
+ res = u_arraylist_add(g_selectedNetworkList, &NETWORK_TCP);
+ break;
+#endif // TCP_ADAPTER
-#ifdef CI_ADAPTER
- case CA_ADAPTER_CLOUD_INTERFACE:
- OIC_LOG(DEBUG, TAG, "Add network type(CI)");
- if (u_arraylist_contains(g_selectedNetworkList, &NETWORK_CI))
+ case CA_ADAPTER_NFC:
+ #ifndef NFC_ADAPTER
+ return CA_NOT_SUPPORTED;
+
+#else
+ if (u_arraylist_contains(g_selectedNetworkList, &NETWORK_NFC))
{
goto exit;
}
- res = u_arraylist_add(g_selectedNetworkList, &NETWORK_CI);
+ res = u_arraylist_add(g_selectedNetworkList, &NETWORK_NFC);
+
break;
-#endif /* CI_ADAPTER */
+#endif // CA_ADAPTER_NFC
default:
break;
}
// start selected interface adapter
CAResult_t result = CAStartAdapter(transportType);
- OIC_LOG(DEBUG, TAG, "OUT");
return result;
exit:
CAResult_t CARemoveNetworkType(CATransportAdapter_t transportType)
{
- OIC_LOG(DEBUG, TAG, "IN");
-
if (NULL == g_selectedNetworkList)
{
OIC_LOG(ERROR, TAG, "SelectedNetwork list is NULL");
OIC_LOG(DEBUG, TAG, "Remove network type(IP)");
u_arraylist_remove(g_selectedNetworkList, index);
-#endif /* IP_ADAPTER */
+
break;
+#endif //IP_ADAPTER
case CA_ADAPTER_RFCOMM_BTEDR:
#ifndef EDR_ADAPTER
#else
OIC_LOG(DEBUG, TAG, "Remove network type(EDR)");
u_arraylist_remove(g_selectedNetworkList, index);
-#endif /* EDR_ADAPTER */
+
break;
+#endif // EDR_ADAPTER
case CA_ADAPTER_GATT_BTLE:
#ifndef LE_ADAPTER
#else
OIC_LOG(DEBUG, TAG, "Remove network type(LE)");
u_arraylist_remove(g_selectedNetworkList, index);
-#endif /* LE_ADAPTER */
break;
+#endif // LE_ADAPTER
+
#ifdef RA_ADAPTER
case CA_ADAPTER_REMOTE_ACCESS:
OIC_LOG(DEBUG, TAG, "Remove network type(RA)");
u_arraylist_remove(g_selectedNetworkList, index);
break;
-#endif /* RA_ADAPTER */
+#endif // RA_ADAPTER
-#ifdef CI_ADAPTER
- case CA_ADAPTER_CLOUD_INTERFACE:
- OIC_LOG(DEBUG, TAG, "Remove network type(RA)");
+#ifdef TCP_ADAPTER
+ case CA_ADAPTER_TCP:
+ OIC_LOG(DEBUG, TAG, "Remove network type(TCP)");
u_arraylist_remove(g_selectedNetworkList, index);
break;
-#endif /* CI_ADAPTER */
+#endif // TCP_ADAPTER
+
+#ifndef NFC_ADAPTER
+ case CA_ADAPTER_NFC:
+ OIC_LOG(DEBUG, TAG, "Add network type(NFC) - Not Supported");
+ return CA_NOT_SUPPORTED;
+#else
+ OIC_LOG(DEBUG, TAG, "Add network type(NFC)");
+ u_arraylist_remove(g_selectedNetworkList, index);
+ break;
+#endif // CA_ADAPTER_NFC
default:
break;
}