Search in sources :

Example 1 with CoapRequestBuilder

use of org.eclipse.leshan.client.californium.impl.CoapRequestBuilder in project leshan by eclipse.

the class LockStepLwM2mClient method sendLwM2mRequest.

public void sendLwM2mRequest(UplinkRequest<? extends LwM2mResponse> lwm2mReq) {
    // create CoAP request
    CoapRequestBuilder coapRequestBuilder = new CoapRequestBuilder(destination);
    lwm2mReq.accept(coapRequestBuilder);
    Request coapReq = coapRequestBuilder.getRequest();
    byte[] token = new byte[8];
    r.nextBytes(token);
    coapReq.setToken(token);
    // serialize request
    UdpDataSerializer serializer = new UdpDataSerializer();
    RawData raw = serializer.serializeRequest(coapReq);
    // send it
    super.send(raw);
}
Also used : RawData(org.eclipse.californium.elements.RawData) CoapRequestBuilder(org.eclipse.leshan.client.californium.impl.CoapRequestBuilder) Request(org.eclipse.californium.core.coap.Request) UplinkRequest(org.eclipse.leshan.core.request.UplinkRequest) UdpDataSerializer(org.eclipse.californium.core.network.serialization.UdpDataSerializer)

Aggregations

Request (org.eclipse.californium.core.coap.Request)1 UdpDataSerializer (org.eclipse.californium.core.network.serialization.UdpDataSerializer)1 RawData (org.eclipse.californium.elements.RawData)1 CoapRequestBuilder (org.eclipse.leshan.client.californium.impl.CoapRequestBuilder)1 UplinkRequest (org.eclipse.leshan.core.request.UplinkRequest)1