mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-04-19 07:51:30 +00:00
Ble tx improvements (#1546)
This commit is contained in:
parent
dceb7255b0
commit
b5c244a09b
@ -187,14 +187,14 @@ void BLETxView::start() {
|
|||||||
// Send first or single packet.
|
// Send first or single packet.
|
||||||
progressbar.set_max(packet_count);
|
progressbar.set_max(packet_count);
|
||||||
button_play.set_bitmap(&bitmap_stop);
|
button_play.set_bitmap(&bitmap_stop);
|
||||||
baseband::set_btletx(channel_number, macAddress, advertisementData);
|
baseband::set_btletx(channel_number, macAddress, advertisementData, pduType);
|
||||||
transmitter_model.enable();
|
transmitter_model.enable();
|
||||||
|
|
||||||
is_running = true;
|
is_running = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Send next packet.
|
// Send next packet.
|
||||||
baseband::set_btletx(channel_number, macAddress, advertisementData);
|
baseband::set_btletx(channel_number, macAddress, advertisementData, pduType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((packet_counter % 10) == 0) {
|
if ((packet_counter % 10) == 0) {
|
||||||
@ -246,6 +246,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
|||||||
&label_speed,
|
&label_speed,
|
||||||
&options_speed,
|
&options_speed,
|
||||||
&options_channel,
|
&options_channel,
|
||||||
|
&options_adv_type,
|
||||||
&label_packets_sent,
|
&label_packets_sent,
|
||||||
&text_packets_sent,
|
&text_packets_sent,
|
||||||
&label_mac_address,
|
&label_mac_address,
|
||||||
@ -268,6 +269,10 @@ BLETxView::BLETxView(NavigationView& nav)
|
|||||||
timer_period = i;
|
timer_period = i;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options_adv_type.on_change = [this](size_t, int32_t i) {
|
||||||
|
pduType = (PKT_TYPE)i;
|
||||||
|
};
|
||||||
|
|
||||||
options_speed.set_selected_index(0);
|
options_speed.set_selected_index(0);
|
||||||
|
|
||||||
button_open.on_select = [this, &nav](Button&) {
|
button_open.on_select = [this, &nav](Button&) {
|
||||||
|
@ -104,11 +104,43 @@ class BLETxView : public View {
|
|||||||
uint32_t packet_count{0};
|
uint32_t packet_count{0};
|
||||||
uint32_t packet_counter{0};
|
uint32_t packet_counter{0};
|
||||||
|
|
||||||
|
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 mac_address_size_str{12};
|
||||||
static constexpr uint8_t max_packet_size_str{62};
|
static constexpr uint8_t max_packet_size_str{62};
|
||||||
static constexpr uint8_t max_packet_count_str{10};
|
static constexpr uint8_t max_packet_count_str{10};
|
||||||
static constexpr uint32_t max_packet_count{UINT32_MAX};
|
static constexpr uint32_t max_packet_count{UINT32_MAX};
|
||||||
|
|
||||||
|
PKT_TYPE pduType = {RAW};
|
||||||
|
|
||||||
static constexpr auto header_height = 8 * 16;
|
static constexpr auto header_height = 8 * 16;
|
||||||
|
|
||||||
Button button_open{
|
Button button_open{
|
||||||
@ -161,6 +193,17 @@ class BLETxView : public View {
|
|||||||
{"Ch.38", 38},
|
{"Ch.38", 38},
|
||||||
{"Ch.39", 39}}};
|
{"Ch.39", 39}}};
|
||||||
|
|
||||||
|
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},
|
||||||
|
{"SCAN_REQ", SCAN_REQ},
|
||||||
|
{"SCAN_RSP", SCAN_RSP},
|
||||||
|
{"CONNECT_REQ", CONNECT_REQ}}};
|
||||||
|
|
||||||
Labels label_packets_sent{
|
Labels label_packets_sent{
|
||||||
{{0 * 8, 10 * 8}, "Packets Left:", Color::light_grey()}};
|
{{0 * 8, 10 * 8}, "Packets Left:", Color::light_grey()}};
|
||||||
|
|
||||||
|
@ -155,11 +155,12 @@ void set_btle(uint8_t channel_number) {
|
|||||||
send_message(&message);
|
send_message(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_btletx(uint8_t channel_number, char* macAddress, char* advertisementData) {
|
void set_btletx(uint8_t channel_number, char* macAddress, char* advertisementData, uint8_t pduType) {
|
||||||
const BTLETxConfigureMessage message{
|
const BTLETxConfigureMessage message{
|
||||||
channel_number,
|
channel_number,
|
||||||
macAddress,
|
macAddress,
|
||||||
advertisementData};
|
advertisementData,
|
||||||
|
pduType};
|
||||||
send_message(&message);
|
send_message(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void set_fsk(const size_t deviation);
|
|||||||
void set_aprs(const uint32_t baudrate);
|
void set_aprs(const uint32_t baudrate);
|
||||||
|
|
||||||
void set_btle(uint8_t channel_number);
|
void set_btle(uint8_t channel_number);
|
||||||
void set_btletx(uint8_t channel_number, char* macAddress, char* advertisementData);
|
void set_btletx(uint8_t channel_number, char* macAddress, char* advertisementData, uint8_t pduType);
|
||||||
|
|
||||||
void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word);
|
void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||||
* Copyright (C) 2016 Furrtek
|
* Copyright (C) 2016 Furrtek
|
||||||
* Copyright (C) TJ Baginski
|
* Copyright (C) 2023 TJ Baginski
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@ -276,7 +276,7 @@ void BTLETxProcessor::fill_adv_pdu_header(PKT_INFO* pkt, int txadd, int rxadd, i
|
|||||||
bit_out[15] = 0;
|
bit_out[15] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BTLETxProcessor::calculate_sample_for_ADV_IND(PKT_INFO* pkt) {
|
int BTLETxProcessor::calculate_sample_for_ADV(PKT_INFO* pkt) {
|
||||||
pkt->num_info_bit = 0;
|
pkt->num_info_bit = 0;
|
||||||
|
|
||||||
// gen preamble and access address
|
// gen preamble and access address
|
||||||
@ -286,7 +286,7 @@ int BTLETxProcessor::calculate_sample_for_ADV_IND(PKT_INFO* pkt) {
|
|||||||
pkt->num_info_bit = pkt->num_info_bit + convert_hex_to_bit((char*)AAValue, pkt->info_bit + pkt->num_info_bit, 0, 4);
|
pkt->num_info_bit = pkt->num_info_bit + convert_hex_to_bit((char*)AAValue, pkt->info_bit + pkt->num_info_bit, 0, 4);
|
||||||
|
|
||||||
// get txadd and rxadd
|
// get txadd and rxadd
|
||||||
int txadd = 1, rxadd = 0;
|
int txadd = 0, rxadd = 0;
|
||||||
|
|
||||||
pkt->num_info_bit = pkt->num_info_bit + 16; // 16 is header length
|
pkt->num_info_bit = pkt->num_info_bit + 16; // 16 is header length
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ int BTLETxProcessor::calculate_sample_from_pkt_type(PKT_INFO* pkt) {
|
|||||||
// Todo: Handle other Enum values.
|
// Todo: Handle other Enum values.
|
||||||
// if (packetType == ADV_IND);
|
// if (packetType == ADV_IND);
|
||||||
|
|
||||||
if (calculate_sample_for_ADV_IND(pkt) == -1) {
|
if (calculate_sample_for_ADV(pkt) == -1) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,6 +376,7 @@ void BTLETxProcessor::on_message(const Message* const message) {
|
|||||||
|
|
||||||
void BTLETxProcessor::configure(const BTLETxConfigureMessage& message) {
|
void BTLETxProcessor::configure(const BTLETxConfigureMessage& message) {
|
||||||
channel_number = message.channel_number;
|
channel_number = message.channel_number;
|
||||||
|
packetType = (PKT_TYPE)message.pduType;
|
||||||
|
|
||||||
memcpy(macAddress, message.macAddress, sizeof(macAddress));
|
memcpy(macAddress, message.macAddress, sizeof(macAddress));
|
||||||
memcpy(advertisementData, message.advertisementData, sizeof(advertisementData));
|
memcpy(advertisementData, message.advertisementData, sizeof(advertisementData));
|
||||||
@ -386,14 +387,6 @@ void BTLETxProcessor::configure(const BTLETxConfigureMessage& message) {
|
|||||||
// Calculates the samples based on the BLE packet data and generates IQ values into an array to be sent out.
|
// Calculates the samples based on the BLE packet data and generates IQ values into an array to be sent out.
|
||||||
calculate_pkt_info(&packets);
|
calculate_pkt_info(&packets);
|
||||||
|
|
||||||
// Todo: determine if we need to copy these values to shared_memory.bb_data.data. I suspect that we might.
|
|
||||||
// I think once we add the UI level, only the generated BLE payload will be sent down. This layer will take care of PHY sample generation
|
|
||||||
// using the bits sent in by the UI level. In short, we will seperate this implementation to the UI level.
|
|
||||||
// memcpy(shared_memory.bb_data.data, (uint8_t *)packets.phy_sample, packets.num_phy_sample);
|
|
||||||
|
|
||||||
// 2 Sample buffers for each IQ data.
|
|
||||||
samples_per_bit = 8;
|
|
||||||
|
|
||||||
#ifdef new_way
|
#ifdef new_way
|
||||||
// This is because each sample contains I and Q, but packet.num_phy_samples just returns the total samples.
|
// This is because each sample contains I and Q, but packet.num_phy_samples just returns the total samples.
|
||||||
length = (uint32_t)(packets.num_phy_sample * 2);
|
length = (uint32_t)(packets.num_phy_sample * 2);
|
||||||
@ -401,10 +394,6 @@ void BTLETxProcessor::configure(const BTLETxConfigureMessage& message) {
|
|||||||
length = (uint32_t)packets.num_phy_bit;
|
length = (uint32_t)packets.num_phy_bit;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 200kHz shift frequency of BLE
|
|
||||||
shift_one = 200000 * (0xFFFFFFFFULL / 4000000);
|
|
||||||
shift_zero = -shift_one;
|
|
||||||
|
|
||||||
// Starting at sample_count 0 since packets.num_phy_sample contains every sample needed to be sent out.
|
// Starting at sample_count 0 since packets.num_phy_sample contains every sample needed to be sent out.
|
||||||
sample_count = 0;
|
sample_count = 0;
|
||||||
progress_count = 0;
|
progress_count = 0;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||||
* Copyright (C) 2016 Furrtek
|
* Copyright (C) 2016 Furrtek
|
||||||
|
* Copyright (C) 2023 TJ Baginski
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@ -99,7 +100,7 @@ class BTLETxProcessor : public BasebandProcessor {
|
|||||||
|
|
||||||
int calculate_pkt_info(PKT_INFO* pkt);
|
int calculate_pkt_info(PKT_INFO* pkt);
|
||||||
int calculate_sample_from_pkt_type(PKT_INFO* pkt);
|
int calculate_sample_from_pkt_type(PKT_INFO* pkt);
|
||||||
int calculate_sample_for_ADV_IND(PKT_INFO* pkt);
|
int calculate_sample_for_ADV(PKT_INFO* pkt);
|
||||||
void fill_adv_pdu_header(PKT_INFO* pkt, int txadd, int rxadd, int payload_len, char* bit_out);
|
void fill_adv_pdu_header(PKT_INFO* pkt, int txadd, int rxadd, int payload_len, char* bit_out);
|
||||||
void crc24_and_scramble_to_gen_phy_bit(char* crc_init_hex, PKT_INFO* pkt);
|
void crc24_and_scramble_to_gen_phy_bit(char* crc_init_hex, PKT_INFO* pkt);
|
||||||
void disp_bit_in_hex(char* bit, int num_bit);
|
void disp_bit_in_hex(char* bit, int num_bit);
|
||||||
|
@ -761,15 +761,18 @@ class BTLETxConfigureMessage : public Message {
|
|||||||
constexpr BTLETxConfigureMessage(
|
constexpr BTLETxConfigureMessage(
|
||||||
const uint8_t channel_number,
|
const uint8_t channel_number,
|
||||||
char* macAddress,
|
char* macAddress,
|
||||||
char* advertisementData)
|
char* advertisementData,
|
||||||
|
const uint8_t pduType)
|
||||||
: Message{ID::BTLETxConfigure},
|
: Message{ID::BTLETxConfigure},
|
||||||
channel_number(channel_number),
|
channel_number(channel_number),
|
||||||
macAddress(macAddress),
|
macAddress(macAddress),
|
||||||
advertisementData(advertisementData) {
|
advertisementData(advertisementData),
|
||||||
|
pduType(pduType) {
|
||||||
}
|
}
|
||||||
const uint8_t channel_number;
|
const uint8_t channel_number;
|
||||||
char* macAddress;
|
char* macAddress;
|
||||||
char* advertisementData;
|
char* advertisementData;
|
||||||
|
const uint8_t pduType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NRFRxConfigureMessage : public Message {
|
class NRFRxConfigureMessage : public Message {
|
||||||
|
1
sdcard/BLETX/Discovery Packet.txt
Normal file
1
sdcard/BLETX/Discovery Packet.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
010203040506 190953445220426c7565746f6f7468204c6f7720456e65726779 1000
|
Loading…
x
Reference in New Issue
Block a user