Implementation of connectivity abstraction feature release v0.2
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caleadapter.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /**
22  * @file caleadapter.h
23  * @brief This file contains the APIs for LE adapters to be implemented
24  */
25 #ifndef _CA_LEADAPTER_H_
26 #define _CA_LEADAPTER_H_
27
28 #include "cacommon.h"
29 #include "caadapterinterface.h"
30 #include "uthreadpool.h" /* for thread pool */
31
32 /**
33  * BLE Interface APIs.
34  */
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39
40 /**
41  * @brief Initialize LE connectivity interface.
42  * @param registerCallback [IN] To register LE interfaces to Connectivity Abstraction Layer
43  * @param reqRespCallback [IN] sending responses and discovery messages from unicast , \
44  *                                             multicast servers
45  * @param netCallback [IN] Intimate the network additions to Connectivity Abstraction Layer.
46  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
47  */
48
49 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
50                           CANetworkPacketReceivedCallback reqRespCallback,
51                           CANetworkChangeCallback netCallback,
52                           u_thread_pool_t handle);
53 /**
54  * @brief Starting LE connectivity adapters . \
55  *           As its peer to peer it doesnot require to start any servers
56  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
57  */
58 CAResult_t CAStartLE();
59
60 /**
61  * @brief Starting listening server for receiving multicast search requests
62  * Transport Specific Behavior:
63  *   LE  Starts GATT Server with prefixed UUID and Characteristics as per OIC Specification.
64  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
65  */
66 CAResult_t CAStartLEListeningServer();
67
68 /**
69  * @brief for starting discovery servers for receiving multicast advertisements
70  * Transport Specific Behavior:
71  *   LE  Starts GATT Server with prefixed UUID and Characteristics as per OIC Specification.
72  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
73  */
74 CAResult_t CAStartLEDiscoveryServer();
75
76 /**
77  * @brief Sends data to the endpoint using the adapter connectivity.
78  * Note: length must be > 0.
79  * @param   endpoint  [IN]  Remote Endpoint information (like ipaddress , port, reference uri \
80  *                                            and connectivity type) to which the unicast data has to be sent.
81  * @param   data        [IN]  Data which required to be sent.
82  * @param   dataLen   [IN]  Size of data to be sent.
83  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
84  */
85 uint32_t CASendLEUnicastData(const CARemoteEndpoint_t *endpoint, void *data, uint32_t dataLen);
86
87 /**
88  * @brief Sends Multicast data to the endpoint using the LE connectivity.
89  * Note: length must be > 0.
90  * @param   data        [IN]    Data which required to be sent.
91  * @param   dataLen     [IN]    Size of data to be sent.
92  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
93  */
94 uint32_t CASendLEMulticastData(void *data, uint32_t dataLen);
95
96 /**
97  * @brief Starts notification server on EDR adapters.
98  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
99  */
100 CAResult_t CAStartLENotifyServer();
101
102 /**
103  * @brief Send notification information.
104  * Note: length must be > 0.
105  * @param   endpoint  [IN]    Remote Endpoint information (like ipaddress , port, reference uri \
106  *                                          and connectivity type) to which the unicast data has to be sent.
107  * @param   data        [IN]    Data which required to be sent.
108  * @param   dataLen   [IN]    Size of data to be sent.
109  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
110  */
111 uint32_t CASendLENotification(const CARemoteEndpoint_t *endpoint, void *data, uint32_t dataLen);
112
113 /**
114  * @brief Get LE Connectivity network information
115  * @param   info        [OUT]   Local connectivity information structures
116  * @param   size        [OUT]   Number of local connectivity structures.
117  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
118  */
119 CAResult_t CAGetLEInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
120
121 /**
122  * @brief Read Synchronous API callback.
123  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
124  */
125 CAResult_t CAReadLEData();
126
127 /**
128  * @brief Stopping the adapters and close socket connections
129  *   LE Stops all GATT servers and close sockets.
130  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
131  */
132 CAResult_t CAStopLE();
133
134 /**
135  * @brief Terminate the LE connectivity adapter.
136  * Configuration information will be deleted from further use
137  */
138 void CATerminateLE();
139
140 #ifdef __cplusplus
141 } /* extern "C" */
142 #endif
143
144 #endif //#ifndef _CA_LEADAPTER_H_