Send night data indication to let phone control night mode

pull/10/head
michal.szwaj 2018-02-13 21:45:45 +01:00
parent ad87a5389e
commit ae28b1ca08
2 changed files with 18 additions and 2 deletions

View File

@ -45,6 +45,7 @@ public:
private:
using std::enable_shared_from_this<SensorService>::shared_from_this;
void sendDrivingStatusUnrestricted();
void sendNightData();
boost::asio::io_service::strand strand_;
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;

View File

@ -61,7 +61,7 @@ void SensorService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryRespons
auto* sensorChannel = channelDescriptor->mutable_sensor_channel();
sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::DRIVING_STATUS);
//sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::LOCATION);
//sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::NIGHT_DATA);
sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::NIGHT_DATA);
}
void SensorService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
@ -92,7 +92,12 @@ void SensorService::onSensorStartRequest(const aasdk::proto::messages::SensorSta
if(request.sensor_type() == aasdk::proto::enums::SensorType::DRIVING_STATUS)
{
promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()),
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
}
else if(request.sensor_type() == aasdk::proto::enums::SensorType::NIGHT_DATA)
{
promise->then(std::bind(&SensorService::sendNightData, this->shared_from_this()),
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
}
else
{
@ -113,6 +118,16 @@ void SensorService::sendDrivingStatusUnrestricted()
channel_->sendSensorEventIndication(indication, std::move(promise));
}
void SensorService::sendNightData()
{
aasdk::proto::messages::SensorEventIndication indication;
indication.add_night_mode()->set_is_night(false);
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
channel_->sendSensorEventIndication(indication, std::move(promise));
}
void SensorService::onChannelError(const aasdk::error::Error& e)
{
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();