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 ******************************************************************/
22 * @file caadapterinterface.h
23 * @brief This file contains the APIs for adapters to be implemented
25 #ifndef __CA_ADAPTER_INTERFACE_H_
26 #define __CA_ADAPTER_INTERFACE_H_
36 * @brief Starting connectivity adapters and each adapter have transport specific behavior.
37 * Transport Specific Behavior:
38 * WIFI/ETH connectivity Starts unicast server on all available IPs and defined
39 * port number as per specification.
40 * EDR will not start any specific servers.
41 * LE will not start any specific servers.
42 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
44 typedef CAResult_t (*CAAdapterStart)();
47 * @brief Starting listening server for receiving multicast search requests
48 * Transport Specific Behavior:
49 * WIFI/ETH Starts multicast server on all available IPs and defined
50 * port number and as per specification.
51 * EDR Starts RFCOMM Server with prefixed UUID as per specification.
52 * LE Start GATT Server with prefixed UUID and Characteristics as per OIC Specification.
53 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
55 typedef CAResult_t (*CAAdapterStartListeningServer)();
58 * @brief for starting discovery servers for receiving multicast advertisements
59 * Transport Specific Behavior:
60 * WIFI/ETH Starts multicast server on all available IPs and defined port
61 * number as per OIC Specification.
62 * EDR Starts RFCOMM Server with prefixed UUID as per OIC Specification.
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)
66 typedef CAResult_t (*CAAdapterStartDiscoveryServer)();
69 * @brief Sends data to the endpoint using the adapter connectivity.
70 * Note: length must be > 0.
71 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port,
72 * reference uri and connectivity type) to which the unicast data has to be sent.
73 * @param data [IN] Data which required to be sent.
74 * @param dataLen [IN] Size of data to be sent.
75 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
77 typedef uint32_t (*CAAdapterSendUnitcastData)(const CARemoteEndpoint_t *endpoint, void *data,
81 * @brief Sends Multicast data to the endpoint using the adapter connectivity.
82 * Note: length must be > 0.
83 * @param data [IN] Data which required to be sent.
84 * @param dataLen [IN] Size of data to be sent.
85 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
87 typedef uint32_t (*CAAdapterSendMulticastData)(void *data, uint32_t dataLen);
90 * @brief Get Network Information
91 * @param info [OUT] Local connectivity information structures
92 * @param size [OUT] Number of local connectivity structures.
93 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
95 typedef CAResult_t (*CAAdapterGetNetworkInfo)(CALocalConnectivity_t **info, uint32_t *size);
98 * @brief Read Synchronous API callback.
99 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
101 typedef CAResult_t (*CAAdapterReadData)();
104 * @brief Stopping the adapters and close socket connections
105 * Transport Specific Behavior:
106 * WIFI/ETH Stops all listening servers and close sockets.
107 * EDR Stops all RFCOMM servers and close sockets.
108 * LE Stops all GATT servers and close sockets.
109 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
111 typedef CAResult_t (*CAAdapterStop)();
114 * @brief Terminate the connectivity adapter.Configuration information will be deleted from
117 typedef void (*CAAdapterTerminate)();
120 * @brief Connectivity handler information for adapter
124 /** Start Transport specific functions*/
125 CAAdapterStart startAdapter;
126 /** Listening Server function address*/
127 CAAdapterStartListeningServer startListenServer;
128 /** Discovery Server function address **/
129 CAAdapterStartDiscoveryServer startDiscoverServer;
130 /** Unicast data function address**/
131 CAAdapterSendUnitcastData sendData;
132 /** Multicast data function address**/
133 CAAdapterSendMulticastData sendDataToAll;
134 /** Get Networking information **/
135 CAAdapterGetNetworkInfo GetnetInfo;
136 /** Read Data function address**/
137 CAAdapterReadData readData;
138 /** Stop Transport specific functions*/
139 CAAdapterStop stopAdapter;
140 /** Terminate function address stored in this pointer**/
141 CAAdapterTerminate terminate;
143 } CAConnectivityHandler_t;
146 * @brief This will be used during the registration of adapters call backs to the common logic
147 * @see CAConnectivityHandler_t , CAConnectivityType_t
149 typedef void (*CARegisterConnectivityCallback)(CAConnectivityHandler_t handler,
150 CAConnectivityType_t cType);
153 * @brief This will be used during the recive of network requests and response.
154 * @see SendUnitcastData(), SendMulticastData()
156 typedef void (*CANetworkPacketReceivedCallback)(CARemoteEndpoint_t *endPoint, void *data,
160 * @brief This will be used to intimate network changes to the connectivity common logic layer
161 * @see SendUnitcastData(), SendMulticastData()
163 typedef void (*CANetworkChangeCallback)(CALocalConnectivity_t *info, CANetworkStatus_t status);
166 * @brief This will be used during the recive of network requests and response.
167 * @see SendUnitcastData(), SendMulticastData()
169 typedef void (*CABLEClientDataReceivedCallback)(const char *remoteAddress, const char *serviceUUID,
170 void *data, uint32_t dataLength, uint32_t *sentLength);
173 * @brief This will be used during the recive of network requests and response.
174 * @see SendUnitcastData(), SendMulticastData()
176 typedef void (*CABLEServerDataReceivedCallback)(const char *remoteAddress, const char *serviceUUID,
177 void *data, uint32_t dataLength, uint32_t *sentLength);
182 #endif // __CA_ADAPTER_INTERFACE_H_