Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_edr_adapter / linux / caedradapter.c
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 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "caedradapter.h"
26 #include "logger.h"
27
28 #define TAG PCF("OIC_CA")
29
30 static CANetworkPacketReceivedCallback g_edrReceivedCallback = NULL;
31 static ca_thread_pool_t g_threadPoolHandle = NULL;
32
33 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
34                            CANetworkPacketReceivedCallback reqRespCallback,
35                            CANetworkChangeCallback networkStateChangeCallback,
36                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
37 {
38     (void)networkStateChangeCallback;
39     (void)errorCallback;
40     OIC_LOG(DEBUG, TAG, "CAInitializeEDR");
41
42     g_edrReceivedCallback = reqRespCallback;
43     g_threadPoolHandle = handle;
44
45     // register handlers
46     CAConnectivityHandler_t handler = {
47         .startAdapter = CAStartEDR,
48         .startListenServer = CAStartEDRListeningServer,
49         .stopListenServer = CAStopEDRListeningServer,
50         .startDiscoveryServer = CAStartEDRDiscoveryServer,
51         .sendData = CASendEDRUnicastData,
52         .sendDataToAll = CASendEDRMulticastData,
53         .GetnetInfo = CAGetEDRInterfaceInformation,
54         .readData = CAReadEDRData,
55         .stopAdapter = CAStopEDR,
56         .terminate = CATerminateEDR,
57         .cType = CA_ADAPTER_RFCOMM_BTEDR
58     };
59
60     registerCallback(handler);
61
62     return CA_STATUS_OK;
63 }
64
65 CAResult_t CAStartEDR()
66 {
67     OIC_LOG(DEBUG, TAG, "CAStartEDR");
68
69     return CA_STATUS_OK;
70 }
71
72 CAResult_t CAStartEDRListeningServer()
73 {
74     OIC_LOG(DEBUG, TAG, "CAStartEDRListeningServer");
75
76     return CA_STATUS_OK;
77 }
78
79 CAResult_t CAStopEDRListeningServer()
80 {
81     OIC_LOG(DEBUG, TAG, "CAStopEDRListeningServer");
82
83     return CA_STATUS_OK;
84 }
85
86 CAResult_t CAStartEDRDiscoveryServer()
87 {
88     OIC_LOG(DEBUG, TAG, "CAStartEDRDiscoveryServer");
89
90     return CA_STATUS_OK;
91 }
92
93 int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
94     uint32_t dataLen)
95 {
96     (void)endpoint;
97     (void)data;
98     (void)dataLen;
99     OIC_LOG(DEBUG, TAG, "CASendEDRUnicastData");
100
101     return -1;
102 }
103
104 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen)
105 {
106     (void)endpoint;
107     (void)data;
108     (void)dataLen;
109     OIC_LOG(DEBUG, TAG, "CASendEDRMulticastData");
110
111     return -1;
112 }
113
114 CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
115 {
116     (void)info;
117     (void)size;
118     OIC_LOG(DEBUG, TAG, "CAGetEDRInterfaceInformation");
119
120     return CA_STATUS_OK;
121 }
122
123 CAResult_t CAReadEDRData()
124 {
125     OIC_LOG(DEBUG, TAG, "Read EDR Data");
126
127     return CA_STATUS_OK;
128 }
129
130 CAResult_t CAStopEDR()
131 {
132     OIC_LOG(DEBUG, TAG, "CAStopEDR");
133
134     return CA_STATUS_OK;
135 }
136
137 void CATerminateEDR()
138 {
139     OIC_LOG(DEBUG, TAG, "CATerminateEDR");
140 }
141