Send night data indication to let phone control night mode
This commit is contained in:
parent
ad87a5389e
commit
ae28b1ca08
@ -45,6 +45,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<SensorService>::shared_from_this;
|
using std::enable_shared_from_this<SensorService>::shared_from_this;
|
||||||
void sendDrivingStatusUnrestricted();
|
void sendDrivingStatusUnrestricted();
|
||||||
|
void sendNightData();
|
||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
|
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
|
||||||
|
@ -61,7 +61,7 @@ void SensorService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryRespons
|
|||||||
auto* sensorChannel = channelDescriptor->mutable_sensor_channel();
|
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::DRIVING_STATUS);
|
||||||
//sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::LOCATION);
|
//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)
|
void SensorService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||||
@ -94,6 +94,11 @@ void SensorService::onSensorStartRequest(const aasdk::proto::messages::SensorSta
|
|||||||
promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()),
|
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
|
else
|
||||||
{
|
{
|
||||||
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
@ -113,6 +118,16 @@ void SensorService::sendDrivingStatusUnrestricted()
|
|||||||
channel_->sendSensorEventIndication(indication, std::move(promise));
|
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)
|
void SensorService::onChannelError(const aasdk::error::Error& e)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user