Merge pull request #19 from SonOfGib/sonofgib-newdev

SonOfGib Fixes
This commit is contained in:
Matthew Hilton 2024-12-30 22:40:17 +00:00 committed by GitHub
commit 5da1376565
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
48 changed files with 339 additions and 85 deletions

4
.gitignore vendored
View File

@ -4,4 +4,6 @@ bin/
build/
.vscode/
openauto.ini
CMakeLists.txt.user
CMakeLists.txt.user
/cmake-build-*/
.idea/

View File

@ -1,4 +1,10 @@
cmake_minimum_required(VERSION 3.5.1)
if(CROSS_COMPILE_ARMHF)
message("Cross compiling for armhf")
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc-8)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-8)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
endif(CROSS_COMPILE)
project(openauto CXX)
set(CMAKE_AUTOMOC ON)
@ -27,7 +33,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-g -O3")
add_definitions(-DBOOST_ALL_DYN_LINK)
find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework)
find_package(Boost REQUIRED COMPONENTS system log_setup log OPTIONAL_COMPONENTS unit_test_framework)
find_package(libusb-1.0 REQUIRED)
find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Network)
find_package(Protobuf REQUIRED)

View File

@ -48,5 +48,24 @@ Copyrights (c) 2018 f1x.studio (Michal Szwaj)
- Broadcom ilclient from RaspberryPI 3 firmware
- OpenMAX IL API
### Building
#### Amd64
Install the packages specified in the [prebuilts](https://github.com/opencardev/prebuilts) repository. Qt5 is required, versions packaged in modern Ubuntu and Debian
seem to work fine.
You will also likely need to install the udev rules from `prebuilts`
You need to point some CMAKE variables at your `aasdk` files.
```text
-DAASDK_INCLUDE_DIRS=<path_to_aasdk_repo>/include
-DAASDK_LIBRARIES=<path_to_aasdk_repo>/lib/libaasdk.so
DAASDK_PROTO_INCLUDE_DIRS=<path_to_aasdk_build>
-DAASDK_PROTO_LIBRARIES=<path_to_aasdk_repo>/lib/libaasdk_proto.so
```
#### Raspberry Pi
Just run the scripts in the `prebuilts` repository for `aasdk` and `openauto`. It is possible to cross compile if your raspberry pi is too slow to compile the code itself.
However, its easiest to just develop on a more capable `amd64` device.
### Remarks
**This software is not certified by Google Inc. It is created for R&D purposes and may not work as expected by the original authors. Do not use while driving. You use this software at your own risk.**

49
buildenv/Dockerfile Normal file
View File

@ -0,0 +1,49 @@
FROM debian:buster AS prebuilts
COPY ./buildenv/pi_binaries/buster.tar.gz buster.tar.gz
COPY ./buildenv/pi_binaries/aasdk_armhf.deb aasdk_armhf.deb
RUN apt-get update &&\
apt-get -y install cmake build-essential git zip &&\
git clone https://github.com/SonOfGib/prebuilts.git &&\
mkdir qt5 &&\
cat prebuilts/qt5/Qt_5151_armv7l_OpenGLES2.tar.xz* > Qt5_OpenGLES2.tar.xz
FROM debian:buster AS openauto
COPY --from=prebuilts Qt5_OpenGLES2.tar.xz Qt5_OpenGLES2.tar.xz
COPY --from=prebuilts buster.tar.gz buster.tar.gz
COPY --from=prebuilts aasdk_armhf.deb aasdk_armhf.deb
RUN dpkg --add-architecture armhf &&\
apt-get update &&\
apt-get -y install cmake build-essential git &&\
apt-get -y install gcc-arm-linux-gnueabihf cpp-arm-linux-gnueabihf g++-arm-linux-gnueabihf protobuf-compiler &&\
apt-get -y install gcc-8-base:armhf libc6:armhf libgcc1:armhf libicu63:armhf libidn2-0:armhf libstdc++6:armhf libunistring2:armhf pulseaudio:armhf librtaudio-dev:armhf libgps-dev:armhf libblkid-dev:armhf libtag1-dev:armhf libgles2-mesa-dev:armhf libdouble-conversion-dev:armhf &&\
tar -xf Qt5_OpenGLES2.tar.xz -C / &&\
tar -xf buster.tar.gz -C /
# These are all the libboost requirements. It would be shorter if libboost-log-dev wasn't a disaster that's being dealt with manually.
RUN apt-get install -y libprotobuf-dev libusb-1.0.0-dev libssl-dev libboost-dev libboost-system-dev libboost-atomic1.67.0 libboost-chrono1.67.0 libboost-date-time1.67.0 libboost-filesystem1.67.0 libboost-regex1.67.0 libboost-thread1.67.0 libboost-filesystem1.67-dev libboost-thread1.67-dev libboost-date-time1.67-dev &&\
apt-get install -y libprotobuf-dev:armhf libusb-1.0.0-dev:armhf libssl-dev:armhf libboost-dev:armhf libboost-system-dev:armhf libboost-atomic1.67.0:armhf libboost-chrono1.67.0:armhf libboost-date-time1.67.0:armhf libboost-filesystem1.67.0:armhf libboost-regex1.67.0:armhf libboost-system1.67.0:armhf libboost-thread1.67.0:armhf libboost-filesystem1.67-dev:armhf libboost-thread1.67-dev:armhf libboost-date-time1.67-dev:armhf
COPY / /src
WORKDIR /src
# Import resources
COPY ./buildenv/patch-libboost-log-deb.sh /src/resources/patch-libboost-log-deb.sh
COPY ./buildenv/entrypoint.sh /entrypoint.sh
# Patch libboost-log-dev and install
RUN chmod +x ./resources/patch-libboost-log-deb.sh
RUN ./resources/patch-libboost-log-deb.sh
# Make Executable
RUN chmod +x /entrypoint.sh
WORKDIR /
RUN dpkg-deb -xv aasdk_armhf.deb /
WORKDIR /src
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

16
buildenv/cross-compile.md Normal file
View File

@ -0,0 +1,16 @@
### RPI Cross Compile
The docker image in this folder is intended to be used to cross compile `openauto` without having to configure your
host pc with multiarch or installing a toolchain.
#### Setup
The `openauto` build for RPI3 requires some files from the PI, as well as aasdk libraries compiled for amrhf.
- RPI files should be compressed to `buildenv/pi_binaries/buster.tar.gz`. The files required in the archive should
match the path/files in the `if(RPI3_BUILD)` section of `CMakeLists.txt`
- Copy the `.deb` file from `aasdk` docker cross compile build and place it in `buildenv/pi_binaries/aasdk_armhf.dev`
#### Build
```bash
cd buildenv
sudo docker compose up --build
```
Binary files will then be available in `buildenv/release`.

View File

@ -0,0 +1,7 @@
services:
openauto-build:
build:
context: ../
dockerfile: buildenv/Dockerfile
volumes:
- ./release/:/release/

14
buildenv/entrypoint.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# Clear out the /build directory
mkdir build;
cd build;
cmake -DCMAKE_BUILD_TYPE=Release -DRPI3_BUILD=true -DCROSS_COMPILE_ARMHF=true -DAASDK_INCLUDE_DIRS=/usr/include/aasdk -DAASDK_LIBRARIES=/usr/lib/libaasdk.so -DAASDK_PROTO_INCLUDE_DIRS=/usr/include/aasdk_proto -DAASDK_PROTO_LIBRARIES=/usr/lib/libaasdk_proto.so ../
make -j4
cd ../bin
# Move it to release
rm -f /release/autoapp
rm -f /release/btservice
mv autoapp /release
mv btservice /release

View File

@ -0,0 +1,46 @@
# All this because of a packaging bug in libboost-log-dev
# 'Multi-Arch: same' is not present in the control file of Debian packages, all the way up to Sid
# Rather than recompiling the parent libbost suite, download the 6 packages, extract, edit, and repackage.
# https://bugs.debian.org/cgi-bin/pkgreport.cgi?package=libboost-log-dev
apt-get -y install --download-only libboost-log-dev:amd64 libboost-log1.67.0:amd64 libboost-log1.67-dev:amd64
apt-get -y install --download-only libboost-log-dev:armhf libboost-log1.67.0:armhf libboost-log1.67-dev:armhf
mkdir -p /tmp/armhf/libboost-log-dev/
dpkg-deb -x /var/cache/apt/archives/libboost-log-dev_1.67.0.1_armhf.deb /tmp/armhf/libboost-log-dev/
dpkg-deb -e /var/cache/apt/archives/libboost-log-dev_1.67.0.1_armhf.deb /tmp/armhf/libboost-log-dev/DEBIAN/
sed -i '/^Priority: optional/a Multi-Arch: same' /tmp/armhf/libboost-log-dev/DEBIAN/control
dpkg-deb -b /tmp/armhf/libboost-log-dev/ /tmp/libboost-log-dev_1.67.0.1_armhf.deb
mkdir -p /tmp/amd64/libboost-log-dev/
dpkg-deb -x /var/cache/apt/archives/libboost-log-dev_1.67.0.1_amd64.deb /tmp/amd64/libboost-log-dev/
dpkg-deb -e /var/cache/apt/archives/libboost-log-dev_1.67.0.1_amd64.deb /tmp/amd64/libboost-log-dev/DEBIAN/
sed -i '/^Priority: optional/a Multi-Arch: same' /tmp/amd64/libboost-log-dev/DEBIAN/control
dpkg-deb -b /tmp/amd64/libboost-log-dev/ /tmp/libboost-log-dev_1.67.0.1_amd64.deb
mkdir -p /tmp/armhf/libboost-log1.67-dev/
dpkg-deb -x /var/cache/apt/archives/libboost-log1.67-dev_1.67.0-13+deb10u1_armhf.deb /tmp/armhf/libboost-log1.67-dev/
dpkg-deb -e /var/cache/apt/archives/libboost-log1.67-dev_1.67.0-13+deb10u1_armhf.deb /tmp/armhf/libboost-log1.67-dev/DEBIAN/
sed -i '/^Priority: optional/a Multi-Arch: same' /tmp/armhf/libboost-log1.67-dev/DEBIAN/control
dpkg-deb -b /tmp/armhf/libboost-log1.67-dev/ /tmp/libboost-log1.67-dev_1.67.0-13+deb10u1_armhf.deb
mkdir -p /tmp/amd64/libboost-log1.67-dev/
dpkg-deb -x /var/cache/apt/archives/libboost-log1.67-dev_1.67.0-13+deb10u1_amd64.deb /tmp/amd64/libboost-log1.67-dev/
dpkg-deb -e /var/cache/apt/archives/libboost-log1.67-dev_1.67.0-13+deb10u1_amd64.deb /tmp/amd64/libboost-log1.67-dev/DEBIAN/
sed -i '/^Priority: optional/a Multi-Arch: same' /tmp/amd64/libboost-log1.67-dev/DEBIAN/control
dpkg-deb -b /tmp/amd64/libboost-log1.67-dev/ /tmp/libboost-log1.67-dev_1.67.0-13+deb10u1_amd64.deb
mkdir -p /tmp/armhf/libboost-log1.67.0/
dpkg-deb -x /var/cache/apt/archives/libboost-log1.67.0_1.67.0-13+deb10u1_armhf.deb /tmp/armhf/libboost-log1.67.0/
dpkg-deb -e /var/cache/apt/archives/libboost-log1.67.0_1.67.0-13+deb10u1_armhf.deb /tmp/armhf/libboost-log1.67.0/DEBIAN/
sed -i '/^Priority: optional/a Multi-Arch: same' /tmp/armhf/libboost-log1.67.0/DEBIAN/control
dpkg-deb -b /tmp/armhf/libboost-log1.67.0/ /tmp/libboost-log1.67.0_1.67.0-13+deb10u1_armhf.deb
mkdir -p /tmp/amd64/libboost-log1.67.0/
dpkg-deb -x /var/cache/apt/archives/libboost-log1.67.0_1.67.0-13+deb10u1_amd64.deb /tmp/amd64/libboost-log1.67.0/
dpkg-deb -e /var/cache/apt/archives/libboost-log1.67.0_1.67.0-13+deb10u1_amd64.deb /tmp/amd64/libboost-log1.67.0/DEBIAN/
sed -i '/^Priority: optional/a Multi-Arch: same' /tmp/amd64/libboost-log1.67.0/DEBIAN/control
dpkg-deb -b /tmp/amd64/libboost-log1.67.0/ /tmp/libboost-log1.67.0_1.67.0-13+deb10u1_amd64.deb
dpkg -i /tmp/libboost*.deb

2
buildenv/pi_binaries/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
buildenv/release/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -18,11 +18,11 @@
#pragma once
#include <f1x/aasdk/USB/IUSBHub.hpp>
#include <f1x/aasdk/USB/IConnectedAccessoriesEnumerator.hpp>
#include <f1x/aasdk/USB/USBWrapper.hpp>
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
#include <aasdk/USB/IUSBHub.hpp>
#include <aasdk/USB/IConnectedAccessoriesEnumerator.hpp>
#include <aasdk/USB/USBWrapper.hpp>
#include <aasdk/TCP/ITCPWrapper.hpp>
#include <aasdk/TCP/ITCPEndpoint.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>

View File

@ -19,8 +19,8 @@
#pragma once
#include <memory>
#include <f1x/aasdk/IO/Promise.hpp>
#include <f1x/aasdk/Common/Data.hpp>
#include <aasdk/IO/Promise.hpp>
#include <aasdk/Common/Data.hpp>
namespace f1x
{

View File

@ -19,8 +19,8 @@
#pragma once
#include <memory>
#include <f1x/aasdk/Messenger/Timestamp.hpp>
#include <f1x/aasdk/Common/Data.hpp>
#include <aasdk/Messenger/Timestamp.hpp>
#include <aasdk/Common/Data.hpp>
namespace f1x
{

View File

@ -16,7 +16,7 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <f1x/aasdk/IO/Promise.hpp>
#include <aasdk/IO/Promise.hpp>
#pragma once

View File

@ -19,7 +19,7 @@
#pragma once
#include <QRect>
#include <f1x/aasdk/IO/Promise.hpp>
#include <aasdk/IO/Promise.hpp>
#include <f1x/openauto/autoapp/Projection/InputEvent.hpp>
namespace f1x

View File

@ -22,7 +22,7 @@
#include <QRect>
#include <aasdk_proto/VideoFPSEnum.pb.h>
#include <aasdk_proto/VideoResolutionEnum.pb.h>
#include <f1x/aasdk/Common/Data.hpp>
#include <aasdk/Common/Data.hpp>
namespace f1x
{

View File

@ -20,7 +20,7 @@
#include <aasdk_proto/ButtonCodeEnum.pb.h>
#include <aasdk_proto/TouchActionEnum.pb.h>
#include <f1x/aasdk/IO/Promise.hpp>
#include <aasdk/IO/Promise.hpp>
namespace f1x
{

View File

@ -21,7 +21,7 @@
#include <QIODevice>
#include <mutex>
#include <boost/circular_buffer.hpp>
#include <f1x/aasdk/Common/Data.hpp>
#include <aasdk/Common/Data.hpp>
namespace f1x
{

View File

@ -19,10 +19,10 @@
#pragma once
#include <boost/asio.hpp>
#include <f1x/aasdk/Transport/ITransport.hpp>
#include <f1x/aasdk/Channel/Control/IControlServiceChannel.hpp>
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
#include <aasdk/Transport/ITransport.hpp>
#include <aasdk/Channel/Control/IControlServiceChannel.hpp>
#include <aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
#include <aasdk/Channel/AV/VideoServiceChannel.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
@ -60,8 +60,10 @@ public:
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
void onChannelError(const aasdk::error::Error& e) override;
void onPingRequest(const aasdk::proto::messages::PingRequest& request) override;
void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) override;
private:
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;

View File

@ -19,7 +19,7 @@
#pragma once
#include <boost/asio.hpp>
#include <f1x/aasdk/Transport/ITransport.hpp>
#include <aasdk/Transport/ITransport.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/Channel/AV/AVInputServiceChannel.hpp>
#include <aasdk/Channel/AV/AVInputServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>

View File

@ -18,8 +18,8 @@
#pragma once
#include <f1x/aasdk/Channel/AV/IAudioServiceChannel.hpp>
#include <f1x/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
#include <aasdk/Channel/AV/IAudioServiceChannel.hpp>
#include <aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
#include <aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/Error/Error.hpp>
#include <aasdk/Error/Error.hpp>
namespace f1x
{

View File

@ -18,8 +18,8 @@
#pragma once
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
#include <f1x/aasdk/USB/IAOAPDevice.hpp>
#include <aasdk/TCP/ITCPEndpoint.hpp>
#include <aasdk/USB/IAOAPDevice.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
namespace f1x

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/IO/Promise.hpp>
#include <aasdk/IO/Promise.hpp>
namespace f1x
{

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
namespace f1x

View File

@ -19,7 +19,7 @@
#pragma once
#include <aasdk_proto/ButtonCodeEnum.pb.h>
#include <f1x/aasdk/Channel/Input/InputServiceChannel.hpp>
#include <aasdk/Channel/Input/InputServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
namespace f1x

View File

@ -19,7 +19,7 @@
#pragma once
#include <gps.h>
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
#include <aasdk/Channel/Sensor/SensorServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
namespace f1x

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
namespace f1x

View File

@ -18,7 +18,7 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
namespace f1x

View File

@ -19,8 +19,8 @@
#pragma once
#include <memory>
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
#include <f1x/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
#include <aasdk/Channel/AV/VideoServiceChannel.hpp>
#include <aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>

View File

@ -21,7 +21,9 @@
#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>
#include <aasdk/Messenger/IMessenger.hpp>
#include <aasdk/Channel/WIFI/WIFIServiceChannel.hpp>
#include <aasdk/Channel/WIFI/IWIFIServiceChannelEventHandler.hpp>
namespace f1x
{
@ -32,22 +34,27 @@ namespace autoapp
namespace service
{
class WifiService: public IService, public std::enable_shared_from_this<WifiService>
class WifiService: public aasdk::channel::wifi::IWIFIServiceChannelEventHandler, public IService, public std::enable_shared_from_this<WifiService>
{
public:
typedef std::shared_ptr<WifiService> Pointer;
WifiService(configuration::IConfiguration::Pointer configuration);
WifiService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, configuration::IConfiguration::Pointer configuration);
void start() override;
void stop() override;
void pause() override;
void resume() override;
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
void onChannelError(const aasdk::error::Error& e) override;
void onWifiSecurityRequest() override;
private:
using std::enable_shared_from_this<WifiService>::shared_from_this;
configuration::IConfiguration::Pointer configuration_;
boost::asio::io_service::strand strand_;
aasdk::channel::wifi::WIFIServiceChannel::Pointer channel_;
};
}

View File

@ -3,8 +3,8 @@
#include <QDialog>
#include <QStringListModel>
#include <QKeyEvent>
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
#include <aasdk/TCP/ITCPEndpoint.hpp>
#include <aasdk/TCP/ITCPWrapper.hpp>
#include <f1x/openauto/autoapp/Configuration/IRecentAddressesList.hpp>
namespace Ui {

View File

@ -23,7 +23,7 @@
#include <QBluetoothServer>
#include <f1x/openauto/btservice/IAndroidBluetoothServer.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/aasdk/Messenger/Message.hpp>
#include <aasdk/Messenger/Message.hpp>
namespace f1x
{

View File

@ -17,8 +17,8 @@
*/
#include <thread>
#include <f1x/aasdk/USB/AOAPDevice.hpp>
#include <f1x/aasdk/TCP/TCPEndpoint.hpp>
#include <aasdk/USB/AOAPDevice.hpp>
#include <aasdk/TCP/TCPEndpoint.hpp>
#include <f1x/openauto/autoapp/App.hpp>
#include <f1x/openauto/Common/Log.hpp>

View File

@ -23,7 +23,7 @@ extern "C"
#include <bcm_host.h>
}
#include <f1x/aasdk/Common/Data.hpp>
#include <aasdk/Common/Data.hpp>
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
#include <f1x/openauto/Common/Log.hpp>

View File

@ -16,7 +16,7 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <f1x/aasdk/Channel/Control/ControlServiceChannel.hpp>
#include <aasdk/Channel/Control/ControlServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
#include <f1x/openauto/Common/Log.hpp>
@ -238,6 +238,20 @@ void AndroidAutoEntity::onShutdownRequest(const aasdk::proto::messages::Shutdown
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
}
void AndroidAutoEntity::onPingRequest(const aasdk::proto::messages::PingRequest& request)
{
OPENAUTO_LOG(info) << "[AndroidAutoEntity] ping request ";
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
controlServiceChannel_->sendPingRequest(request, std::move(promise));
}
void AndroidAutoEntity::onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request)
{
OPENAUTO_LOG(error) << "[AndroidAutoEntity] voice session request not implemented";
}
void AndroidAutoEntity::onShutdownResponse(const aasdk::proto::messages::ShutdownResponse&)
{
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Shutdown response ";

View File

@ -16,14 +16,14 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <f1x/aasdk/USB/AOAPDevice.hpp>
#include <f1x/aasdk/Transport/SSLWrapper.hpp>
#include <f1x/aasdk/Transport/USBTransport.hpp>
#include <f1x/aasdk/Transport/TCPTransport.hpp>
#include <f1x/aasdk/Messenger/Cryptor.hpp>
#include <f1x/aasdk/Messenger/MessageInStream.hpp>
#include <f1x/aasdk/Messenger/MessageOutStream.hpp>
#include <f1x/aasdk/Messenger/Messenger.hpp>
#include <aasdk/USB/AOAPDevice.hpp>
#include <aasdk/Transport/SSLWrapper.hpp>
#include <aasdk/Transport/USBTransport.hpp>
#include <aasdk/Transport/TCPTransport.hpp>
#include <aasdk/Messenger/Cryptor.hpp>
#include <aasdk/Messenger/MessageInStream.hpp>
#include <aasdk/Messenger/MessageOutStream.hpp>
#include <aasdk/Messenger/Messenger.hpp>
#include <f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp>
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
#include <f1x/openauto/autoapp/Service/Pinger.hpp>

View File

@ -16,7 +16,7 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
#include <aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
namespace f1x

View File

@ -188,7 +188,7 @@ void SensorService::sendGPSLocationData()
auto * locInd = indication.add_gps_location();
// epoch seconds
locInd->set_timestamp(this->gpsData_.fix.time * 1e3);
locInd->set_timestamp(this->gpsData_.fix.time.tv_sec);
// degrees
locInd->set_latitude(this->gpsData_.fix.latitude * 1e7);
locInd->set_longitude(this->gpsData_.fix.longitude * 1e7);
@ -229,8 +229,7 @@ void SensorService::sensorPolling()
if ((this->gpsEnabled_) &&
(gps_waiting(&this->gpsData_, 0)) &&
(gps_read(&this->gpsData_) > 0) &&
(this->gpsData_.status != STATUS_NO_FIX) &&
(gps_read(&this->gpsData_, nullptr, 0) > 0) &&
(this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) &&
(this->gpsData_.set & TIME_SET) &&
(this->gpsData_.set & LATLON_SET))

View File

@ -18,9 +18,9 @@
#include <QApplication>
#include <QScreen>
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
#include <aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
#include <aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
#include <aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/ServiceFactory.hpp>
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
@ -68,7 +68,7 @@ ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messeng
serviceList.emplace_back(this->createVideoService(messenger));
serviceList.emplace_back(this->createBluetoothService(messenger));
serviceList.emplace_back(this->createInputService(messenger));
serviceList.emplace_back(std::make_shared<WifiService>(configuration_));
serviceList.emplace_back(std::make_shared<WifiService>(ioService_, messenger, configuration_));
return serviceList;
}

View File

@ -16,7 +16,7 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
#include <aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
namespace f1x

View File

@ -16,7 +16,7 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
#include <aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
namespace f1x

View File

@ -19,6 +19,7 @@
#include <f1x/openauto/Common/Log.hpp>
#include <f1x/openauto/autoapp/Service/WifiService.hpp>
#include <fstream>
#include <QNetworkInterface>
#include <QString>
namespace f1x
@ -30,26 +31,41 @@ namespace autoapp
namespace service
{
WifiService::WifiService(configuration::IConfiguration::Pointer configuration)
WifiService::WifiService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, configuration::IConfiguration::Pointer configuration)
: configuration_(std::move(configuration))
, strand_(ioService)
, channel_(std::make_shared<aasdk::channel::wifi::WIFIServiceChannel>(strand_, std::move(messenger)))
{
}
void WifiService::start()
{
strand_.dispatch([this, self = this->shared_from_this()]() {
OPENAUTO_LOG(info) << "[WifiService] start.";
channel_->receive(this->shared_from_this());
});
}
void WifiService::stop()
{
strand_.dispatch([this, self = this->shared_from_this()]() {
OPENAUTO_LOG(info) << "[WifiService] stop.";
});
}
void WifiService::pause()
{
strand_.dispatch([this, self = this->shared_from_this()]() {
OPENAUTO_LOG(info) << "[WifiService] pause.";
});
}
void WifiService::resume()
{
strand_.dispatch([this, self = this->shared_from_this()]() {
OPENAUTO_LOG(info) << "[WifiService] resume.";
});
}
void WifiService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
@ -57,12 +73,47 @@ void WifiService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse&
OPENAUTO_LOG(info) << "[WifiService] fill features.";
auto* channelDescriptor = response.add_channels();
channelDescriptor->set_channel_id(14);
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
auto* channel = channelDescriptor->mutable_wifi_channel();
channel->set_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString());
}
void WifiService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[WifiService] open request, priority: " << request.priority();
const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
OPENAUTO_LOG(info) << "[WifiService] open status: " << status;
aasdk::proto::messages::ChannelOpenResponse response;
response.set_status(status);
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, std::bind(&WifiService::onChannelError, this->shared_from_this(), std::placeholders::_1));
channel_->sendChannelOpenResponse(response, std::move(promise));
channel_->receive(this->shared_from_this());
}
void WifiService::onChannelError(const aasdk::error::Error &e) {
OPENAUTO_LOG(error) << "[WifiService] channel error: " << e.what();
}
void WifiService::onWifiSecurityRequest() {
OPENAUTO_LOG(info) << "[WifiService] handle Wifi Security Request ";
aasdk::proto::messages::WifiSecurityResponse response;
response.set_access_point_type(aasdk::proto::messages::WifiSecurityResponse_AccessPointType_STATIC);
response.set_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString());
response.set_key(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","wpa_passphrase").toStdString());
// response.set_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString());
response.set_security_mode(aasdk::proto::messages::WifiSecurityResponse_SecurityMode_WPA2_PERSONAL);
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, std::bind(&WifiService::onChannelError, this->shared_from_this(), std::placeholders::_1));
channel_->sendWifiSecurityResponse(response, std::move(promise));
channel_->receive(this->shared_from_this());
}
}
}
}

