CA Integration: Use only non-confirmed messages for initial integration
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / arduino / caleserver.h
1
2 /******************************************************************
3 *
4 * Copyright 2014 Samsung Electronics All Rights Reserved.
5 *
6 *
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 ******************************************************************/
21
22 #ifndef _BLE_ADAPTER_ARDUINO_H_
23 #define _BLE_ADAPTER_ARDUINO_H_
24
25
26 #include <Arduino.h>
27 #include <SPI.h>
28 #include <boards.h>
29 #include <RBL_nRF8001.h>
30 #include <services.h>
31
32 #include "cacommon.h"
33 #include "caadapterinterface.h"
34
35 /**
36  * @brief API to initialize Arduino BLE module and advertise the service
37  * @return - int
38  */
39 CAResult_t CAInitializeBle();
40
41 /**
42  * @brief API to send received data to upper layer
43  * @param[in] data - data received from BLE characteristics
44  * @param[in] dataLen - received data Length
45  * @param[in] senderAdrs - sender Address.
46  * @param[in] senderPort - sender port
47  * @return - Error Code
48  */
49 void CANotifyCallback(void *data, int32_t dataLen, char *senderAdrs, int32_t senderPort);
50
51 /**
52  * @brief API to add new service in Gatt Server
53  * @param[in] service_uuid - unique identifier for each service.
54  * @return - Error Code
55  */
56 CAResult_t CAAddNewBleServiceInGattServer(const char *service_uuid);
57
58 /**
59  * @brief API to remove the added service from  Ble Gatt server.
60  * @param[in] svc_path - unique identifier for each service.
61  * @return - Error Code
62  */
63 CAResult_t CARemoveBleServiceFromGattServer(const char *svc_path);
64
65 /**
66  * @brief API to remove all the services from Ble Gatt server.
67  * @return - Error Code
68  */
69 CAResult_t CARemoveAllBleServicesFromGattServer();
70
71 /**
72  * @brief API to register service with GattService after adding the service.
73  * @param[in] svc_path - unique identifier for each service.
74  * @return - Error Code
75  */
76 CAResult_t CARegisterBleServicewithGattServer(const char *svc_path);
77
78 /**
79  * @brief API to add new characteristics to the service
80  * @param[in]  svc_path service path to which this characteristic belongs to.
81  * @param[in]  char_uuid    Gatt characteristic uuid.
82  * @param[in]  char_value   Gatt characteristic value.
83  * @param[in]  value_len    Caracteristic value length.
84  * @param[in]  char_flags   Characteristic flags.
85  * @param[in]  flags_length Caracteristic flags length.
86  * @param[out] char_path    characteristic path registered on the interface.
87  * @return - Error Code
88  */
89 CAResult_t CAAddNewCharacteristicsToGattServer(const char *svc_path,
90         const char *char_uuid,
91         const char *char_value,
92         int char_value_len,
93         int read);
94
95 /**
96  * @brief API to remove the characteristics.
97  * @param[in]  char_path    characteristic path registered on the interface and unique
98  * identifier for added characteristics.
99  * @return - Error Code
100  */
101 CAResult_t CARemoveCharacteristicsFromGattServer(const char *char_path);
102
103 /**
104  * @brief API to check whether data is available in BLE shield
105  * @return - unsigned char
106  */
107 unsigned char CAIsBleDataAvailable();
108
109 /**
110  * @brief API to check whether client is connected with BLE Shield
111  * @return - unsigned char
112  */
113 unsigned char CAIsBleConnected();
114
115 /**
116  * @brief API to read data from BLE shield
117  * @return - char
118  */
119 char CAReadBleData();
120
121 /**
122  * @brief API to perform BLE events
123  * @return - Error Code
124  */
125 CAResult_t CABleDoEvents();
126
127 /**
128  * @brief  API used to send data to connected ble client
129  *
130  * @param[in]  data  -  data to be sent
131  * @param[in]  len  -  data length
132  *
133  * @return  Error Code
134  */
135 CAResult_t CAWriteBleData(unsigned char *data, uint8_t len);
136
137
138 #endif //#ifndef _BLE_ADAPTER_ARDUINO_H_