Corrected @file tags and restored 'Files' section.
[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
23  *
24  * This file contains the APIs for WiFi Adapter.
25  */
26
27 #ifndef __CA_WIFI_ADAPTER_H__
28 #define __CA_WIFI_ADAPTER_H__
29
30 #include "cacommon.h"
31 #include "caadapterinterface.h"
32 #include "uthreadpool.h" /* for thread pool */
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  * @brief Initialize WIFI Interface.
41  * @param registerCallback      [IN] Callback to register WIFI interfaces to Connectivity
42  *                                   Abstraction Layer
43  * @param networkPacketCallback [IN] Callback to notify request and response messages from server(s)
44  *                                   started at Connectivity Abstraction Layer.
45  * @param netCallback           [IN] Callback to notify the network additions to Connectivity
46  *                                   Abstraction Layer.
47  * @param handle                [IN] Threadpool Handle
48  * @return  #CA_STATUS_OK or Appropriate error code
49  */
50 CAResult_t CAInitializeWifi(CARegisterConnectivityCallback registerCallback,
51                             CANetworkPacketReceivedCallback networkPacketCallback,
52                             CANetworkChangeCallback netCallback, u_thread_pool_t handle);
53
54 /**
55  * @brief Start WIFI Interface adapter.
56  * @return  #CA_STATUS_OK or Appropriate error code
57  */
58 CAResult_t CAStartWIFI();
59
60 /**
61  * @brief Start Listening Server for receiving multicast search requests
62  * Transport Specific Behavior:
63  * WIFI Start multicast server on a particular interface and prefixed port
64  * as per OIC Specification.
65  * @return  #CA_STATUS_OK or Appropriate error code
66  */
67 CAResult_t CAStartWIFIListeningServer();
68
69 /**
70  * @brief Start WIFI Discovery Server for receiving multicast advertisements
71  * Transport Specific Behavior:
72  * WIFI Start multicast server on a particular interface and prefixed port
73  * number as per OIC Specification
74  * @return  #CA_STATUS_OK or Appropriate error code
75  */
76 CAResult_t CAStartWIFIDiscoveryServer();
77
78 /**
79  * @brief Sends data to the endpoint using the adapter connectivity.
80  * @param endpoint  [IN] Remote Endpoint information (like ipaddress, port, reference uri and
81  *                       connectivity type) to which the unicast data has to be sent.
82  * @param data      [IN] Data to be sent.
83  * @param dataLen   [IN] Size of data to be sent.
84  * @return The number of bytes sent on the network. Returns -1 on error.
85  * @remarks  dataLen must be > 0.
86  */
87 int32_t CASendWIFIUnicastData(const CARemoteEndpoint_t *endpoint, const void *data,
88                                uint32_t dataLen);
89
90 /**
91  * @brief Sends Multicast data to the endpoint using the WIFI connectivity.
92  * @param   data        [IN] Data which required to be sent.
93  * @param   dataLen     [IN] Size of data to be sent.
94  * @return  The number of bytes sent on the network. Returns -1 on error.
95  * @remarks  dataLen must be > 0.
96  */
97 int32_t CASendWIFIMulticastData(const void *data, uint32_t dataLen);
98
99 /**
100  * @brief Get WIFI Connectivity network information
101  * @param   info  [OUT] Local connectivity information structures
102  * @param   size  [OUT] Number of local connectivity structures.
103  * @return  #CA_STATUS_OK or Appropriate error code
104  * @remarks info is allocated in this API and should be freed by the caller.
105  */
106 CAResult_t CAGetWIFIInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
107
108 /**
109  * @brief Read Synchronous API callback.
110  * @return  #CA_STATUS_OK or Appropriate error code
111  */
112 CAResult_t CAReadWIFIData();
113
114 /**
115  * @brief WIFI Stops Unicast, Multicast servers and close the sockets.
116  * @return  #CA_STATUS_OK or Appropriate error code
117  */
118 CAResult_t CAStopWIFI();
119
120 /**
121  * @brief Terminate the WIFI connectivity adapter.
122  * Configuration information will be deleted from further use
123  * @return  NONE
124  */
125 void CATerminateWIFI();
126
127 #ifdef __cplusplus
128 } /* extern "C" */
129 #endif
130
131 #endif  // #ifndef __CA_WIFI_ADAPTER_H__
132