Implementation of connectivity abstraction feature Release v0.3
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caedradapter_singlethread.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  * @file caedradapter_singlethread.h
22  * @brief This file contains the APIs for single threaded EDR adapters.
23  */
24 #ifndef __CA_EDRADAPTER_SINGLETHREAD_H_
25 #define __CA_EDRADAPTER_SINGLETHREAD_H_
26
27 /**
28  * BT Interface AP
29  **/
30 #include "cacommon.h"
31 #include "caadapterinterface.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 #ifndef BLUETOOTH_ADAPTER_TAG
39 #define BLUETOOTH_ADAPTER_TAG "CA_EDR"
40 #endif //BLUETOOTH_ADAPTER_TAG
41
42 #define OIC_BT_SERVICE_ID "12341234-1C25-481F-9DFB-59193D238280"
43
44 /**
45  * @brief Initialize EDR connectivity interface.
46  * @param registerCallback [IN] To register EDR interfaces to Connectivity Abstraction Layer
47  * @param reqRespCallback [IN] sending responses and discovery messages from unicast , multicast servers
48  * @param netCallback [IN] Intimate the network additions to Connectivity Abstraction Layer.
49  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
50  */
51 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
52                            CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback);
53 /**
54  * @brief Starting EDR connectivity adapters .As its peer to peer it doesnot require to start any servers
55  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
56  */
57 CAResult_t CAStartEDR();
58
59 /**
60  * @brief Starting listening server for receiving multicast search requests
61  * Transport Specific Behavior:
62  *   EDR  Starts RFCOMM Server with prefixed UUID as per specification.
63  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
64  */
65 CAResult_t CAStartEDRListeningServer();
66
67 /**
68  * @brief for starting discovery servers for receiving multicast advertisements
69  * Transport Specific Behavior:
70  *   EDR Starts RFCOMM server with prefixed UUID as per OIC Specification.
71  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
72  */
73 CAResult_t CAStartEDRDiscoveryServer();
74
75 /**
76  * @brief Sends data to the endpoint using the adapter connectivity.
77  * Note: length must be > 0.
78  * @param   endpoint    [IN]    Remote Endpoint information (like ipaddress , port, reference uri and connectivity type) to
79  *                              which the unicast data has to be sent.
80  * @param   data        [IN]    Data which required to be sent.
81  * @param   dataLen     [IN]    Size of data to be sent.
82  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
83  */
84 uint32_t CASendEDRUnicastData(const CARemoteEndpoint_t *endpoint, void *data, uint32_t dataLen);
85
86 /**
87  * @brief Sends Multicast data to the endpoint using the EDR connectivity.
88  * Note: length must be > 0.
89  * @param   data        [IN]    Data which required to be sent.
90  * @param   dataLen     [IN]    Size of data to be sent.
91  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
92  */
93 uint32_t CASendEDRMulticastData(void *data, uint32_t dataLen);
94
95 /**
96  * @brief Starts notification server on EDR adapters.
97  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
98  */
99 CAResult_t CAStartEDRNotifyServer();
100
101 /**
102  * @brief Send notification information.
103  * Note: length must be > 0.
104  * @param   endpoint    [IN]    Remote Endpoint information (like ipaddress , port, reference uri and connectivity type) to
105  *                              which the unicast data has to be sent.
106  * @param   data        [IN]    Data which required to be sent.
107  * @param   dataLen     [IN]    Size of data to be sent.
108  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
109  */
110 uint32_t CASendEDRNotification(const CARemoteEndpoint_t *endpoint, void *data, uint32_t dataLen);
111
112 /**
113  * @brief Get EDR Connectivity network information
114  * @param   info        [OUT]   Local connectivity information structures
115  * @param   size        [OUT]   Number of local connectivity structures.
116  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
117  */
118 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
119
120 /**
121  * @brief Read Synchronous API callback.
122  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
123  */
124 CAResult_t CAReadEDRData();
125
126 /**
127  * @brief Stopping the adapters and close socket connections
128  *   EDR Stops all RFCOMM servers and close sockets.
129  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
130  */
131 CAResult_t CAStopEDR();
132
133 /**
134  * @brief Terminate the EDR connectivity adapter.
135  * Configuration information will be deleted from further use
136  */
137 void CATerminateEDR();
138
139 #ifdef __cplusplus
140 } /* extern "C" */
141 #endif
142
143 #endif  //__CA_EDRADAPTER_H_