Search in sources :

Example 6 with CoapOkCallback

use of org.thingsboard.server.transport.coap.callback.CoapOkCallback in project thingsboard by thingsboard.

the class CoapTransportResource method handleToDeviceRpcResponse.

private void handleToDeviceRpcResponse(TbCoapClientState clientState, CoapExchange exchange, Request request) throws AdaptorException {
    TransportProtos.SessionInfoProto session = clientState.getSession();
    if (session == null) {
        session = clients.getNewSyncSession(clientState);
    }
    UUID sessionId = toSessionId(session);
    transportService.process(session, clientState.getAdaptor().convertToDeviceRpcResponse(sessionId, request, clientState.getConfiguration().getRpcResponseMsgDescriptor()), new CoapOkCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
}
Also used : CoapOkCallback(org.thingsboard.server.transport.coap.callback.CoapOkCallback) TransportProtos(org.thingsboard.server.gen.transport.TransportProtos) UUID(java.util.UUID)

Example 7 with CoapOkCallback

use of org.thingsboard.server.transport.coap.callback.CoapOkCallback in project thingsboard by thingsboard.

the class DefaultCoapClientContext method cancelAttributeSubscription.

private void cancelAttributeSubscription(TbCoapClientState state) {
    if (state.getAttrs() != null) {
        clientsByToken.remove(state.getAttrs().getToken());
        CoapExchange exchange = state.getAttrs().getExchange();
        state.setAttrs(null);
        transportService.process(state.getSession(), TransportProtos.SubscribeToAttributeUpdatesMsg.newBuilder().setUnsubscribe(true).build(), new CoapOkCallback(exchange, CoAP.ResponseCode.DELETED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
        if (state.getRpc() == null) {
            closeAndCleanup(state);
        }
    }
}
Also used : CoapOkCallback(org.thingsboard.server.transport.coap.callback.CoapOkCallback) CoapExchange(org.eclipse.californium.core.server.resources.CoapExchange)

Aggregations

CoapOkCallback (org.thingsboard.server.transport.coap.callback.CoapOkCallback)7 TransportProtos (org.thingsboard.server.gen.transport.TransportProtos)5 UUID (java.util.UUID)4 CoapExchange (org.eclipse.californium.core.server.resources.CoapExchange)2 CoapNoOpCallback (org.thingsboard.server.transport.coap.callback.CoapNoOpCallback)1