projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 0.9.2
[platform/upstream/iotivity.git]
/
resource
/
csdk
/
connectivity
/
src
/
bt_edr_adapter
/
android
/
caedrclient.c
diff --git
a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c
b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c
index
0065fbe
..
0a58c91
100644
(file)
--- a/
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c
+++ b/
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c
@@
-27,10
+27,12
@@
#include "caedrclient.h"
#include "logger.h"
#include "oic_malloc.h"
#include "caedrclient.h"
#include "logger.h"
#include "oic_malloc.h"
+#include "oic_string.h"
#include "cathreadpool.h" /* for thread pool */
#include "camutex.h"
#include "uarraylist.h"
#include "caadapterutils.h"
#include "cathreadpool.h" /* for thread pool */
#include "camutex.h"
#include "uarraylist.h"
#include "caadapterutils.h"
+#include "caremotehandler.h"
//#define DEBUG_MODE
#define TAG PCF("CA_EDR_CLIENT")
//#define DEBUG_MODE
#define TAG PCF("CA_EDR_CLIENT")
@@
-43,7
+45,7
@@
static const char METHODID_BT_DEVICEPARAM[] =
"(Ljava/lang/String;)Landroid/bluetooth/BluetoothDevice;";
static const char CLASSPATH_BT_ADPATER[] = "android/bluetooth/BluetoothAdapter";
static const char CLASSPATH_BT_DEVICE[] = "android/bluetooth/BluetoothDevice";
"(Ljava/lang/String;)Landroid/bluetooth/BluetoothDevice;";
static const char CLASSPATH_BT_ADPATER[] = "android/bluetooth/BluetoothAdapter";
static const char CLASSPATH_BT_DEVICE[] = "android/bluetooth/BluetoothDevice";
-static const char CLASSPATH_BT_INTERFACE[] = "org/iotivity/
jar/caedri
nterface";
+static const char CLASSPATH_BT_INTERFACE[] = "org/iotivity/
ca/CaEdrI
nterface";
static const char CLASSPATH_BT_SOCKET[] = "android/bluetooth/BluetoothSocket";
static const char CLASSPATH_BT_UUID[] = "java/util/UUID";
static const char CLASSPATH_CONTEXT[] = "android/content/Context";
static const char CLASSPATH_BT_SOCKET[] = "android/bluetooth/BluetoothSocket";
static const char CLASSPATH_BT_UUID[] = "java/util/UUID";
static const char CLASSPATH_CONTEXT[] = "android/content/Context";
@@
-96,6
+98,12
@@
static ca_mutex g_mutexStateList = NULL;
*/
static ca_mutex g_mutexObjectList = NULL;
*/
static ca_mutex g_mutexObjectList = NULL;
+/**
+ * @var g_edrErrorHandler
+ * @brief Error callback to update error in EDR
+ */
+static CAEDRErrorHandleCallback g_edrErrorHandler = NULL;
+
typedef struct send_data
{
char* address;
typedef struct send_data
{
char* address;
@@
-120,13
+128,13
@@
typedef struct
/**
* implement for BT-EDR adapter common method
*/
/**
* implement for BT-EDR adapter common method
*/
-CAResult_t CAEDRGetInterfaceInformation(CA
LocalConnectivity
_t **info)
+CAResult_t CAEDRGetInterfaceInformation(CA
Endpoint
_t **info)
{
OIC_LOG(DEBUG, TAG, "IN - CAEDRGetInterfaceInformation");
if (!info)
{
{
OIC_LOG(DEBUG, TAG, "IN - CAEDRGetInterfaceInformation");
if (!info)
{
- OIC_LOG(ERROR, TAG, "
LocalConnectivity
info is null");
+ OIC_LOG(ERROR, TAG, "
endpoint
info is null");
return CA_STATUS_FAILED;
}
return CA_STATUS_FAILED;
}
@@
-150,7
+158,8
@@
CAResult_t CAEDRGetInterfaceInformation(CALocalConnectivity_t **info)
}
// Create local endpoint using util function
}
// Create local endpoint using util function
- CALocalConnectivity_t *endpoint = CAAdapterCreateLocalEndpoint(CA_EDR, macAddress);
+ CAEndpoint_t *endpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS, CA_ADAPTER_RFCOMM_BTEDR,
+ macAddress, 0);
if (NULL == endpoint)
{
OIC_LOG(ERROR, TAG, "Failed to create Local Endpoint!");
if (NULL == endpoint)
{
OIC_LOG(ERROR, TAG, "Failed to create Local Endpoint!");
@@
-159,21
+168,19
@@
CAResult_t CAEDRGetInterfaceInformation(CALocalConnectivity_t **info)
}
// copy unicast server information
}
// copy unicast server information
- endpoint->isSecured = false;
- CALocalConnectivity_t *netInfo = (CALocalConnectivity_t *) OICMalloc(
- sizeof(CALocalConnectivity_t) * netInfoSize);
+ CAEndpoint_t *netInfo = (CAEndpoint_t *)OICMalloc(sizeof(CAEndpoint_t) * netInfoSize);
if (NULL == netInfo)
{
OIC_LOG(ERROR, TAG, "Invalid input..");
OICFree(macAddress);
if (NULL == netInfo)
{
OIC_LOG(ERROR, TAG, "Invalid input..");
OICFree(macAddress);
- CA
AdapterFreeLocal
Endpoint(endpoint);
+ CA
Free
Endpoint(endpoint);
return CA_MEMORY_ALLOC_FAILED;
}
return CA_MEMORY_ALLOC_FAILED;
}
-
memcpy(netInfo, endpoint, sizeof(CALocalConnectivity_t))
;
+
*netInfo = *endpoint
;
*info = netInfo;
OICFree(macAddress);
*info = netInfo;
OICFree(macAddress);
- CA
AdapterFreeLocal
Endpoint(endpoint);
+ CA
Free
Endpoint(endpoint);
OIC_LOG(DEBUG, TAG, "OUT - CAEDRGetInterfaceInformation");
return CA_STATUS_OK;
OIC_LOG(DEBUG, TAG, "OUT - CAEDRGetInterfaceInformation");
return CA_STATUS_OK;
@@
-198,18
+205,18
@@
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *ser
const void *data, uint32_t dataLength, uint32_t *sentLength)
{
OIC_LOG(DEBUG, TAG, "IN");
const void *data, uint32_t dataLength, uint32_t *sentLength)
{
OIC_LOG(DEBUG, TAG, "IN");
- CAEDRSendUnicastMessage(remoteAddress, (const char*) data, dataLength);
+ CA
Result_t result = CA
EDRSendUnicastMessage(remoteAddress, (const char*) data, dataLength);
OIC_LOG(DEBUG, TAG, "OUT");
OIC_LOG(DEBUG, TAG, "OUT");
- return
CA_STATUS_OK
;
+ return
result
;
}
CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, const void *data,
uint32_t dataLength, uint32_t *sentLength)
{
OIC_LOG(DEBUG, TAG, "IN");
}
CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, const void *data,
uint32_t dataLength, uint32_t *sentLength)
{
OIC_LOG(DEBUG, TAG, "IN");
- CAEDRSendMulticastMessage((const char*) data, dataLength);
+ CA
Result_t result = CA
EDRSendMulticastMessage((const char*) data, dataLength);
OIC_LOG(DEBUG, TAG, "OUT");
OIC_LOG(DEBUG, TAG, "OUT");
- return
CA_STATUS_OK
;
+ return
result
;
}
// It will be updated when android EDR support is added
}
// It will be updated when android EDR support is added
@@
-309,7
+316,7
@@
CAResult_t CAEDRCreateJNIInterfaceObject(jobject context)
jclass EDRJniInterface = (*env)->FindClass(env, CLASSPATH_BT_INTERFACE);
if (!EDRJniInterface)
{
jclass EDRJniInterface = (*env)->FindClass(env, CLASSPATH_BT_INTERFACE);
if (!EDRJniInterface)
{
- OIC_LOG(ERROR, TAG, "[EDRCore] Could not get
caedri
nterface class");
+ OIC_LOG(ERROR, TAG, "[EDRCore] Could not get
CaEdrI
nterface class");
return CA_STATUS_FAILED;
}
return CA_STATUS_FAILED;
}
@@
-317,7
+324,7
@@
CAResult_t CAEDRCreateJNIInterfaceObject(jobject context)
"(Landroid/content/Context;)V");
if (!EDRInterfaceConstructorMethod)
{
"(Landroid/content/Context;)V");
if (!EDRInterfaceConstructorMethod)
{
- OIC_LOG(ERROR, TAG, "[EDRCore] Could not get
caedri
nterface constructor method");
+ OIC_LOG(ERROR, TAG, "[EDRCore] Could not get
CaEdrI
nterface constructor method");
return CA_STATUS_FAILED;
}
return CA_STATUS_FAILED;
}
@@
-451,7
+458,7
@@
void CAEDRInitialize(ca_thread_pool_t handle)
if (g_context)
{
if (g_context)
{
- CAEDRCreateJNIInterfaceObject(g_context); /* create java
caedri
nterface instance*/
+ CAEDRCreateJNIInterfaceObject(g_context); /* create java
CaEdrI
nterface instance*/
}
OIC_LOG(DEBUG, TAG, "OUT");
}
OIC_LOG(DEBUG, TAG, "OUT");
@@
-510,8
+517,8
@@
CAResult_t CAEDRSendUnicastMessage(const char* address, const char* data, uint32
{
OIC_LOG_V(DEBUG, TAG, "CAEDRSendUnicastMessage(%s, %s)", address, data);
{
OIC_LOG_V(DEBUG, TAG, "CAEDRSendUnicastMessage(%s, %s)", address, data);
- CAEDRSendUnicastMessageImpl(address, data, dataLen);
- return
CA_STATUS_OK
;
+ CA
Result_t result = CA
EDRSendUnicastMessageImpl(address, data, dataLen);
+ return
result
;
}
CAResult_t CAEDRSendMulticastMessage(const char* data, uint32_t dataLen)
}
CAResult_t CAEDRSendMulticastMessage(const char* data, uint32_t dataLen)
@@
-534,7
+541,12
@@
CAResult_t CAEDRSendMulticastMessage(const char* data, uint32_t dataLen)
isAttached = true;
}
isAttached = true;
}
- CAEDRSendMulticastMessageImpl(env, data, dataLen);
+ CAResult_t result = CAEDRSendMulticastMessageImpl(env, data, dataLen);
+ if(CA_STATUS_OK != result)
+ {
+ OIC_LOG(ERROR, TAG, "CAEDRSendMulticastMessage - could not send multicast message");
+ return result;
+ }
OIC_LOG(DEBUG, TAG, "sent data");
OIC_LOG(DEBUG, TAG, "sent data");
@@
-575,7
+587,7
@@
void CAEDRGetLocalAddress(char **address)
if (jni_address)
{
const char* localAddress = (*env)->GetStringUTFChars(env, jni_address, NULL);
if (jni_address)
{
const char* localAddress = (*env)->GetStringUTFChars(env, jni_address, NULL);
- *address =
(char*) OICMalloc(strlen(localAddress) + 1
);
+ *address =
OICStrdup(localAddress
);
if (*address == NULL)
{
if (isAttached)
if (*address == NULL)
{
if (isAttached)
@@
-584,7
+596,7
@@
void CAEDRGetLocalAddress(char **address)
}
return;
}
}
return;
}
- memcpy(*address, localAddress, strlen(localAddress));
+
(*env)->ReleaseStringUTFChars(env, jni_address, localAddress);
}
(*env)->ReleaseStringUTFChars(env, jni_address, localAddress);
}
@@
-738,7
+750,10
@@
CAResult_t CAEDRSendMulticastMessageImpl(JNIEnv *env, const char* data, uint32_t
(*env)->ReleaseStringUTFChars(env, j_str_address, remoteAddress);
if (CA_STATUS_OK != res)
{
(*env)->ReleaseStringUTFChars(env, j_str_address, remoteAddress);
if (CA_STATUS_OK != res)
{
- return res;
+ OIC_LOG_V(ERROR, TAG, "CASendMulticastMessageImpl, failed to send message to : %s",
+ remoteAddress);
+ g_edrErrorHandler(remoteAddress, OIC_EDR_SERVICE_ID, data, dataLen, res);
+ continue;
}
}
}
}
@@
-1073,3
+1088,8
@@
void CAEDRInitializeClient(ca_thread_pool_t handle)
CAEDRInitialize(handle);
OIC_LOG(DEBUG, TAG, "OUT");
}
CAEDRInitialize(handle);
OIC_LOG(DEBUG, TAG, "OUT");
}
+
+void CAEDRSetErrorHandler(CAEDRErrorHandleCallback errorHandleCallback)
+{
+ g_edrErrorHandler = errorHandleCallback;
+}