61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
//
|
|
// Created by erki on 13.07.22.
|
|
//
|
|
|
|
#ifndef SKL_TUNNEL_APP_TRANSPARENT_CLIENT_HPP
|
|
#define SKL_TUNNEL_APP_TRANSPARENT_CLIENT_HPP
|
|
|
|
#include <optional>
|
|
#include <utility_function.hpp>
|
|
|
|
#include "app_settings.hpp"
|
|
#include "radio_interrupts.hpp"
|
|
|
|
namespace radio
|
|
{
|
|
class HwInstance;
|
|
}
|
|
|
|
namespace App
|
|
{
|
|
|
|
class TransparentClient
|
|
{
|
|
public:
|
|
TransparentClient(const RadioSettings& initial_settings);
|
|
|
|
TransparentClient(const TransparentClient&) = delete;
|
|
TransparentClient(TransparentClient&&) = delete;
|
|
TransparentClient& operator=(const TransparentClient&) = delete;
|
|
TransparentClient& operator=(TransparentClient&&) = delete;
|
|
|
|
void apply_settings(const RadioSettings& settings);
|
|
void process();
|
|
private:
|
|
radio::HwInstance* m_radio;
|
|
Utility::FunctionOwned<TransparentClient, void (radio::HwInstance*)> m_isr_cb_pointer;
|
|
std::optional<radio::Interrupts> m_pending_irqs = std::nullopt;
|
|
|
|
enum class AppState
|
|
{
|
|
STARTUP,
|
|
PASSIVE,
|
|
ACTIVE_RX,
|
|
ACTIVE_TX,
|
|
RX_FRAME_READY
|
|
};
|
|
|
|
AppState m_state = AppState::STARTUP;
|
|
|
|
void m_cbRadioIrqHandler(radio::HwInstance*);
|
|
std::optional<AppState> m_hwInterruptToNewState();
|
|
void m_transitionToState(const AppState& new_state);
|
|
void m_processState();
|
|
void m_initiateTx();
|
|
bool m_txBufferIsReady();
|
|
};
|
|
|
|
}
|
|
|
|
#endif //SKL_TUNNEL_APP_TRANSPARENT_CLIENT_HPP
|