mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-08 17:08:28 -04:00
AP_Bootloader: added reboot button
This commit is contained in:
parent
1bee4630cc
commit
29876f649a
@ -16,6 +16,7 @@
|
|||||||
<form action="" method="post" enctype="multipart/form-data">
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
<input type="file" name="fileToUpload" id="fileToUpload">
|
<input type="file" name="fileToUpload" id="fileToUpload">
|
||||||
<input type="submit" value="Upload" name="submit">
|
<input type="submit" value="Upload" name="submit">
|
||||||
|
<input type="button" onclick="location.href='/REBOOT';" value="Reboot" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</BODY>
|
</BODY>
|
||||||
|
@ -467,6 +467,10 @@ void BL_Network::handle_request(SocketAPM *sock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strncmp(headers, "GET /REBOOT", 11) == 0) {
|
||||||
|
need_reboot = true;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
/*
|
/*
|
||||||
we only need one URL in the bootloader
|
we only need one URL in the bootloader
|
||||||
@ -477,9 +481,14 @@ void BL_Network::handle_request(SocketAPM *sock)
|
|||||||
"\r\n";
|
"\r\n";
|
||||||
const auto *msg = AP_ROMFS::find_decompress("index.html", size);
|
const auto *msg = AP_ROMFS::find_decompress("index.html", size);
|
||||||
sock->send(header, strlen(header));
|
sock->send(header, strlen(header));
|
||||||
|
if (need_reboot) {
|
||||||
|
const char *str = "<html><head><meta http-equiv=\"refresh\" content=\"2; url=/\"></head></html>";
|
||||||
|
sock->send(str, strlen(str));
|
||||||
|
} else {
|
||||||
char *msg2 = substitute_vars((const char *)msg, size);
|
char *msg2 = substitute_vars((const char *)msg, size);
|
||||||
sock->send(msg2, strlen(msg2));
|
sock->send(msg2, strlen(msg2));
|
||||||
delete msg2;
|
delete msg2;
|
||||||
|
}
|
||||||
delete headers;
|
delete headers;
|
||||||
AP_ROMFS::free(msg);
|
AP_ROMFS::free(msg);
|
||||||
}
|
}
|
||||||
@ -495,6 +504,10 @@ void BL_Network::web_server(void)
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto *sock = listen_socket->accept(20);
|
auto *sock = listen_socket->accept(20);
|
||||||
|
if (need_reboot) {
|
||||||
|
need_reboot = false;
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
if (sock == nullptr) {
|
if (sock == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,8 @@ private:
|
|||||||
struct {
|
struct {
|
||||||
uint32_t ip, gateway, netmask;
|
uint32_t ip, gateway, netmask;
|
||||||
} addr;
|
} addr;
|
||||||
|
|
||||||
|
bool need_reboot;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AP_BOOTLOADER_NETWORK_ENABLED
|
#endif // AP_BOOTLOADER_NETWORK_ENABLED
|
||||||
|
Loading…
Reference in New Issue
Block a user