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 port number as per specification.
39 * EDR will not start any specific servers.
40 * LE will not start any specific servers.
41 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
43 typedef CAResult_t (*CAAdapterStart)();
46 * @brief Starting listening server for receiving multicast search requests
47 * Transport Specific Behavior:
48 * WIFI/ETH Starts multicast server on all available IPs and defined port number and as per specification.
49 * EDR Starts RFCOMM Server with prefixed UUID as per specification.
50 * LE Start GATT Server with prefixed UUID and Characteristics as per OIC Specification.
51 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
53 typedef CAResult_t (*CAAdapterStartListeningServer)();
56 * @brief for starting discovery servers for receiving multicast advertisements
57 * Transport Specific Behavior:
58 * WIFI/ETH Starts multicast server on all available IPs and defined port number as per OIC Specification.
59 * EDR Starts RFCOMM Server with prefixed UUID as per OIC Specification.
60 * LE Starts GATT Server with prefixed UUID and Characteristics as per OIC Specification.
61 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
63 typedef CAResult_t (*CAAdapterStartDiscoveryServer)();
66 * @brief Sends data to the endpoint using the adapter connectivity.
67 * Note: length must be > 0.
68 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port, reference uri and connectivity type) to
69 * which the unicast data has to be sent.
70 * @param data [IN] Data which required to be sent.
71 * @param dataLen [IN] Size of data to be sent.
72 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
74 typedef uint32_t (*CAAdapterSendUnitcastData)(const CARemoteEndpoint_t* endpoint, void* data,
78 * @brief Sends Multicast data to the endpoint using the adapter connectivity.
79 * Note: length must be > 0.
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.
84 typedef uint32_t (*CAAdapterSendMulticastData)(void* data, uint32_t dataLen);
87 * @brief Starts notification server on adapters.
88 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
90 typedef CAResult_t (*CAAdapterStartNotificationRecvServer)();
93 * @brief Send notification information to the given endpoint.
94 * Note: length must be > 0.
95 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port, reference uri and connectivity type) to
96 * which the unicast data has to be sent.
97 * @param data [IN] Data which required to be sent.
98 * @param dataLen [IN] Size of data to be sent.
99 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
101 typedef uint32_t (*CAAdapterSendNotification)(const CARemoteEndpoint_t* endpoint, void* data,
105 * @brief Get Network Information
106 * @param info [OUT] Local connectivity information structures
107 * @param size [OUT] Number of local connectivity structures.
108 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
110 typedef CAResult_t (*CAAdapterGetNetworkInfo)(CALocalConnectivityt_t** info, uint32_t* size);
113 * @brief Read Synchronous API callback.
114 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
116 typedef CAResult_t (*CAAdapterReadData)();
119 * @brief Stopping the adapters and close socket connections
120 * Transport Specific Behavior:
121 * WIFI/ETH Stops all listening servers and close sockets.
122 * EDR Stops all RFCOMM servers and close sockets.
123 * LE Stops all GATT servers and close sockets.
124 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
126 typedef CAResult_t (*CAAdapterStop)();
129 * @brief Terminate the connectivity adapter.Configuration information will be deleted from further use
131 typedef void (*CAAdapterTerminate)();
134 * @brief Connectivity handler information for adapter
138 /** Start Transport specific functions*/
139 CAAdapterStart startAdapter;
140 /** Listening Server function address*/
141 CAAdapterStartListeningServer startListenServer;
142 /** Discovery Server function address **/
143 CAAdapterStartDiscoveryServer startDiscoverServer;
144 /** Unicast data function address**/
145 CAAdapterSendUnitcastData sendData;
146 /** Multicast data function address**/
147 CAAdapterSendMulticastData sendDataToAll;
148 /** Notify server function address**/
149 CAAdapterStartNotificationRecvServer startNotifyServer;
150 /** Send Notification function address**/
151 CAAdapterSendNotification sendNotification;
152 /** Get Networking information **/
153 CAAdapterGetNetworkInfo GetnetInfo;
154 /** Read Data function address**/
155 CAAdapterReadData readData;
156 /** Stop Transport specific functions*/
157 CAAdapterStop stopAdapter;
158 /** Terminate function address stored in this pointer**/
159 CAAdapterTerminate terminate;
161 } CAConnectivityHandler_t;
164 * @brief This will be used during the registration of adapters call backs to the common logic
165 * @see CAConnectivityHandler_t , CAConnectivityType_t
167 typedef void (*CARegisterConnectivityCallback)(CAConnectivityHandler_t handler,
168 CAConnectivityType_t cType);
171 * @brief This will be used during the recive of network requests and response.
172 * @see SendUnitcastData(), SendMulticastData()
174 typedef void (*CANetworkPacketReceivedCallback)(CARemoteEndpoint_t* endPoint, void* data,
178 * @brief This will be used to intimate network changes to the connectivity common logic layer
179 * @see SendUnitcastData(), SendMulticastData()
181 typedef void (*CANetworkChangeCallback)(CALocalConnectivityt_t* info, CANetworkStatus_t status);
187 #endif // __CA_ADAPTER_INTERFACE_H_