#include "uarraylist.h"
#include "cacommon.h"
#include "caprotocolmessage.h"
+#include "camessagehandler.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
/**
* Callback to send block data.
typedef enum
{
CA_BLOCK_UNKNOWN = 0,
- CA_OPTION1_ACK,
- CA_OPTION1_NO_ACK_LAST_BLOCK,
- CA_OPTION1_NO_ACK_BLOCK,
+ CA_OPTION1_RESPONSE,
+ CA_OPTION1_REQUEST_LAST_BLOCK,
+ CA_OPTION1_REQUEST_BLOCK,
CA_OPTION2_FIRST_BLOCK,
CA_OPTION2_LAST_BLOCK,
- CA_OPTION2_ACK,
- CA_OPTION2_NON,
- CA_OPTION2_CON,
- CA_SENT_PREVIOUS_NON_MSG,
+ CA_OPTION2_RESPONSE,
+ CA_OPTION2_REQUEST,
CA_BLOCK_INCOMPLETE,
CA_BLOCK_TOO_LARGE,
CA_BLOCK_RECEIVED_ALREADY
} CABlockState_t;
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
/**
* Initializes the block-wise transfer context.
* @param[in] CASendThreadFunc function point to add data in send queue thread.
* send block message to remote device.
* @param[in] pdu received pdu binary data.
* @param[in] msgType the message type of the block.
- * @param[in] status block-wise state to move next step.
* @param[in] blockID ID set of CABlockData.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CASendBlockMessage(const coap_pdu_t *pdu, CAMessageType_t msgType,
- uint8_t status, const CABlockDataID_t *blockID);
+ const CABlockDataID_t *blockID);
/**
* send error message to remote device.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CANegotiateBlockSize(CABlockData_t *currData, coap_block_t *block,
- CAMessageType_t msgType, uint16_t blockType);
+ const coap_pdu_t *pdu, uint16_t blockType);
/**
* Update the block option in block-wise transfer list.
* @param[out] block block option.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CAGetMoreBitFromBlock(size_t payloadLen, coap_block_t *block);
+CAResult_t CASetMoreBitFromBlock(size_t payloadLen, coap_block_t *block);
/**
* check the block option what kind of option have to set.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
- const CAEndpoint_t *endpoint);
+ const CAEndpoint_t *endpoint, coap_list_t **options);
/**
* Write the block option2 in pdu binary data.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
- const CABlockDataID_t *blockID);
+ const CABlockDataID_t *blockID, coap_list_t **options);
/**
* Write the block option1 in pdu binary data.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
- const CABlockDataID_t *blockID);
+ const CABlockDataID_t *blockID, coap_list_t **options);
/**
- * Add the block option in pdu data.
- * @param[in] pdu pdu object.
+ * Add the block option in option list.
* @param[out] block block data.
* @param[in] blockType block option type.
+ * @param[out] options option list.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CAAddBlockOptionImpl(coap_block_t *block, uint8_t blockType,
+ coap_list_t **options);
+
+/**
+ * Add the option list in pdu data.
+ * @param[out] pdu pdu object.
+ * @param[out] options option list.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CAAddBlockOptionImpl(coap_pdu_t *pdu, coap_block_t *block, uint8_t blockType);
+CAResult_t CAAddOptionToPDU(coap_pdu_t *pdu, coap_list_t **options);
/**
* Add the size option in pdu data.
* @param[in] dataLength the total payload length to be sent.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataLength);
+CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataLength,
+ coap_list_t **options);
/**
* Get the size option from pdu data.
CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID);
/**
- * Check if data exist in block-wise transfer list.
- * @param[in] blockID ID set of CABlockData.
- * @return true or false.
+ * Remove all block data in block-wise transfer list.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-bool CAIsBlockDataInList(const CABlockDataID_t *blockID);
+CAResult_t CARemoveAllBlockDataFromList();
+/**
+ * Find the block data with seed info and remove it from block-wise transfer list.
+ * @param[in] token token of the message.
+ * @param[in] tokenLength token length of the message.
+ * @param[in] portNumber port.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength,
+ uint16_t portNumber);
#ifdef __cplusplus
} /* extern "C" */