2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
21 internal static partial class Interop
23 internal static partial class IoTConnectivity
25 internal static partial class Server
27 internal enum RequestType
36 internal static partial class IoTCon
38 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_start_presence")]
39 internal static extern int StartPresence(uint time);
41 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_stop_presence")]
42 internal static extern int StopPresence();
44 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_device_name")]
45 internal static extern int SetDeviceName(string deviceName);
48 internal static partial class Resource
50 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
51 internal delegate void RequestHandlerCallback(IntPtr resource, IntPtr request, IntPtr userData);
53 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_create")]
54 internal static extern int Create(string uriPath, IntPtr resTypes, IntPtr ifaces, int properties, RequestHandlerCallback cb, IntPtr userData, out IntPtr resourceHandle);
56 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_destroy")]
57 internal static extern int Destroy(IntPtr resourceHandle);
59 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_interface")]
60 internal static extern int BindInterface(IntPtr resource, string iface);
62 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_type")]
63 internal static extern int BindType(IntPtr resourceHandle, string resourceType);
65 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_set_request_handler")]
66 internal static extern int SetRequestHandler(IntPtr resource, RequestHandlerCallback cb, IntPtr userData);
68 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_child_resource")]
69 internal static extern int BindChildResource(IntPtr parent, IntPtr child);
71 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_unbind_child_resource")]
72 internal static extern int UnbindChildResource(IntPtr parent, IntPtr child);
74 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_notify")]
75 internal static extern int Notify(IntPtr resource, IntPtr repr, IntPtr observers, int qos);
77 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_number_of_children")]
78 internal static extern int GetNumberOfChildren(IntPtr resource, out int number);
80 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_nth_child")]
81 internal static extern int GetNthChild(IntPtr parent, int index, out IntPtr child);
83 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_uri_path")]
84 internal static extern int GetUriPath(IntPtr resource, out IntPtr uriPath);
86 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_types")]
87 internal static extern int GetTypes(IntPtr resource, out IntPtr types);
89 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_interfaces")]
90 internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
92 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_properties")]
93 internal static extern int GetProperties(IntPtr resource, out int properties);
96 internal static partial class Request
98 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_host_address")]
99 internal static extern int GetHostAddress(IntPtr request, out IntPtr hostAddress);
101 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_connectivity_type")]
102 internal static extern int GetConnectivityType(IntPtr request, out int connectivityType);
104 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_representation")]
105 internal static extern int GetRepresentation(IntPtr request, out IntPtr repr);
107 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_request_type")]
108 internal static extern int GetRequestType(IntPtr request, out int type);
110 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_options")]
111 internal static extern int GetOptions(IntPtr request, out IntPtr options);
113 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_query")]
114 internal static extern int GetQuery(IntPtr request, out IntPtr query);
116 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_type")]
117 internal static extern int GetObserveType(IntPtr request, out int observeType);
119 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_id")]
120 internal static extern int GetObserveId(IntPtr request, out int observeId);
123 internal static partial class Response
125 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_create")]
126 internal static extern int Create(IntPtr request, out IntPtr response);
128 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_destroy")]
129 internal static extern void Destroy(IntPtr resp);
131 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_options")]
132 internal static extern int GetOptions(IntPtr resp, out IntPtr options);
134 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_representation")]
135 internal static extern int GetRepresentation(IntPtr resp, out IntPtr repr);
137 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_result")]
138 internal static extern int GetResult(IntPtr resp, out int result);
140 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_result")]
141 internal static extern int SetResult(IntPtr resp, int result);
143 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_representation")]
144 internal static extern int SetRepresentation(IntPtr resp, IntPtr repr);
146 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_options")]
147 internal static extern int SetOptions(IntPtr resp, IntPtr options);
149 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_send")]
150 internal static extern int Send(IntPtr resp);
153 internal static partial class Observers
155 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_create")]
156 internal static extern int Create(out IntPtr observers);
158 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_destroy")]
159 internal static extern void Destroy(IntPtr observers);
161 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_add")]
162 internal static extern int Add(IntPtr observers, int observeId);
164 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_remove")]
165 internal static extern int Remove(IntPtr observers, int observeId);