45dcab85ccc8e571ee6999f4756d8c871b60e0cc
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / cawifiethernetadapter.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 cawifiethernetadapter.h
23  * @brief This file contains the APIs for WiFi/Ethernet Adapter.
24  */
25 #ifndef __CA_WIFI_ETHERNET_ADAPTER_H__
26 #define __CA_WIFI_ETHERNET_ADAPTER_H__
27
28 #include "cacommon.h"
29 #include "caadapterinterface.h"
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /**
37  * @brief API to initialize WiFi Interface.
38  * @param registerCallback to register WIFI interfaces to things communication
39  * @param reqRespCallback for sending responses and discovery messages from unicast , multicast servers
40  * @param netCallback to intimate the network additions to things communication
41  * @return Error Code
42  */
43 CAResult_t CAInitializeWifi(CARegisterConnectivityCallback registerCallback,
44         CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback);
45
46 /**
47  * @brief API to Start WiFi Interface.
48  * @return Error Code
49  */
50 CAResult_t CAStartWIFI();
51
52 /**
53  * @brief starting listening server
54  * Transport Specific Behaviour
55  *       IP :- Start Multicast Server on  all available IPs and prefixed port number and as per OIC Specification.
56  * @return Error Code CAResult_t.
57  */
58 CAResult_t CAStartWIFIListeningServer();
59
60 /**
61  * @brief for starting discovery servers.
62  * Transport Specific Behaviour
63  *       IP :- Start Multicast Server on all available IPs and prefixed port number as per OIC Specification.
64  * @return CAResult_t.
65  * CA_STATUS_OK = 0 else ERROR CODES ( CAResult_t error codes in cacommon.h)
66  */
67 CAResult_t CAStartWIFIDiscoveryServer();
68
69 /**
70  * @brief Send Multicast Data interface API callback.
71  * Note: length must be > 0
72  * @param endpoint - Endpoint information (like ipaddress , port, reference uri and connectivity type) to which the multicast data has to be sent.
73  * @param data - void pointer data which will be sent via client
74  * @param dataLen - size of data to be sent
75  * @return - Will return the number of bytes sent on the network. Return value equal to zero indicates error.
76  */
77 uint32_t CASendWIFIUnicastData(const CARemoteEndpoint_t* endpoint, void* data, uint32_t dataLen);
78
79 /**
80  * @brief API to send data to a group of remote addresses.
81  * @param endpoint - Endpoint information (like ipaddress , port, reference uri and connectivity type) to which the multicast data has to be sent.
82  * @param data - void pointer data which will be sent via client
83  * @param dataLen - size of data to be sent
84  * @return - size of data sent or -1 on error
85  */
86 uint32_t CASendWIFIMulticastData(void* data, uint32_t dataLen);
87
88 /**
89  * @brief Start Notification Server interface API callback.
90  *
91  * @return CAResult_t.
92  * CA_STATUS_OK = 0 else ERROR CODES ( CAResult_t error codes in cacommon.h)
93  */
94 CAResult_t CAStartWIFINotifyRecvServers();
95
96 /**
97  * @brief Send Notification Data interface API callback.
98  * Note: length must be > 0
99  * @param endpoint - remote endpoint having endpoint details
100  *  @param data - data to be sent
101  *  @param dataLen - length of data to be sent
102  *  @return Will return the number of bytes sent on the network. Return value equal to zero indicates error.
103  */
104 uint32_t CASendWIFINotification(const CARemoteEndpoint_t* endpoint, void* data, uint32_t dataLen);
105 /**
106  * @brief Get Network Information
107  *
108  * @return CAResult_t.
109  * CA_STATUS_OK = 0 else ERROR CODES ( CAResult_t error codes in cacommon.h)
110  */
111 CAResult_t CAGetWIFIInterfaceInformation(CALocalConnectivityt_t** info, uint32_t* size);
112
113 /**
114  * @brief Read Synchronous API callback.
115  * @return Error Code CAResult_t.
116  * @return CAResult_t.
117  * CA_STATUS_OK = 0 else ERROR CODES ( CAResult_t error codes in cacommon.h)
118  */
119 CAResult_t CAReadWIFIData();
120
121 /**
122  * @brief API to Stop WiFi Interface.
123  * @return CAResult_t
124  */
125 CAResult_t CAStopWIFI();
126
127 /**
128  * @brief API to terminate WiFi Interface.
129  * @return none.
130  */
131 void CATerminateWifi();
132
133 #ifdef __cplusplus
134 } /* extern "C" */
135 #endif
136
137 #endif