diff --git a/src/service/device_io_service.cpp b/src/service/device_io_service.cpp index 35ecd00..a0426e3 100644 --- a/src/service/device_io_service.cpp +++ b/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_" diff --git a/src/service/device_io_service.hpp b/src/service/device_io_service.hpp index 8374fa2..c007865 100644 --- a/src/service/device_io_service.hpp +++ b/src/service/device_io_service.hpp @@ -149,6 +149,8 @@ class DeviceIOService : public enable_shared_from_this { 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 { uint16_t atmospheric_pressure; uint16_t tvoc; uint16_t hcho; + uint32_t light_intensity; } env_sensor_state_t; virtual env_sensor_state_t getEnvSensorState(); diff --git a/src/service/main_control_service.cpp b/src/service/main_control_service.cpp index e66d345..f4143b7 100644 --- a/src/service/main_control_service.cpp +++ b/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);