fix upload

# Conflicts:
#	rust/src/webserver/webserver.rs
This commit is contained in:
Empire 2024-08-12 21:17:16 +02:00
parent ca26f090fa
commit 7415e74643
4 changed files with 23 additions and 22 deletions

View File

@ -16460,16 +16460,6 @@
) )
(uuid "234f63f9-9a2c-4be4-959e-c63254bdf769") (uuid "234f63f9-9a2c-4be4-959e-c63254bdf769")
) )
(text "All NPN are wrongly pined for common types!\n"
(exclude_from_sim no)
(at 508.508 215.646 0)
(effects
(font
(size 15 15)
)
)
(uuid "2d9b22f8-0267-40d2-b6ee-41daff296e78")
)
(text "ESP32" (text "ESP32"
(exclude_from_sim no) (exclude_from_sim no)
(at 81.28 30.734 0) (at 81.28 30.734 0)
@ -16524,6 +16514,16 @@
) )
(uuid "491f884a-ca01-4332-91f5-1fdea04f1b4a") (uuid "491f884a-ca01-4332-91f5-1fdea04f1b4a")
) )
(text "Change is solar pin? USB boot mode"
(exclude_from_sim no)
(at 286.766 551.688 0)
(effects
(font
(size 5 5)
)
)
(uuid "4ef2c8f1-2d7a-4d3c-a869-fae9e17e4c52")
)
(text "Low Power supply" (text "Low Power supply"
(exclude_from_sim no) (exclude_from_sim no)
(at 140.97 182.88 0) (at 140.97 182.88 0)

View File

@ -1078,7 +1078,7 @@ impl CreatePlantHal<'_> for PlantHal {
let config = I2cConfig::new() let config = I2cConfig::new()
.scl_enable_pullup(true) .scl_enable_pullup(true)
.sda_enable_pullup(true) .sda_enable_pullup(true)
.baudrate(1_u32.kHz().into()) .baudrate(400_u32.kHz().into())
.timeout(APBTickType::from(Duration::from_millis(100))); .timeout(APBTickType::from(Duration::from_millis(100)));
let scl = peripherals.pins.gpio19.downgrade(); let scl = peripherals.pins.gpio19.downgrade();
let sda = peripherals.pins.gpio20.downgrade(); let sda = peripherals.pins.gpio20.downgrade();

View File

@ -295,7 +295,7 @@ pub fn shared() -> Box<EspHttpServer<'static>> {
server server
.fn_handler("/flashbattery", Method::Post, move |mut request| { .fn_handler("/flashbattery", Method::Post, move |mut request| {
let mut board = BOARD_ACCESS.lock().unwrap(); let mut board = BOARD_ACCESS.lock().unwrap();
let mut buffer: [u8; 32] = [0; 32]; let mut buffer: [u8; 128] = [0; 128];
let mut line_buffer: VecDeque<u8> = VecDeque::new(); let mut line_buffer: VecDeque<u8> = VecDeque::new();
let is_dry_run = !request.uri().ends_with("?flash=true"); let is_dry_run = !request.uri().ends_with("?flash=true");
@ -307,7 +307,6 @@ pub fn shared() -> Box<EspHttpServer<'static>> {
delay.delay_us(2); delay.delay_us(2);
let read = request.read(&mut buffer).unwrap(); let read = request.read(&mut buffer).unwrap();
total_read += read; total_read += read;
println!("received {read} bytes ota {total_read}");
if read == 0 { if read == 0 {
if line_buffer.len() > 0 { if line_buffer.len() > 0 {
println!("No further body but no endline"); println!("No further body but no endline");
@ -323,29 +322,28 @@ pub fn shared() -> Box<EspHttpServer<'static>> {
break; break;
} }
let to_write = &buffer[0..read]; let to_write = &buffer[0..read];
line_buffer.write_all(to_write).unwrap(); line_buffer.write_all(to_write).unwrap();
println!("Write to deque new lenght is {}", line_buffer.len());
board.general_fault(toggle); board.general_fault(toggle);
toggle = !toggle; toggle = !toggle;
println!("Updated btn");
loop { loop {
println!("Check for line");
let has_line = line_buffer.contains(&b'\n'); let has_line = line_buffer.contains(&b'\n');
if has_line { if !has_line {
println!("Was no line no string read");
break; break;
} }
let mut line = std::string::String::new(); let mut line = std::string::String::new();
let line_size = line_buffer.read_line(&mut line)?; line_buffer.read_line(&mut line)?;
println!("Processing line with size {} {}", line_size, line); let line2 = &line[0..line.len()-1];
let validate = board.flash_bq34_z100(&line, is_dry_run); println!("Processing dry:{} line {}", is_dry_run, line2);
let validate = board.flash_bq34_z100(&line2, is_dry_run);
delay.delay_us(2); delay.delay_us(2);
if validate.is_err() { if validate.is_err() {
let mut response = request.into_status_response(400_u16).unwrap(); let mut response = request.into_status_response(400_u16).unwrap();
let err = validate.unwrap_err(); let err = validate.unwrap_err();
let err_str = err.to_string(); let err_str = err.to_string();
let err_msg = err_str.as_bytes(); let err_msg = err_str.as_bytes();
println!("Error writing {}", err_str);
response response
.write(err_msg) .write(err_msg)
.unwrap(); .unwrap();

View File

@ -33,6 +33,9 @@ ajax.addEventListener("abort", () => {
battery_flash_button.onclick = async function (){ battery_flash_button.onclick = async function (){
ajax.open("POST", "/flashbattery"); //ajax.open("POST", "/flashbattery");
//ajax.send(battery_flash_file.files[0]);
ajax.open("POST", "/flashbattery?flash=true");
ajax.send(battery_flash_file.files[0]); ajax.send(battery_flash_file.files[0]);
}; };