typedef void (*CAErrorCallback)(const CAEndpoint_t *object,
const CAErrorInfo_t *errorInfo);
+/**
+ * Callback function type for network status changes delivery from CA common logic.
+ * @param[out] info Endpoint object from which the network status is changed.
+ * It contains endpoint address based on the connectivity type.
+ * @param[out] status Current network status info.
+ */
+typedef void (*CANetworkMonitorCallback)(const CAEndpoint_t *info, CANetworkStatus_t status);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#ifndef CA_UTILS_INTERFACE_H_
+#define CA_UTILS_INTERFACE_H_
+
+#include "cacommon.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * Callback function type for connection status changes delivery.
+ */
+typedef void (*CAConnectionStateChangedCB)(CATransportAdapter_t adapter,
+ const char *remote_address, bool connected);
+
+/**
+ * Callback function type for adapter status changes delivery.
+ * @param[out] adapter Transport type information.
+ * @param[out] enabled Current adapter status info.
+ */
+typedef void (*CAAdapterStateChangedCB)(CATransportAdapter_t adapter, bool enabled);
+
+/**
+ * Register network monitoring callback.
+ * Network status changes are delivered these callback.
+ * @param[in] adapterStateCB Adapter state monitoring callback.
+ * @param[in] connStateCB Connection state monitoring callback.
+ *
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
+ */
+CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB);
+
+CAResult_t CASetAutoConnectionDeviceInfo(const char* address);
+
+CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* CA_UTILS_INTERFACE_H_ */
+
env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
os.path.join(root_dir, 'lib/libcoap-4.1.1'),
os.path.join(src_dir, '/resource/csdk/logger/include/'),
- os.path.join(root_dir, 'common/inc') ])
+ os.path.join(root_dir, 'common/inc'),
+ os.path.join(root_dir, 'util/inc') ])
if ca_os not in ['arduino', 'windows', 'winrt']:
env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
# Getting common source files
env.SConscript('./../common/SConscript')
+# Getting util source files
+env.SConscript(root_dir + '/util/SConscript')
+
# The tinydtls library is found in '#extlibs/tinydtls', where the '#'
# is interpreted by SCons as the top-level iotivity directory where
# the SConscruct file is found.
static CARequestCallback g_requestHandler = NULL;
static CAResponseCallback g_responseHandler = NULL;
static CAErrorCallback g_errorHandler = NULL;
+static CANetworkMonitorCallback g_nwMonitorHandler = NULL;
static void CAErrorHandler(const CAEndpoint_t *endpoint,
const void *data, uint32_t dataLen,
{
(void)info;
(void)status;
- OIC_LOG(DEBUG, TAG, "IN");
- OIC_LOG(DEBUG, TAG, "OUT");
+ if (g_nwMonitorHandler)
+ {
+ g_nwMonitorHandler(info, status);
+ }
}
void CAHandleRequestResponseCallbacks()
g_errorHandler = errorHandler;
}
+void CASetNetworkMonitorCallback(CANetworkMonitorCallback nwMonitorHandler)
+{
+ g_nwMonitorHandler = nwMonitorHandler;
+}
+
CAResult_t CAInitializeMessageHandler()
{
CASetPacketReceivedCallback(CAReceivedPacketCallback);
--- /dev/null
+#######################################################
+# Build Common Util
+#######################################################
+
+Import('env')
+import os.path
+
+print "Reading util folder script"
+
+ca_os = env.get('TARGET_OS')
+ca_transport = env.get('TARGET_TRANSPORT')
+src_dir = env.get('SRC_DIR')
+root_dir = './../'
+src_dir = './../util/src/'
+
+env.PrependUnique(CPPPATH = [ os.path.join(root_dir, 'api') ])
+env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
+ os.path.join(root_dir, 'lib/libcoap-4.1.1'),
+ os.path.join(src_dir, '/resource/csdk/logger/include/'),
+ os.path.join(root_dir, 'common/inc'),
+ os.path.join(root_dir, 'util/inc') ])
+
+######################################################################
+# Source files to build common for platforms
+######################################################################
+
+env.AppendUnique(CA_SRC = [os.path.join(src_dir,'cautilinterface.c')])
+
+if (('BLE' in ca_transport) or ('ALL' in ca_transport)):
+ if ca_os in ['linux', 'tizen', 'arduino']:
+ env.AppendUnique(CA_SRC = [
+ os.path.join(src_dir,'camanager/' + ca_os + '/caleconnectionmanager.c')])
+
+ if ca_os == 'android':
+ env.AppendUnique(CA_SRC = [
+ os.path.join(src_dir,'camanager/android/caleconnectionmanager.c')])
\ No newline at end of file
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#ifndef CA_MANAGER_LE_INF_H_
+#define CA_MANAGER_LE_INF_H_
+
+#include "cacommon.h"
+#include "cautilinterface.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * Register network monitor callbacks.
+ * Adapter state changes and network state changes are delivered these callbacks.
+ * @param[in] adapterStateCB Adapter state changed callback.
+ * @param[in] connStateCB Connection state changed callback.
+ */
+void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB);
+
+/**
+ * Set device information for auto connection.
+ */
+CAResult_t CASetLEClientAutoConnectionDeviceInfo();
+
+/**
+ * Unset device information to stop auto connection.
+ */
+CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo();
+
+/**
+ * Start advertise to receive request for scanning or connecting.
+ */
+void CAStartServerLEAdvertising();
+
+/**
+ * Stop advertise to destroy advertiser.
+ */
+void CAStopServerLEAdvertising();
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* CA_MANAGER_LE_INF_H_ */
+
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "camanagerleinterface.h"
+#include "cacommon.h"
+#include "logger.h"
+
+#define TAG "OIC_CA_MANAGER_AN_LE"
+
+static CAAdapterStateChangedCB g_adapterStateCB = NULL;
+static CAConnectionStateChangedCB g_connStateCB = NULL;
+
+void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB)
+{
+ OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
+
+ g_adapterStateCB = adapterStateCB;
+ g_connStateCB = connStateCB;
+}
+
+CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char* address)
+{
+ OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char* address)
+{
+ OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+void CAStartServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
+}
+
+void CAStopServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
+}
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "camanagerleinterface.h"
+#include "cacommon.h"
+#include "logger.h"
+
+#define TAG "OIC_CA_MANAGER_AR_LE"
+
+static CAAdapterStateChangedCB g_adapterStateCB = NULL;
+static CAConnectionStateChangedCB g_connStateCB = NULL;
+
+void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB)
+{
+ OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
+
+ g_adapterStateCB = adapterStateCB;
+ g_connStateCB = connStateCB;
+}
+
+CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
+{
+ OIC_LOG(DEBUG, TAG, "CASetClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
+{
+ OIC_LOG(DEBUG, TAG, "CAUnsetClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+void CAStartServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
+}
+
+void CAStopServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
+}
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "camanagerleinterface.h"
+#include "cacommon.h"
+#include "logger.h"
+
+#define TAG "OIC_CA_MANAGER_LI_LE"
+
+static CAAdapterStateChangedCB g_adapterStateCB = NULL;
+static CAConnectionStateChangedCB g_connStateCB = NULL;
+
+void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB)
+{
+ OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
+
+ g_adapterStateCB = adapterStateCB;
+ g_connStateCB = connStateCB;
+}
+
+CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
+{
+ OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
+{
+ OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+void CAStartServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
+}
+
+void CAStopServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
+}
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "camanagerleinterface.h"
+#include "cacommon.h"
+#include "logger.h"
+
+#define TAG "OIC_CA_MANAGER_TZ_LE"
+
+static CAAdapterStateChangedCB g_adapterStateCB = NULL;
+static CAConnectionStateChangedCB g_connStateCB = NULL;
+
+void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB)
+{
+ OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
+
+ g_adapterStateCB = adapterStateCB;
+ g_connStateCB = connStateCB;
+}
+
+CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
+{
+ OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
+{
+ OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
+
+ return CA_NOT_SUPPORTED;
+}
+
+void CAStartServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
+}
+
+void CAStopServerLEAdvertising()
+{
+ OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
+}
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "camanagerleinterface.h"
+#include "cautilinterface.h"
+
+#include "cacommon.h"
+#include "logger.h"
+
+#define TAG "OIC_CA_UTIL_INF"
+
+CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB)
+{
+ OIC_LOG(DEBUG, TAG, "CARegisterNetworkMonitorHandler");
+
+#ifdef LE_ADAPTER
+ CASetLENetworkMonitorCallbacks(adapterStateCB, connStateCB);
+ return CA_STATUS_OK;
+#else
+ return CA_NOT_SUPPORTED;
+#endif
+
+}
+
+CAResult_t CASetAutoConnectionDeviceInfo(const char *address)
+{
+ OIC_LOG(DEBUG, TAG, "CASetAutoConnectionDeviceInfo");
+
+#ifdef LE_ADAPTER
+ return CASetLEClientAutoConnectionDeviceInfo(address);
+#else
+ return CA_NOT_SUPPORTED;
+#endif
+}
+
+CAResult_t CAUnsetAutoConnectionDeviceInfo(const char *address)
+{
+ OIC_LOG(DEBUG, TAG, "CAUnsetAutoConnectionDeviceInfo");
+
+#ifdef LE_ADAPTER
+ return CAUnsetLEClientAutoConnectionDeviceInfo(address);
+#else
+ return CA_NOT_SUPPORTED;
+#endif
+}