openauto/btservice/btservice.cpp
Cole Brinsfield 50e077aa6e
automatic wireless device connection (#12)
* fix for omx when performing GST build

* wireless android auto bluetooth negotation

* Grab local bluetooth adapter

* Handling ping and voice session

* wait for both usb and wifi device ]connections

* Make btservice launch with openauto, allows for wireless connection automatically

* WiFi hotspot info pulled from openauto config

* Install btservice correctly

Co-authored-by: Rhys_M <rhys1802@hotmail.co.uk>
Co-authored-by: Robert Judka <robertjudka@gmail.com>
2020-08-26 19:48:36 -05:00

36 lines
1.1 KiB
C++

#include "btservice/btservice.hpp"
namespace openauto{
namespace btservice{
btservice::btservice(openauto::configuration::IConfiguration::Pointer config) : androidBluetoothService(servicePortNumber), androidBluetoothServer(config){
QBluetoothAddress address;
auto adapters = QBluetoothLocalDevice::allDevices();
if (adapters.size() > 0)
address =adapters.at(0).address();
else{
OPENAUTO_LOG(error) << "[btservice] No adapter found";
}
if(!androidBluetoothServer.start(address, servicePortNumber))
{
OPENAUTO_LOG(error) << "[btservice] Server start failed.";
return;
}
OPENAUTO_LOG(info) << "[btservice] Listening for connections, address: " << address.toString().toStdString()
<< ", port: " << servicePortNumber;
if(!androidBluetoothService.registerService(address))
{
OPENAUTO_LOG(error) << "[btservice] Service registration failed.";
}
else
{
OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << servicePortNumber;
}
}
}
}