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_singlethread.h"
29 #include <RBL_nRF8001.h>
31 #include "caleadapter_singlethread.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 CALEInitializeNetworkMonitor()
55 OIC_LOG(DEBUG, TAG, "IN");
56 OIC_LOG(DEBUG, TAG, "OUT");
60 void CALETerminateNetworkMonitor()
62 OIC_LOG(DEBUG, TAG, "IN");
63 OIC_LOG(DEBUG, TAG, "OUT");
66 CAResult_t CAGetLEAdapterState()
68 OIC_LOG(DEBUG, TAG, "IN");
69 OIC_LOG(DEBUG, TAG, "OUT");
73 CAResult_t CAGetLEAddress(char **leAddress)
75 OIC_LOG(DEBUG, TAG, "IN");
76 VERIFY_NON_NULL(leAddress, TAG, "leAddress");
78 g_leAddress = ble_getAddress();
80 * Below Allocated Memory will be freed by caller API
82 *leAddress = (char*)OICMalloc(CA_MACADDR_SIZE);
83 if (NULL == *leAddress)
85 OIC_LOG(ERROR, TAG, "malloc fail");
86 return CA_MEMORY_ALLOC_FAILED;
88 memcpy(*leAddress, g_leAddress, CA_MACADDR_SIZE);
89 OIC_LOG(DEBUG, TAG, "OUT");
93 CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
95 OIC_LOG(DEBUG, TAG, "IN");
97 g_caLEDeviceStateChangedCallback = callback;
99 OIC_LOG(DEBUG, TAG, "OUT");
103 CAResult_t CAUnSetLEAdapterStateChangedCb()
105 OIC_LOG(DEBUG, TAG, "IN");
107 g_caLEDeviceStateChangedCallback = NULL;
109 OIC_LOG(DEBUG, TAG, "OUT");