mirror of https://github.com/f1xpl/openauto.git
Change service registration data
parent
2c84f2afc5
commit
68bf0e3990
|
@ -27,13 +27,19 @@ namespace btservice
|
||||||
|
|
||||||
AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
|
AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
|
||||||
{
|
{
|
||||||
|
//"4de17a00-52cb-11e6-bdf4-0800200c9a66";
|
||||||
|
//"669a0c20-0008-f4bd-e611-cb52007ae14d";
|
||||||
|
const QBluetoothUuid serviceUuid(QLatin1String("4de17a00-52cb-11e6-bdf4-0800200c9a66"));
|
||||||
|
|
||||||
|
QBluetoothServiceInfo::Sequence classId;
|
||||||
|
classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
|
||||||
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, classId);
|
||||||
|
classId.prepend(QVariant::fromValue(serviceUuid));
|
||||||
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceName, "OpenAuto Bluetooth Service");
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceName, "OpenAuto Bluetooth Service");
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceDescription, "AndroidAuto WiFi projection automatic setup");
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceDescription, "AndroidAuto WiFi projection automatic setup");
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "f1xstudio.com");
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "f1xstudio.com");
|
||||||
|
serviceInfo_.setServiceUuid(serviceUuid);
|
||||||
//"4de17a00-52cb-11e6-bdf4-0800200c9a66";
|
|
||||||
//"669a0c20-0008-f4bd-e611-cb52007ae14d";
|
|
||||||
serviceInfo_.setServiceUuid(QBluetoothUuid(QString("4de17a00-52cb-11e6-bdf4-0800200c9a66")));
|
|
||||||
|
|
||||||
QBluetoothServiceInfo::Sequence publicBrowse;
|
QBluetoothServiceInfo::Sequence publicBrowse;
|
||||||
publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
|
publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
|
||||||
|
@ -41,9 +47,11 @@ AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
|
||||||
|
|
||||||
QBluetoothServiceInfo::Sequence protocolDescriptorList;
|
QBluetoothServiceInfo::Sequence protocolDescriptorList;
|
||||||
QBluetoothServiceInfo::Sequence protocol;
|
QBluetoothServiceInfo::Sequence protocol;
|
||||||
|
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
|
||||||
|
protocolDescriptorList.append(QVariant::fromValue(protocol));
|
||||||
|
protocol.clear();
|
||||||
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
|
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
|
||||||
<< QVariant::fromValue(portNumber);
|
<< QVariant::fromValue(quint16(portNumber));
|
||||||
protocolDescriptorList.append(QVariant::fromValue(protocol));
|
protocolDescriptorList.append(QVariant::fromValue(protocol));
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,18 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
const QBluetoothAddress address;
|
const QBluetoothAddress address;
|
||||||
const uint16_t portNumber = 5000;
|
const uint16_t portNumber = 5000;
|
||||||
btservice::AndroidBluetoothService androidBluetoothService(portNumber);
|
|
||||||
|
|
||||||
|
btservice::AndroidBluetoothServer androidBluetoothServer;
|
||||||
|
if(!androidBluetoothServer.start(address, portNumber))
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[btservice] Server start failed.";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[btservice] Listening for connections, address: " << address.toString().toStdString()
|
||||||
|
<< ", port: " << portNumber;
|
||||||
|
|
||||||
|
btservice::AndroidBluetoothService androidBluetoothService(portNumber);
|
||||||
if(!androidBluetoothService.registerService(address))
|
if(!androidBluetoothService.registerService(address))
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[btservice] Service registration failed.";
|
OPENAUTO_LOG(error) << "[btservice] Service registration failed.";
|
||||||
|
@ -41,17 +51,6 @@ int main(int argc, char* argv[])
|
||||||
OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << portNumber;
|
OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << portNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
btservice::AndroidBluetoothServer androidBluetoothServer;
|
|
||||||
|
|
||||||
if(!androidBluetoothServer.start(address, portNumber))
|
|
||||||
{
|
|
||||||
OPENAUTO_LOG(error) << "[btservice] Server start failed.";
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
OPENAUTO_LOG(info) << "[btservice] Listening for connections, address: " << address.toString().toStdString()
|
|
||||||
<< ", port: " << portNumber;
|
|
||||||
|
|
||||||
qApplication.exec();
|
qApplication.exec();
|
||||||
androidBluetoothService.unregisterService();
|
androidBluetoothService.unregisterService();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue