43 SUB_NUMBER(motion_on_hits)
44 SUB_NUMBER(motion_off_hits)
47 SUB_SELECT(traffic_mode)
48 SUB_SELECT(detection_algorithm)
49 SUB_SELECT(csi_sample_spacing)
56 void setup()
override;
58 void dump_config()
override;
59 void on_shutdown()
override;
63 void set_detection_algorithm(::espectre::DetectionAlgorithm
value) {
64 this->runtime_.config().detection_algorithm =
value;
66 void set_csi_capture_profile(::espectre::CsiCapturePolicy
value) {
67 this->runtime_.config().csi_capture_policy =
value;
69 void set_traffic_generator_mode(::espectre::TrafficGeneratorMode
value) {
70 this->runtime_.config().traffic_generator_mode =
value;
72 void set_traffic_generator_target_ip(
const std::string &
value) {
73 this->runtime_.config().traffic_generator_target_ip =
value;
75 void set_traffic_generator_target_mac(
const std::string &
value) {
76 this->runtime_.config().traffic_generator_target_mac =
value;
78 void set_csi_sample_spacing(::espectre::TemporalCsiSpacing
value) {
79 this->runtime_.config().csi_sample_spacing =
value;
81 void set_csi_traffic_multicast_group(
const std::string &
value) {
82 this->runtime_.config().csi_traffic_multicast_group =
value;
84 void set_motion_on_hits(uint8_t
value) { this->runtime_.config().motion_on_hits =
value; }
85 void set_motion_off_hits(uint8_t
value) { this->runtime_.config().motion_off_hits =
value; }
86 void set_window_size_ms(
uint32_t value) { this->runtime_.config().window_size_ms =
value; }
87 void set_csi_target_pps(
uint32_t value) { this->runtime_.config().csi_target_pps =
value; }
88 void set_evaluation_interval_ms(
uint32_t value) { this->runtime_.config().evaluation_interval_ms =
value; }
89 void set_lowpass_enabled(
bool value) { this->runtime_.config().lowpass_enabled =
value; }
90 void set_lowpass_cutoff(
float value) { this->runtime_.config().lowpass_cutoff =
value; }
91 void set_hampel_enabled(
bool value) { this->runtime_.config().hampel_enabled =
value; }
92 void set_hampel_window(uint8_t
value) { this->runtime_.config().hampel_window =
value; }
93 void set_hampel_threshold(
float value) { this->runtime_.config().hampel_threshold =
value; }
94 void set_wifi_band_policy(::espectre::WifiBandPolicy
value) { this->runtime_.config().wifi_band_policy =
value; }
96 void recalibrate() { this->recalibrate_pending_ =
true; }
98 void request_threshold(
float value) { this->pending_threshold_ =
value; }
99 void request_motion_on_hits(
float value) { this->pending_motion_on_hits_ =
static_cast<uint8_t
>(std::lround(
value)); }
100 void request_motion_off_hits(
float value) {
101 this->pending_motion_off_hits_ =
static_cast<uint8_t
>(std::lround(
value));
105 void request_traffic_generator_mode(::espectre::TrafficGeneratorMode
mode) { this->pending_traffic_mode_ =
mode; }
107 void request_traffic_generator_mode(
const char *name);
109 void request_detection_algorithm(
const char *name);
111 void request_csi_sample_spacing(
const char *name);
114 void request_sensing(
bool enabled) { this->pending_sensing_ = enabled; }
116#ifdef USE_ESPECTRE_TARGET_MAC_TEXT
117 void set_target_mac_text(
text::Text *text) { this->target_mac_text_ = text; }
119 void request_traffic_generator_target_mac(
const std::string &target);
122#ifdef USE_BINARY_SENSOR
123 SUB_BINARY_SENSOR(motion)
124 SUB_BINARY_SENSOR(calibrating)
130 const ::espectre::RuntimeDiagnosticsSample *diagnostics_sample()
const {
return this->runtime_.diagnostics_sample(); }
134 void on_live_telemetry(const ::espectre::RuntimeSnapshot &snapshot)
override { this->movement_pending_ =
true; }
135 void on_calibration_finished(const ::espectre::RuntimeSnapshot &snapshot,
bool success)
override;
136 void on_runtime_fault(
const char *
message)
override;
137 void start_runtime_();
138 void schedule_restart_();
139 void invalidate_sensing_();
142 void apply_pending_traffic_mode_();
143 void publish_traffic_mode_();
146 void restore_controls_();
147 void apply_pending_controls_();
148 void publish_controls_();
150 static constexpr uint32_t RESTART_DELAY_MS = 30000;
152 ::espectre::RuntimeFrontendController runtime_;
157 float pending_threshold_{NAN};
159 uint8_t pending_motion_on_hits_{0};
160 uint8_t pending_motion_off_hits_{0};
166 optional<::espectre::TrafficGeneratorMode> pending_traffic_mode_;
167 optional<::espectre::DetectionAlgorithm> pending_detection_algorithm_;
168 optional<::espectre::TemporalCsiSpacing> pending_csi_sample_spacing_;
171 optional<bool> pending_sensing_;
173#ifdef USE_ESPECTRE_TARGET_MAC_TEXT
174 void restore_target_mac_();
178 bool target_mac_pending_{
false};
180 bool recalibrate_pending_{
false};
181 bool movement_pending_{
false};
183 bool motion_state_{
false};
184 bool calibrating_state_{
false};
185 bool calibrating_published_{
false};
186 bool runtime_fault_{
false};
187 bool running_{
false};
188 bool restart_pending_{
false};
189 bool calibrated_{
false};
190 bool roaming_suppressed_{
false};
Base-class for all text inputs.