2018-03-17 23:30:04 +01:00
|
|
|
/*
|
|
|
|
* This file is part of openauto project.
|
|
|
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
|
|
|
*
|
|
|
|
* openauto is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
|
|
* openauto is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-03-18 00:04:21 +01:00
|
|
|
#include <QApplication>
|
2018-03-17 23:30:04 +01:00
|
|
|
#include <f1x/openauto/Common/Log.hpp>
|
|
|
|
#include <f1x/openauto/btservice/AndroidBluetoothService.hpp>
|
|
|
|
#include <f1x/openauto/btservice/AndroidBluetoothServer.hpp>
|
|
|
|
|
|
|
|
namespace btservice = f1x::openauto::btservice;
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
2018-03-17 21:47:10 +01:00
|
|
|
{
|
2018-03-18 00:04:21 +01:00
|
|
|
QApplication qApplication(argc, argv);
|
2018-03-17 23:30:04 +01:00
|
|
|
|
|
|
|
const QBluetoothAddress address;
|
|
|
|
const uint16_t portNumber = 5000;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-03-18 00:46:20 +01:00
|
|
|
btservice::AndroidBluetoothService androidBluetoothService(portNumber);
|
|
|
|
if(!androidBluetoothService.registerService(address))
|
|
|
|
{
|
|
|
|
OPENAUTO_LOG(error) << "[btservice] Service registration failed.";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << portNumber;
|
|
|
|
}
|
|
|
|
|
2018-03-17 23:30:04 +01:00
|
|
|
qApplication.exec();
|
|
|
|
androidBluetoothService.unregisterService();
|
|
|
|
|
2018-03-17 21:47:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|