DataModelVersion,
}
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_device_info")]
- internal static extern int Get(string hostAddress, int connectivityType, DeviceInformationCallback cb, IntPtr userData);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_device_info")]
+ internal static extern int Find(string hostAddress, int connectivityType, DeviceInformationCallback cb, IntPtr userData);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_device_info_get_property")]
- internal static extern int GetProperty(IntPtr deviceInfoHandle, int property, out string value);
+ internal static extern int GetProperty(IntPtr deviceInfoHandle, int property, out IntPtr value);
}
internal static partial class PlatformInformation
SystemTime
}
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_platform_info")]
- internal static extern int Get(string hostAddress, int connectivityType, PlatformInformationCallback cb, IntPtr userData);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_platform_info")]
+ internal static extern int Find(string hostAddress, int connectivityType, PlatformInformationCallback cb, IntPtr userData);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_platform_info_get_property")]
- internal static extern int GetProperty(IntPtr platformInfoHandle, int property, out string value);
+ internal static extern int GetProperty(IntPtr platformInfoHandle, int property, out IntPtr value);
}
internal static partial class RemoteResource
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_monitoring")]
internal static extern int StopMonitoring(IntPtr resource);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_uriPath")]
- internal static extern int GetUriPath(IntPtr resource, out string uriPath);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_uri_path")]
+ internal static extern int GetUriPath(IntPtr resource, out IntPtr uriPath);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_connectivity_type")]
internal static extern int GetConnectivityType(IntPtr resource, out int connectivityType);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_host_address")]
- internal static extern int GetHostAddress(IntPtr resource, out string hostAddress);
+ internal static extern int GetHostAddress(IntPtr resource, out IntPtr hostAddress);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_device_id")]
- internal static extern int GetDeviceId(IntPtr resource, out string deviceId);
+ internal static extern int GetDeviceId(IntPtr resource, out IntPtr deviceId);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_types")]
internal static extern int GetTypes(IntPtr resource, out IntPtr types);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_interfaces")]
internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_properties")]
- internal static extern int GetProperties(IntPtr resource, out int properties);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_policies")]
+ internal static extern int GetPolicies(IntPtr resource, out int properties);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_options")]
internal static extern int GetOptions(IntPtr resource, out IntPtr options);
internal static extern int GetCachedRepresentation(IntPtr resource, out IntPtr representation);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_time_interval")]
- internal static extern int GetTimeInterval(IntPtr resource, out int timeInterval);
+ internal static extern int GetTimeInterval(out int timeInterval);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_time_interval")]
- internal static extern int SetTimeInterval(IntPtr resource, int timeInterval);
+ internal static extern int SetTimeInterval(int timeInterval);
+
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_device_name")]
+ internal static extern int GetDeviceName(IntPtr resource, out IntPtr deviceName);
}
internal static partial class IoTCon
{
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_secure_initialize")]
+ internal static extern int SecureInitialize(string filePath);
+
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_initialize")]
internal static extern int Initialize();
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_timeout")]
internal static extern int SetTimeout(int timeoutSeconds);
+
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_get_interval")]
+ internal static extern int GetPollingInterval(out int interval);
+
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_set_interval")]
+ internal static extern int SetPollingInterval(int interval);
+
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_invoke")]
+ internal static extern int InvokePolling();
}
internal static partial class ResourceFinder
internal static extern int RemovePresenceCb(IntPtr presenceHandle);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_host_address")]
- internal static extern int GetHostAddress(IntPtr presence, out string hostAddress);
+ internal static extern int GetHostAddress(IntPtr presence, out IntPtr hostAddress);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_connectivity_type")]
internal static extern int GetConnectivityType(IntPtr presence, out int connectivityType);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_resource_type")]
- internal static extern int GetResourceType(IntPtr presence, out string resourceType);
+ internal static extern int GetResourceType(IntPtr presence, out IntPtr resourceType);
}
internal static partial class PresenceResponse
internal static extern int GetTrigger(IntPtr response, out int trigger);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_host_address")]
- internal static extern int GetHostAddress(IntPtr response, out string hostAddress);
+ internal static extern int GetHostAddress(IntPtr response, out IntPtr hostAddress);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_connectivity_type")]
internal static extern int GetConnectivityType(IntPtr response, out int connectivityType);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_resource_type")]
- internal static extern int GetResourceType(IntPtr response, out string resourceType);
+ internal static extern int GetResourceType(IntPtr response, out IntPtr resourceType);
}
}
}
ByteStr,
Null,
List,
- State
+ Attributes
}
internal static partial class ResourceTypes
internal static extern int Clone(IntPtr src, out IntPtr dest);
}
- internal static partial class State
+ internal static partial class Attributes
{
- internal delegate bool StateCallback(IntPtr state, string key, IntPtr userData);
+ internal delegate bool AttributesCallback(IntPtr attributes, string key, IntPtr userData);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_create")]
- internal static extern int Create(out IntPtr state);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_create")]
+ internal static extern int Create(out IntPtr attributes);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_destroy")]
- internal static extern void Destroy(IntPtr state);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_destroy")]
+ internal static extern void Destroy(IntPtr attributes);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_clone")]
- internal static extern int Clone(IntPtr state, out IntPtr dest);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_clone")]
+ internal static extern int Clone(IntPtr attributes, out IntPtr attributes_clone);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_int")]
- internal static extern int AddInt(IntPtr state, string key, int val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_int")]
+ internal static extern int AddInt(IntPtr attributes, string key, int val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_bool")]
- internal static extern int AddBool(IntPtr state, string key, bool val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_bool")]
+ internal static extern int AddBool(IntPtr attributes, string key, bool val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_double")]
- internal static extern int AddDouble(IntPtr state, string key, double val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_double")]
+ internal static extern int AddDouble(IntPtr attributes, string key, double val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_str")]
- internal static extern int AddStr(IntPtr state, string key, string val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_str")]
+ internal static extern int AddStr(IntPtr attributes, string key, string val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_byte_str")]
- internal static extern unsafe int AddByteStr(IntPtr state, string key, byte[] val, int len);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_byte_str")]
+ internal static extern int AddByteStr(IntPtr attributes, string key, byte[] val, int len);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_list")]
- internal static extern int AddList(IntPtr state, string key, IntPtr list);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_list")]
+ internal static extern int AddList(IntPtr attributes, string key, IntPtr list);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_state")]
- internal static extern int AddState(IntPtr dest, string key, IntPtr src);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_attributes")]
+ internal static extern int AddAttributes(IntPtr dest, string key, IntPtr src);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_null")]
- internal static extern int AddNull(IntPtr state, string key);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_null")]
+ internal static extern int AddNull(IntPtr attributes, string key);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_int")]
- internal static extern int GetInt(IntPtr state, string key, out int val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_int")]
+ internal static extern int GetInt(IntPtr attributes, string key, out int val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_bool")]
- internal static extern int GetBool(IntPtr state, string key, out bool val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_bool")]
+ internal static extern int GetBool(IntPtr attributes, string key, out bool val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_double")]
- internal static extern int GetDouble(IntPtr state, string key, out double val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_double")]
+ internal static extern int GetDouble(IntPtr attributes, string key, out double val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_str")]
- internal static extern int GetStr(IntPtr state, string key, out string val);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_str")]
+ internal static extern int GetStr(IntPtr attributes, string key, out string val);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_byte_str")]
- internal static extern int GetByteStr(IntPtr state, string key, out IntPtr value, out int size);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_byte_str")]
+ internal static extern int GetByteStr(IntPtr attributes, string key, out IntPtr value, out int size);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_list")]
- internal static extern int GetList(IntPtr state, string key, out IntPtr list);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_list")]
+ internal static extern int GetList(IntPtr attributes, string key, out IntPtr list);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_state")]
- internal static extern int GetState(IntPtr src, string key, out IntPtr dest);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_attributes")]
+ internal static extern int GetAttributes(IntPtr src, string key, out IntPtr dest);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_is_null")]
- internal static extern int IsNull(IntPtr state, string key, out bool isNull);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_is_null")]
+ internal static extern int IsNull(IntPtr attributes, string key, out bool isNull);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_remove")]
- internal static extern int Remove(IntPtr state, string key);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_remove")]
+ internal static extern int Remove(IntPtr attributes, string key);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_type")]
- internal static extern int GetType(IntPtr state, string key, out DataType type);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_type")]
+ internal static extern int GetType(IntPtr attributes, string key, out DataType type);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_foreach")]
- internal static extern int Foreach(IntPtr state, StateCallback cb, IntPtr userData);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_foreach")]
+ internal static extern int Foreach(IntPtr attributes, AttributesCallback cb, IntPtr userData);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_keys_count")]
- internal static extern int GetKeysCount(IntPtr state, out int count);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_keys_count")]
+ internal static extern int GetKeysCount(IntPtr attributes, out int count);
}
internal static partial class Query
internal static extern void Destroy(IntPtr query);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_resource_type")]
- internal static extern int GetResourceType(IntPtr query, out string resourceType);
+ internal static extern int GetResourceType(IntPtr query, out IntPtr resourceType);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_interface")]
- internal static extern int GetInterface(IntPtr query, out string resourceInterface);
+ internal static extern int GetInterface(IntPtr query, out IntPtr resourceInterface);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_resource_type")]
internal static extern int SetResourceType(IntPtr query, string resourceType);
internal static extern int Remove(IntPtr query, string key);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_lookup")]
- internal static extern int Lookup(IntPtr query, string key, out string data);
+ internal static extern int Lookup(IntPtr query, string key, out IntPtr data);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_foreach")]
internal static extern int Foreach(IntPtr query, QueryCallback cb, IntPtr userData);
internal static extern int SetUriPath(IntPtr repr, string uriPath);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_uri_path")]
- internal static extern int GetUriPath(IntPtr repr, out string uriPath);
+ internal static extern int GetUriPath(IntPtr repr, out IntPtr uriPath);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_types")]
internal static extern int SetResourceTypes(IntPtr repr, IntPtr types);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_interfaces")]
internal static extern int GetResourceInterfaces(IntPtr repr, out IntPtr ifaces);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_state")]
- internal static extern int SetState(IntPtr repr, IntPtr state);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_attributes")]
+ internal static extern int SetAttributes(IntPtr repr, IntPtr attribs);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_state")]
- internal static extern int GetState(IntPtr repr, out IntPtr state);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_attributes")]
+ internal static extern int GetAttributes(IntPtr repr, out IntPtr attribs);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_add_child")]
internal static extern int AddChild(IntPtr parent, IntPtr child);
internal static extern int Remove(IntPtr options, ushort id);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_lookup")]
- internal static extern int Lookup(IntPtr options, ushort id, out string data);
+ internal static extern int Lookup(IntPtr options, ushort id, out IntPtr data);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_foreach")]
internal static extern int ForEach(IntPtr options, OptionsCallback cb, IntPtr userData);
internal delegate bool ListCallback(int pos, IntPtr value, IntPtr userData);
- internal delegate bool StateCallback(int pos, IntPtr value, IntPtr userData);
+ internal delegate bool AttribsCallback(int pos, IntPtr value, IntPtr userData);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_create")]
internal static extern int Create(DataType type, out IntPtr list);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_list")]
internal static extern int AddList(IntPtr list, IntPtr val, int pos);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_state")]
- internal static extern int AddState(IntPtr list, IntPtr val, int pos);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_attributes")]
+ internal static extern int AddAttributes(IntPtr list, IntPtr val, int pos);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_int")]
internal static extern int GetNthInt(IntPtr list, int pos, out int val);
internal static extern int GetNthDouble(IntPtr list, int pos, out double val);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_str")]
- internal static extern int GetNthStr(IntPtr list, int pos, out string val);
+ internal static extern int GetNthStr(IntPtr list, int pos, out IntPtr val);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_byte_str")]
- internal static extern int GetNthByteStr(IntPtr list, int pos, out string val, out int len);
+ internal static extern int GetNthByteStr(IntPtr list, int pos, out IntPtr val, out int len);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_list")]
internal static extern int GetNthList(IntPtr src, int pos, out IntPtr dest);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_state")]
- internal static extern int GetNthState(IntPtr list, int pos, out IntPtr state);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_attributes")]
+ internal static extern int GetNthAttributes(IntPtr list, int pos, out IntPtr attribs);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_remove_nth")]
internal static extern int RemoveNth(IntPtr list, int pos);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_list")]
internal static extern int ForeachList(IntPtr list, ListCallback cb, IntPtr userData);
- [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_state")]
- internal static extern int ForeachState(IntPtr list, StateCallback cb, IntPtr userData);
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_attributes")]
+ internal static extern int ForeachAttributes(IntPtr list, AttribsCallback cb, IntPtr userData);
}
}
}
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_stop_presence")]
internal static extern int StopPresence();
+
+ [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_device_name")]
+ internal static extern int SetDeviceName(string deviceName);
}
internal static partial class Resource
internal static extern int GetNthChild(IntPtr parent, int index, out IntPtr child);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_uri_path")]
- internal static extern int GetUriPath(IntPtr resource, out string uriPpath);
+ internal static extern int GetUriPath(IntPtr resource, out IntPtr uriPath);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_types")]
internal static extern int GetTypes(IntPtr resource, out IntPtr types);
internal static partial class Request
{
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_host_address")]
- internal static extern int GetHostAddress(IntPtr request, out string hostAddress);
+ internal static extern int GetHostAddress(IntPtr request, out IntPtr hostAddress);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_connectivity_type")]
internal static extern int GetConnectivityType(IntPtr request, out int connectivityType);
internal static extern int SetResult(IntPtr resp, int result);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_representation")]
- internal static extern int SetRepresentation(IntPtr resp, string iface, IntPtr repr);
+ internal static extern int SetRepresentation(IntPtr resp, IntPtr repr);
[DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_options")]
internal static extern int SetOptions(IntPtr resp, IntPtr options);
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="Tizen.Network.IoTConnectivity\Attributes.cs" />\r
<Compile Include="Tizen.Network.IoTConnectivity\CacheUpdatedEventArgs.cs" />
<Compile Include="Tizen.Network.IoTConnectivity\DeviceInformationFoundEventArgs.cs" />
<Compile Include="Tizen.Network.IoTConnectivity\FindingErrorOccurredEventArgs.cs" />
<Compile Include="Tizen.Network.IoTConnectivity\ResourceQuery.cs" />
<Compile Include="Tizen.Network.IoTConnectivity\Representation.cs" />
<Compile Include="Tizen.Network.IoTConnectivity\ResourceOptions.cs" />
- <Compile Include="Tizen.Network.IoTConnectivity\State.cs" />
<Compile Include="Tizen.Network.IoTConnectivity\ResourceTypes.cs" />
<Compile Include="Interop\Interop.Libraries.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
namespace Tizen.Network.IoTConnectivity
{
/// <summary>
- /// State represents current state of a resource
+ /// Attributes represents current attributes of a resource
/// </summary>
- public class State : IDictionary<string, object>, IDisposable
+ public class Attributes : IDictionary<string, object>, IDisposable
{
- internal IntPtr _resourceStateHandle = IntPtr.Zero;
- private readonly IDictionary<string, object> _state = new Dictionary<string, object>();
+ internal IntPtr _resourceAttributesHandle = IntPtr.Zero;
+ private readonly IDictionary<string, object> _attributes = new Dictionary<string, object>();
private bool _disposed = false;
/// <summary>
/// Constructor
/// </summary>
- public State()
+ public Attributes()
{
- int ret = Interop.IoTConnectivity.Common.State.Create(out _resourceStateHandle);
+ int ret = Interop.IoTConnectivity.Common.Attributes.Create(out _resourceAttributesHandle);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create state handle");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create attributes handle");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
- internal State(IntPtr stateHandleToClone)
+ internal Attributes(IntPtr attributesHandleToClone)
{
- int ret = Interop.IoTConnectivity.Common.State.Clone(stateHandleToClone, out _resourceStateHandle);
+ int ret = Interop.IoTConnectivity.Common.Attributes.Clone(attributesHandleToClone, out _resourceAttributesHandle);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create state handle");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create attributes handle");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- SetState(stateHandleToClone);
+ SetAttributes(attributesHandleToClone);
}
- ~State()
+ ~Attributes()
{
Dispose(false);
}
{
get
{
- return _state.Count;
+ return _attributes.Count;
}
}
/// <summary>
- /// Represents whether State is readonly
+ /// Represents whether Attributes is readonly
/// </summary>
public bool IsReadOnly
{
get
{
- return _state.IsReadOnly;
+ return _attributes.IsReadOnly;
}
}
{
get
{
- return _state.Keys;
+ return _attributes.Keys;
}
}
{
get
{
- return _state.Values;
+ return _attributes.Values;
}
}
{
get
{
- return _state[key];
+ return _attributes[key];
}
set
/// <summary>
/// Adds status element
/// </summary>
- /// <param name="key">The key representing the state</param>
- /// <param name="value">The value representing the state</param>
+ /// <param name="key">The key representing the attributes</param>
+ /// <param name="value">The value representing the attributes</param>
public void Add(string key, object value)
{
int ret = 0;
if (value is int)
{
- ret = Interop.IoTConnectivity.Common.State.AddInt(_resourceStateHandle, key, (int)value);
+ ret = Interop.IoTConnectivity.Common.Attributes.AddInt(_resourceAttributesHandle, key, (int)value);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add int");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
- else if (value is State)
+ else if (value is Attributes)
{
- State state = (State)value;
- ret = Interop.IoTConnectivity.Common.State.AddState(_resourceStateHandle, key, state._resourceStateHandle);
+ Attributes attribs = (Attributes)value;
+ ret = Interop.IoTConnectivity.Common.Attributes.AddAttributes(_resourceAttributesHandle, key, attribs._resourceAttributesHandle);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
else if (value is string)
{
- ret = Interop.IoTConnectivity.Common.State.AddStr(_resourceStateHandle, key, (string)value);
+ ret = Interop.IoTConnectivity.Common.Attributes.AddStr(_resourceAttributesHandle, key, (string)value);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add string");
}
else if (value is double)
{
- ret = Interop.IoTConnectivity.Common.State.AddDouble(_resourceStateHandle, key, (double)value);
+ ret = Interop.IoTConnectivity.Common.Attributes.AddDouble(_resourceAttributesHandle, key, (double)value);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add double");
}
else if (value is bool)
{
- ret = Interop.IoTConnectivity.Common.State.AddBool(_resourceStateHandle, key, (bool)value);
+ ret = Interop.IoTConnectivity.Common.Attributes.AddBool(_resourceAttributesHandle, key, (bool)value);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get byte[] val");
throw new ArgumentException("Invalid Parameter");
}
- ret = Interop.IoTConnectivity.Common.State.AddByteStr(_resourceStateHandle, key, val, val.Length);
+ ret = Interop.IoTConnectivity.Common.Attributes.AddByteStr(_resourceAttributesHandle, key, val, val.Length);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
else if (value is IEnumerable)
{
IntPtr listHandle = List.GetListHandle(value);
- ret = Interop.IoTConnectivity.Common.State.AddList(_resourceStateHandle, key, listHandle);
- Interop.IoTConnectivity.Common.State.Destroy(listHandle);
+ ret = Interop.IoTConnectivity.Common.Attributes.AddList(_resourceAttributesHandle, key, listHandle);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add list");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Add");
throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
}
- _state.Add(key, value);
+ _attributes.Add(key, value);
}
/// <summary>
- /// Clears state collection
+ /// Clears attributes collection
/// </summary>
public void Clear()
{
- foreach (string key in _state.Keys)
+ foreach (string key in _attributes.Keys)
{
- int ret = Interop.IoTConnectivity.Common.State.Remove(_resourceStateHandle, key);
+ int ret = Interop.IoTConnectivity.Common.Attributes.Remove(_resourceAttributesHandle, key);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to clear state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to clear attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
- _state.Clear();
+ _attributes.Clear();
}
/// <summary>
- /// Checks the given key value pair exists in state collection
+ /// Checks the given key value pair exists in attributes collection
/// </summary>
/// <param name="item">The status key value pair</param>
/// <returns>true if exists. Otherwise, false</returns>
public bool Contains(KeyValuePair<string, object> item)
{
- return _state.Contains(item);
+ return _attributes.Contains(item);
}
/// <summary>
- /// Checks the given key exists in state collection
+ /// Checks the given key exists in attributes collection
/// </summary>
/// <param name="key">The status key</param>
/// <returns>true if exists. Otherwise, false</returns>
public bool ContainsKey(string key)
{
- return _state.ContainsKey(key);
+ return _attributes.ContainsKey(key);
}
/// <summary>
- /// Copies the elements of the state to an Array, starting at a particular index.
+ /// Copies the elements of the attributes to an Array, starting at a particular index.
/// </summary>
/// <param name="array">The destination array</param>
/// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
{
- _state.CopyTo(array, arrayIndex);
+ _attributes.CopyTo(array, arrayIndex);
}
/// <summary>
/// <returns> An enumerator that can be used to iterate through the collection.</returns>
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
{
- return _state.GetEnumerator();
+ return _attributes.GetEnumerator();
}
/// <summary>
- /// Removes a state element from collection
+ /// Removes a attributes element from collection
/// </summary>
- /// <param name="item">The state element to remove</param>
+ /// <param name="item">The attributes element to remove</param>
/// <returns>true if operation is success. Otherwise, false</returns>
public bool Remove(KeyValuePair<string, object> item)
{
- int ret = Interop.IoTConnectivity.Common.State.Remove(_resourceStateHandle, item.Key);
+ int ret = Interop.IoTConnectivity.Common.Attributes.Remove(_resourceAttributesHandle, item.Key);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- return _state.Remove(item);
+ return _attributes.Remove(item);
}
/// <summary>
- /// Removes a state element from collection using key
+ /// Removes a attributes element from collection using key
/// </summary>
- /// <param name="key">The state element to remove</param>
+ /// <param name="key">The attributes element to remove</param>
/// <returns>true if operation is success. Otherwise, false</returns>
public bool Remove(string key)
{
- int ret = Interop.IoTConnectivity.Common.State.Remove(_resourceStateHandle, key);
+ int ret = Interop.IoTConnectivity.Common.Attributes.Remove(_resourceAttributesHandle, key);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- return _state.Remove(key);
+ return _attributes.Remove(key);
}
/// <summary>
/// </summary>
/// <param name="key">The key whose value to get.</param>
/// <param name="value"> The value associated with the specified key</param>
- /// <returns> true if the state collection contains an element with the specified key; otherwise, false.</returns>
+ /// <returns> true if the attributes collection contains an element with the specified key; otherwise, false.</returns>
public bool TryGetValue(string key, out object value)
{
- return _state.TryGetValue(key, out value);
+ return _attributes.TryGetValue(key, out value);
}
IEnumerator IEnumerable.GetEnumerator()
{
- return _state.GetEnumerator();
+ return _attributes.GetEnumerator();
}
public void Dispose()
// Free managed objects
}
- Interop.IoTConnectivity.Common.State.Destroy(_resourceStateHandle);
+ Interop.IoTConnectivity.Common.Attributes.Destroy(_resourceAttributesHandle);
_disposed = true;
}
- private void SetState(IntPtr stateHandle)
+ private void SetAttributes(IntPtr attributesHandle)
{
- Interop.IoTConnectivity.Common.State.StateCallback cb = (IntPtr state, string key, IntPtr userData) =>
+ Interop.IoTConnectivity.Common.Attributes.AttributesCallback cb = (IntPtr attributes, string key, IntPtr userData) =>
{
- Interop.IoTConnectivity.Common.DataType type = 0;
- int ret = Interop.IoTConnectivity.Common.State.GetType(state, key, out type);
+ Interop.IoTConnectivity.Common.DataType dataType;
+ int ret = Interop.IoTConnectivity.Common.Attributes.GetType(attributes, key, out dataType);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- switch (type)
+
+ switch ((Interop.IoTConnectivity.Common.DataType)dataType)
{
case Interop.IoTConnectivity.Common.DataType.Int:
{
int value;
- ret = Interop.IoTConnectivity.Common.State.GetInt(state, key, out value);
+ ret = Interop.IoTConnectivity.Common.Attributes.GetInt(attributes, key, out value);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
Add(key, value);
case Interop.IoTConnectivity.Common.DataType.Bool:
{
bool value;
- ret = Interop.IoTConnectivity.Common.State.GetBool(state, key, out value);
+ ret = Interop.IoTConnectivity.Common.Attributes.GetBool(attributes, key, out value);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
Add(key, value);
case Interop.IoTConnectivity.Common.DataType.Double:
{
double value;
- ret = Interop.IoTConnectivity.Common.State.GetDouble(state, key, out value);
+ ret = Interop.IoTConnectivity.Common.Attributes.GetDouble(attributes, key, out value);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
Add(key, value);
case Interop.IoTConnectivity.Common.DataType.String:
{
string value;
- ret = Interop.IoTConnectivity.Common.State.GetStr(state, key, out value);
+ ret = Interop.IoTConnectivity.Common.Attributes.GetStr(attributes, key, out value);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
Add(key, value);
{
IntPtr byteStrPtr;
int byteStrSize;
- ret = Interop.IoTConnectivity.Common.State.GetByteStr(state, key, out byteStrPtr, out byteStrSize);
+ ret = Interop.IoTConnectivity.Common.Attributes.GetByteStr(attributes, key, out byteStrPtr, out byteStrSize);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
byte[] byteStr = new byte[byteStrSize];
case Interop.IoTConnectivity.Common.DataType.List:
{
IntPtr listHandle;
- ret = Interop.IoTConnectivity.Common.State.GetList(state, key, out listHandle);
+ ret = Interop.IoTConnectivity.Common.Attributes.GetList(attributes, key, out listHandle);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
Add(key, List.GetList(listHandle));
break;
}
- case Interop.IoTConnectivity.Common.DataType.State:
+ case Interop.IoTConnectivity.Common.DataType.Attributes:
{
- IntPtr stateHndle;
- ret = Interop.IoTConnectivity.Common.State.GetState(state, key, out stateHndle);
+ IntPtr attribsHandle;
+ ret = Interop.IoTConnectivity.Common.Attributes.GetAttributes(attributes, key, out attribsHandle);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- Add(key, new State(stateHndle));
+ Add(key, new Attributes(attribsHandle));
break;
}
default:
return true;
};
- int res = Interop.IoTConnectivity.Common.State.Foreach(stateHandle, cb, IntPtr.Zero);
+ int res = Interop.IoTConnectivity.Common.Attributes.Foreach(attributesHandle, cb, IntPtr.Zero);
if (res != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove attributes");
throw IoTConnectivityErrorFactory.GetException(res);
}
}
ret = Interop.IoTConnectivity.Common.List.AddList(listHandle, childList, pos++);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
Interop.IoTConnectivity.Common.List.Destroy(childList);
throw IoTConnectivityErrorFactory.GetException(ret);
}
ret = Interop.IoTConnectivity.Common.List.AddInt(listHandle, val, pos++);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
ret = Interop.IoTConnectivity.Common.List.AddStr(listHandle, val, pos++);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add str");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
ret = Interop.IoTConnectivity.Common.List.AddDouble(listHandle, val, pos++);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add double");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
ret = Interop.IoTConnectivity.Common.List.AddBool(listHandle, val, pos++);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
}
- else if (list is IEnumerable<State>)
+ else if (list is IEnumerable<Attributes>)
{
- ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.State, out listHandle);
+ ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Attributes, out listHandle);
pos = 0;
- foreach (State val in (IEnumerable<State>)list)
+ foreach (Attributes val in (IEnumerable<Attributes>)list)
{
- ret = Interop.IoTConnectivity.Common.List.AddState(listHandle, val._resourceStateHandle, pos++);
+ ret = Interop.IoTConnectivity.Common.List.AddAttributes(listHandle, val._resourceAttributesHandle, pos++);
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
ret = Interop.IoTConnectivity.Common.List.ForeachStr(listHandle, cb, IntPtr.Zero);
break;
}
- case Interop.IoTConnectivity.Common.DataType.State:
+ case Interop.IoTConnectivity.Common.DataType.Attributes:
{
- list = new List<State>();
- Interop.IoTConnectivity.Common.List.StateCallback cb = (int pos, IntPtr value, IntPtr userData) =>
+ list = new List<Attributes>();
+ Interop.IoTConnectivity.Common.List.AttribsCallback cb = (int pos, IntPtr value, IntPtr userData) =>
{
- list.Add(new State(value));
+ list.Add(new Attributes(value));
return true;
};
- ret = Interop.IoTConnectivity.Common.List.ForeachState(listHandle, cb, IntPtr.Zero);
+ ret = Interop.IoTConnectivity.Common.List.ForeachAttributes(listHandle, cb, IntPtr.Zero);
break;
}
case Interop.IoTConnectivity.Common.DataType.ByteStr:
}
if (ret != (int)IoTConnectivityError.None)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
throw IoTConnectivityErrorFactory.GetException(ret);
}
return list;
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
namespace Tizen.Network.IoTConnectivity
{
}
/// <summary>
+ /// Timeout property
+ /// </summary>
+ public static int PollingInterval
+ {
+ get
+ {
+ int interval;
+ int ret = Interop.IoTConnectivity.Client.IoTCon.GetPollingInterval(out interval);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Warn(IoTConnectivityErrorFactory.LogTag, "Failed to get polling interval");
+ return 0;
+ }
+ return interval;
+ }
+ set
+ {
+ int ret = Interop.IoTConnectivity.Client.IoTCon.SetPollingInterval(value);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set polling interval");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
+ }
+ }
+
+ /// <summary>
/// Connects to the iotcon service
/// </summary>
public static void Initialize()
}
/// <summary>
+ /// Initializes IoTCon with secure mode.
+ /// </summary>
+ public static void SecureInitialize(string filePath)
+ {
+ int ret = Interop.IoTConnectivity.Client.IoTCon.SecureInitialize(filePath);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to initialize securely");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
+ }
+
+ /// <summary>
/// Disconnects from the iotcon service
/// </summary>
public static void Deinitialize()
}
/// <summary>
+ /// Invokes a next message from a queue for receiving messages from others, immediately.
+ /// </summary>
+ public static void InvokePolling()
+ {
+ int ret = Interop.IoTConnectivity.Client.IoTCon.InvokePolling();
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to invoke polling");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
+ }
+
+ /// <summary>
/// Starts receiving presence events
/// </summary>
/// <returns>
Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid type");
throw new ArgumentException("Invalid type");
}
-
IntPtr id = IntPtr.Zero;
lock (s_resourceFoundCallbacksMap)
{
}
}
};
-
int errorCode = Interop.IoTConnectivity.Client.ResourceFinder.AddResourceFoundCb(hostAddress, (int)connectivityType, resourceType, isSecure, s_resourceFoundCallbacksMap[id], id);
if (errorCode != (int)IoTConnectivityError.None)
{
}
};
- int errorCode = Interop.IoTConnectivity.Client.DeviceInformation.Get(hostAddress, (int)connectivityType, s_deviceInformationCallbacksMap[id], id);
+ int errorCode = Interop.IoTConnectivity.Client.DeviceInformation.Find(hostAddress, (int)connectivityType, s_deviceInformationCallbacksMap[id], id);
if (errorCode != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device information");
}
};
- int errorCode = Interop.IoTConnectivity.Client.PlatformInformation.Get(hostAddress, (int)connectivityType, s_platformInformationCallbacksMap[id], id);
+ int errorCode = Interop.IoTConnectivity.Client.PlatformInformation.Find(hostAddress, (int)connectivityType, s_platformInformationCallbacksMap[id], id);
if (errorCode != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get platform information");
private static PresenceReceivedEventArgs GetPresenceReceivedEventArgs(int presenceId, IntPtr presenceResponseHandle)
{
int trigger;
- string host, type;
+ IntPtr host, type;
int ret = Interop.IoTConnectivity.Client.PresenceResponse.GetHostAddress(presenceResponseHandle, out host);
if (ret != (int)IoTConnectivityError.None)
PresenceReceivedEventArgs e = new PresenceReceivedEventArgs()
{
PresenceId = presenceId,
- HostAddress = host,
- Type = type,
+ HostAddress = Marshal.PtrToStringAuto(host),
+ Type = Marshal.PtrToStringAuto(type),
EventType = (PresenceEventType)trigger
};
private static DeviceInformationFoundEventArgs GetDeviceInformationFoundEventArgs(int requestId, IntPtr deviceInfoHandle)
{
- string name, specVersion, deviceId, dataModelVersion;
+ IntPtr name, specVersion, deviceId, dataModelVersion;
int ret = Interop.IoTConnectivity.Client.DeviceInformation.GetProperty(deviceInfoHandle, (int)Interop.IoTConnectivity.Client.DeviceInformation.Property.Name, out name);
if (ret != (int)IoTConnectivityError.None)
DeviceInformationFoundEventArgs e = new DeviceInformationFoundEventArgs()
{
RequestId = requestId,
- Name = name,
- SpecVersion = specVersion,
- DeviceId = deviceId,
- DataModelVersion = dataModelVersion
+ Name = Marshal.PtrToStringAuto(name),
+ SpecVersion = Marshal.PtrToStringAuto(specVersion),
+ DeviceId = Marshal.PtrToStringAuto(deviceId),
+ DataModelVersion = Marshal.PtrToStringAuto(dataModelVersion)
};
return e;
private static PlatformInformationFoundEventArgs GetPlatformInformationFoundEventArgs(int requestId, IntPtr platformInfoHandle)
{
- string platformId, manufacturerName, manufacturerUrl, modelNumber, dateOfManufacture, platformVersion, osVersion, hardwareVersion, firmwareVersion, supportUrl, systemTime;
+ IntPtr platformId, manufacturerName, manufacturerUrl, modelNumber, dateOfManufacture, platformVersion, osVersion, hardwareVersion, firmwareVersion, supportUrl, systemTime;
int ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.Id, out platformId);
if (ret != (int)IoTConnectivityError.None)
PlatformInformationFoundEventArgs e = new PlatformInformationFoundEventArgs()
{
RequestId = requestId,
- PlatformId = platformId,
- ManufacturerName = manufacturerName,
- ManufacturerURL = manufacturerUrl,
- DateOfManufacture = dateOfManufacture,
- ModelNumber = modelNumber,
- PlatformVersion = platformVersion,
- OsVersion = osVersion,
- HardwareVersion = hardwareVersion,
- FirmwareVersion = firmwareVersion,
- SupportUrl = supportUrl,
- SystemTime = systemTime
+ PlatformId = Marshal.PtrToStringAuto(platformId),
+ ManufacturerName = Marshal.PtrToStringAuto(manufacturerName),
+ ManufacturerURL = Marshal.PtrToStringAuto(manufacturerUrl),
+ DateOfManufacture = Marshal.PtrToStringAuto(dateOfManufacture),
+ ModelNumber = Marshal.PtrToStringAuto(modelNumber),
+ PlatformVersion = Marshal.PtrToStringAuto(platformVersion),
+ OsVersion = Marshal.PtrToStringAuto(osVersion),
+ HardwareVersion = Marshal.PtrToStringAuto(hardwareVersion),
+ FirmwareVersion = Marshal.PtrToStringAuto(firmwareVersion),
+ SupportUrl = Marshal.PtrToStringAuto(supportUrl),
+ SystemTime = Marshal.PtrToStringAuto(systemTime)
};
return e;
throw IoTConnectivityErrorFactory.GetException(ret);
}
}
+
+ /// <summary>
+ /// Sets the device name
+ /// </summary>
+ /// <param name="deviceName">The device name</param>
+ public static void SetDeviceName(string deviceName)
+ {
+ int ret = Interop.IoTConnectivity.Server.IoTCon.SetDeviceName(deviceName);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed set device name");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
+ }
}
}
/// <param name="uri">The uri path of the lite resource</param>
/// <param name="types">Resource type</param>
/// <param name="policy">Policy of the resource</param>
- /// <param name="state">Optional State of the resource</param>
- public LiteResource(string uri, ResourceTypes types, ResourcePolicy policy, State state = null)
+ /// <param name="attribs">Optional attributes of the resource</param>
+ public LiteResource(string uri, ResourceTypes types, ResourcePolicy policy, Attributes attribs = null)
: base(uri, types, new ResourceInterfaces(new string[] { ResourceInterfaces.DefaultInterface }), policy)
{
- State = state;
+ Attributes = attribs;
}
/// <summary>
- /// The state of the lite resource
+ /// The attributes of the lite resource
/// </summary>
- public State State { get; set; }
+ public Attributes Attributes { get; set; }
/// <summary>
/// The method to accept post request
/// </summary>
- /// <param name="state">The new state of the lite resource</param>
+ /// <param name="attribs">The new attributes of the lite resource</param>
/// <returns>true to accept post request, false to reject it</returns>
- public virtual bool OnPost(State state)
+ public virtual bool OnPost(Attributes attribs)
{
return true;
}
UriPath = UriPath,
Interface = Interfaces,
Type = Types,
- State = State
+ Attributes = Attributes
};
Response response = new Response()
/// <param name="request">Request.</param>
public sealed override Response OnPost(Request request)
{
- if (OnPost(request.Representation.State))
+ if (OnPost(request.Representation.Attributes))
{
- State = request.Representation.State;
+ Attributes = request.Representation.Attributes;
Representation representation = new Representation() {
UriPath = UriPath,
Interface = Interfaces,
Type = Types,
- State = State
+ Attributes = Attributes
};
Response response = new Response() {
using System;
using System.Collections.Generic;
using System.Net;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Network.IoTConnectivity
public ResourcePolicy Policy { get; private set; }
/// <summary>
+ /// The device name of the remote resource
+ /// </summary>
+ public string DeviceName { get; private set; }
+
+ /// <summary>
/// The header options of the resource
/// </summary>
public ResourceOptions Options
get
{
int interval;
- int ret = Interop.IoTConnectivity.Client.RemoteResource.GetTimeInterval(_remoteResourceHandle, out interval);
+ int ret = Interop.IoTConnectivity.Client.RemoteResource.GetTimeInterval(out interval);
if (ret != (int)IoTConnectivityError.None)
{
Log.Warn(IoTConnectivityErrorFactory.LogTag, "Failed to get time interval");
int ret = (int)IoTConnectivityError.InvalidParameter;
if (value < TimeOutMax && value > 0)
{
- ret = Interop.IoTConnectivity.Client.RemoteResource.SetTimeInterval(_remoteResourceHandle, value);
+ ret = Interop.IoTConnectivity.Client.RemoteResource.SetTimeInterval(value);
}
if (ret != (int)IoTConnectivityError.None)
{
else
{
IPAddress address;
- if (IPAddress.TryParse(hostAddress, out address))
+ string hostName = hostAddress;
+ if (hostAddress.Contains(":"))
+ {
+ string[] hostParts = hostAddress.Split(':');
+ if (hostParts.Length == 2)
+ {
+ hostName = hostParts[0];
+ }
+ }
+ if (IPAddress.TryParse(hostName, out address))
{
switch (address.AddressFamily)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get remote resource");
throw IoTConnectivityErrorFactory.GetException(ret);
}
+
+ /*IntPtr deviceName;
+ ret = Interop.IoTConnectivity.Client.RemoteResource.GetDeviceName(_remoteResourceHandle, out deviceName);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device name of remote resource");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
+ DeviceName = Marshal.PtrToStringAuto(deviceName);*/
}
private void SetRemoteResource()
{
- string hostAddress, uriPath;
- int ret = Interop.IoTConnectivity.Client.RemoteResource.GetHostAddress(_remoteResourceHandle, out hostAddress);
+ IntPtr hostAddressPtr, uriPathPtr;
+ int ret = Interop.IoTConnectivity.Client.RemoteResource.GetHostAddress(_remoteResourceHandle, out hostAddressPtr);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Faled to get host address");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- ret = Interop.IoTConnectivity.Client.RemoteResource.GetUriPath(_remoteResourceHandle, out uriPath);
+ ret = Interop.IoTConnectivity.Client.RemoteResource.GetUriPath(_remoteResourceHandle, out uriPathPtr);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Faled to get uri path");
}
int policy = (int)ResourcePolicy.NoProperty;
- ret = Interop.IoTConnectivity.Client.RemoteResource.GetProperties(_remoteResourceHandle, out policy);
+ ret = Interop.IoTConnectivity.Client.RemoteResource.GetPolicies(_remoteResourceHandle, out policy);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Faled to get uri path");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- string deviceId;
- ret = Interop.IoTConnectivity.Client.RemoteResource.GetDeviceId(_remoteResourceHandle, out deviceId);
+ IntPtr deviceIdPtr;
+ ret = Interop.IoTConnectivity.Client.RemoteResource.GetDeviceId(_remoteResourceHandle, out deviceIdPtr);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device id");
throw IoTConnectivityErrorFactory.GetException(ret);
}
-
- DeviceId = deviceId;
- HostAddress = hostAddress;
- UriPath = uriPath;
+ IntPtr deviceName;
+ ret = Interop.IoTConnectivity.Client.RemoteResource.GetDeviceName(_remoteResourceHandle, out deviceName);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device name of remote resource");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
+ DeviceName = Marshal.PtrToStringAuto(deviceName);
+ DeviceId = Marshal.PtrToStringAuto(deviceIdPtr);
+ HostAddress = Marshal.PtrToStringAuto(hostAddressPtr);
+ UriPath = Marshal.PtrToStringAuto(uriPathPtr);
Types = new ResourceTypes(typesHandle);
Interfaces = new ResourceInterfaces(interfacesHandle);
Policy = (ResourcePolicy)policy;
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get options");
throw IoTConnectivityErrorFactory.GetException(ret);
}
-
return new RemoteResponse()
{
Result = (ResponseCode)result,
Representation = new Representation(representationHandle),
- Options = new ResourceOptions(optionsHandle)
+ Options = (optionsHandle == IntPtr.Zero)? null : new ResourceOptions(optionsHandle)
};
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Runtime.InteropServices;
namespace Tizen.Network.IoTConnectivity
{
{
get
{
- string path;
+ IntPtr path;
int ret = Interop.IoTConnectivity.Common.Representation.GetUriPath(_representationHandle, out path);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get uri");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- return path;
+ return Marshal.PtrToStringAuto(path);
}
set
{
get
{
IntPtr interfaceHandle;
- int ret = Interop.IoTConnectivity.Common.Representation.GetResourceTypes(_representationHandle, out interfaceHandle);
+ int ret = Interop.IoTConnectivity.Common.Representation.GetResourceInterfaces(_representationHandle, out interfaceHandle);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get interface");
{
int ret = (int)IoTConnectivityError.InvalidParameter;
if (value != null)
- ret = Interop.IoTConnectivity.Common.Representation.SetResourceTypes(_representationHandle, value.ResourceInterfacesHandle);
+ ret = Interop.IoTConnectivity.Common.Representation.SetResourceInterfaces(_representationHandle, value.ResourceInterfacesHandle);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set interface");
}
/// <summary>
- /// Current state of the resource
+ /// Current attributes of the resource
/// </summary>
- public State State
+ public Attributes Attributes
{
get
{
- return State;
+ IntPtr attributeHandle;
+ int ret = Interop.IoTConnectivity.Common.Representation.GetAttributes(_representationHandle, out attributeHandle);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
+ return new Attributes(attributeHandle);
}
set
{
- State = value;
int ret = (int)IoTConnectivityError.InvalidParameter;
- if (State != null)
- ret = Interop.IoTConnectivity.Common.Representation.SetState(_representationHandle, State._resourceStateHandle);
- if (ret != (int)IoTConnectivityError.None)
+ if (value != null)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set interface");
- throw IoTConnectivityErrorFactory.GetException(ret);
+ ret = Interop.IoTConnectivity.Common.Representation.SetAttributes(_representationHandle, value._resourceAttributesHandle);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set attributes");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
}
}
}
if (disposing)
{
// Free managed objects
- Type.Dispose();
- Interface.Dispose();
- State?.Dispose();
+ Type?.Dispose();
+ Interface?.Dispose();
+ Attributes?.Dispose();
}
Interop.IoTConnectivity.Common.Representation.Destroy(_representationHandle);
foreach (Representation r in e.NewItems)
{
int ret = Interop.IoTConnectivity.Common.Representation.AddChild(_representationHandle, r._representationHandle);
- throw IoTConnectivityErrorFactory.GetException(ret);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add child");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
}
}
else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
foreach (Representation r in e.NewItems)
{
int ret = Interop.IoTConnectivity.Common.Representation.RemoveChild(_representationHandle, r._representationHandle);
- throw IoTConnectivityErrorFactory.GetException(ret);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove child");
+ throw IoTConnectivityErrorFactory.GetException(ret);
+ }
}
}
}
/// <summary>
/// Class respresenting Request to a resource
/// </summary>
- public class Request: IDisposable
+ public class Request : IDisposable
{
private bool _disposed = false;
if (disposing)
{
- Representation.Dispose();
- Query.Dispose();
- Options.Dispose();
+ Representation?.Dispose();
+ Query?.Dispose();
+ Options?.Dispose();
}
_disposed = true;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Runtime.InteropServices;
namespace Tizen.Network.IoTConnectivity
{
if (disposing)
{
- Types.Dispose();
- Interfaces.Dispose();
+ Types?.Dispose();
+ Interfaces?.Dispose();
}
- Interop.IoTConnectivity.Server.Resource.Destroy(_resourceHandle);
- Interop.IoTConnectivity.Server.Observers.Destroy(_observerHandle);
+ if (_resourceHandle != IntPtr.Zero)
+ Interop.IoTConnectivity.Server.Resource.Destroy(_resourceHandle);
+ if (_observerHandle != IntPtr.Zero)
+ Interop.IoTConnectivity.Server.Observers.Destroy(_observerHandle);
_disposed = true;
}
}
finally
{
- request.Dispose();
+ request?.Dispose();
response?.Dispose();
}
}
private Request GetRequest(IntPtr requestHandle)
{
- string hostAddress;
- int ret = Interop.IoTConnectivity.Server.Request.GetHostAddress(requestHandle, out hostAddress);
+ IntPtr hostAddressPtr;
+ int ret = Interop.IoTConnectivity.Server.Request.GetHostAddress(requestHandle, out hostAddressPtr);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get host address");
return new Request()
{
- HostAddress = hostAddress,
+ HostAddress = Marshal.PtrToStringAuto(hostAddressPtr),
Options = opts,
Query = query,
Representation = representation
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
namespace Tizen.Network.IoTConnectivity
{
{
get
{
- string type;
+ IntPtr type;
int ret = Interop.IoTConnectivity.Common.Query.GetResourceType(_resourceQueryHandle, out type);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- return type;
+ return Marshal.PtrToStringAuto(type);
}
set
{
{
get
{
- string iface;
+ IntPtr iface;
int ret = Interop.IoTConnectivity.Common.Query.GetInterface(_resourceQueryHandle, out iface);
if (ret != (int)IoTConnectivityError.None)
{
Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get interface");
throw IoTConnectivityErrorFactory.GetException(ret);
}
- return iface;
+ return Marshal.PtrToStringAuto(iface);
}
set
{
return false;
}
- string iface = "oic.if.baseline";
- // TODO: iface parameter will be removed after native API is changed
- ret = Interop.IoTConnectivity.Server.Response.SetRepresentation(responseHandle, iface, Representation._representationHandle);
- if (ret != (int)IoTConnectivityError.None)
+ if (Representation != null)
{
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send response");
- Interop.IoTConnectivity.Server.Response.Destroy(responseHandle);
- return false;
+ ret = Interop.IoTConnectivity.Server.Response.SetRepresentation(responseHandle, Representation._representationHandle);
+ if (ret != (int)IoTConnectivityError.None)
+ {
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send response");
+ Interop.IoTConnectivity.Server.Response.Destroy(responseHandle);
+ return false;
+ }
}
ret = Interop.IoTConnectivity.Server.Response.Send(responseHandle);
if (disposing)
{
- Representation?.Dispose();
}
_disposed = true;