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 ******************************************************************/
24 * This file provides APIs for BLE modules.
27 #ifndef _CA_LE_INTERFACE_SINGLETHREAD_H_
28 #define _CA_LE_INTERFACE_SINGLETHREAD_H_
33 #include "caleadapter_singlethread.h"
41 * @enum CALETransferType_t
42 * @brief Provide information about different mode of data transfer
43 * This enum is used to differentiate between unicast and multicast data transfer.
47 LE_MULTICAST, /**< When this enum is selected, data will be updated to all OIC servers. */
48 LE_UNICAST /**< When this enum is selected, data will be updated to desired OIC Server. */
53 * @brief Used to get the current state of the LE adapter.
55 * @return #CA_STATUS_OK or Appropriate error code
56 * @retval #CA_STATUS_OK Successful
57 * @retval #CA_ADAPTER_NOT_ENABLED adapter not enabled
58 * @retval #CA_STATUS_FAILED Operation failed
60 CAResult_t CAGetLEAdapterState();
63 * @brief Used to initialize the network monitor layer of the LE adapter.
65 * @return #CA_STATUS_OK or Appropriate error code
66 * @retval #CA_STATUS_OK Successful
67 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
68 * @retval #CA_STATUS_FAILED Operation failed
70 CAResult_t CALEInitializeNetworkMonitor();
73 * @brief Used to terminate the network monitor layer of the LE adapter.
76 void CALETerminateNetworkMonitor();
79 * @brief This function is used to set the callback for the Device state changes in the adapter.
81 * @param callback [IN] Callback to notify the Device state change to the CA Layer
83 * @return #CA_STATUS_OK or Appropriate error code
84 * @retval #CA_STATUS_OK Successful
85 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
86 * @retval #CA_STATUS_FAILED Operation failed
88 CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback);
91 * @brief Provides the BD address of the local adapter.
92 * @param local_address [IN] pointer to the location where bd address needs to be stored.
96 void CAGetLEAddress(char **local_address);
99 * @brief Used to start Gatt Server thread for service creation and advertise ble service.
101 * @return #CA_STATUS_OK or Appropriate error code
102 * @retval #CA_STATUS_OK Successful
103 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
104 * @retval #CA_STATUS_FAILED Operation failed
106 CAResult_t CAStartBleGattServer();
109 * @brief Used to stop BLE Gatt Service.
111 * @return #CA_STATUS_OK or Appropriate error code
112 * @retval #CA_STATUS_OK Successful
113 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
114 * @retval #CA_STATUS_FAILED Operation failed
116 CAResult_t CAStopBleGattServer();
119 * @brief Used to store upper layer callback locally which will be used to send the data to
121 * @param callback [IN] Callback function to pass the data to CA layer.
124 void CASetBLEReqRespServerCallback(CABLEServerDataReceivedCallback callback);
127 * @brief Used to update characteristics(Read/Write) value that we want to send to particular
128 * client. Both unicast and multicast will use the same api. In mulicast, we will be
129 * sending in loop to all clients.
131 * @param charValue [IN] Data that we want to send to client(unicast)/clients(multicast)
132 * @param charValueLen [IN] Length of the data.
134 * @return #CA_STATUS_OK or Appropriate error code
135 * @retval #CA_STATUS_OK Successful
136 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
137 * @retval #CA_STATUS_FAILED Operation failed
139 CAResult_t CAUpdateCharacteristicsInGattServer(const char *charValue,
140 uint32_t charValueLen);
143 * @brief Used to start CAStartBleGattClientThread for initializing Gatt Client
145 * @return #CA_STATUS_OK or Appropriate error code
146 * @retval #CA_STATUS_OK Successful
147 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
148 * @retval #CA_STATUS_FAILED Operation failed
150 CAResult_t CAStartBLEGattClient();
153 * @brief Used to stop Gatt Client gracefully in turn it will call CATerminateBLEGattClient
155 * @return #CA_STATUS_OK or Appropriate error code
156 * @retval #CA_STATUS_OK Successful
157 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
158 * @retval #CA_STATUS_FAILED Operation failed
160 void CAStopBLEGattClient();
163 * @brief Used to unset all the callbacks and stop service discovery
166 void CATerminateBLEGattClient();
169 * @brief Sets the value of characteristic and update the value to GATTServer(unicast).
171 * @param remoteAddress [IN] The address of the remote device
172 * @param data [IN] The value of characteristic (byte array)
173 * @param dataLen [IN] The length of value
174 * @param type [IN] Type of the transfer(#CALETransferType_t)
175 * @param position [IN] The unique index of each ble server. Used for multicast feature.
177 * @return #CA_STATUS_OK or Appropriate error code
178 * @retval #CA_STATUS_OK Successful
179 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
180 * @retval #CA_STATUS_FAILED Operation failed
182 CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const char *data,
183 const int32_t dataLen, CALETransferType_t type,
184 const int32_t position);
187 * @brief Sets the value of characteristic and update the value to all registered
188 * GATTServer -> Multicast
189 * @param data [IN] The value of characteristic (byte array)
190 * @param dataLen [IN] The length of value
192 * @return #CA_STATUS_OK or Appropriate error code
193 * @retval #CA_STATUS_OK Successful
194 * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
195 * @retval #CA_STATUS_FAILED Operation failed
197 CAResult_t CAUpdateCharacteristicsToAllGattServers(const char *data, int32_t dataLen);
200 * @brief Used to store upper layer callback locally which will be used to send the data to
202 * @param callback [IN] Callback function to pass the data to CA layer.
206 void CASetBLEReqRespClientCallback(CABLEClientDataReceivedCallback callback);
212 #endif //_CA_LE_INTERFACE_SINGLETHREAD_H_