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 ******************************************************************/
21 //logger.h included first to avoid conflict with RBL library PROGMEM attribute
24 #include "caleinterface.h"
29 #include <RBL_nRF8001.h>
31 #include "caleadapter.h"
32 #include "caadapterutils.h"
33 #include "oic_malloc.h"
37 * @brief Logging tag for module name
42 * @var g_caLEDeviceStateChangedCallback
43 * @brief Maintains the callback to be notified on device state changed.
45 static CALEDeviceStateChangedCallback g_caLEDeviceStateChangedCallback = NULL;
49 * @brief Maintains the local BLE Shield Address
51 static unsigned char *g_leAddress = NULL;
53 CAResult_t CAInitializeLENetworkMonitor()
55 OIC_LOG(DEBUG, TAG, "IN");
56 OIC_LOG(DEBUG, TAG, "OUT");
60 void CATerminateLENetworkMonitor()
62 OIC_LOG(DEBUG, TAG, "IN");
63 OIC_LOG(DEBUG, TAG, "OUT");
66 CAResult_t CAInitializeLEAdapter(const ca_thread_pool_t threadPool)
68 OIC_LOG(DEBUG, TAG, "IN");
69 OIC_LOG(DEBUG, TAG, "OUT");
73 CAResult_t CAStartLEAdapter()
80 CAResult_t CAStopLEAdapter()
87 CAResult_t CAGetLEAdapterState()
89 OIC_LOG(DEBUG, TAG, "IN");
90 OIC_LOG(DEBUG, TAG, "OUT");
94 CAResult_t CAGetLEAddress(char **leAddress)
96 OIC_LOG(DEBUG, TAG, "IN");
97 VERIFY_NON_NULL(leAddress, TAG, "leAddress");
99 g_leAddress = ble_getAddress();
101 * Below Allocated Memory will be freed by caller API
103 *leAddress = (char*)OICMalloc(CA_MACADDR_SIZE);
104 if (NULL == *leAddress)
106 OIC_LOG(ERROR, TAG, "malloc fail");
107 return CA_MEMORY_ALLOC_FAILED;
109 memcpy(*leAddress, g_leAddress, CA_MACADDR_SIZE);
110 OIC_LOG(DEBUG, TAG, "OUT");
114 CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
116 OIC_LOG(DEBUG, TAG, "IN");
118 g_caLEDeviceStateChangedCallback = callback;
120 OIC_LOG(DEBUG, TAG, "OUT");
124 CAResult_t CAUnSetLEAdapterStateChangedCb()
126 OIC_LOG(DEBUG, TAG, "IN");
128 g_caLEDeviceStateChangedCallback = NULL;
130 OIC_LOG(DEBUG, TAG, "OUT");
135 CAResult_t CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCallback callback)