Implementation of connectivity abstraction feature Release v0.5
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / cawifiadapter.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 cawifiadapter.h
23  * @brief This file contains the APIs for WiFi Adapter.
24  */
25 #ifndef __CA_WIFI_ADAPTER_H__
26 #define __CA_WIFI_ADAPTER_H__
27
28 #include "cacommon.h"
29 #include "caadapterinterface.h"
30 #include "uthreadpool.h" /* for thread pool */
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36
37 /**
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)
44  */
45 CAResult_t CAInitializeWifi(CARegisterConnectivityCallback registerCallback,
46                             CANetworkPacketReceivedCallback networkPacketCallback,
47                             CANetworkChangeCallback netCallback, u_thread_pool_t handle);
48
49 /**
50  * @brief Start WiFi Interface adapter.
51  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
52  */
53 CAResult_t CAStartWIFI();
54
55 /**
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)
61  */
62 CAResult_t CAStartWIFIListeningServer();
63
64 /**
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)
70  */
71 CAResult_t CAStartWIFIDiscoveryServer();
72
73 /**
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.
81  */
82 uint32_t CASendWIFIUnicastData(const CARemoteEndpoint_t *endpoint, void *data, 
83                                         uint32_t dataLen);
84
85 /**
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.
91  */
92 uint32_t CASendWIFIMulticastData(void *data, uint32_t dataLen);
93
94 /**
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)
99  */
100 CAResult_t CAGetWIFIInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
101
102 /**
103  * @brief Read Synchronous API callback.
104  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
105  */
106 CAResult_t CAReadWIFIData();
107
108 /**
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)
112  */
113 CAResult_t CAStopWIFI();
114
115 /**
116  * @brief Terminate the WIFI connectivity adapter.
117  * Configuration information will be deleted from further use
118  */
119 void CATerminateWIfI();
120
121 #ifdef __cplusplus
122 } /* extern "C" */
123 #endif
124
125 #endif  // #ifndef __CA_WIFI_ADAPTER_H__