[Win32] Change libcoap bitfield structure to use ushort
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caedradapter.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
23  * This file contains the APIs for EDR adapters.
24  */
25
26 #ifndef CA_EDRADAPTER_H_
27 #define CA_EDRADAPTER_H_
28
29 /**
30  * EDR Interface AP.
31  **/
32 #include "cacommon.h"
33 #include "caadapterinterface.h"
34 #include "cathreadpool.h" /* for thread pool */
35
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40
41 /**
42  * Initialize EDR Interface.
43  * @param[in]   registerCallback   Callback to register EDR interface to Connectivity
44  *                                 Abstraction Layer.
45  * @param[in]   reqRespCallback    Callback to notify request and response messages from
46  *                                 server(s) started at Connectivity Abstraction Layer.
47  * @param[in]   netCallback        Callback to notify the network additions to Connectivity
48  *                                 Abstraction Layer.
49  * @param[in]   errorCallback      errorCallback to notify error to connectivity common logic
50  *                                 layer from adapter.
51  * @param[in]   handle             Threadpool Handle.
52  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
53  */
54 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
55                            CANetworkPacketReceivedCallback reqRespCallback,
56                            CANetworkChangeCallback netCallback,
57                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
58
59 /**
60  * Starts EDR connectivity adapters.
61  * As its peer to peer it does not require to start any servers.
62  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
63  */
64 CAResult_t CAStartEDR();
65
66 /**
67  * Starts listening server for receiving multicast search requests.
68  * Starts  RFCOMM Server with prefixed UUID as per OIC specification.
69  *
70  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
71  */
72 CAResult_t CAStartEDRListeningServer();
73
74 /**
75  * Stop listening server for receiving multicast search requests.
76  * Stop  RFCOMM Server with prefixed UUID as per OIC specification.
77  *
78  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
79  */
80 CAResult_t CAStopEDRListeningServer();
81
82 /**
83  * Starting discovery server for receiving multicast advertisements.
84  * Starts  RFCOMM Server with prefixed UUID as per OIC specification.
85  *
86  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
87  */
88 CAResult_t CAStartEDRDiscoveryServer();
89
90 /**
91  * Sends data to the peer bluetooth OIC device using the adapter connectivity.
92  * @param[in]  endpoint         Remote Endpoint information (like ipaddress, port, and
93  *                              connectivity type) to which the unicast data has to be sent.
94  * @param[in]  data             Data to be sent.
95  * @param[in]  dataLength       Size of data to be sent.
96  * @return The number of bytes sent on the network. Returns -1 on error.
97  *
98  */
99 int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
100                              uint32_t dataLength);
101
102 /**
103  * Sends multicast data to all discovered bluetooth OIC devices using the adapter.
104  * @param[in]  endpoint      Remote Endpoint information (like ipaddress, port, and connectivity.
105  * @param[in]  data          Data which needs to be sent to all discovered bluetooth OIC device.
106  * @param[in]  dataLength    Length of data in bytes.
107  * @return Number of bytes sent on the network. Returns -1 on error.
108  */
109 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data,
110                                uint32_t dataLength);
111
112 /**
113  * Get EDR Connectivity network information.
114  *
115  * @param[out]  info    Array of local connectivity information structures.
116  * @param[out]  size    Size of the array @info.
117  *
118  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
119  */
120 CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
121
122 /**
123  * Read Synchronous API callback.
124  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
125  */
126 CAResult_t CAReadEDRData();
127
128 /**
129  * EDR Stops all RFCOMM servers and close sockets.
130  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
131  */
132 CAResult_t CAStopEDR();
133
134 /**
135  * Terminate the EDR connectivity adapter.
136  * Configuration information will be deleted from further use.
137  */
138 void CATerminateEDR();
139
140 /**
141  * Initializes the adapter queues.
142  * This will initiates both server and receiver adapter queues.
143  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
144  */
145 CAResult_t CAAdapterStartQueue();
146
147 #ifdef __cplusplus
148 } /* extern "C" */
149 #endif
150
151 #endif  /* CA_EDRADAPTER_H_ */
152