error_t coapServerInitResponse(CoapServerContext *context)
{
   CoapMessageHeader *requestHeader;
   CoapMessageHeader *responseHeader;

   //Point to the CoAP request header
   requestHeader = (CoapMessageHeader *) context->request.buffer;
   //Point to the CoAP response header
   responseHeader = (CoapMessageHeader *) context->response.buffer;

   //Format message header
   responseHeader->version = COAP_VERSION_1;
   responseHeader->tokenLen = requestHeader->tokenLen;
   responseHeader->code = COAP_CODE_INTERNAL_SERVER;
   responseHeader->mid = requestHeader->mid;

   //If immediately available, the response to a request carried in a
   //Confirmable message is carried in an Acknowledgement (ACK) message
   if(requestHeader->type == COAP_TYPE_CON)
   {
      responseHeader->type = COAP_TYPE_ACK;
   }
   else
   {
      responseHeader->type = COAP_TYPE_NON;
   }

   //The token is used to match a response with a request
   osMemcpy(responseHeader->token, requestHeader->token,
      requestHeader->tokenLen);

   //Set the length of the CoAP message
   context->response.length = sizeof(CoapMessageHeader) + responseHeader->tokenLen;
   context->response.pos = 0;

   //Sucessful processing
   return NO_ERROR;
}
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.