Search in sources :

Example 1 with TbLwM2MWriteResponseCompositeCallback

use of org.thingsboard.server.transport.lwm2m.server.downlink.composite.TbLwM2MWriteResponseCompositeCallback in project thingsboard by thingsboard.

the class DefaultLwM2MRpcRequestHandler method sendWriteCompositeRequest.

/**
 * WriteComposite {"nodes":{"/3/0/14":"+04", "/1/0/2":100, "/5/0/1":"coap://localhost:5685"}}
 * {"result":"CHANGED"}
 * Map<String, Object> nodes = new HashMap<>();
 * nodes.put("/3/0/14", "+02");
 * nodes.put("/1/0/2", 100);
 * nodes.put("/5/0/1", "coap://localhost:5685");
 */
private void sendWriteCompositeRequest(LwM2mClient client, TransportProtos.ToDeviceRpcRequestMsg requestMsg, ContentFormat contentFormatComposite) {
    RpcWriteCompositeRequest rpcWriteCompositeRequest = JacksonUtil.fromString(requestMsg.getParams(), RpcWriteCompositeRequest.class);
    Map<String, Object> validNodes = validateNodes(client, rpcWriteCompositeRequest.getNodes());
    if (validNodes.size() > 0) {
        rpcWriteCompositeRequest.setNodes(validNodes);
        var mainCallback = new TbLwM2MWriteResponseCompositeCallback(uplinkHandler, logService, client, null);
        var rpcCallback = new RpcEmptyResponseCallback<>(transportService, client, requestMsg, mainCallback);
        downlinkHandler.sendWriteCompositeRequest(client, rpcWriteCompositeRequest, rpcCallback, contentFormatComposite);
    } else {
        throw new IllegalArgumentException(String.format("nodes: %s is not validate value", rpcWriteCompositeRequest.getNodes().toString()));
    }
}
Also used : TbLwM2MWriteResponseCompositeCallback(org.thingsboard.server.transport.lwm2m.server.downlink.composite.TbLwM2MWriteResponseCompositeCallback) RpcWriteCompositeRequest(org.thingsboard.server.transport.lwm2m.server.rpc.composite.RpcWriteCompositeRequest)

Aggregations

TbLwM2MWriteResponseCompositeCallback (org.thingsboard.server.transport.lwm2m.server.downlink.composite.TbLwM2MWriteResponseCompositeCallback)1 RpcWriteCompositeRequest (org.thingsboard.server.transport.lwm2m.server.rpc.composite.RpcWriteCompositeRequest)1