#if defined(__TIZEN__) || defined(__ANDROID__)
// get MTU size
- OIC_LOG_V(INFO, CALEADAPTER_TAG, "Get MTU size using API");
-
-
g_mtuSize = CALEServerGetMtuSize(bleData->remoteEndpoint->addr);
#endif
OIC_LOG_V(INFO, CALEADAPTER_TAG, "MTU size [%d]", g_mtuSize);
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Server Sent Unicast First Data - data length [%zu]",
+ "Server Sent Unicast First Data - data length [%u]",
length);
result = CAGenerateHeader(dataHeader,
return;
}
}
+#endif
+#if defined(__TIZEN__) || defined(__ANDROID__)
g_mtuSize = CALEClientGetMtuSize(bleData->remoteEndpoint->addr);
#endif
OIC_LOG_V(INFO, CALEADAPTER_TAG, "MTU size [%d]", g_mtuSize);
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Client Sent Unicast First Data - data length [%zu]",
+ "Client Sent Unicast First Data - data length [%u]",
length);
result = CAGenerateHeader(dataHeader,
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Client Sent Unicast %d Data - data(mtu) length [%zu]",
+ "Client Sent Unicast %d Data - data(mtu) length [%hu]",
index + 1,
g_mtuSize);
}
static CAResult_t CALEAdapterGattServerStart()
{
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "%s", __func__);
+ CAResult_t result = CA_STATUS_FAILED;
if (caglobals.bleFlags & CA_LE_SERVER_DISABLE)
{
return CA_STATUS_OK;
}
- CAResult_t result = CAStartLEGattServer();
+#ifndef DISABLE_BLE_SERVER
+ OIC_LOG_V(INFO, CALEADAPTER_TAG, "Starting LE GATT Server");
+ result = CAStartLEGattServer();
+#endif
#ifndef SINGLE_THREAD
/*
VERIFY_NON_NULL(endpoint, CALEADAPTER_TAG, "endpoint is NULL");
VERIFY_NON_NULL(data, CALEADAPTER_TAG, "data is NULL");
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "IN %s", __func__);
- OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "encrypted datalen = %d", dataLen);
+ OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "encrypted datalen = %zd", dataLen);
CAResult_t result;
CADataType_t dataType = g_dataType;
VERIFY_NON_NULL(data, CALEADAPTER_TAG, "data is NULL");
OIC_LOG_V(DEBUG, CALEADAPTER_TAG,
- "Secure Data Receive - decrypted datalen = %d", dataLen);
+ "Secure Data Receive - decrypted datalen = %zd", dataLen);
if (dataLen <= 0)
{
#endif
#ifdef __WITH_DTLS__
+#if defined(__TIZEN__) && !defined(SINGLE_THREAD)
+ // CAcloseSslConnection returns CAResult_t instead of void*, but the size is the same and crash shouldn't occur
+ pthread_t ccThread;
+ pthread_attr_t attr;
+ int initAttrRes = -1;
+ int pthreadCreateRes = -1;
+ int detachStatusRes = -1;
+ int memoryAllocationRes = -1;
+
+ do
+ {
+ initAttrRes = pthread_attr_init(&attr);
+ if (initAttrRes != 0)
+ {
+ break;
+ }
+ CAEndpoint_t *localEndpointCpyPtr = OICMalloc(sizeof(CAEndpoint_t));
+
+ if(NULL == localEndpointCpyPtr)
+ {
+ memoryAllocationRes = -1;
+ break;
+ }
+ else
+ {
+ memoryAllocationRes = 0;
+ }
+
+ (*localEndpointCpyPtr) = localEndpoint;
+ // this piece of code is reached on the main thread
+ // CAcloseSslConnection might wait for too long (network + mutexes) and watchdog might kill it
+ // Asynchronous call protects this function from watchdog
+ pthreadCreateRes = pthread_create(&ccThread, &attr, (void *(*)(void*))&CAcloseSslConnectionFreeEndpoint, (void*)localEndpointCpyPtr);
+
+ if (pthreadCreateRes != 0)
+ {
+ break;
+ }
+ detachStatusRes = pthread_detach(ccThread);
+ }while (0);
+
+ // regardless of CAcloseSslConnection result, the function will continue and g_connectionCallback will be called
+ OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "CAcloseSslConnection pthread_init [%d], mem_alloc [%d] pthread_create [%d], pthread_detach [%d]",
+ initAttrRes, memoryAllocationRes, pthreadCreateRes, detachStatusRes);
+#else
CAcloseSslConnection(&localEndpoint);
#endif
+#endif
}
if (g_connectionCallback)
// Create bleData to add to queue
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Data received from LE Client layer [%zu]",
+ "Data received from LE Client layer [%u]",
dataLength);
CALEData_t * const bleData =