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 cawifiadapter.h
23 * @brief This file contains the APIs for WiFi Adapter.
25 #ifndef __CA_WIFI_ADAPTER_H__
26 #define __CA_WIFI_ADAPTER_H__
29 #include "caadapterinterface.h"
30 #include "uthreadpool.h" /* for thread pool */
38 * @brief API to initialize WiFi Interface.
39 * @param registerCallback [IN] To register WIFI interfaces to Connectivity Abstraction Layer
40 * @param networkPacketCallback [IN] sending responses and discovery messages
41 * from unicast , multicast servers
42 * @param netCallback [IN] Intimate the network additions to Connectivity Abstraction Layer.
43 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
45 CAResult_t CAInitializeWifi(CARegisterConnectivityCallback registerCallback,
46 CANetworkPacketReceivedCallback networkPacketCallback,
47 CANetworkChangeCallback netCallback, u_thread_pool_t handle);
50 * @brief Start WiFi Interface adapter.
51 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
53 CAResult_t CAStartWIFI();
56 * @brief Starting listening server for receiving multicast search requests
57 * Transport Specific Behavior:
58 * WIFI Starts Multicast Server on all available IPs and prefixed port number and
59 * as per OIC Specification.
60 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
62 CAResult_t CAStartWIFIListeningServer();
65 * @brief for starting discovery servers for receiving multicast advertisements
66 * Transport Specific Behavior:
67 * WIFI Starts Start multicast server on all available IPs and prefixed port
68 * number as per OIC Specification
69 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
71 CAResult_t CAStartWIFIDiscoveryServer();
74 * @brief Sends data to the endpoint using the adapter connectivity.
75 * Note: length must be > 0.
76 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port,
77 * reference uri and connectivity type) to which the unicast data has to be sent.
78 * @param data [IN] Data which required to be sent.
79 * @param dataLen [IN] Size of data to be sent.
80 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
82 uint32_t CASendWIFIUnicastData(const CARemoteEndpoint_t *endpoint, void *data,
86 * @brief Sends Multicast data to the endpoint using the WIFI connectivity.
87 * Note: length must be > 0.
88 * @param data [IN] Data which required to be sent.
89 * @param dataLen [IN] Size of data to be sent.
90 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
92 uint32_t CASendWIFIMulticastData(void *data, uint32_t dataLen);
95 * @brief Get WIFI Connectivity network information
96 * @param info [OUT] Local connectivity information structures
97 * @param size [OUT] Number of local connectivity structures.
98 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
100 CAResult_t CAGetWIFIInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
103 * @brief Read Synchronous API callback.
104 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
106 CAResult_t CAReadWIFIData();
109 * @brief Stopping the adapters and close socket connections
110 * WIFI Stops all multicast and unicast servers and close sockets.
111 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
113 CAResult_t CAStopWIFI();
116 * @brief Terminate the WIFI connectivity adapter.
117 * Configuration information will be deleted from further use
119 void CATerminateWIfI();
125 #endif // #ifndef __CA_WIFI_ADAPTER_H__