49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "activities/Activity.h"
|
|
#include "network/CrossPointWebServer.h"
|
|
|
|
enum class CalibreConnectState { WIFI_SELECTION, SERVER_STARTING, SERVER_RUNNING, ERROR };
|
|
|
|
/**
|
|
* CalibreConnectActivity starts the file transfer server in STA mode,
|
|
* but renders Calibre-specific instructions instead of the web transfer UI.
|
|
*/
|
|
class CalibreConnectActivity final : public Activity {
|
|
CalibreConnectState state = CalibreConnectState::WIFI_SELECTION;
|
|
|
|
std::unique_ptr<CrossPointWebServer> webServer;
|
|
std::string connectedIP;
|
|
std::string connectedSSID;
|
|
unsigned long lastHandleClientTime = 0;
|
|
size_t lastProgressReceived = 0;
|
|
size_t lastProgressTotal = 0;
|
|
std::string currentUploadName;
|
|
std::string lastCompleteName;
|
|
unsigned long lastCompleteAt = 0;
|
|
unsigned long lastProcessedCompleteAt = 0; // Track which server value we've already processed
|
|
int currentRssi = 0;
|
|
unsigned long lastRssiUpdateTime = 0;
|
|
bool exitRequested = false;
|
|
|
|
void renderServerRunning() const;
|
|
|
|
void onWifiSelectionComplete(bool connected);
|
|
void startWebServer();
|
|
void stopWebServer();
|
|
|
|
public:
|
|
explicit CalibreConnectActivity(GfxRenderer& renderer, MappedInputManager& mappedInput)
|
|
: Activity("CalibreConnect", renderer, mappedInput) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
void render(RenderLock&&) override;
|
|
bool skipLoopDelay() override { return webServer && webServer->isRunning(); }
|
|
bool preventAutoSleep() override { return webServer && webServer->isRunning(); }
|
|
};
|