openauto/include/btservice/AndroidBluetoothServer.hpp
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

61 lines
1.4 KiB
C++

#pragma once
#include <stdint.h>
#include <memory>
#include <sstream>
#include <QBluetoothServer>
#include <QBluetoothLocalDevice>
#include <QDataStream>
#include <btservice_proto/NetworkInfo.pb.h>
#include <btservice_proto/PhoneResponse.pb.h>
#include <btservice_proto/SocketInfo.pb.h>
#include "openauto/Configuration/Configuration.hpp"
#include "IAndroidBluetoothServer.hpp"
namespace openauto
{
namespace btservice
{
class AndroidBluetoothServer: public QObject, public IAndroidBluetoothServer
{
Q_OBJECT
public:
AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config_);
bool start(const QBluetoothAddress& address, uint16_t portNumber) override;
private slots:
void onClientConnected();
void readSocket();
private:
std::unique_ptr<QBluetoothServer> rfcommServer_;
QBluetoothSocket* socket;
void writeSocketInfoMessage();
void writeNetworkInfoMessage();
void stateMachine();
bool writeProtoMessage(uint16_t messageType, google::protobuf::Message &message);
enum CONNECTION_STATUS {
IDLE,
DEVICE_CONNECTED,
SENDING_SOCKETINFO_MESSAGE,
SENT_SOCKETINFO_MESSAGE,
PHONE_RESP_SOCKETINFO,
SENDING_NETWORKINFO_MESSAGE,
SENT_NETWORKINFO_MESSAGE,
PHONE_RESP_NETWORKINFO,
ERROR
};
CONNECTION_STATUS handshakeState = IDLE;
protected:
openauto::configuration::IConfiguration::Pointer config;
};
}
}