Add raspbian reboot and shutdown behavior

This commit is contained in:
Jonathan Bennett 2023-12-14 19:53:42 -06:00
parent ded1cbf4dd
commit 6c1db94ae7
6 changed files with 25 additions and 4 deletions

View File

@ -1,6 +1,6 @@
; The Portduino based sim environment on top of any host OS, all hardware will be simulated
[portduino_base]
platform = https://github.com/meshtastic/platform-native.git#ff5da1d203b5c1163cfcda858d5f84920187f030
platform = https://github.com/meshtastic/platform-native.git#8a66ef82cf38a4135d85cbb5043d0e8ebbb8ba17
framework = arduino
build_src_filter =

View File

@ -23,6 +23,11 @@ LinuxInput::LinuxInput(const char *name) : concurrency::OSThread(name)
this->_originName = name;
}
void LinuxInput::deInit()
{
close(fd);
}
int32_t LinuxInput::runOnce()
{

View File

@ -21,6 +21,7 @@ class LinuxInput : public Observable<const InputEvent *>, public concurrency::OS
{
public:
explicit LinuxInput(const char *name);
void deInit(); // Strictly for cleanly "rebooting" the binary on native
protected:
virtual int32_t runOnce() override;

View File

@ -15,6 +15,10 @@ void initApiServer(int port)
apiPort->init();
}
}
void deInitApiServer()
{
delete apiPort;
}
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : ServerAPI(_client)
{

View File

@ -23,3 +23,4 @@ class WiFiServerPort : public APIServerPort<WiFiServerAPI, WiFiServer>
};
void initApiServer(int port = 4403);
void deInitApiServer();

View File

@ -1,6 +1,8 @@
#include "api/WiFiServerAPI.h"
#include "buzz.h"
#include "configuration.h"
#include "graphics/Screen.h"
#include "input/LinuxInputImpl.h"
#include "main.h"
#include "power.h"
@ -15,7 +17,13 @@ void powerCommandsCheck()
#elif defined(ARCH_RP2040)
rp2040.reboot();
#elif defined(ARCH_RASPBERRY_PI)
exit(EXIT_SUCCESS);
deInitApiServer();
if (aLinuxInputImpl)
aLinuxInputImpl->deInit();
SPI.end();
Wire.end();
Serial1.end();
reboot();
#else
rebootAtMsec = -1;
LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied.\n");
@ -33,6 +41,8 @@ void powerCommandsCheck()
#if defined(ARCH_NRF52) || defined(ARCH_ESP32)
playShutdownMelody();
power->shutdown();
#elif ARCH_RASPBERRY_PI
exit(EXIT_SUCCESS);
#else
LOG_WARN("FIXME implement shutdown for this platform");
#endif