forked from M-Labs/ionpak-thermostat
Unbreak network configuration page.
This commit is contained in:
parent
2d29078ba1
commit
2bdc483e15
|
@ -4,6 +4,7 @@ use core::cell::RefCell;
|
||||||
use core::str;
|
use core::str;
|
||||||
use cortex_m;
|
use cortex_m;
|
||||||
use cortex_m::interrupt::Mutex;
|
use cortex_m::interrupt::Mutex;
|
||||||
|
use smoltcp::wire::IpCidr;
|
||||||
use smoltcp::socket::TcpSocket;
|
use smoltcp::socket::TcpSocket;
|
||||||
|
|
||||||
use http;
|
use http;
|
||||||
|
@ -96,14 +97,17 @@ pub fn serve(output: &mut TcpSocket, request: &http::Request,
|
||||||
if ip_arg.is_ok() {
|
if ip_arg.is_ok() {
|
||||||
let ip_arg = str::from_utf8(ip_arg.unwrap());
|
let ip_arg = str::from_utf8(ip_arg.unwrap());
|
||||||
if ip_arg.is_ok() {
|
if ip_arg.is_ok() {
|
||||||
let ip = ip_arg.unwrap().parse();
|
let mut ip_arg = ip_arg.unwrap().split("%2F");
|
||||||
if ip.is_ok() {
|
let ip = ip_arg.next().map(|x| x.parse());
|
||||||
let ip = ip.unwrap();
|
let cidr = ip_arg.next().map(|x| x.parse());
|
||||||
|
match (ip, cidr) {
|
||||||
|
(Some(Ok(ip)), Some(Ok(cidr))) => {
|
||||||
status = "IP address has been updated and will be active after a reboot.";
|
status = "IP address has been updated and will be active after a reboot.";
|
||||||
config.ip = ip;
|
config.ip = IpCidr::new(ip, cidr);
|
||||||
config.save();
|
config.save();
|
||||||
} else {
|
}
|
||||||
status = "failed to parse IP address";
|
_ =>
|
||||||
|
status = "failed to parse IP address"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = "IP address contains an invalid UTF-8 character";
|
status = "IP address contains an invalid UTF-8 character";
|
||||||
|
|
Loading…
Reference in New Issue