/// Generic code for driving a BBNOW interface. #ifndef _BBNOW_DRIVER_HPP #define _BBNOW_DRIVER_HPP #include #include #include #include #include #include "esp_err.h" #include "bb_expantions.hpp" #include "bbnow_pub.hpp" #include "bbnow_priv.hpp" class BBNowDriver { public: using MacAddress = std::array; 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 get_paired_expanders(); private: static constexpr MacAddress BROADCAST_MAC = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static bool initialized_; static std::vector paired_expanders; }; #endif /* _BBNOW_DRIVER_HPP */