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 Client
27 internal static partial class DeviceInformation
29 internal delegate bool DeviceInformationCallback(IntPtr deviceInfoHandle, int result, IntPtr userData);
31 internal enum Property
39 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_device_info")]
40 internal static extern int Find(string hostAddress, int connectivityType, IntPtr query, DeviceInformationCallback cb, IntPtr userData);
42 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_device_info_get_property")]
43 internal static extern int GetProperty(IntPtr deviceInfoHandle, int property, out IntPtr value);
46 internal static partial class PlatformInformation
48 internal delegate bool PlatformInformationCallback(IntPtr platformInfoHandle, int result, IntPtr userData);
65 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_platform_info")]
66 internal static extern int Find(string hostAddress, int connectivityType, IntPtr query, PlatformInformationCallback cb, IntPtr userData);
68 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_platform_info_get_property")]
69 internal static extern int GetProperty(IntPtr platformInfoHandle, int property, out IntPtr value);
72 internal static partial class RemoteResource
74 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
75 internal delegate void ResponseCallback(IntPtr resource, int err, int requestType, IntPtr response, IntPtr userData);
77 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
78 internal delegate void ObserveCallback(IntPtr resource, int err, int sequenceNumber, IntPtr response, IntPtr userData);
80 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
81 internal delegate void CachedRepresentationChangedCallback(IntPtr resource, IntPtr representation, IntPtr userData);
83 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
84 internal delegate void StateChangedCallback(IntPtr resource, int state, IntPtr userData);
86 internal enum ConnectivityType
95 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_create")]
96 internal static extern int Create(string hostAddress, int connectivityType, string uriPath, int properties, IntPtr resourceTypes, IntPtr resourceInterfaces, out IntPtr remoteResource);
98 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_destroy")]
99 internal static extern void Destroy(IntPtr resource);
101 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_clone")]
102 internal static extern int Clone(IntPtr src, out IntPtr dest);
104 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_register")]
105 internal static extern int RegisterObserve(IntPtr resource, int observePolicy, IntPtr query, ObserveCallback cb, IntPtr userData);
107 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_deregister")]
108 internal static extern int DeregisterObserve(IntPtr resource);
110 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get")]
111 internal static extern int Get(IntPtr resource, IntPtr query, ResponseCallback cb, IntPtr userData);
113 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_put")]
114 internal static extern int Put(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
116 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_post")]
117 internal static extern int Post(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
119 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_delete")]
120 internal static extern int Delete(IntPtr resource, ResponseCallback cb, IntPtr userData);
122 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_caching")]
123 internal static extern int StartCaching(IntPtr resource, CachedRepresentationChangedCallback cb, IntPtr userData);
125 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_caching")]
126 internal static extern int StopCaching(IntPtr resource);
128 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_monitoring")]
129 internal static extern int StartMonitoring(IntPtr resource, StateChangedCallback cb, IntPtr userData);
131 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_monitoring")]
132 internal static extern int StopMonitoring(IntPtr resource);
134 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_uri_path")]
135 internal static extern int GetUriPath(IntPtr resource, out IntPtr uriPath);
137 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_connectivity_type")]
138 internal static extern int GetConnectivityType(IntPtr resource, out int connectivityType);
140 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_host_address")]
141 internal static extern int GetHostAddress(IntPtr resource, out IntPtr hostAddress);
143 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_device_id")]
144 internal static extern int GetDeviceId(IntPtr resource, out IntPtr deviceId);
146 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_types")]
147 internal static extern int GetTypes(IntPtr resource, out IntPtr types);
149 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_interfaces")]
150 internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
152 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_policies")]
153 internal static extern int GetPolicies(IntPtr resource, out int properties);
155 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_options")]
156 internal static extern int GetOptions(IntPtr resource, out IntPtr options);
158 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_options")]
159 internal static extern int SetOptions(IntPtr resource, IntPtr options);
161 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_cached_representation")]
162 internal static extern int GetCachedRepresentation(IntPtr resource, out IntPtr representation);
164 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_checking_interval")]
165 internal static extern int GetTimeInterval(IntPtr resource, out int timeInterval);
167 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_checking_interval")]
168 internal static extern int SetTimeInterval(IntPtr resource, int timeInterval);
171 internal static partial class IoTCon
173 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_initialize")]
174 internal static extern int Initialize(string filePath);
176 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_deinitialize")]
177 internal static extern void Deinitialize();
179 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_timeout")]
180 internal static extern int GetTimeout(out int timeoutSeconds);
182 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_timeout")]
183 internal static extern int SetTimeout(int timeoutSeconds);
185 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_get_interval")]
186 internal static extern int GetPollingInterval(out int interval);
188 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_set_interval")]
189 internal static extern int SetPollingInterval(int interval);
191 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_invoke")]
192 internal static extern int InvokePolling();
195 internal static partial class ResourceFinder
197 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
198 internal delegate bool FoundResourceCallback(IntPtr remoteResourceHandle, int result, IntPtr userData);
200 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_resource")]
201 internal static extern int AddResourceFoundCb(string hostAddress, int connectivityType, IntPtr query, FoundResourceCallback cb, IntPtr userData);
204 internal static partial class Presence
206 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
207 internal delegate void PresenceCallback(IntPtr presenceResponseHandle, int err, IntPtr response, IntPtr userData);
209 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_add_presence_cb")]
210 internal static extern int AddPresenceCb(string hostAddress, int connectivityType, string resourceType, PresenceCallback cb, IntPtr userData, out IntPtr presenceHandle);
212 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remove_presence_cb")]
213 internal static extern int RemovePresenceCb(IntPtr presenceHandle);
215 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_host_address")]
216 internal static extern int GetHostAddress(IntPtr presence, out IntPtr hostAddress);
218 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_connectivity_type")]
219 internal static extern int GetConnectivityType(IntPtr presence, out int connectivityType);
221 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_resource_type")]
222 internal static extern int GetResourceType(IntPtr presence, out IntPtr resourceType);
225 internal static partial class PresenceResponse
227 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_result")]
228 internal static extern int GetResult(IntPtr response, out int result);
230 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_trigger")]
231 internal static extern int GetTrigger(IntPtr response, out int trigger);
233 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_host_address")]
234 internal static extern int GetHostAddress(IntPtr response, out IntPtr hostAddress);
236 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_connectivity_type")]
237 internal static extern int GetConnectivityType(IntPtr response, out int connectivityType);
239 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_resource_type")]
240 internal static extern int GetResourceType(IntPtr response, out IntPtr resourceType);