priv impl and scaffold for driver
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
/// Generic code for driving a BBNOW interface.
|
||||
|
||||
#ifndef _BBNOW_DRIVER_HPP
|
||||
#define _BBNOW_DRIVER_HPP
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "bb_expantions.hpp"
|
||||
#include "bbnow_pub.hpp"
|
||||
#include "bbnow_priv.hpp"
|
||||
|
||||
class BBNowDriver {
|
||||
public:
|
||||
using MacAddress = std::array<uint8_t, 6>;
|
||||
|
||||
struct PairedExpander {
|
||||
MacAddress mac;
|
||||
std::string name;
|
||||
BlkBoxExpantion type;
|
||||
};
|
||||
|
||||
static constexpr uint8_t DEFAULT_CHANNEL = 6;
|
||||
|
||||
static esp_err_t init();
|
||||
static esp_err_t deinit();
|
||||
|
||||
static esp_err_t send_pub(const BBNowPubPacket& packet);
|
||||
static bool has_pub();
|
||||
static bool recv_pub(BBNowPubPacket& packet);
|
||||
|
||||
static esp_err_t send_priv(
|
||||
const MacAddress& destination,
|
||||
const BBNowPrivPacket& packet
|
||||
);
|
||||
static bool has_priv();
|
||||
static bool recv_priv(
|
||||
MacAddress& source,
|
||||
BBNowPrivPacket& packet
|
||||
);
|
||||
|
||||
/// Broadcast a discovery packet.
|
||||
static size_t send_discovery(
|
||||
BlkBoxExpantion type
|
||||
);
|
||||
|
||||
static esp_err_t pair_expander(
|
||||
BlkBoxExpantion type,
|
||||
const MacAddress& mac
|
||||
);
|
||||
|
||||
static esp_err_t unpair_expander(
|
||||
const MacAddress& mac
|
||||
);
|
||||
|
||||
static std::span<const PairedExpander> get_paired_expanders();
|
||||
|
||||
private:
|
||||
static constexpr MacAddress BROADCAST_MAC = {
|
||||
0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
static bool initialized_;
|
||||
|
||||
static std::vector<PairedExpander> paired_expanders;
|
||||
};
|
||||
|
||||
#endif /* _BBNOW_DRIVER_HPP */
|
||||
Reference in New Issue
Block a user