Browse Source

环境传感器中新增一项大气压力

master
zhaohe 3 years ago
parent
commit
746f3e47ec
  1. 4
      src/service/device_io_service.cpp
  2. 3
      src/service/device_io_service.hpp
  3. 2
      src/service/main_control_service.cpp

4
src/service/device_io_service.cpp

@ -192,6 +192,8 @@ DeviceIOService::env_sensor_state_t DeviceIOService::getEnvSensorState() {
56(16Byte) | PPM
57(16Byte) | tvoc ppm
58(16Byte) | hcho mg/m3
59(16Byte) | light_intensity H
60(16Byte) | light_intensity L
*/
env_sensor_state.wind_speed = modbus03rx.getReg(48);
env_sensor_state.wind_direction = modbus03rx.getReg(49);
@ -204,6 +206,8 @@ DeviceIOService::env_sensor_state_t DeviceIOService::getEnvSensorState() {
env_sensor_state.atmospheric_pressure = modbus03rx.getReg(56);
env_sensor_state.tvoc = modbus03rx.getReg(57);
env_sensor_state.hcho = modbus03rx.getReg(58);
env_sensor_state.light_intensity = uint32_t(modbus03rx.getReg(59)) << 16 | uint32_t(modbus03rx.getReg(60));
logger->debug(
"getEnvSensorState, "
"wind_speed={},wind_direction={},temperature={},humidity={},noise={},pm2_5={},pm10={},co2={},atmospheric_"

3
src/service/device_io_service.hpp

@ -149,6 +149,8 @@ class DeviceIOService : public enable_shared_from_this<DeviceIOService> {
56(16Byte) | PPM
57(16Byte) | tvoc ppm
58(16Byte) | hcho mg/m3
59(16Byte) | light_intensity H
60(16Byte) | light_intensity L
*/
typedef struct {
@ -163,6 +165,7 @@ class DeviceIOService : public enable_shared_from_this<DeviceIOService> {
uint16_t atmospheric_pressure;
uint16_t tvoc;
uint16_t hcho;
uint32_t light_intensity;
} env_sensor_state_t;
virtual env_sensor_state_t getEnvSensorState();

2
src/service/main_control_service.cpp

@ -82,6 +82,7 @@ void MainControlService::processReceiveMessage(fromwhere_t fromwhere, const json
SET_DEVICE_STATE("atmospheric_pressure", env.atmospheric_pressure, "hPa");
SET_DEVICE_STATE("tvoc", env.tvoc, "ppm");
SET_DEVICE_STATE("hcho", env.hcho, "mg/m³");
SET_DEVICE_STATE("light_intensity", env.atmospheric_pressure, "lux");
SET_DEVICE_STATE("InterTemperature", m_deviceIOService->getInterTemperature(), "");
SET_DEVICE_STATE("fan1powerRate", m_deviceIOService->fanGetState(0), "%");
@ -141,6 +142,7 @@ void MainControlService::processReceiveMessage(fromwhere_t fromwhere, const json
receipt["atmospheric_pressure"] = env.atmospheric_pressure;
receipt["tvoc"] = env.tvoc;
receipt["hcho"] = env.hcho;
receipt["light_intensity"] = env.light_intensity;
} else if (in["command"] == "fanGetState") {
// int id = in["id"];
receipt["power"][0] = m_deviceIOService->fanGetState(0);

Loading…
Cancel
Save