- 0);
-
- if (CA_STATUS_OK != result)
- {
- OIC_LOG_V(ERROR,
- CALEADAPTER_TAG,
- "Update characteristics failed, result [%d]",
- result);
- g_errorHandler(bleData->remoteEndpoint,
- bleData->data,
- bleData->dataLen,
- result);
- return;
- }
-
- OIC_LOG_V(DEBUG,
- CALEADAPTER_TAG,
- "Client Sent Data length is [%u]",
- length);
-
- result = CAGenerateHeader(dataHeader,
- CA_BLE_PACKET_NOT_START,
- g_localBLESourcePort,
- secureFlag,
- bleData->remoteEndpoint->port);
-
- if (CA_STATUS_OK != result)
- {
- OIC_LOG_V(ERROR, CALEADAPTER_TAG,
- "CAGenerateHeader failed, result [%d]", result);
- g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
- return;
- }
-
- for (index = 0; index < iter; index++)
- {
- result = CAMakeRemainDataSegment(dataSegment,
- bleData->data,
- CA_SUPPORTED_BLE_MTU_SIZE - CA_BLE_HEADER_SIZE,
- index,
- dataHeader);
-
- if (CA_STATUS_OK != result)
- {
- OIC_LOG_V(ERROR, CALEADAPTER_TAG,
- "Making data segment failed, result [%d]", result);
- g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
- return;
- }
-
- // Send the remaining header.
- result = CAUpdateCharacteristicsToGattServer(
- bleData->remoteEndpoint->addr,
- dataSegment,
- CA_SUPPORTED_BLE_MTU_SIZE,
- LE_UNICAST, 0);
-
- if (CA_STATUS_OK != result)
- {
- OIC_LOG_V(ERROR,
- CALEADAPTER_TAG,
- "Update characteristics failed, result [%d]",
- result);
- g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
- return;
- }
- OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Client Sent Data length is [%d]",
- CA_SUPPORTED_BLE_MTU_SIZE);
- }
-
- if (remainingLen && (totalLength > CA_SUPPORTED_BLE_MTU_SIZE))
- {
- // send the last segment of the data (Ex: 22 bytes of 622
- // bytes of data when MTU is 200)
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "Sending the last chunk");
-
- result = CAMakeRemainDataSegment(dataSegment,
- bleData->data,
- remainingLen,
- index,
- dataHeader);
-
- if (CA_STATUS_OK != result)
- {
- OIC_LOG_V(ERROR, CALEADAPTER_TAG,
- "Making data segment failed, result [%d]", result);
- g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
- return;
- }
-
- result = CAUpdateCharacteristicsToGattServer(
- bleData->remoteEndpoint->addr,
- dataSegment,
- remainingLen + CA_BLE_HEADER_SIZE,
- LE_UNICAST, 0);
-
- if (CA_STATUS_OK != result)
- {
- OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]",
- result);
- g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
- return;
- }
- OIC_LOG_V(DEBUG, CALEADAPTER_TAG,
- "Client Sent Data length is [%d]", remainingLen + CA_BLE_HEADER_SIZE);
- }
- }
- else
- {
- //Sending Mulitcast Data
- // Send the first segment with the header.
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "Sending Multicast Data");
- result = CAUpdateCharacteristicsToAllGattServers(dataSegment, length);