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);
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
/*
#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)