Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / canfcinterface.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 provides APIs NFC client/server/network monitor modules.\r
24  */\r
25 \r
26 #ifndef CA_NFC_INTERFACE_H_\r
27 #define CA_NFC_INTERFACE_H_\r
28 \r
29 #include <stdbool.h>\r
30 \r
31 #include "cacommon.h"\r
32 #include "cathreadpool.h"\r
33 #include "uarraylist.h"\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C"\r
37 {\r
38 #endif\r
39 \r
40 /**\r
41  * CAAdapterServerType_t.\r
42  * Enum for defining different server types.\r
43  */\r
44 typedef enum\r
45 {\r
46     CA_NFC_SERVER = 0, /**< Listening Server */\r
47 } CAAdapterServerType_t;\r
48 \r
49 /**\r
50  * Callback to be notified on reception of any data from remote OIC devices.\r
51  *\r
52  * @param[in]  endpoint    network endpoint description\r
53  * @param[in]  data        Data received from remote OIC device.\r
54  * @param[in]  dataLength  Length of data in bytes.\r
55  */\r
56 typedef void (*CANFCPacketReceivedCallback)(const CASecureEndpoint_t *endpoint, const void *data,\r
57                                             uint32_t dataLength);\r
58 \r
59 /**\r
60   * Callback to notify error in the NFC adapter.\r
61   *\r
62   * @param[in]  endpoint     network endpoint description.\r
63   * @param[in]  data         Data sent/received.\r
64   * @param[in]  dataLength   Length of data in bytes.\r
65   * @param[in]  result       result of request.\r
66   */\r
67 typedef void (*CANFCErrorHandleCallback)(const CAEndpoint_t *endpoint, const void *data,\r
68                                          uint32_t dataLength, CAResult_t result);\r
69 \r
70 /**\r
71  * Callback to be notified when exception occures on multicast/unicast server.\r
72  * @param[in]  type    Type of server(::CAAdapterServerType_t).\r
73  */\r
74 typedef void (*CANFCExceptionCallback)(CAAdapterServerType_t type);\r
75 \r
76 /**\r
77  * Initialize Nfc server.\r
78  *\r
79  * @return  ::CA_STATUS_OK, if success or Appropriate error code.\r
80  */\r
81 CAResult_t CAInitializeNfcServer();\r
82 \r
83 /**\r
84  * Starts Nfc server.\r
85  *\r
86  * @return  ::CA_STATUS_OK, if success or Appropriate error code.\r
87  */\r
88 CAResult_t CANFCStartServer();\r
89 \r
90 /**\r
91  * Stop Nfc server.\r
92  */\r
93 void CANFCStopServer();\r
94 \r
95 /**\r
96  * Set this callback for receiving data packets from peer devices.\r
97  *\r
98  * @param[in]  callback   Callback to be notified when data received.\r
99  */\r
100 void CANFCSetPacketReceiveCallback(CANFCPacketReceivedCallback callback);\r
101 \r
102 /**\r
103  * Set this callback for receiving exception notifications.\r
104  *\r
105  * @param[in]  callback    Callback to be notified in case of exception.\r
106  */\r
107 void CANFCSetExceptionCallback(CANFCExceptionCallback callback);\r
108 \r
109 /**\r
110  * API to send Data.\r
111  *\r
112  * @param[in]  endpoint    Remote End point.\r
113  * @param[in]  data        Data to be send.\r
114  * @param[in]  dataLength  Length of data in bytes.\r
115  */\r
116 void CANFCSendData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength);\r
117 \r
118 /**\r
119  * Get a list of CAInterface_t items.\r
120  * @param[in] desiredIndex    Get interface information for the given index.\r
121  * @return  List of CAInterface_t items if success, NULL pointer if failed.\r
122  */\r
123 u_arraylist_t *CANFCGetInterfaceInformation(int desiredIndex);\r
124 \r
125 /**\r
126  * Set callback for error handling.\r
127  *\r
128  * @param[in] nfcErrorCallback    callback to notify error to the nfcadapter.\r
129  */\r
130 void CANFCSetErrorHandleCallback(CANFCErrorHandleCallback nfcErrorCallback);\r
131 \r
132 #ifdef __cplusplus\r
133 }\r
134 #endif\r
135 \r
136 #endif /* CA_NFC_INTERFACE_H_ */\r