mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
Our esp32 consistently dropped the last few packets of the TCP transfer in the old implementation. Only about 1/5 transfers would complete. I've refactored that entire system into an actual Calibre Device Plugin that basically uses the exact same system as the web server's file transfer protocol. I kept them separate so that we don't muddy up the existing file transfer stuff even if it's basically the same at the end of the day I didn't want to limit our ability to change it later. I've also added basic auth to OPDS and renamed that feature to OPDS Browser to just disassociate it from Calibre. --------- Co-authored-by: Arthur Tazhitdinov <lisnake@gmail.com> Co-authored-by: Dave Allie <dave@daveallie.com>
43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
#pragma once
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include <freertos/task.h>
|
|
|
|
#include <functional>
|
|
|
|
#include "../Activity.h"
|
|
|
|
// Enum for network mode selection
|
|
enum class NetworkMode { JOIN_NETWORK, CONNECT_CALIBRE, CREATE_HOTSPOT };
|
|
|
|
/**
|
|
* NetworkModeSelectionActivity presents the user with a choice:
|
|
* - "Join a Network" - Connect to an existing WiFi network (STA mode)
|
|
* - "Connect to Calibre" - Use Calibre wireless device transfers
|
|
* - "Create Hotspot" - Create an Access Point that others can connect to (AP mode)
|
|
*
|
|
* The onModeSelected callback is called with the user's choice.
|
|
* The onCancel callback is called if the user presses back.
|
|
*/
|
|
class NetworkModeSelectionActivity final : public Activity {
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
|
SemaphoreHandle_t renderingMutex = nullptr;
|
|
int selectedIndex = 0;
|
|
bool updateRequired = false;
|
|
const std::function<void(NetworkMode)> onModeSelected;
|
|
const std::function<void()> onCancel;
|
|
|
|
static void taskTrampoline(void* param);
|
|
[[noreturn]] void displayTaskLoop();
|
|
void render() const;
|
|
|
|
public:
|
|
explicit NetworkModeSelectionActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
|
const std::function<void(NetworkMode)>& onModeSelected,
|
|
const std::function<void()>& onCancel)
|
|
: Activity("NetworkModeSelection", renderer, mappedInput), onModeSelected(onModeSelected), onCancel(onCancel) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
};
|