Refactor services into classes (#183)

This commit is contained in:
Ken Van Hoeylandt
2025-01-24 18:21:47 +01:00
committed by GitHub
parent bb7e79886f
commit 3be251d8fb
20 changed files with 382 additions and 373 deletions
@@ -137,25 +137,25 @@ int getRssi() {
// endregion Public functions
static void service_start(TT_UNUSED ServiceContext& service) {
tt_check(wifi == nullptr);
wifi = new Wifi();
}
class WifiService final : public Service {
static void service_stop(TT_UNUSED ServiceContext& service) {
tt_check(wifi != nullptr);
delete wifi;
wifi = nullptr;
}
public:
void wifi_main(void*) {
// NO-OP
}
void onStart(TT_UNUSED ServiceContext& service) final {
tt_check(wifi == nullptr);
wifi = new Wifi();
}
void onStop(TT_UNUSED ServiceContext& service) final {
tt_check(wifi != nullptr);
delete wifi;
wifi = nullptr;
}
};
extern const ServiceManifest manifest = {
.id = "Wifi",
.onStart = &service_start,
.onStop = &service_stop
.createService = create<WifiService>
};
} // namespace