67 lines
1.6 KiB
C++
67 lines
1.6 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"
|
|
#include "radio_protocol_frame.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;
|
|
RadioSettings m_active_settings;
|
|
std::optional<radio::Interrupts> m_pending_irqs = std::nullopt;
|
|
std::optional<radio::protocol::FrameStructure> m_tx_buffer_frame = std::nullopt;
|
|
std::array<std::uint8_t, 128> m_tx_buffer_raw;
|
|
|
|
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();
|
|
|
|
void m_prepareTransmission(const std::uint16_t dst_mac, const std::array<std::uint8_t, 22>& buffer);
|
|
};
|
|
|
|
}
|
|
|
|
#endif //SKL_TUNNEL_APP_TRANSPARENT_CLIENT_HPP
|