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()
68 OIC_LOG(DEBUG, TAG, "IN");
69 OIC_LOG(DEBUG, TAG, "OUT");
73 CAResult_t CAStartLEAdapter()
80 CAResult_t CAGetLEAdapterState()
82 OIC_LOG(DEBUG, TAG, "IN");
83 OIC_LOG(DEBUG, TAG, "OUT");
87 CAResult_t CAGetLEAddress(char **leAddress)
89 OIC_LOG(DEBUG, TAG, "IN");
90 VERIFY_NON_NULL(leAddress, TAG, "leAddress");
92 g_leAddress = ble_getAddress();
94 * Below Allocated Memory will be freed by caller API
96 *leAddress = (char*)OICMalloc(CA_MACADDR_SIZE);
97 if (NULL == *leAddress)
99 OIC_LOG(ERROR, TAG, "malloc fail");
100 return CA_MEMORY_ALLOC_FAILED;
102 memcpy(*leAddress, g_leAddress, CA_MACADDR_SIZE);
103 OIC_LOG(DEBUG, TAG, "OUT");
107 CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
109 OIC_LOG(DEBUG, TAG, "IN");
111 g_caLEDeviceStateChangedCallback = callback;
113 OIC_LOG(DEBUG, TAG, "OUT");
117 CAResult_t CAUnSetLEAdapterStateChangedCb()
119 OIC_LOG(DEBUG, TAG, "IN");
121 g_caLEDeviceStateChangedCallback = NULL;
123 OIC_LOG(DEBUG, TAG, "OUT");