private void handleIncomingConfirmableCoapMessage(ChannelHandlerContext ctx, MessageEvent me) { InetSocketAddress remoteEndpoint = (InetSocketAddress) me.getRemoteAddress(); CoapMessage coapMessage = (CoapMessage) me.getMessage(); // Empty CON messages can be used as application layer PING (is CoAP endpoints alive?) if (coapMessage.getMessageCodeName() == MessageCode.Name.EMPTY) writeReset(remoteEndpoint, coapMessage.getMessageID()); else if (MessageCode.isResponse(coapMessage.getMessageCode())) handleIncomingConfirmableCoapResponse(ctx, me); else if (MessageCode.isRequest(coapMessage.getMessageCode())) handleIncomingConfirmableCoapRequest(ctx, me); else log.error("Incoming CoAP message is neither empty nor request nor response: ", coapMessage); }
private String msg(MessageCode code, String msg) { return code.getCode() + ":" + msg; }