use of org.thingsboard.server.transport.coap.client.TbCoapClientState in project thingsboard by thingsboard.
the class CoapTransportResource method processRequest.
private void processRequest(CoapExchange exchange, SessionMsgType type, Request request, ValidateDeviceCredentialsResponse deviceCredentials, DeviceProfile deviceProfile) {
TbCoapClientState clientState = null;
try {
clientState = clients.getOrCreateClient(type, deviceCredentials, deviceProfile);
clients.awake(clientState);
switch(type) {
case POST_ATTRIBUTES_REQUEST:
handlePostAttributesRequest(clientState, exchange, request);
break;
case POST_TELEMETRY_REQUEST:
handlePostTelemetryRequest(clientState, exchange, request);
break;
case CLAIM_REQUEST:
handleClaimRequest(clientState, exchange, request);
break;
case SUBSCRIBE_ATTRIBUTES_REQUEST:
handleAttributeSubscribeRequest(clientState, exchange, request);
break;
case UNSUBSCRIBE_ATTRIBUTES_REQUEST:
handleAttributeUnsubscribeRequest(clientState, exchange, request);
break;
case SUBSCRIBE_RPC_COMMANDS_REQUEST:
handleRpcSubscribeRequest(clientState, exchange, request);
break;
case UNSUBSCRIBE_RPC_COMMANDS_REQUEST:
handleRpcUnsubscribeRequest(clientState, exchange, request);
break;
case TO_DEVICE_RPC_RESPONSE:
handleToDeviceRpcResponse(clientState, exchange, request);
break;
case TO_SERVER_RPC_REQUEST:
handleToServerRpcRequest(clientState, exchange, request);
break;
case GET_ATTRIBUTES_REQUEST:
handleGetAttributesRequest(clientState, exchange, request);
break;
}
} catch (AdaptorException e) {
if (clientState != null) {
log.trace("[{}] Failed to decode message: ", clientState.getDeviceId(), e);
}
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
}
}
Aggregations