mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-08 22:52:27 -04:00
BLE Comm WIP (#1578)
* Initial BLE Comm commit. * SCAN_RSP MAC was reversed. * Added Auto Channel Hop. * Improvements to Tx to better handle timers. * Auto channel and more work on timers. * more advertisement numbers.
This commit is contained in:
parent
d2e9a8dc06
commit
8479d2edf0
11 changed files with 697 additions and 82 deletions
|
@ -55,11 +55,42 @@ class BLELoggerTx {
|
|||
|
||||
namespace ui {
|
||||
|
||||
enum PKT_TYPE {
|
||||
PKT_TYPE_INVALID_TYPE,
|
||||
PKT_TYPE_RAW,
|
||||
PKT_TYPE_DISCOVERY,
|
||||
PKT_TYPE_IBEACON,
|
||||
PKT_TYPE_ADV_IND,
|
||||
PKT_TYPE_ADV_DIRECT_IND,
|
||||
PKT_TYPE_ADV_NONCONN_IND,
|
||||
PKT_TYPE_ADV_SCAN_IND,
|
||||
PKT_TYPE_SCAN_REQ,
|
||||
PKT_TYPE_SCAN_RSP,
|
||||
PKT_TYPE_CONNECT_REQ,
|
||||
PKT_TYPE_LL_DATA,
|
||||
PKT_TYPE_LL_CONNECTION_UPDATE_REQ,
|
||||
PKT_TYPE_LL_CHANNEL_MAP_REQ,
|
||||
PKT_TYPE_LL_TERMINATE_IND,
|
||||
PKT_TYPE_LL_ENC_REQ,
|
||||
PKT_TYPE_LL_ENC_RSP,
|
||||
PKT_TYPE_LL_START_ENC_REQ,
|
||||
PKT_TYPE_LL_START_ENC_RSP,
|
||||
PKT_TYPE_LL_UNKNOWN_RSP,
|
||||
PKT_TYPE_LL_FEATURE_REQ,
|
||||
PKT_TYPE_LL_FEATURE_RSP,
|
||||
PKT_TYPE_LL_PAUSE_ENC_REQ,
|
||||
PKT_TYPE_LL_PAUSE_ENC_RSP,
|
||||
PKT_TYPE_LL_VERSION_IND,
|
||||
PKT_TYPE_LL_REJECT_IND,
|
||||
PKT_TYPE_NUM_PKT_TYPE
|
||||
};
|
||||
|
||||
struct BLETxPacket {
|
||||
char macAddress[13];
|
||||
char advertisementData[63];
|
||||
char packetCount[11];
|
||||
uint32_t packet_count;
|
||||
PKT_TYPE packetType;
|
||||
};
|
||||
|
||||
class BLETxView : public View {
|
||||
|
@ -84,6 +115,7 @@ class BLETxView : public View {
|
|||
std::string title() const override { return "BLE TX"; };
|
||||
|
||||
private:
|
||||
void on_timer();
|
||||
void on_data(uint32_t value, bool is_data);
|
||||
void on_file_changed(const std::filesystem::path& new_file_path);
|
||||
void on_save_file(const std::string value);
|
||||
|
@ -105,12 +137,14 @@ class BLETxView : public View {
|
|||
std::filesystem::path file_path{};
|
||||
std::filesystem::path packet_save_path{u"BLETX/BLETX_????.TXT"};
|
||||
uint8_t channel_number = 37;
|
||||
bool auto_channel = false;
|
||||
|
||||
char randomMac[13] = "010203040506";
|
||||
|
||||
bool is_running = false;
|
||||
bool is_sending = false;
|
||||
uint64_t timer_count{0};
|
||||
uint64_t timer_period{256};
|
||||
int16_t timer_period{1};
|
||||
bool repeatLoop = false;
|
||||
uint32_t packet_counter{0};
|
||||
uint32_t num_packets{0};
|
||||
|
@ -118,45 +152,16 @@ class BLETxView : public View {
|
|||
bool random_mac = false;
|
||||
bool file_override = false;
|
||||
|
||||
enum PKT_TYPE {
|
||||
INVALID_TYPE,
|
||||
RAW,
|
||||
DISCOVERY,
|
||||
IBEACON,
|
||||
ADV_IND,
|
||||
ADV_DIRECT_IND,
|
||||
ADV_NONCONN_IND,
|
||||
ADV_SCAN_IND,
|
||||
SCAN_REQ,
|
||||
SCAN_RSP,
|
||||
CONNECT_REQ,
|
||||
LL_DATA,
|
||||
LL_CONNECTION_UPDATE_REQ,
|
||||
LL_CHANNEL_MAP_REQ,
|
||||
LL_TERMINATE_IND,
|
||||
LL_ENC_REQ,
|
||||
LL_ENC_RSP,
|
||||
LL_START_ENC_REQ,
|
||||
LL_START_ENC_RSP,
|
||||
LL_UNKNOWN_RSP,
|
||||
LL_FEATURE_REQ,
|
||||
LL_FEATURE_RSP,
|
||||
LL_PAUSE_ENC_REQ,
|
||||
LL_PAUSE_ENC_RSP,
|
||||
LL_VERSION_IND,
|
||||
LL_REJECT_IND,
|
||||
NUM_PKT_TYPE
|
||||
};
|
||||
|
||||
static constexpr uint8_t mac_address_size_str{12};
|
||||
static constexpr uint8_t max_packet_size_str{62};
|
||||
static constexpr uint8_t max_packet_repeat_str{10};
|
||||
static constexpr uint32_t max_packet_repeat_count{UINT32_MAX};
|
||||
static constexpr uint32_t max_num_packets{32};
|
||||
int16_t mscounter = 0;
|
||||
|
||||
BLETxPacket packets[max_num_packets];
|
||||
|
||||
PKT_TYPE pduType = {DISCOVERY};
|
||||
PKT_TYPE pduType = {PKT_TYPE_DISCOVERY};
|
||||
|
||||
static constexpr auto header_height = 9 * 16;
|
||||
static constexpr auto switch_button_height = 3 * 16;
|
||||
|
@ -204,30 +209,31 @@ class BLETxView : public View {
|
|||
OptionsField options_speed{
|
||||
{7 * 8, 6 * 8},
|
||||
3,
|
||||
{{"1 ", 256},
|
||||
{"2 ", 128},
|
||||
{"3 ", 64},
|
||||
{"4 ", 32},
|
||||
{"5 ", 16}}};
|
||||
{{"1 ", 1}, // 16ms
|
||||
{"2 ", 2}, // 32ms
|
||||
{"3 ", 3}, // 48ms
|
||||
{"4 ", 6}, // 100ms
|
||||
{"5 ", 12}}}; // 200ms
|
||||
|
||||
OptionsField options_channel{
|
||||
{11 * 8, 6 * 8},
|
||||
5,
|
||||
{{"Ch.37 ", 37},
|
||||
{"Ch.38", 38},
|
||||
{"Ch.39", 39}}};
|
||||
{"Ch.39", 39},
|
||||
{"Auto", 40}}};
|
||||
|
||||
OptionsField options_adv_type{
|
||||
{17 * 8, 6 * 8},
|
||||
14,
|
||||
{{"DISCOVERY ", DISCOVERY},
|
||||
{"ADV_IND", ADV_IND},
|
||||
{"ADV_DIRECT", ADV_DIRECT_IND},
|
||||
{"ADV_NONCONN", ADV_NONCONN_IND},
|
||||
{"ADV_SCAN_IND", ADV_SCAN_IND},
|
||||
{"SCAN_REQ", SCAN_REQ},
|
||||
{"SCAN_RSP", SCAN_RSP},
|
||||
{"CONNECT_REQ", CONNECT_REQ}}};
|
||||
{{"DISCOVERY ", PKT_TYPE_DISCOVERY},
|
||||
{"ADV_IND", PKT_TYPE_ADV_IND},
|
||||
{"ADV_DIRECT", PKT_TYPE_ADV_DIRECT_IND},
|
||||
{"ADV_NONCONN", PKT_TYPE_ADV_NONCONN_IND},
|
||||
{"ADV_SCAN_IND", PKT_TYPE_ADV_SCAN_IND},
|
||||
{"SCAN_REQ", PKT_TYPE_SCAN_REQ},
|
||||
{"SCAN_RSP", PKT_TYPE_SCAN_RSP},
|
||||
{"CONNECT_REQ", PKT_TYPE_CONNECT_REQ}}};
|
||||
|
||||
Labels label_packet_index{
|
||||
{{0 * 8, 10 * 8}, "Packet Index:", Color::light_grey()}};
|
||||
|
@ -284,6 +290,12 @@ class BLETxView : public View {
|
|||
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
||||
this->on_tx_progress(message.done);
|
||||
}};
|
||||
|
||||
MessageHandlerRegistration message_handler_frame_sync{
|
||||
Message::ID::DisplayFrameSync,
|
||||
[this](const Message* const) {
|
||||
this->on_timer();
|
||||
}};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue