/**
* 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
/**
* 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.
* @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.
/**
* 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
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;
{
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;
}
}
{
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;
/**
* 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);
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;
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
*/
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
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,
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();
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);
}
const char *remoteAddress = NULL;
- const char *serviceUUID = OIC_EDR_SERVICE_ID;
if (NULL == message->remoteEndpoint)
{
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;
// 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 !");
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)
{
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
}
-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");
// 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)
// 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!");
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)
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,
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);
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");
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_NOT_SUPPORTED;
}
-
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.
* @param[in] data data for transmission.