+//packet format define value
+#define CA_BLE_START_POS 7
+#define CA_BLE_START_LEN 1
+#define CA_BLE_SOURCE_PORT_POS 6
+#define CA_BLE_SOURCE_PORT_LEN 7
+#define CA_BLE_SECURE_POS 7
+#define CA_BLE_SECURE_LEN 1
+#define CA_BLE_DESTINATION_PORT_POS 6
+#define CA_BLE_DESTINATION_PORT_LEN 7
+
+/**
+ * This function is used to set value in specific bit position.
+ *
+ * @param[out] x Pointer to the octet variable that will contain
+ * value in specific bit position.
+ * @param[in] p Position which need to embed specific bits(0~7).
+ * @param[in] n Length to fill several bits from the position.
+ * @param[in] v Value to contain in specific bit position.
+ */
+static void CASetBits(uint8_t *x, unsigned p, unsigned n, unsigned v)
+{
+ if ((p+1) < n)
+ {
+ OIC_LOG(ERROR, TAG, "set bits - lower err");
+ return;
+ }
+ else if(~(unsigned)(~0u<<n) < v)
+ {
+ OIC_LOG(ERROR, TAG, "set bits - upper err");
+ return;
+ }
+ *x = (*x & (~(~0u << (p-n+1)))) | (*x & (~0u << (p+1))) | ((v & ~(~0u << n)) << (p-n+1));
+}
+
+/**
+ * This function is used to get value in specific bit position.
+ *
+ * @param[in] x Pointer to the octet variable that have infomation
+ * to be extracted.
+ * @param[in] p Position which need to get specific bits(0~7).
+ * @param[in] n Length to get several bits from the position.
+ *
+ * @return @c Extracted value from specific position.
+ */
+static uint8_t CAGetBits(uint8_t x, unsigned p, unsigned n)
+{
+ return (x >> (p + 1 - n)) & ~(~0u << n);
+}
+
+CAResult_t CAGenerateVariableForFragmentation(size_t dataLength,
+ uint32_t *midPacketCount,
+ size_t *remainingLen,
+ size_t *totalLength,
+ uint16_t mtuSize)
+{
+ OIC_LOG_V(DEBUG, TAG, "IN, dataLength = %zu, mtu = %zu", dataLength, mtuSize);
+
+ size_t remainDataSize = 0;
+ size_t dataOnlyLen =
+ mtuSize - (CA_BLE_HEADER_SIZE + CA_BLE_LENGTH_HEADER_SIZE);
+ //total data size is smaller than 14 byte case.
+ if (dataLength < dataOnlyLen)
+ {
+ remainDataSize = 0;
+ }
+ else
+ {
+ remainDataSize = dataLength - dataOnlyLen;
+ }
+
+ if (mtuSize - CA_BLE_HEADER_SIZE <= 0)
+ {
+ OIC_LOG_V(ERROR, TAG, "BLE header size shouldn't be bigger than BLE MTU size.");
+ return CA_STATUS_FAILED;
+ }
+
+ *midPacketCount = (uint32_t)remainDataSize / (mtuSize - CA_BLE_HEADER_SIZE);
+ *remainingLen = (uint32_t)remainDataSize % (mtuSize - CA_BLE_HEADER_SIZE);
+ uint32_t remainHeaderSize = CA_BLE_HEADER_SIZE * (*midPacketCount + (*remainingLen == 0 ? 0:1));
+ *totalLength = dataLength + (CA_BLE_HEADER_SIZE + CA_BLE_LENGTH_HEADER_SIZE) + remainHeaderSize;
+
+ OIC_LOG(DEBUG, TAG, "OUT");
+
+ return CA_STATUS_OK;
+}
+
+CAResult_t CAGenerateHeader(uint8_t *header,
+ CABLEPacketStart_t type,
+ const uint8_t sourcePort,
+ CABLEPacketSecure_t secure,
+ const uint8_t destPort)