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 ******************************************************************/
22 * @file caleinterface.h
23 * @brief This file provides APIs for BLE modules
26 #ifndef _CA_LE_INTERFACE_H_
27 #define _CA_LE_INTERFACE_H_
41 * @brief Provide info about different mode of data transfer
43 * This enum is used to differentiate between unicast and multicast data transfer.
47 MULTICAST, /**< When this enum is selected, data will be updated to all OIC servers. */
48 UNICAST /**< When this enum is selected, data will be updated to desired OIC Server. */
52 * @fn CAStartBleGattServer
53 * @brief Used to start Gatt Server thread for service creation and advertise ble service.
55 * @return 0 on success otherwise a positive error value.
56 * @retval CA_STATUS_OK Successful
57 * @retval CA_STATUS_INVALID_PARAM Invalid input argumets
58 * @retval CA_STATUS_FAILED Operation failed
60 CAResult_t CAStartBleGattServer();
63 * @fn CAStopBleGattServer
64 * @brief Used to terminate BLE Gatt Service.
66 * @return 0 on success otherwise a positive error value.
67 * @retval CA_STATUS_OK Successful
68 * @retval CA_STATUS_INVALID_PARAM Invalid input argumets
69 * @retval CA_STATUS_FAILED Operation failed
71 CAResult_t CAStopBleGattServer();
74 * @fn CASetBLEReqRespServerCallback
75 * @brief used to store upper layer callback locally which will be used to send the data
77 * @param[in] CANetworkPacketReceivedCallback - upper layer callback function
78 * to pass the data to CA layer.
81 void CASetBLEReqRespServerCallback(CABLEServerDataReceivedCallback callback);
84 * @fn CAUpdateCharacteristicsInGattServer
85 * @brief Used to update characteristics(Read/Write) value that we want to send to particular client.
86 * Both unicast and multicast will use the same api. In mulicast, we will be sending in loop to all clients.
88 * @param[in] charValue - data that we want to send to client(unicast)/clients(multicast)
89 * @param[in] charValueLen - length of the data.
91 * @return 0 on success otherwise a positive error value.
92 * @retval CA_STATUS_OK Successful
93 * @retval CA_STATUS_INVALID_PARAM Invalid input argumets
94 * @retval CA_STATUS_FAILED Operation failed
96 CAResult_t CAUpdateCharacteristicsInGattServer(const char *charValue, const uint32_t charValueLen);
99 * @fn CAStartBLEGattClient
100 * @brief Used to start CAStartBleGattClientThread for initializing Gatt Client
102 * @return 0 on success otherwise a positive error value.
103 * @retval CA_STATUS_OK Successful
104 * @retval CA_STATUS_INVALID_PARAM Invalid input argumets
105 * @retval CA_STATUS_FAILED Operation failed
107 CAResult_t CAStartBLEGattClient();
110 * @fn CAStopBLEGattClient
111 * @brief Used to stop Gatt Client gracefully in turn it will call CATerminateBLEGattClient function.
113 * @return 0 on success otherwise a positive error value.
114 * @retval CA_STATUS_OK Successful
115 * @retval CA_STATUS_INVALID_PARAM Invalid input argumets
116 * @retval CA_STATUS_FAILED Operation failed
118 void CAStopBLEGattClient();
121 * @fn CATerminateBLEGattClient
122 * @brief Used to unset all the callbacks and stop service discovery
126 void CATerminateBLEGattClient();
129 * @fn CAUpdateCharacteristicsToGattServer
130 * @brief Sets the value of characteristic and update the value to GATTServer(unicast).
132 * @param[in] remoteAddress The address of the remote device
133 * @param[in] data The value of characteristic (byte array)
134 * @param[in] dataLen The length of value
135 * @param[in] TRANSFER_TYPE (UNICAST/MULTICAST)
136 * @param[in] position The unique index of each ble server. Used for multicast feature.
138 * @return 0 on success otherwise a positive error value.
139 * @retval CA_STATUS_OK Successful
140 * @retval CA_STATUS_INVALID_PARAM Invalid input argumets
141 * @retval CA_STATUS_FAILED Operation failed
143 CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const char *data,
144 const int32_t dataLen, TRANSFER_TYPE type, const int32_t position);
147 * @fn CAUpdateCharacteristicsToAllGattServers
148 * @brief Sets the value of characteristic and update the value to All registered GATTServer -> Multicast
150 * @param[in] data The value of characteristic (byte array)
151 * @param[in] dataLen The length of value
153 * @return 0 on success otherwise a positive error value.
154 * @retval CA_STATUS_OK Successful
155 * @retval CA_STATUS_INVALID_PARAM Invalid input argumets
156 * @retval CA_STATUS_FAILED Operation failed
158 CAResult_t CAUpdateCharacteristicsToAllGattServers(const char *data, const int32_t dataLen);
161 * @fn CASetBLEReqRespClientCallback
162 * @brief used to store upper layer callback locally which will be used to send the data to application
164 * @param[in] CANetworkPacketReceivedCallback - upper layer callback function to pass the data to CA layer.
168 void CASetBLEReqRespClientCallback(CABLEClientDataReceivedCallback callback);
174 #endif //_CA_LE_INTERFACE_H_