Merge branch 'feature/enable-mqtt-login' into develop
This commit is contained in:
commit
5bc20d312a
@ -17,6 +17,16 @@ incremental = true
|
|||||||
opt-level = 2
|
opt-level = 2
|
||||||
|
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
# Explicitly disable LTO which the Xtensa codegen backend has issues
|
||||||
|
lto = false
|
||||||
|
strip = true
|
||||||
|
debug = false
|
||||||
|
overflow-checks = false
|
||||||
|
panic = "abort"
|
||||||
|
incremental = true
|
||||||
|
opt-level = "z"
|
||||||
|
|
||||||
[package.metadata.cargo_runner]
|
[package.metadata.cargo_runner]
|
||||||
# The string `$TARGET_FILE` will be replaced with the path from cargo.
|
# The string `$TARGET_FILE` will be replaced with the path from cargo.
|
||||||
command = [
|
command = [
|
||||||
|
@ -11,6 +11,8 @@ pub struct NetworkConfig {
|
|||||||
pub password: Option<heapless::String<64>>,
|
pub password: Option<heapless::String<64>>,
|
||||||
pub mqtt_url: Option<heapless::String<128>>,
|
pub mqtt_url: Option<heapless::String<128>>,
|
||||||
pub base_topic: Option<heapless::String<64>>,
|
pub base_topic: Option<heapless::String<64>>,
|
||||||
|
pub mqtt_user: Option<heapless::String<32>>,
|
||||||
|
pub mqtt_password: Option<heapless::String<64>>,
|
||||||
pub max_wait: u32,
|
pub max_wait: u32,
|
||||||
}
|
}
|
||||||
impl Default for NetworkConfig {
|
impl Default for NetworkConfig {
|
||||||
@ -21,6 +23,8 @@ impl Default for NetworkConfig {
|
|||||||
password: None,
|
password: None,
|
||||||
mqtt_url: None,
|
mqtt_url: None,
|
||||||
base_topic: None,
|
base_topic: None,
|
||||||
|
mqtt_user: None,
|
||||||
|
mqtt_password: None,
|
||||||
max_wait: 10000,
|
max_wait: 10000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,6 +419,8 @@ impl Esp<'_> {
|
|||||||
}),
|
}),
|
||||||
client_id: Some("plantctrl"),
|
client_id: Some("plantctrl"),
|
||||||
keep_alive_interval: Some(Duration::from_secs(60 * 60 * 2)),
|
keep_alive_interval: Some(Duration::from_secs(60 * 60 * 2)),
|
||||||
|
username: network_config.mqtt_user.as_ref().map(|v| &**v),
|
||||||
|
password: network_config.mqtt_password.as_ref().map(|v| &**v),
|
||||||
//room for improvement
|
//room for improvement
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,6 @@ use std::result::Result::Ok as OkStd;
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use esp_idf_hal::can::CAN;
|
use esp_idf_hal::can::CAN;
|
||||||
use esp_idf_hal::pcnt::PCNT1;
|
|
||||||
|
|
||||||
//Only support for 8 right now!
|
//Only support for 8 right now!
|
||||||
pub const PLANT_COUNT: usize = 8;
|
pub const PLANT_COUNT: usize = 8;
|
||||||
@ -114,7 +113,7 @@ pub trait BoardInteraction<'a> {
|
|||||||
|
|
||||||
impl dyn BoardInteraction<'_> {
|
impl dyn BoardInteraction<'_> {
|
||||||
//the counter is just some arbitrary number that increases whenever some progress was made, try to keep the updates < 10 per second for ux reasons
|
//the counter is just some arbitrary number that increases whenever some progress was made, try to keep the updates < 10 per second for ux reasons
|
||||||
fn progress(&mut self, counter: u32) {
|
fn _progress(&mut self, counter: u32) {
|
||||||
let even = counter % 2 == 0;
|
let even = counter % 2 == 0;
|
||||||
let current = counter / (PLANT_COUNT as u32);
|
let current = counter / (PLANT_COUNT as u32);
|
||||||
for led in 0..PLANT_COUNT {
|
for led in 0..PLANT_COUNT {
|
||||||
|
@ -210,7 +210,7 @@ impl<'a> BoardInteraction<'a> for V3<'a> {
|
|||||||
&self.config
|
&self.config
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_battery_monitor(&mut self) -> &mut Box<(dyn BatteryInteraction + Send + 'static)> {
|
fn get_battery_monitor(&mut self) -> &mut Box<dyn BatteryInteraction + Send + 'static> {
|
||||||
&mut self.battery_monitor
|
&mut self.battery_monitor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ use anyhow::bail;
|
|||||||
use embedded_hal::digital::OutputPin;
|
use embedded_hal::digital::OutputPin;
|
||||||
use embedded_hal_bus::i2c::MutexDevice;
|
use embedded_hal_bus::i2c::MutexDevice;
|
||||||
use esp_idf_hal::gpio::{AnyInputPin, IOPin, InputOutput, Output, PinDriver, Pull};
|
use esp_idf_hal::gpio::{AnyInputPin, IOPin, InputOutput, Output, PinDriver, Pull};
|
||||||
use esp_idf_hal::i2c::{I2cDriver, I2cError};
|
use esp_idf_hal::i2c::I2cDriver;
|
||||||
use esp_idf_hal::pcnt::{
|
use esp_idf_hal::pcnt::{
|
||||||
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
|
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
|
||||||
};
|
};
|
||||||
@ -23,12 +23,10 @@ use ina219::calibration::UnCalibrated;
|
|||||||
use ina219::configuration::{Configuration, OperatingMode};
|
use ina219::configuration::{Configuration, OperatingMode};
|
||||||
use ina219::SyncIna219;
|
use ina219::SyncIna219;
|
||||||
use measurements::{Current, Resistance, Voltage};
|
use measurements::{Current, Resistance, Voltage};
|
||||||
use pca9535::{ExpanderError, GPIOBank, Pca9535Immediate, StandardExpanderInterface};
|
use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
|
||||||
use std::result::Result::Ok as OkStd;
|
use std::result::Result::Ok as OkStd;
|
||||||
use embedded_can::nb::Can;
|
|
||||||
use embedded_can::Frame;
|
use embedded_can::Frame;
|
||||||
use embedded_can::StandardId;
|
use embedded_can::StandardId;
|
||||||
use esp_idf_hal::prelude::*;
|
|
||||||
use esp_idf_hal::can;
|
use esp_idf_hal::can;
|
||||||
|
|
||||||
pub enum Charger<'a> {
|
pub enum Charger<'a> {
|
||||||
@ -205,7 +203,7 @@ pub(crate) fn create_v4(
|
|||||||
println!("Can bus mode ");
|
println!("Can bus mode ");
|
||||||
let timing = can::config::Timing::B25K;
|
let timing = can::config::Timing::B25K;
|
||||||
let config = can::config::Config::new().timing(timing);
|
let config = can::config::Config::new().timing(timing);
|
||||||
let mut can = can::CanDriver::new(peripherals.can, peripherals.gpio0, peripherals.gpio2, &config).unwrap();
|
let can = can::CanDriver::new(peripherals.can, peripherals.gpio0, peripherals.gpio2, &config).unwrap();
|
||||||
|
|
||||||
|
|
||||||
let frame = StandardId::new(0x042).unwrap();
|
let frame = StandardId::new(0x042).unwrap();
|
||||||
|
@ -93,14 +93,6 @@ pub struct PumpResult {
|
|||||||
pump_time_s: u16,
|
pump_time_s: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
|
||||||
/// humidity sensor error
|
|
||||||
enum SensorError {
|
|
||||||
Unknown,
|
|
||||||
ShortCircuit { hz: f32, max: f32 },
|
|
||||||
OpenCircuit { hz: f32, min: f32 },
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq)]
|
#[derive(Serialize, Debug, PartialEq)]
|
||||||
enum SntpMode {
|
enum SntpMode {
|
||||||
OFFLINE,
|
OFFLINE,
|
||||||
@ -867,7 +859,7 @@ fn pump_info(
|
|||||||
median_current_ma: u16,
|
median_current_ma: u16,
|
||||||
max_current_ma: u16,
|
max_current_ma: u16,
|
||||||
min_current_ma: u16,
|
min_current_ma: u16,
|
||||||
error: bool,
|
_error: bool,
|
||||||
) {
|
) {
|
||||||
let pump_info = PumpInfo {
|
let pump_info = PumpInfo {
|
||||||
enabled: pump_active,
|
enabled: pump_active,
|
||||||
|
@ -238,7 +238,7 @@ impl PlantState {
|
|||||||
}
|
}
|
||||||
PlantWateringMode::MinMoisture => {
|
PlantWateringMode::MinMoisture => {
|
||||||
let (moisture_percent, _) = self.plant_moisture();
|
let (moisture_percent, _) = self.plant_moisture();
|
||||||
if let Some(moisture_percent) = moisture_percent {
|
if let Some(_moisture_percent) = moisture_percent {
|
||||||
if self.pump_in_timeout(plant_conf, current_time) {
|
if self.pump_in_timeout(plant_conf, current_time) {
|
||||||
false
|
false
|
||||||
} else if !in_time_range(
|
} else if !in_time_range(
|
||||||
@ -247,10 +247,10 @@ impl PlantState {
|
|||||||
plant_conf.pump_hour_end,
|
plant_conf.pump_hour_end,
|
||||||
) {
|
) {
|
||||||
false
|
false
|
||||||
} else if (true) {
|
} else if true {
|
||||||
//if not cooldown min and below max
|
//if not cooldown min and below max
|
||||||
true
|
true
|
||||||
} else if (true) {
|
} else if true {
|
||||||
//if below min disable cooldown min
|
//if below min disable cooldown min
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,6 +29,8 @@ export interface NetworkConfig {
|
|||||||
password: string,
|
password: string,
|
||||||
mqtt_url: string,
|
mqtt_url: string,
|
||||||
base_topic: string,
|
base_topic: string,
|
||||||
|
mqtt_user: string | null,
|
||||||
|
mqtt_password: string | null,
|
||||||
max_wait: number
|
max_wait: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<input class="mqttvalue" type="text" id="base_topic" placeholder="plants/one">
|
<input class="mqttvalue" type="text" id="base_topic" placeholder="plants/one">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flexcontainer">
|
||||||
|
<div class="mqttkey">
|
||||||
|
MQTT User
|
||||||
|
</div>
|
||||||
|
<input class="mqttvalue" type="text" id="mqtt_user" placeholder="">
|
||||||
|
</div>
|
||||||
|
<div class="flexcontainer">
|
||||||
|
<div class="mqttkey">
|
||||||
|
MQTT Password
|
||||||
|
</div>
|
||||||
|
<input class="mqttvalue" type="text" id="mqtt_password" placeholder="">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ export class NetworkConfigView {
|
|||||||
private readonly mqtt_url: HTMLInputElement;
|
private readonly mqtt_url: HTMLInputElement;
|
||||||
private readonly base_topic: HTMLInputElement;
|
private readonly base_topic: HTMLInputElement;
|
||||||
private readonly max_wait: HTMLInputElement;
|
private readonly max_wait: HTMLInputElement;
|
||||||
|
private readonly mqtt_user: HTMLInputElement;
|
||||||
|
private readonly mqtt_password: HTMLInputElement;
|
||||||
private readonly ssidlist: HTMLElement;
|
private readonly ssidlist: HTMLElement;
|
||||||
|
|
||||||
constructor(controller: Controller, publicIp: string) {
|
constructor(controller: Controller, publicIp: string) {
|
||||||
@ -37,6 +39,10 @@ export class NetworkConfigView {
|
|||||||
this.mqtt_url.onchange = controller.configChanged
|
this.mqtt_url.onchange = controller.configChanged
|
||||||
this.base_topic = document.getElementById("base_topic") as HTMLInputElement;
|
this.base_topic = document.getElementById("base_topic") as HTMLInputElement;
|
||||||
this.base_topic.onchange = controller.configChanged
|
this.base_topic.onchange = controller.configChanged
|
||||||
|
this.mqtt_user = document.getElementById("mqtt_user") as HTMLInputElement;
|
||||||
|
this.mqtt_user.onchange = controller.configChanged
|
||||||
|
this.mqtt_password = document.getElementById("mqtt_password") as HTMLInputElement;
|
||||||
|
this.mqtt_password.onchange = controller.configChanged
|
||||||
|
|
||||||
this.ssidlist = document.getElementById("ssidlist") as HTMLElement
|
this.ssidlist = document.getElementById("ssidlist") as HTMLElement
|
||||||
|
|
||||||
@ -52,6 +58,8 @@ export class NetworkConfigView {
|
|||||||
this.password.value = network.password;
|
this.password.value = network.password;
|
||||||
this.mqtt_url.value = network.mqtt_url;
|
this.mqtt_url.value = network.mqtt_url;
|
||||||
this.base_topic.value = network.base_topic;
|
this.base_topic.value = network.base_topic;
|
||||||
|
this.mqtt_user.value = network.mqtt_user ?? "";
|
||||||
|
this.mqtt_password.value = network.mqtt_password ?? "";
|
||||||
this.max_wait.value = network.max_wait.toString();
|
this.max_wait.value = network.max_wait.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +70,8 @@ export class NetworkConfigView {
|
|||||||
ssid: this.ssid.value ?? null,
|
ssid: this.ssid.value ?? null,
|
||||||
password: this.password.value ?? null,
|
password: this.password.value ?? null,
|
||||||
mqtt_url: this.mqtt_url.value ?? null,
|
mqtt_url: this.mqtt_url.value ?? null,
|
||||||
|
mqtt_user: this.mqtt_user.value ? this.mqtt_user.value : null,
|
||||||
|
mqtt_password: this.mqtt_password.value ? this.mqtt_password.value : null,
|
||||||
base_topic: this.base_topic.value ?? null
|
base_topic: this.base_topic.value ?? null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user