Skip to content

Commit

Permalink
Added wifi fixes @presslab-us
Browse files Browse the repository at this point in the history
added Bluetooth fixes @presslab-us
Added local GPS device support @presslab-us
  • Loading branch information
matt2005 committed Oct 10, 2020
1 parent fd3a00a commit d5e16bc
Show file tree
Hide file tree
Showing 28 changed files with 665 additions and 101 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ find_package(OpenSSL REQUIRED)
find_package(rtaudio REQUIRED)
find_package(taglib REQUIRED)
find_package(blkid REQUIRED)
find_package(gps REQUIRED)

if(WIN32)
set(WINSOCK2_LIBRARIES "ws2_32")
Expand Down Expand Up @@ -89,12 +90,13 @@ target_link_libraries(autoapp libusb
${RTAUDIO_LIBRARIES}
${TAGLIB_LIBRARIES}
${BLKID_LIBRARIES}
${GPS_LIBRARIES}
${AASDK_PROTO_LIBRARIES}
${AASDK_LIBRARIES})

set(btservice_sources_directory ${sources_directory}/btservice)
set(btservice_include_directory ${include_directory}/f1x/openauto/btservice)
file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${btservice_include_directory}/*.hpp ${common_include_directory}/*.hpp)
file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${btservice_include_directory}/*.hpp ${autoapp_sources_directory}/Configuration/*.cpp ${autoapp_includes_directory}/Configuration/*.hpp ${common_include_directory}/*.hpp)

add_executable(btservice ${btservice_source_files})

Expand Down
70 changes: 70 additions & 0 deletions cmake_modules/Findgps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# 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/>.
#

if (GPS_LIBRARIES AND GPS_INCLUDE_DIRS)
# in cache already
set(GPS_FOUND TRUE)
else (GPS_LIBRARIES AND GPS_INCLUDE_DIRS)
find_path(GPS_INCLUDE_DIR
NAMES
gps.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
gps
)

find_library(GPS_LIBRARY
NAMES
gps
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)

set(GPS_INCLUDE_DIRS
${GPS_INCLUDE_DIR}
)
set(GPS_LIBRARIES
${GPS_LIBRARY}
)

if (GPS_INCLUDE_DIRS AND GPS_LIBRARIES)
set(GPS_FOUND TRUE)
endif (GPS_INCLUDE_DIRS AND GPS_LIBRARIES)

if (GPS_FOUND)
if (NOT gps_FIND_QUIETLY)
message(STATUS "Found gps:")
message(STATUS " - Includes: ${GPS_INCLUDE_DIRS}")
message(STATUS " - Libraries: ${GPS_LIBRARIES}")
endif (NOT gps_FIND_QUIETLY)
else (GPS_FOUND)
if (gps_FIND_REQUIRED)
message(FATAL_ERROR "Could not find gps")
endif (gps_FIND_REQUIRED)
endif (GPS_FOUND)

mark_as_advanced(GPS_INCLUDE_DIRS GPS_LIBRARIES)

endif (GPS_LIBRARIES AND GPS_INCLUDE_DIRS)
5 changes: 5 additions & 0 deletions include/f1x/openauto/autoapp/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ class App: public service::IAndroidAutoEntityEventHandler, public std::enable_sh
boost::asio::io_service& ioService_;
aasdk::usb::USBWrapper& usbWrapper_;
aasdk::tcp::ITCPWrapper& tcpWrapper_;
boost::asio::ip::tcp::acceptor acceptor_;
boost::asio::io_service::strand strand_;
service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
aasdk::usb::IUSBHub::Pointer usbHub_;
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
service::IAndroidAutoEntity::Pointer androidAutoEntity_;
bool isStopped_;

void startServerSocket();

void handleNewClient(std::shared_ptr<boost::asio::ip::tcp::socket> socket, const boost::system::error_code &err);
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class Configuration: public IConfiguration
static const std::string cInputScrollWheelButtonKey;
static const std::string cInputBackButtonKey;
static const std::string cInputEnterButtonKey;
static const std::string cInputNavButtonKey;
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <QBluetoothLocalDevice>
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
#include <QBluetoothServiceInfo>
#include <QtBluetooth/QBluetoothServer>

#pragma once

Expand Down Expand Up @@ -60,6 +62,10 @@ private slots:
std::unique_ptr<QBluetoothLocalDevice> localDevice_;
PairingPromise::Pointer pairingPromise_;
QBluetoothAddress pairingAddress_;
QBluetoothServiceInfo serviceInfo_;
std::unique_ptr<QBluetoothServer> rfcommServer_;

void onClientConnected();
};

}
Expand Down
2 changes: 1 addition & 1 deletion include/f1x/openauto/autoapp/Projection/QtAudioOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected slots:

private:
QAudioFormat audioFormat_;
SequentialBuffer audioBuffer_;
QIODevice * audioBuffer_;
std::unique_ptr<QAudioOutput> audioOutput_;
bool playbackStarted_;
};
Expand Down
6 changes: 5 additions & 1 deletion include/f1x/openauto/autoapp/Service/SensorService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <gps.h>
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>

Expand Down Expand Up @@ -51,13 +52,16 @@ class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHa
using std::enable_shared_from_this<SensorService>::shared_from_this;
void sendDrivingStatusUnrestricted();
void sendNightData();
void sendGPSLocationData();
bool is_file_exist(const char *filename);
void nightSensorPolling();
void sensorPolling();
bool firstRun = true;

boost::asio::deadline_timer timer_;
boost::asio::io_service::strand strand_;
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
struct gps_data_t gpsData_;
bool gpsEnabled_ = false;
};

}
Expand Down
56 changes: 56 additions & 0 deletions include/f1x/openauto/autoapp/Service/WifiService.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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/>.
*/

