I have an AllJoyn property like this
<property name="DeviceAddresses" type="ay" access="read">
I a Windows 10 UWP app when I try to read it - I get success - but I don't know how to get out the value from the result Code looks like this:
var vProperty = pInterface.GetProperty(propertyName);
if (vProperty == null) return null;
var result = await vProperty.ReadValueAsync();
if (result.Status.IsSuccess)
{
if (vProperty.TypeInfo.Type == TypeId.Uint8Array)
{
byte[] Erg = result.Value ???
}
}
The property value is created via
object o = Windows.Foundation.PropertyValue.CreateUInt8Array(value);
But I found no way (casting or so) the get the bytes out.
I use DeviceProviders to access AllJoyn methods. It uses
IAsyncOperation<InvokeMethodResult> InvokeAsync(IList<object> @params);
to get the server response. It looks similar to what your ReadValueAsync()
returns. But not quite the same. This is how I access the bytes.
InvokeMethodResult result = await MyAllJoynMethod.InvokeAsync(new List<object> { "parameter", 2 });
if (result.Status.IsSuccess)
{
var resultList = result.Values as IList<object>;
foreach (var resultListItem in resultList)
{
var pairs = resultListItem as IList<KeyValuePair<object, object>>;
foreach (var pair in pairs)
{
var key = pair.Key as string; //<- type string taken from MyAllJoynMethod definition
var variant = pair.Value as AllJoynMessageArgVariant;//<- type AllJoynMessageArgVariant taken from MyAllJoynMethod definition (variant)
if (variant.TypeDefinition.Type == TypeId.Uint8Array)
{
var array8 = j as IList<object>;
foreach (byte b in array8)
{
// do something with b
}
}
}
}
}
EDIT: If you do not want to program it yourself you can use OpenAlljoynExplorer. Not sure if byte arrays are actually supported, yet.