getAttributes method
Implementation
AsyncReply<Structure> getAttributes(IResource resource,
[List<String>? attributes = null]) {
var rt = new AsyncReply<Structure>();
if (attributes == null) {
(sendRequest(IIPPacketAction.GetAllAttributes)
..addUint32(resource.instance?.id as int))
.done()
..then((ar) {
if (ar != null) {
var d = ar[0] as DC;
Codec.parseStructure(d, 0, d.length, this)
..then((st) {
resource.instance?.setAttributes(st);
rt.trigger(st);
})
..error((ex) => rt.triggerError(ex));
} else {
rt.triggerError(Exception("Null response"));
}
});
} else {
var attrs = DC.stringArrayToBytes(attributes);
(sendRequest(IIPPacketAction.GetAttributes)
..addUint32(resource.instance?.id as int)
..addInt32(attrs.length)
..addDC(attrs))
.done()
..then((ar) {
if (ar != null) {
var d = ar[0] as DC;
Codec.parseStructure(d, 0, d.length, this)
..then((st) {
resource.instance?.setAttributes(st);
rt.trigger(st);
})
..error((ex) => rt.triggerError(ex));
} else {
rt.triggerError(Exception("Null response"));
}
});
}
return rt;
}