#pragma once

#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include <boost/asio/io_service.hpp>
#include <f1x/aasdk/Messenger/IMessenger.hpp>

namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{

class WifiService: public IService, public std::enable_shared_from_this<WifiService>
{
public:
typedef std::shared_ptr<WifiService> Pointer;

WifiService(configuration::IConfiguration::Pointer configuration);

void start() override;
void stop() override;
void pause() override;
void resume() override;
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;

private:
using std::enable_shared_from_this<WifiService>::shared_from_this;
configuration::IConfiguration::Pointer configuration_;
};

}
}
}
}
22 changes: 20 additions & 2 deletions include/f1x/openauto/btservice/AndroidBluetoothServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <memory>
#include <QBluetoothServer>
#include <f1x/openauto/btservice/IAndroidBluetoothServer.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/aasdk/Messenger/Message.hpp>

namespace f1x
{
Expand All @@ -35,15 +37,31 @@ class AndroidBluetoothServer: public QObject, public IAndroidBluetoothServer
Q_OBJECT

public:
AndroidBluetoothServer();
AndroidBluetoothServer(autoapp::configuration::IConfiguration::Pointer configuration);

bool start(const QBluetoothAddress& address, uint16_t portNumber) override;
uint16_t start(const QBluetoothAddress& address) override;

private slots:
void onClientConnected();

private:
std::unique_ptr<QBluetoothServer> rfcommServer_;
QBluetoothSocket* socket = nullptr;
autoapp::configuration::IConfiguration::Pointer configuration_;

void readSocket();

QByteArray buffer;

void handleWifiInfoRequest(QByteArray &buffer, uint16_t length);

void sendMessage(const google::protobuf::Message &message, uint16_t type);

void handleWifiSecurityRequest(QByteArray &buffer, uint16_t length);

void handleWifiInfoRequestResponse(QByteArray &buffer, uint16_t length);

const ::std::string getIP4_(const QString intf);
};

}
Expand Down
2 changes: 1 addition & 1 deletion include/f1x/openauto/btservice/IAndroidBluetoothServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IAndroidBluetoothServer
public:
virtual ~IAndroidBluetoothServer() = default;

virtual bool start(const QBluetoothAddress& address, uint16_t portNumber) = 0;
virtual uint16_t start(const QBluetoothAddress& address) = 0;
};

}
Expand Down
Loading

0 comments on commit d5e16bc

Please sign in to comment.