cmd_handler: Add cmd to get temp adc polling interval
This commit is contained in:
parent
31e108a4b5
commit
51b82e0447
|
@ -17,7 +17,7 @@ use crate::{device::{dfu, hw_rev::HWRev, sys_timer},
|
|||
thermostat::{ad7172::FilterType,
|
||||
pid_state::PidSettings::*,
|
||||
thermostat::{StatusReport as TecStatusReport, TempAdcFilter, Thermostat,
|
||||
ThermostatSettingsSummary}},
|
||||
ThermostatSettingsSummary, Time}},
|
||||
DeviceSettings, IpSettings, State};
|
||||
|
||||
#[derive(Deserialize, Serialize, Copy, Clone, Default, Debug)]
|
||||
|
@ -27,6 +27,7 @@ pub enum ResponseEnum {
|
|||
Settings,
|
||||
Report,
|
||||
HwRev,
|
||||
Interval,
|
||||
Acknowledge,
|
||||
InvalidDatatype,
|
||||
InvalidSettings,
|
||||
|
@ -119,6 +120,7 @@ enum ThermostatCmdEnum {
|
|||
SetPidUpdateInterval, // Update Interval is set based on the sampling rate of ADC
|
||||
// Temperature ADC
|
||||
ConfigTempAdcFilter,
|
||||
GetPollInterval,
|
||||
// TempMon
|
||||
SetTempMonUpperLimit,
|
||||
SetTempMonLowerLimit,
|
||||
|
@ -181,6 +183,17 @@ pub struct SettingsSummaryObj {
|
|||
json: SettingsSummary,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
||||
pub struct IntervalType {
|
||||
msg_type: ResponseEnum,
|
||||
interval: Time,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
||||
pub struct IntervalObj {
|
||||
json: IntervalType,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
||||
pub struct HwRevType {
|
||||
msg_type: ResponseEnum,
|
||||
|
@ -258,6 +271,20 @@ pub fn send_hw_rev(buffer: &mut [u8], hw_rev_o: &mut HWRev, socket: &mut SocketH
|
|||
num_bytes += 1;
|
||||
net::eth_send(buffer, num_bytes, *socket);
|
||||
}
|
||||
|
||||
pub fn send_interval(buffer: &mut [u8], interval: Time, socket: &mut SocketHandle) {
|
||||
let hw_rev = IntervalObj {
|
||||
json: IntervalType {
|
||||
msg_type: ResponseEnum::Interval,
|
||||
interval: interval,
|
||||
},
|
||||
};
|
||||
let mut num_bytes = hw_rev.get_json("/json", buffer).unwrap();
|
||||
buffer[num_bytes] = b'\n';
|
||||
num_bytes += 1;
|
||||
net::eth_send(buffer, num_bytes, *socket);
|
||||
}
|
||||
|
||||
// Use a minimal struct for high speed cmd ctrl to reduce processing overhead
|
||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Default, Tree)]
|
||||
pub struct TecSetICmdJson {
|
||||
|
@ -777,6 +804,9 @@ pub fn execute_cmd(
|
|||
);
|
||||
}
|
||||
},
|
||||
Some(ThermostatCmdEnum::GetPollInterval) => {
|
||||
send_interval(buffer, thermostat.get_poll_interval(), socket)
|
||||
}
|
||||
Some(ThermostatCmdEnum::SetTempMonUpperLimit) => match cmd.json.data_f32 {
|
||||
Some(val) => {
|
||||
send_response(buffer, ResponseEnum::Acknowledge, None, socket);
|
||||
|
|
Loading…
Reference in New Issue