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 "caleadapter.h"
30 static CANetworkPacketReceivedCallback g_leReceivedCallback = NULL;
31 static ca_thread_pool_t g_threadPoolHandle = NULL;
33 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
34 CANetworkPacketReceivedCallback reqRespCallback,
35 CANetworkChangeCallback netCallback,
36 CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
38 OIC_LOG(DEBUG, TAG, "CAInitializeLE");
40 g_leReceivedCallback = reqRespCallback;
41 g_threadPoolHandle = handle;
44 CAConnectivityHandler_t handler = {};
46 handler.startAdapter = CAStartLE;
47 handler.startListenServer = CAStartLEListeningServer;
48 handler.startDiscoveryServer = CAStartLEDiscoveryServer;
49 handler.sendData = CASendLEUnicastData;
50 handler.sendDataToAll = CASendLEMulticastData;
51 handler.GetnetInfo = CAGetLEInterfaceInformation;
52 handler.readData = CAReadLEData;
53 handler.stopAdapter = CAStopLE;
54 handler.terminate = CATerminateLE;
56 registerCallback(handler, CA_ADAPTER_GATT_BTLE);
61 CAResult_t CAStartLE()
63 OIC_LOG(DEBUG, TAG, "CAStartLE");
68 CAResult_t CAStartLEListeningServer()
70 OIC_LOG(DEBUG, TAG, "CAStartLEListeningServer");
75 CAResult_t CAStartLEDiscoveryServer()
77 OIC_LOG(DEBUG, TAG, "CAStartLEDiscoveryServer");
82 int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen)
84 OIC_LOG(DEBUG, TAG, "CASendLEUnicastData");
89 int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen)
91 OIC_LOG(DEBUG, TAG, "CASendLEMulticastData");
96 CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
98 OIC_LOG(DEBUG, TAG, "CAGetLEInterfaceInformation");
103 CAResult_t CAReadLEData()
105 OIC_LOG(DEBUG, TAG, "Read LE Data");
110 CAResult_t CAStopLE()
112 OIC_LOG(DEBUG, TAG, "CAStopLE");
119 OIC_LOG(DEBUG, TAG, "TerminatLE");