error_t coapClientSetRxBlockSize(CoapClientRequest *request, uint_t blockSize)
{
   //Make sure the CoAP request handle is valid
   if(request == NULL)
      return ERROR_INVALID_PARAMETER;

   //Acquire exclusive access to the CoAP client context
   osAcquireMutex(&request->context->mutex);

   //Set RX block size
   if(blockSize == 16)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_16;
   }
   else if(blockSize == 32)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_32;
   }
   else if(blockSize == 64)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_64;
   }
   else if(blockSize == 128)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_128;
   }
   else if(blockSize == 256)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_256;
   }
   else if(blockSize == 512)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_512;
   }
   else
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_1024;
   }

   //Ensure the block size is acceptable
   if(request->rxBlockSzx > coapClientGetMaxBlockSize())
   {
      request->rxBlockSzx = coapClientGetMaxBlockSize();
   }

   //Release exclusive access to the CoAP client context
   osReleaseMutex(&request->context->mutex);

   //Successful processing
   return NO_ERROR;
}
error_t coapClientSetRxBlockSize(CoapClientRequest *request, uint_t blockSize)
{
    
   if(request == NULL)
      return ERROR_INVALID_PARAMETER;

    
   osAcquireMutex(&request->context->mutex);

    
   if(blockSize == 16)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_16;
   }
   else if(blockSize == 32)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_32;
   }
   else if(blockSize == 64)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_64;
   }
   else if(blockSize == 128)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_128;
   }
   else if(blockSize == 256)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_256;
   }
   else if(blockSize == 512)
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_512;
   }
   else
   {
      request->rxBlockSzx = COAP_BLOCK_SIZE_1024;
   }

    
   if(request->rxBlockSzx > coapClientGetMaxBlockSize())
   {
      request->rxBlockSzx = coapClientGetMaxBlockSize();
   }

    
   osReleaseMutex(&request->context->mutex);

    
   return NO_ERROR;
}