summaryrefslogtreecommitdiff
path: root/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc')
-rw-r--r--src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc
index d6f9f26317..5f1eed4c5e 100644
--- a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc
+++ b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc
@@ -51,13 +51,12 @@ namespace transport_adapter {
CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
BluetoothSocketConnection::BluetoothSocketConnection(
- const DeviceUID& device_uid, const ApplicationHandle& app_handle,
- TransportAdapterController* controller)
- : ThreadedSocketConnection(device_uid, app_handle, controller) {
-}
+ const DeviceUID& device_uid,
+ const ApplicationHandle& app_handle,
+ TransportAdapterController* controller)
+ : ThreadedSocketConnection(device_uid, app_handle, controller) {}
-BluetoothSocketConnection::~BluetoothSocketConnection() {
-}
+BluetoothSocketConnection::~BluetoothSocketConnection() {}
bool BluetoothSocketConnection::Establish(ConnectError** error) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -65,21 +64,22 @@ bool BluetoothSocketConnection::Establish(ConnectError** error) {
DeviceSptr device = controller()->FindDevice(device_handle());
BluetoothDevice* bluetooth_device =
- static_cast<BluetoothDevice*>(device.get());
+ static_cast<BluetoothDevice*>(device.get());
uint8_t rfcomm_channel;
if (!bluetooth_device->GetRfcommChannel(application_handle(),
&rfcomm_channel)) {
LOG4CXX_DEBUG(logger_,
- "Application " << application_handle() << " not found");
+ "Application " << application_handle() << " not found");
*error = new ConnectError();
LOG4CXX_TRACE(logger_, "exit with FALSE");
return false;
}
- struct sockaddr_rc remoteSocketAddress = { 0 };
+ struct sockaddr_rc remoteSocketAddress = {0};
remoteSocketAddress.rc_family = AF_BLUETOOTH;
- memcpy(&remoteSocketAddress.rc_bdaddr, &bluetooth_device->address(),
+ memcpy(&remoteSocketAddress.rc_bdaddr,
+ &bluetooth_device->address(),
sizeof(bdaddr_t));
remoteSocketAddress.rc_channel = rfcomm_channel;
@@ -92,13 +92,14 @@ bool BluetoothSocketConnection::Establish(ConnectError** error) {
rfcomm_socket = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
if (-1 == rfcomm_socket) {
LOG4CXX_ERROR_WITH_ERRNO(logger_,
- "Failed to create RFCOMM socket for device " << device_handle());
+ "Failed to create RFCOMM socket for device "
+ << device_handle());
*error = new ConnectError();
LOG4CXX_TRACE(logger_, "exit with FALSE");
return false;
}
connect_status = ::connect(rfcomm_socket,
- (struct sockaddr*) &remoteSocketAddress,
+ (struct sockaddr*)&remoteSocketAddress,
sizeof(remoteSocketAddress));
if (0 == connect_status) {
LOG4CXX_DEBUG(logger_, "rfcomm Connect ok");
@@ -116,9 +117,11 @@ bool BluetoothSocketConnection::Establish(ConnectError** error) {
} while (--attempts > 0);
LOG4CXX_INFO(logger_, "rfcomm Connect attempts finished");
if (0 != connect_status) {
- LOG4CXX_DEBUG(logger_,
- "Failed to Connect to remote device " << BluetoothDevice::GetUniqueDeviceId(
- remoteSocketAddress.rc_bdaddr) << " for session " << this);
+ LOG4CXX_DEBUG(
+ logger_,
+ "Failed to Connect to remote device "
+ << BluetoothDevice::GetUniqueDeviceId(remoteSocketAddress.rc_bdaddr)
+ << " for session " << this);
*error = new ConnectError();
LOG4CXX_TRACE(logger_, "exit with FALSE");
return false;