How to write the value of Opc Ua Node

I’m looking the OPC UA Device example.The example show how to add Opc Ua Node.
But I have 2 question: to update the value of Opc Ua Node, is ManagedAddressSpaceServices.write(WriteContext context,List writeValues) ?
2.I try to update the value of one Opc Ua Node like this:
new AttributeContext(
new DataValue(new Variant((long) 101), StatusCode.GOOD),
But the ig show err .“UaException: status=Bad_TypeMismatch, message=The value supplied for the attribute is not of the same type as the attribute’s value.”

You can call node.setValue() to update the value once, or install an AttributeFilter that will act as a callback any time an attribute is being read from the Node.

The device APIs are just a thin layer on top of the Eclipse Milo OPC UA SDK. You may find it useful to look at examples that use the API here and here.

hi Kevin.
As you say,I try to install an AttributeFilter like:
node.setValue(new DataValue(new Variant(100 + i)));

                new AttributeLoggingFilter(),
                    ctx ->
                        new DataValue(new Variant((long) new Random().nextInt()))

but it run err :
java.lang.NoSuchMethodError: ‘org.eclipse.milo.opcua.sdk.server.nodes.filters.AttributeFilterChain org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode.getFilterChain()’

in pom.xml,I have add:


Ah, I forgot AttributeFilterchain is new to version 0.4. The SDK currently uses a 0.3.x version of Milo. There is something called AttributeDelegate instead. Look at the examples from one of the 0.3 release branches:

You shouldn’t add your own Milo dependency - you get one as a transitive dependency from the module SDK.

I done it. Thanks for your support.