Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / canfcadapter.h
1 /* *****************************************************************\r
2  *\r
3  * Copyright 2015 Samsung Electronics All Rights Reserved.\r
4  *\r
5  *\r
6  *\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  *\r
19  ******************************************************************/\r
20 \r
21 /**\r
22  * @file\r
23  * This file contains the APIs for NFC Adapter.\r
24  */\r
25 #ifndef CA_NFC_ADAPTER_H_\r
26 #define CA_NFC_ADAPTER_H_\r
27 \r
28 #include "cacommon.h"\r
29 #include "caadapterinterface.h"\r
30 #include "cathreadpool.h"\r
31 \r
32 #ifdef __cplusplus\r
33 extern "C"\r
34 {\r
35 #endif\r
36 \r
37 /**\r
38  * API to initialize NFC Interface.\r
39  * @param[in] registerCallback      Callback to register NFC interfaces to Connectivity\r
40  *                                  Abstraction Layer\r
41  * @param[in] networkPacketCallback Callback to notify request and response messages from server(s)\r
42  *                                  started at Connectivity Abstraction Layer.\r
43  * @param[in] netCallback           Callback to notify the network additions to Connectivity\r
44  *                                  Abstraction Layer.\r
45  * @param[in] errorCallback         Callback to notify the network errors to Connectivity\r
46  *                                  Abstraction Layer\r
47  * @param[in] handle                Threadpool Handle\r
48  * @return  ::CA_STATUS_OK, if success or Appropriate error code\r
49  */\r
50 CAResult_t CAInitializeNFC(CARegisterConnectivityCallback registerCallback,\r
51                           CANetworkPacketReceivedCallback networkPacketCallback,\r
52                           CANetworkChangeCallback netCallback,\r
53                           CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);\r
54 \r
55 /**\r
56  * Start NFC Interface adapter.\r
57  * @return  ::CA_STATUS_OK, if success or Appropriate error code\r
58  */\r
59 CAResult_t CAStartNFC();\r
60 \r
61 /**\r
62  * Start listening server for receiving multicast search requests.\r
63  * @return  ::CA_STATUS_OK, if success or Appropriate error code\r
64  */\r
65 CAResult_t CAStartNFCListeningServer();\r
66 \r
67 /**\r
68  * Start listening server for receiving multicast search requests.\r
69  * @return  ::CA_STATUS_OK, if success or Appropriate error code\r
70  */\r
71 CAResult_t CAStopNFCListeningServer();\r
72 \r
73 /**\r
74  * Start discovery servers for receiving multicast advertisements.\r
75  * @return  ::CA_STATUS_OK, if success or Appropriate error code.\r
76  */\r
77 CAResult_t CAStartNFCDiscoveryServer();\r
78 \r
79 /**\r
80  * Sends data to the endpoint using the adapter connectivity.\r
81  * @param[in]   endpoint    Remote Endpoint information.\r
82  * @param[in]   data        data to be sent.\r
83  * @param[in]   dataLen     Size of data to be sent.\r
84  * @return  number of bytes sent on the network. Return value equal to -1 indicates error.\r
85  * @remark  dataLen must be > 0.\r
86  */\r
87 int32_t CASendNFCUnicastData(const CAEndpoint_t *endpoint, const void *data,\r
88                              uint32_t dataLen);\r
89 \r
90 /**\r
91  * Send Multicast data to the endpoint using the NFC connectivity.\r
92  * @param[in]   endpoint    Remote Endpoint information.\r
93  * @param[in]   data        Data which is required to be sent.\r
94  * @param[in]   dataLen     Size of data to be sent.\r
95  * @return  number of bytes sent on the network. Return value equal to -1 indicates error.\r
96  * @remark  dataLen must be > 0.\r
97  */\r
98 int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);\r
99 \r
100 /**\r
101  * Get NFC Connectivity network information\r
102  * @param[out]   info        Local connectivity information structures.\r
103  * @param[out]   size        Number of local connectivity structures.\r
104  * @return  ::CA_STATUS_OK, if success or Appropriate error code.\r
105  * @remarks info is allocated in this API and must be freed by the caller.\r
106  */\r
107 CAResult_t CAGetNFCInterfaceInformation(CAEndpoint_t **info, uint32_t *size);\r
108 \r
109 /**\r
110  * Read Synchronous API callback.\r
111  * @return  ::CA_STATUS_OK, if success or Appropriate error code.\r
112  */\r
113 CAResult_t CAReadNFCData();\r
114 \r
115 /**\r
116  * Stops stop servers and close the sockets.\r
117  * @return  ::CA_STATUS_OK, if success or Appropriate error code.\r
118  */\r
119 CAResult_t CAStopNFC();\r
120 \r
121 /**\r
122  * Terminate the NFC connectivity adapter.\r
123  * Configuration information will be deleted from further use\r
124  */\r
125 void CATerminateNFC();\r
126 \r
127 #ifdef __cplusplus\r
128 } /* extern "C" */\r
129 #endif\r
130 \r
131 #endif  /* CA_NFC_ADAPTER_H_ */\r
132 \r