diff --git a/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp b/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp index f88c1c3..d68b82d 100644 --- a/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp +++ b/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp b/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp index 3b0bd5f..93bdb23 100644 --- a/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp +++ b/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp @@ -22,7 +22,7 @@ #include #include #include - +#include namespace f1x::openauto::autoapp::service::wifiprojection { @@ -31,7 +31,7 @@ namespace f1x::openauto::autoapp::service::wifiprojection { public IService, public std::enable_shared_from_this { public: - WifiProjectionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger); + WifiProjectionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger, configuration::IConfiguration::Pointer configuration); void start() override; @@ -53,6 +53,7 @@ namespace f1x::openauto::autoapp::service::wifiprojection { private: using std::enable_shared_from_this::shared_from_this; + configuration::IConfiguration::Pointer configuration_; boost::asio::deadline_timer timer_; boost::asio::io_service::strand strand_; aasdk::channel::wifiprojection::WifiProjectionService::Pointer channel_; diff --git a/src/autoapp/Service/AndroidAutoEntity.cpp b/src/autoapp/Service/AndroidAutoEntity.cpp index 80cf5c5..c692d07 100644 --- a/src/autoapp/Service/AndroidAutoEntity.cpp +++ b/src/autoapp/Service/AndroidAutoEntity.cpp @@ -263,21 +263,6 @@ namespace f1x { 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(info) << "[AndroidAutoEntity] onVoiceSessionRequest()"; - controlServiceChannel_->receive(this->shared_from_this()); - } - void AndroidAutoEntity::onByeByeResponse( const aap_protobuf::service::control::message::ByeByeResponse &response) { OPENAUTO_LOG(info) << "[AndroidAutoEntity] onByeByeResponse()"; diff --git a/src/autoapp/Service/Sensor/SensorService.cpp b/src/autoapp/Service/Sensor/SensorService.cpp index b66c23a..adf570d 100644 --- a/src/autoapp/Service/Sensor/SensorService.cpp +++ b/src/autoapp/Service/Sensor/SensorService.cpp @@ -178,7 +178,11 @@ namespace f1x::openauto::autoapp::service::sensor { auto *locInd = indication.add_location_data(); // epoch seconds - // locInd->set_timestamp(this->gpsData_.fix.time * 1e3); +#if GPSD_API_MAJOR_VERSION >= 7 + locInd->set_timestamp(this->gpsData_.fix.time.tv_sec); +#else + locInd->set_timestamp(this->gpsData_.fix.time); +#endif // degrees locInd->set_latitude_e7(this->gpsData_.fix.latitude * 1e7); locInd->set_longitude_e7(this->gpsData_.fix.longitude * 1e7); @@ -214,14 +218,23 @@ namespace f1x::openauto::autoapp::service::sensor { this->previous = this->isNight; this->sendNightData(); } - + bool gpsDataAvailable = false; +#if GPSD_API_MAJOR_VERSION >= 7 + if (gps_read (&this->gpsData_, NULL, 0) != -1) { + gpsDataAvailable = true; + } +#else + if (gps_read (&this->gpsData_) != -1) { + gpsDataAvailable = true; + } +#endif if ((this->gpsEnabled_) && (gps_waiting(&this->gpsData_, 0)) && - (gps_read(&this->gpsData_) > 0) && - (this->gpsData_.status != STATUS_NO_FIX) && + (gpsDataAvailable == true) && (this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) && (this->gpsData_.set & TIME_SET) && - (this->gpsData_.set & LATLON_SET)) { + (this->gpsData_.set & LATLON_SET)) + { this->sendGPSLocationData(); } diff --git a/src/autoapp/Service/SensorService.cpp b/src/autoapp/Service/SensorService.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp b/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp index 080a898..ab71a62 100644 --- a/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp +++ b/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp @@ -25,8 +25,10 @@ namespace f1x::openauto::autoapp::service::wifiprojection { WifiProjectionService::WifiProjectionService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger) - : strand_(ioService), + aasdk::messenger::IMessenger::Pointer messenger, + configuration::IConfiguration::Pointer configuration) + : configuration_(std::move(configuration)), + strand_(ioService), timer_(ioService), channel_( std::make_shared(strand_, std::move(messenger))) { @@ -76,8 +78,10 @@ namespace f1x::openauto::autoapp::service::wifiprojection { aap_protobuf::service::wifiprojection::message::WifiCredentialsResponse response; response.set_access_point_type(aap_protobuf::service::wifiprojection::message::AccessPointType::STATIC); - response.set_car_wifi_ssid("CRANKSHAFT-NG"); - response.set_car_wifi_password("1234567890"); + response.set_car_wifi_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString()); + response.set_car_wifi_password(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","wpa_passphrase").toStdString()); + + // Might need to set WPA2_ENTERPRISE response.set_car_wifi_security_mode( aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_PERSONAL); diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index a110b52..8d37079 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -71,8 +72,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("Severity"); + boost::log::register_simple_formatter_factory("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) {