View File

@ -19,12 +19,13 @@
#include <thread>
#include <QApplication>
#include <QDesktopWidget>
#include <f1x/aasdk/USB/USBHub.hpp>
#include <f1x/aasdk/USB/ConnectedAccessoriesEnumerator.hpp>
#include <f1x/aasdk/USB/AccessoryModeQueryChain.hpp>
#include <f1x/aasdk/USB/AccessoryModeQueryChainFactory.hpp>
#include <f1x/aasdk/USB/AccessoryModeQueryFactory.hpp>
#include <f1x/aasdk/TCP/TCPWrapper.hpp>
#include <aasdk/USB/USBHub.hpp>
#include <aasdk/USB/ConnectedAccessoriesEnumerator.hpp>
#include <aasdk/USB/AccessoryModeQueryChain.hpp>
#include <aasdk/USB/AccessoryModeQueryChainFactory.hpp>
#include <aasdk/USB/AccessoryModeQueryFactory.hpp>
#include <aasdk/TCP/TCPWrapper.hpp>
#include <boost/log/utility/setup.hpp>
#include <f1x/openauto/autoapp/App.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/openauto/autoapp/Configuration/RecentAddressesList.hpp>
@ -38,7 +39,6 @@
#include <f1x/openauto/autoapp/UI/UpdateDialog.hpp>
#include <f1x/openauto/Common/Log.hpp>
namespace aasdk = f1x::aasdk;
namespace autoapp = f1x::openauto::autoapp;
using ThreadPool = std::vector<std::thread>;
@ -71,8 +71,25 @@ void startIOServiceWorkers(boost::asio::io_service& ioService, ThreadPool& threa
threadPool.emplace_back(ioServiceWorker);
}
void configureLogging() {
const std::string logIni = "openauto-logs.ini";
std::ifstream logSettings(logIni);
if (logSettings.good()) {
try {
// For boost < 1.71 the severity types are not automatically parsed so lets register them.
boost::log::register_simple_filter_factory<boost::log::trivial::severity_level>("Severity");
boost::log::register_simple_formatter_factory<boost::log::trivial::severity_level, char>("Severity");
boost::log::init_from_stream(logSettings);
} catch (std::exception const & e) {
OPENAUTO_LOG(warning) << "[OpenAuto] " << logIni << " was provided but was not valid.";
}
}
}
int main(int argc, char* argv[])
{
configureLogging();
libusb_context* usbContext;
if(libusb_init(&usbContext) != 0)
{

View File

@ -23,6 +23,7 @@
#include <QString>
#include <QtCore/QDataStream>
#include <QNetworkInterface>
#include <aasdk_proto/WifiInfoRequestMessage.pb.h>
#include <aasdk_proto/WifiInfoResponseMessage.pb.h>
#include <aasdk_proto/WifiSecurityResponseMessage.pb.h>
@ -61,7 +62,7 @@ namespace f1x {
// connect(socket, &QBluetoothSocket::disconnected, this,
// QOverload<>::of(&ChatServer::clientDisconnected));
f1x::aasdk::proto::messages::WifiInfoRequest request;
::aasdk::proto::messages::WifiInfoRequest request;
request.set_ip_address(getIP4_("wlan0"));
request.set_port(5000);
@ -121,26 +122,26 @@ namespace f1x {
}
void AndroidBluetoothServer::handleWifiInfoRequest(QByteArray &buffer, uint16_t length) {
f1x::aasdk::proto::messages::WifiInfoRequest msg;
::aasdk::proto::messages::WifiInfoRequest msg;
msg.ParseFromArray(buffer.data() + 4, length);
OPENAUTO_LOG(info) << "WifiInfoRequest: " << msg.DebugString();
f1x::aasdk::proto::messages::WifiInfoResponse response;
::aasdk::proto::messages::WifiInfoResponse response;
response.set_ip_address(getIP4_("wlan0"));
response.set_port(5000);
response.set_status(aasdk::proto::messages::WifiInfoResponse_Status_STATUS_SUCCESS);
response.set_status(::aasdk::proto::messages::WifiInfoResponse_Status_STATUS_SUCCESS);
sendMessage(response, 7);
}
void AndroidBluetoothServer::handleWifiSecurityRequest(QByteArray &buffer, uint16_t length) {
f1x::aasdk::proto::messages::WifiSecurityReponse response;
::aasdk::proto::messages::WifiSecurityResponse response;
response.set_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString());
response.set_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString());
// response.set_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString());
response.set_key(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","wpa_passphrase").toStdString());
response.set_security_mode(aasdk::proto::messages::WifiSecurityReponse_SecurityMode_WPA2_PERSONAL);
response.set_access_point_type(aasdk::proto::messages::WifiSecurityReponse_AccessPointType_STATIC);
response.set_security_mode(::aasdk::proto::messages::WifiSecurityResponse_SecurityMode_WPA2_PERSONAL);
response.set_access_point_type(::aasdk::proto::messages::WifiSecurityResponse_AccessPointType_STATIC);
sendMessage(response, 3);
}
@ -170,7 +171,7 @@ namespace f1x {
}
void AndroidBluetoothServer::handleWifiInfoRequestResponse(QByteArray &buffer, uint16_t length) {
f1x::aasdk::proto::messages::WifiInfoResponse msg;
::aasdk::proto::messages::WifiInfoResponse msg;
msg.ParseFromArray(buffer.data() + 4, length);
OPENAUTO_LOG(info) << "WifiInfoResponse: " << msg.DebugString();
}
@ -184,4 +185,4 @@ namespace f1x {
}
}
}
}
}