Commit 4e671c7d authored by jihwan.seo's avatar jihwan.seo Committed by Jon A. Cruz

removed warning for Android EDR

- there was a few warning message in EDR
- also removed unused method in BLE

Change-Id: Ie9f181f8771d01696d47f9e876baac4a3a538773
Signed-off-by: default avatarjihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2111Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarJon A. Cruz <jonc@osg.samsung.com>
parent 5f41e787
......@@ -100,14 +100,13 @@ typedef void (*CAEDRNetworkStatusCallback)(CANetworkStatus_t status);
/**
* Callback to notify the error in the EDR adapter.
* @param[in] remoteAddress Remote EDR Address.
* @param[in] serviceUUID Service UUID of the device.
* @param[in] data data containing token, uri and coap data.
* @param[in] dataLength length of data.
* @param[in] result error code as defined in ::CAResult_t.
* @pre Callback must be registered using CAEDRSetPacketReceivedCallback().
*/
typedef void (*CAEDRErrorHandleCallback)(const char *remoteAddress, const char *serviceUUID,
const void *data, uint32_t dataLength, CAResult_t result);
typedef void (*CAEDRErrorHandleCallback)(const char *remoteAddress, const void *data,
uint32_t dataLength, CAResult_t result);
/**
* Initialize the network monitor module
......@@ -216,9 +215,6 @@ CAResult_t CAEDRGetInterfaceInformation(CAEndpoint_t **info);
/**
* Start RFCOMM server for given service UUID
*
* @param[in] serviceUUID The UUID of service with which RFCOMM server
* needs to be started.
* @param[in] serverFD The RFCOMM server socket file descriptor.
* @param[in] handle Threadpool Handle.
*
* @return ::CA_STATUS_OK or Appropriate error code.
......@@ -227,19 +223,16 @@ CAResult_t CAEDRGetInterfaceInformation(CAEndpoint_t **info);
* @retval ::CA_STATUS_FAILED Operation failed.
*
*/
CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_pool_t handle);
CAResult_t CAEDRServerStart(ca_thread_pool_t handle);
/**
* Stop RFCOMM server
*
* @param[in] serverFD The RFCOMM server socket file descriptor which
* needs to be stopped.
*
* @return ::CA_STATUS_OK or Appropriate error code.
* @retval ::CA_STATUS_OK Successful.
* @retval ::CA_STATUS_FAILED Operation failed.
*/
CAResult_t CAEDRServerStop(int serverFD);
CAResult_t CAEDRServerStop();
/**
* Terminate server for EDR.
......@@ -266,23 +259,20 @@ CAResult_t CAEDRGetAdapterEnableState(bool *state);
/**
* This function sends data to specified remote bluetooth device.
* @param[in] remoteAddress Remote EDR Address.
* @param[in] serviceUUID Service UUID of the device.
* @param[in] data Data to be sent.
* @param[in] dataLength Length of the data to be sent.
* @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *serviceUUID,
const void *data, uint32_t dataLength);
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const void *data,
uint32_t dataLength);
/**
* This function sends data to all bluetooth devices running OIC service.
* @param[in] serviceUUID Service UUID of the device.
* @param[in] data Data to be sent.
* @param[in] dataLength Length of the data to be sent.
* @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, const void *data,
uint32_t dataLength);
CAResult_t CAEDRClientSendMulticastData(const void *data, uint32_t dataLength);
/**
* This function gets bonded bluetooth device list
......
......@@ -201,19 +201,20 @@ CAResult_t CAEDRManagerReadData(void)
return CA_NOT_SUPPORTED;
}
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *serviceUUID,
const void *data, uint32_t dataLength)
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const void *data,
uint32_t dataLength)
{
OIC_LOG(DEBUG, TAG, "IN");
CAResult_t result = CAEDRSendUnicastMessage(remoteAddress, (const char*) data, dataLength);
OIC_LOG(DEBUG, TAG, "OUT");
return result;
}
CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, const void *data,
uint32_t dataLength)
CAResult_t CAEDRClientSendMulticastData(const void *data, uint32_t dataLength)
{
OIC_LOG(DEBUG, TAG, "IN");
CAResult_t result = CAEDRSendMulticastMessage((const char*) data, dataLength);
OIC_LOG(DEBUG, TAG, "OUT");
return result;
......@@ -752,7 +753,7 @@ CAResult_t CAEDRSendMulticastMessageImpl(JNIEnv *env, const char* data, uint32_t
{
OIC_LOG_V(ERROR, TAG, "CASendMulticastMessageImpl, failed to send message to : %s",
remoteAddress);
g_edrErrorHandler(remoteAddress, OIC_EDR_SERVICE_ID, data, dataLen, res);
g_edrErrorHandler(remoteAddress, data, dataLen, res);
continue;
}
}
......
......@@ -61,8 +61,15 @@ CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, TAG, "IN");
CAEDRNetworkMonitorJniInit();
CANativeJNIGetJavaVM();
if (!threadPool)
{
return CA_STATUS_FAILED;
}
else
{
CAEDRNetworkMonitorJniInit();
CANativeJNIGetJavaVM();
}
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
......
......@@ -288,7 +288,7 @@ static void CAAcceptHandler(void *data)
/**
* implement for adapter common method.
*/
CAResult_t CAEDRServerStart(const char *serviceUUID, int32_t *serverFD, ca_thread_pool_t handle)
CAResult_t CAEDRServerStart(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IN");
CAEDRServerInitialize(handle);
......@@ -299,16 +299,15 @@ CAResult_t CAEDRServerStart(const char *serviceUUID, int32_t *serverFD, ca_threa
return CA_STATUS_FAILED;
}
*serverFD = 1;
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAEDRServerStop(int serverFD)
CAResult_t CAEDRServerStop()
{
OIC_LOG(DEBUG, TAG, "IN");
CAEDRStopUnicastServer(-1);
CAEDRStopMulticastServer(-1);
CAEDRStopUnicastServer();
CAEDRStopMulticastServer();
ca_mutex_lock(g_mutexAcceptServer);
g_stopAccept = true;
......
......@@ -88,12 +88,6 @@ static CAErrorHandleCallback g_errorCallback = NULL;
*/
static CAEndpoint_t *g_localConnectivity = NULL;
/**
* @var g_serverId
* @brief Storing RfcommserverUUID
*/
static int g_serverId = -1;
/**
* @var g_serverState
* @brief Storing Rfcommserver state information
......@@ -116,8 +110,8 @@ CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID,
uint32_t dataLength, uint32_t *sentLength);
CAEDRNetworkEvent *CAEDRCreateNetworkEvent(CAEndpoint_t *connectivity,
CANetworkStatus_t status);
CAResult_t CAEDRClientSendData(const char *remoteAddress, const char *serviceUUID,
const void *data, uint32_t dataLength);
CAResult_t CAEDRClientSendData(const char *remoteAddress, const void *data,
uint32_t dataLength);
/**
* @fn CACreateEDRData
* @brief Helper function to create CAEDRData
......@@ -139,7 +133,7 @@ void CAEDRFreeNetworkEvent(CAEDRNetworkEvent *event);
static void CAEDRDataDestroyer(void *data, uint32_t size);
static void CAEDRErrorHandler(const char *remoteAddress, const char *serviceUUID, const void *data,
static void CAEDRErrorHandler(const char *remoteAddress, const void *data,
uint32_t dataLength, CAResult_t result);
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
......@@ -351,11 +345,7 @@ CAResult_t CAStopEDR()
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
// Stop RFComm server if it is running
if (-1 != g_serverId)
{
CAEDRServerStop(g_serverId);
g_serverId = -1;
}
CAEDRServerStop();
// Stop network monitor
CAEDRStopNetworkMonitor();
......@@ -418,13 +408,7 @@ CAResult_t CAStartServer()
return CA_STATUS_OK;
}
if (-1 < g_serverId)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Server is already in running state.");
return CA_SERVER_STARTED_ALREADY;
}
if (CA_STATUS_OK != (err = CAEDRServerStart(OIC_EDR_SERVICE_ID, &g_serverId, g_edrThreadPool)))
if (CA_STATUS_OK != (err = CAEDRServerStart(g_edrThreadPool)))
{
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to start RFCOMM server!, error num [%d]",
err);
......@@ -535,7 +519,6 @@ void CAAdapterDataSendHandler(void *context)
}
const char *remoteAddress = NULL;
const char *serviceUUID = OIC_EDR_SERVICE_ID;
if (NULL == message->remoteEndpoint)
{
......@@ -547,27 +530,27 @@ void CAAdapterDataSendHandler(void *context)
remoteAddress = message->remoteEndpoint->addr;
}
if(!remoteAddress || !serviceUUID)
if(!remoteAddress)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDR Send Message error");
//Error cannot be sent if remote address is NULL
return;
}
CAResult_t result = CAEDRClientSendData(remoteAddress, serviceUUID, message->data,
CAResult_t result = CAEDRClientSendData(remoteAddress, message->data,
message->dataLen);
if(CA_STATUS_OK != result)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAEDRClientSendData API failed");
CAEDRErrorHandler(remoteAddress, serviceUUID, message->data, message->dataLen, result);
CAEDRErrorHandler(remoteAddress, message->data, message->dataLen, result);
return;
}
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
CAResult_t CAEDRClientSendData(const char *remoteAddress, const char *serviceUUID,
const void *data, uint32_t dataLength)
CAResult_t CAEDRClientSendData(const char *remoteAddress, const void *data,
uint32_t dataLength)
{
CAResult_t result = CA_SEND_FAILED;
......@@ -575,8 +558,7 @@ CAResult_t CAEDRClientSendData(const char *remoteAddress, const char *serviceUUI
// Send the first segment with the header.
if ((NULL != remoteAddress) && (0 < strlen(remoteAddress))) //Unicast data
{
result = CAEDRClientSendUnicastData(remoteAddress, serviceUUID, data,
dataLength);
result = CAEDRClientSendUnicastData(remoteAddress, data, dataLength);
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send unicast data !");
......@@ -586,7 +568,7 @@ CAResult_t CAEDRClientSendData(const char *remoteAddress, const char *serviceUUI
else
{
OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "sending multicast data : %s", data);
result = CAEDRClientSendMulticastData(serviceUUID, data, dataLength);
result = CAEDRClientSendMulticastData(data, dataLength);
if (CA_STATUS_OK != result)
{
......@@ -696,10 +678,9 @@ void CAAdapterRecvData(const char *remoteAddress, const void *data, uint32_t dat
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
void CAEDRErrorHandler(const char *remoteAddress, const char *serviceUUID, const void *data,
void CAEDRErrorHandler(const char *remoteAddress, const void *data,
uint32_t dataLength, CAResult_t result)
{
(void)serviceUUID;
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
// Input validation
......
......@@ -583,8 +583,8 @@ void CAEDRClientDisconnectAll(void)
}
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *serviceUUID,
const void *data, uint32_t dataLength)
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const void *data,
uint32_t dataLength)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
......@@ -592,7 +592,6 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *ser
// Input validation
VERIFY_NON_NULL(remoteAddress, EDR_ADAPTER_TAG, "Remote address is null");
VERIFY_NON_NULL(serviceUUID, EDR_ADAPTER_TAG, "service UUID is null");
VERIFY_NON_NULL(data, EDR_ADAPTER_TAG, "Data is null");
if (0 >= dataLength)
......@@ -659,7 +658,7 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *ser
// Make a rfcomm connection with remote BT Device
if (device->serviceSearched &&
CA_STATUS_OK != CAEDRClientConnect(remoteAddress, serviceUUID))
CA_STATUS_OK != CAEDRClientConnect(remoteAddress, OIC_EDR_SERVICE_ID))
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to make RFCOMM connection!");
......@@ -682,13 +681,11 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *ser
return CA_STATUS_OK;
}
CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, const void *data,
uint32_t dataLength)
CAResult_t CAEDRClientSendMulticastData(const void *data, uint32_t dataLength)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
// Input validation
VERIFY_NON_NULL(serviceUUID, EDR_ADAPTER_TAG, "service UUID is null");
VERIFY_NON_NULL(data, EDR_ADAPTER_TAG, "Data is null");
if (0 >= dataLength)
......
......@@ -37,21 +37,17 @@
static int32_t g_maxPendingConnections = 10;
CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_pool_t handle)
/**
* Storing RfcommserverUUID
*/
static int g_serverFD = -1;
CAResult_t CAEDRServerStart(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
VERIFY_NON_NULL(serviceUUID, EDR_ADAPTER_TAG, "Service UUID is null");
VERIFY_NON_NULL(serverFD, EDR_ADAPTER_TAG, "Server fd holder is null");
if (!serviceUUID[0])
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: Empty service uuid!");
return CA_STATUS_INVALID_PARAM;
}
bool isRunning = false;
bt_error_e err = bt_adapter_is_service_used(serviceUUID, &isRunning);
bt_error_e err = bt_adapter_is_service_used(OIC_EDR_SERVICE_ID, &isRunning);
if (BT_ERROR_NONE != err)
{
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG,
......@@ -67,7 +63,7 @@ CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_po
int socketFD = 0;
// Registers a rfcomm socket with a specific service_uuid.
err = bt_socket_create_rfcomm(serviceUUID, &socketFD);
err = bt_socket_create_rfcomm(OIC_EDR_SERVICE_ID, &socketFD);
if (BT_ERROR_NONE != err)
{
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to create rfcomm socket!, error num [%x]", err);
......@@ -84,21 +80,26 @@ CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_po
return CA_STATUS_FAILED;
}
*serverFD = socketFD;
g_serverFD = socketFD;
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAEDRServerStop(int serverFD)
CAResult_t CAEDRServerStop()
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
bt_error_e err = bt_socket_destroy_rfcomm(serverFD);
if (BT_ERROR_NONE != err)
if (-1 < g_serverFD)
{
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed close server socket!, error num [%x]", err);
return CA_STATUS_FAILED;
bt_error_e err = bt_socket_destroy_rfcomm(g_serverFD);
if (BT_ERROR_NONE != err)
{
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed close server socket!, error num [%x]", err);
return CA_STATUS_FAILED;
}
g_serverFD = -1;
}
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
......@@ -117,4 +118,3 @@ CAResult_t CAEDRManagerReadData(void)
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_NOT_SUPPORTED;
}
......@@ -145,13 +145,6 @@ void CALEClientStopMulticastServer();
*/
void CALEClientSetCallback(CAPacketReceiveCallback callback);
/**
* get local address (implement).
* @param[out] address local address.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CALEClientGetLocalAddress(char** address);
/**
* send data for unicast (implement).
* @param[in] address remote address.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment