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 CAGetLEAdapterState()
75 OIC_LOG(DEBUG, TAG, "IN");
76 OIC_LOG(DEBUG, TAG, "OUT");
80 CAResult_t CAGetLEAddress(char **leAddress)
82 OIC_LOG(DEBUG, TAG, "IN");
83 VERIFY_NON_NULL(leAddress, TAG, "leAddress");
85 g_leAddress = ble_getAddress();
87 * Below Allocated Memory will be freed by caller API
89 *leAddress = (char*)OICMalloc(CA_MACADDR_SIZE);
90 if (NULL == *leAddress)
92 OIC_LOG(ERROR, TAG, "malloc fail");
93 return CA_MEMORY_ALLOC_FAILED;
95 memcpy(*leAddress, g_leAddress, CA_MACADDR_SIZE);
96 OIC_LOG(DEBUG, TAG, "OUT");
100 CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
102 OIC_LOG(DEBUG, TAG, "IN");
104 g_caLEDeviceStateChangedCallback = callback;
106 OIC_LOG(DEBUG, TAG, "OUT");
110 CAResult_t CAUnSetLEAdapterStateChangedCb()
112 OIC_LOG(DEBUG, TAG, "IN");
114 g_caLEDeviceStateChangedCallback = NULL;
116 OIC_LOG(DEBUG, TAG, "OUT");