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 ******************************************************************/
25 #include "caedradapter.h"
28 #define TAG PCF("OIC_CA")
30 static CANetworkPacketReceivedCallback g_edrReceivedCallback = NULL;
31 static ca_thread_pool_t g_threadPoolHandle = NULL;
33 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
34 CANetworkPacketReceivedCallback reqRespCallback,
35 CANetworkChangeCallback networkStateChangeCallback,
36 CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
38 (void)networkStateChangeCallback;
40 OIC_LOG(DEBUG, TAG, "CAInitializeEDR");
42 g_edrReceivedCallback = reqRespCallback;
43 g_threadPoolHandle = handle;
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
60 registerCallback(handler);
65 CAResult_t CAStartEDR()
67 OIC_LOG(DEBUG, TAG, "CAStartEDR");
72 CAResult_t CAStartEDRListeningServer()
74 OIC_LOG(DEBUG, TAG, "CAStartEDRListeningServer");
79 CAResult_t CAStopEDRListeningServer()
81 OIC_LOG(DEBUG, TAG, "CAStopEDRListeningServer");
86 CAResult_t CAStartEDRDiscoveryServer()
88 OIC_LOG(DEBUG, TAG, "CAStartEDRDiscoveryServer");
93 int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
99 OIC_LOG(DEBUG, TAG, "CASendEDRUnicastData");
104 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen)
109 OIC_LOG(DEBUG, TAG, "CASendEDRMulticastData");
114 CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
118 OIC_LOG(DEBUG, TAG, "CAGetEDRInterfaceInformation");
123 CAResult_t CAReadEDRData()
125 OIC_LOG(DEBUG, TAG, "Read EDR Data");
130 CAResult_t CAStopEDR()
132 OIC_LOG(DEBUG, TAG, "CAStopEDR");
137 void CATerminateEDR()
139 OIC_LOG(DEBUG, TAG, "CATerminateEDR");