Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / arduino / cablenwmonitor.cpp
1 /******************************************************************
2 *
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
4 *
5 *
6 *
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
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 ******************************************************************/
20
21 //logger.h included first to avoid conflict with RBL library PROGMEM attribute
22 #include "logger.h"
23
24 #include "caleinterface.h"
25
26 #include <Arduino.h>
27 #include <SPI.h>
28 #include <boards.h>
29 #include <RBL_nRF8001.h>
30
31 #include "caleadapter.h"
32 #include "caadapterutils.h"
33 #include "oic_malloc.h"
34
35 /**
36  * @def TAG
37  * @brief Logging tag for module name
38  */
39 #define TAG "LENW"
40
41 /**
42  * @var g_caLEDeviceStateChangedCallback
43  * @brief Maintains the callback to be notified on device state changed.
44  */
45 static CALEDeviceStateChangedCallback g_caLEDeviceStateChangedCallback = NULL;
46
47 /**
48  * @var g_leAddress
49  * @brief Maintains the local BLE Shield Address
50  */
51 static unsigned char *g_leAddress = NULL;
52
53 CAResult_t CAInitializeLENetworkMonitor()
54 {
55     OIC_LOG(DEBUG, TAG, "IN");
56     OIC_LOG(DEBUG, TAG, "OUT");
57     return CA_STATUS_OK;
58 }
59
60 void CATerminateLENetworkMonitor()
61 {
62     OIC_LOG(DEBUG, TAG, "IN");
63     OIC_LOG(DEBUG, TAG, "OUT");
64 }
65
66 CAResult_t CAInitializeLEAdapter(const ca_thread_pool_t threadPool)
67 {
68     OIC_LOG(DEBUG, TAG, "IN");
69     OIC_LOG(DEBUG, TAG, "OUT");
70     return CA_STATUS_OK;
71 }
72
73 CAResult_t CAStartLEAdapter()
74 {
75     // Nothing to do.
76
77     return CA_STATUS_OK;
78 }
79
80 CAResult_t CAStopLEAdapter()
81 {
82     // Nothing to do.
83
84     return CA_STATUS_OK;
85 }
86
87 CAResult_t CAGetLEAdapterState()
88 {
89     OIC_LOG(DEBUG, TAG, "IN");
90     OIC_LOG(DEBUG, TAG, "OUT");
91     return CA_STATUS_OK;
92 }
93
94 CAResult_t CAGetLEAddress(char **leAddress)
95 {
96     OIC_LOG(DEBUG, TAG, "IN");
97     VERIFY_NON_NULL(leAddress, TAG, "leAddress");
98
99     g_leAddress = ble_getAddress();
100     /**
101      *   Below Allocated Memory will be freed by caller API
102      */
103     *leAddress = (char*)OICMalloc(CA_MACADDR_SIZE);
104     if (NULL == *leAddress)
105     {
106         OIC_LOG(ERROR, TAG, "malloc fail");
107         return CA_MEMORY_ALLOC_FAILED;
108     }
109     memcpy(*leAddress, g_leAddress, CA_MACADDR_SIZE);
110     OIC_LOG(DEBUG, TAG, "OUT");
111     return CA_STATUS_OK;
112 }
113
114 CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
115 {
116     OIC_LOG(DEBUG, TAG, "IN");
117
118     g_caLEDeviceStateChangedCallback = callback;
119
120     OIC_LOG(DEBUG, TAG, "OUT");
121     return CA_STATUS_OK;
122 }
123
124 CAResult_t CAUnSetLEAdapterStateChangedCb()
125 {
126     OIC_LOG(DEBUG, TAG, "IN");
127
128     g_caLEDeviceStateChangedCallback = NULL;
129
130     OIC_LOG(DEBUG, TAG, "OUT");
131     return CA_STATUS_OK;
132 }
133
134
135 CAResult_t CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCallback callback)
136 {
137     //TODO
138     return CA_STATUS_OK;
139 }