mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Jammer ramp mode
Jammer range splitting, hopping. Only 1MHz wide splits for now.
This commit is contained in:
parent
66de53744e
commit
bcbad4629f
@ -535,6 +535,11 @@ int main(void) {
|
|||||||
const auto message = static_cast<const TXDoneMessage*>(p);
|
const auto message = static_cast<const TXDoneMessage*>(p);
|
||||||
(void)message;
|
(void)message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
context.message_map[Message::ID::Retune] = [](const Message* const p) {
|
||||||
|
const auto message = static_cast<const RetuneMessage*>(p);
|
||||||
|
(void)message;
|
||||||
|
};
|
||||||
|
|
||||||
EventDispatcher event_dispatcher { &system_view, painter, context };
|
EventDispatcher event_dispatcher { &system_view, painter, context };
|
||||||
|
|
||||||
|
@ -98,13 +98,31 @@ void JammerView::updfreq(uint8_t id, rf::Frequency f) {
|
|||||||
std::string bw;
|
std::string bw;
|
||||||
|
|
||||||
for (c = 0; c < 3; c++) {
|
for (c = 0; c < 3; c++) {
|
||||||
if (c == 0) center = (range1_min + range1_max) / 2;
|
if (c == 0) {
|
||||||
if (c == 1) center = (range2_min + range2_max) / 2;
|
center = (range1_min + range1_max) / 2;
|
||||||
if (c == 2) center = (range3_min + range3_max) / 2;
|
range1_center = center;
|
||||||
|
}
|
||||||
|
if (c == 1) {
|
||||||
|
center = (range2_min + range2_max) / 2;
|
||||||
|
range2_center = center;
|
||||||
|
}
|
||||||
|
if (c == 2) {
|
||||||
|
center = (range3_min + range3_max) / 2;
|
||||||
|
range3_center = center;
|
||||||
|
}
|
||||||
|
|
||||||
if (c == 0) bw = to_string_dec_int(abs(range1_max - range1_min) / 1000, 5);
|
if (c == 0) {
|
||||||
if (c == 1) bw = to_string_dec_int(abs(range2_max - range2_min) / 1000, 5);
|
range1_width = abs(range1_max - range1_min) / 1000;
|
||||||
if (c == 2) bw = to_string_dec_int(abs(range3_max - range3_min) / 1000, 5);
|
bw = to_string_dec_int(range1_width, 5);
|
||||||
|
}
|
||||||
|
if (c == 1) {
|
||||||
|
range2_width = abs(range2_max - range2_min) / 1000;
|
||||||
|
bw = to_string_dec_int(range2_width, 5);
|
||||||
|
}
|
||||||
|
if (c == 2) {
|
||||||
|
range3_width = abs(range3_max - range3_min) / 1000;
|
||||||
|
bw = to_string_dec_int(range3_width, 5);
|
||||||
|
}
|
||||||
|
|
||||||
auto center_mhz = to_string_dec_int(center / 1000000, 4);
|
auto center_mhz = to_string_dec_int(center / 1000000, 4);
|
||||||
auto center_hz100 = to_string_dec_int((center / 100) % 10000, 4, '0');
|
auto center_hz100 = to_string_dec_int((center / 100) % 10000, 4, '0');
|
||||||
@ -132,6 +150,7 @@ JammerView::JammerView(
|
|||||||
TransmitterModel& transmitter_model
|
TransmitterModel& transmitter_model
|
||||||
) : transmitter_model(transmitter_model)
|
) : transmitter_model(transmitter_model)
|
||||||
{
|
{
|
||||||
|
|
||||||
static constexpr Style style_val {
|
static constexpr Style style_val {
|
||||||
.font = font::fixed_8x16,
|
.font = font::fixed_8x16,
|
||||||
.background = Color::green(),
|
.background = Color::green(),
|
||||||
@ -151,7 +170,6 @@ JammerView::JammerView(
|
|||||||
};
|
};
|
||||||
|
|
||||||
transmitter_model.set_modulation(18);
|
transmitter_model.set_modulation(18);
|
||||||
transmitter_model.set_tuning_frequency(persistent_memory::tuned_frequency());
|
|
||||||
|
|
||||||
add_children({ {
|
add_children({ {
|
||||||
&text_type,
|
&text_type,
|
||||||
@ -211,24 +229,45 @@ JammerView::JammerView(
|
|||||||
nav.push(new_view);
|
nav.push(new_view);
|
||||||
};
|
};
|
||||||
|
|
||||||
button_transmit.on_select = [this,&transmitter_model](Button&){
|
button_transmit.on_select = [this,&transmitter_model](Button&) {
|
||||||
/*uint16_t c;
|
uint8_t i = 0;
|
||||||
ui::Context context;
|
rf::Frequency t, range_lower;
|
||||||
|
|
||||||
make_frame();
|
context().message_map[Message::ID::Retune] = [this, &transmitter_model](const Message* const p) {
|
||||||
|
const auto message = static_cast<const RetuneMessage*>(p);
|
||||||
shared_memory.afsk_samples_per_bit = 228000/persistent_memory::afsk_bitrate();
|
if (message->freq > 0) {
|
||||||
shared_memory.afsk_phase_inc_mark = persistent_memory::afsk_mark_freq()*(65536*1024)/2280;
|
transmitter_model.set_tuning_frequency(message->freq);
|
||||||
shared_memory.afsk_phase_inc_space = persistent_memory::afsk_space_freq()*(65536*1024)/2280;
|
}
|
||||||
|
};
|
||||||
for (c = 0; c < 256; c++) {
|
|
||||||
shared_memory.lcrdata[c] = this->lcrframe[c];
|
for (i = 0; i < 16; i++) {
|
||||||
|
shared_memory.jammer_ranges[i].active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_memory.afsk_transmit_done = false;
|
if (range1_min > range1_max) {
|
||||||
shared_memory.afsk_repeat = 5; // DEFAULT
|
t = range1_min;
|
||||||
|
range1_min = range1_max;
|
||||||
text_status.set("Send...");*/
|
range1_max = t;
|
||||||
|
}
|
||||||
|
range_lower = range1_min;
|
||||||
|
for (i = 0;;) {
|
||||||
|
if (range1_max - range_lower > 1000000) {
|
||||||
|
shared_memory.jammer_ranges[i].center = range_lower + (1000000/2);
|
||||||
|
shared_memory.jammer_ranges[i].width = 1000000 / 10;
|
||||||
|
shared_memory.jammer_ranges[i].active = true;
|
||||||
|
shared_memory.jammer_ranges[i].duration = 2280000/10;
|
||||||
|
range_lower += 1000000;
|
||||||
|
} else {
|
||||||
|
shared_memory.jammer_ranges[i].center = (range1_max + range_lower) / 2;
|
||||||
|
shared_memory.jammer_ranges[i].width = (range1_max - range_lower) / 10;
|
||||||
|
shared_memory.jammer_ranges[i].active = true;
|
||||||
|
shared_memory.jammer_ranges[i].duration = 2280000/10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
transmitter_model.set_tuning_frequency(shared_memory.jammer_ranges[0].center);
|
||||||
|
|
||||||
if (jamming == true) {
|
if (jamming == true) {
|
||||||
jamming = false;
|
jamming = false;
|
||||||
|
@ -51,13 +51,20 @@ private:
|
|||||||
rf::Frequency range3_min;
|
rf::Frequency range3_min;
|
||||||
rf::Frequency range3_max;
|
rf::Frequency range3_max;
|
||||||
|
|
||||||
|
rf::Frequency range1_center;
|
||||||
|
rf::Frequency range1_width;
|
||||||
|
rf::Frequency range2_center;
|
||||||
|
rf::Frequency range2_width;
|
||||||
|
rf::Frequency range3_center;
|
||||||
|
rf::Frequency range3_width;
|
||||||
|
|
||||||
typedef struct rangepreset {
|
typedef struct rangepreset {
|
||||||
bool active;
|
bool active;
|
||||||
rf::Frequency min;
|
rf::Frequency min;
|
||||||
rf::Frequency max;
|
rf::Frequency max;
|
||||||
} rangepreset;
|
} rangepreset;
|
||||||
|
|
||||||
const rangepreset range_presets[8][3] = {
|
const rangepreset range_presets[9][3] = {
|
||||||
// Orange
|
// Orange
|
||||||
{{ true, 935000000, 945000000 }, // GSM 900
|
{{ true, 935000000, 945000000 }, // GSM 900
|
||||||
{ true, 1808000000, 1832000000 }, // GSM 1800
|
{ true, 1808000000, 1832000000 }, // GSM 1800
|
||||||
@ -99,6 +106,11 @@ private:
|
|||||||
// ISM 433
|
// ISM 433
|
||||||
{{ true, 433050000, 434790000 }, // BW: 0.2%
|
{{ true, 433050000, 434790000 }, // BW: 0.2%
|
||||||
{ false, 0, 0 },
|
{ false, 0, 0 },
|
||||||
|
{ false, 0, 0 }},
|
||||||
|
|
||||||
|
// Reims 164
|
||||||
|
{{ true, 164000000 - 200000, 164000000 + 200000}, // BW: 400kHz
|
||||||
|
{ false, 0, 0 },
|
||||||
{ false, 0, 0 }}
|
{ false, 0, 0 }}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -164,7 +176,7 @@ private:
|
|||||||
};
|
};
|
||||||
OptionsField options_preset {
|
OptionsField options_preset {
|
||||||
{ 10 * 8, 3 * 16 },
|
{ 10 * 8, 3 * 16 },
|
||||||
8,
|
9,
|
||||||
{
|
{
|
||||||
{ "Orange ", 0 },
|
{ "Orange ", 0 },
|
||||||
{ "SFR ", 1 },
|
{ "SFR ", 1 },
|
||||||
@ -174,6 +186,7 @@ private:
|
|||||||
{ "DECT ", 5 },
|
{ "DECT ", 5 },
|
||||||
{ "Optifib ", 6 },
|
{ "Optifib ", 6 },
|
||||||
{ "ISM 433 ", 7 },
|
{ "ISM 433 ", 7 },
|
||||||
|
{ "Reims ", 8 },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@ private:
|
|||||||
TXDoneMessage message;
|
TXDoneMessage message;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ToneProcessor : public BasebandProcessor {
|
/*class ToneProcessor : public BasebandProcessor {
|
||||||
public:
|
public:
|
||||||
void execute(buffer_c8_t buffer) override {
|
void execute(buffer_c8_t buffer) override {
|
||||||
|
|
||||||
@ -887,7 +887,7 @@ private:
|
|||||||
uint32_t sample_count;
|
uint32_t sample_count;
|
||||||
uint32_t aphase, phase, sphase;
|
uint32_t aphase, phase, sphase;
|
||||||
int32_t sample, sig, frq;
|
int32_t sample, sig, frq;
|
||||||
};
|
};*/
|
||||||
|
|
||||||
#define POLY_MASK_32 0xB4BCD35C
|
#define POLY_MASK_32 0xB4BCD35C
|
||||||
|
|
||||||
@ -918,19 +918,50 @@ public:
|
|||||||
|
|
||||||
sample = sintab[(aphase & 0x03FF0000)>>16];*/
|
sample = sintab[(aphase & 0x03FF0000)>>16];*/
|
||||||
|
|
||||||
if (s >= 10) {
|
// Duration timer
|
||||||
if (sample < 128)
|
//
|
||||||
sample++;
|
if (s >= 10000) { //shared_memory.jammer_ranges[ir].duration
|
||||||
else
|
|
||||||
sample = -127;
|
|
||||||
s = 0;
|
s = 0;
|
||||||
|
for (;;) {
|
||||||
|
ir++;
|
||||||
|
if (ir > 15) ir = 0;
|
||||||
|
if (shared_memory.jammer_ranges[ir].active == true) break;
|
||||||
|
}
|
||||||
|
jammer_bw = shared_memory.jammer_ranges[ir].width;
|
||||||
|
|
||||||
|
if( message.is_free() ) {
|
||||||
|
message.freq = shared_memory.jammer_ranges[ir].center;
|
||||||
|
shared_memory.application_queue.push(&message);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FM
|
// Ramp
|
||||||
frq = sample << 17; // Bandwidth
|
/*if (r >= 10) {
|
||||||
|
if (sample < 128)
|
||||||
|
sample++;
|
||||||
|
else
|
||||||
|
sample = -127;
|
||||||
|
r = 0;
|
||||||
|
} else {
|
||||||
|
r++;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Phase
|
||||||
|
if (r >= 70) {
|
||||||
|
aphase += ((aphase>>4) ^ 0x4573) << 14;
|
||||||
|
r = 0;
|
||||||
|
} else {
|
||||||
|
r++;
|
||||||
|
}
|
||||||
|
|
||||||
|
aphase += 35320;
|
||||||
|
sample = sintab[(aphase & 0x03FF0000)>>16];
|
||||||
|
|
||||||
|
//FM
|
||||||
|
frq = sample * jammer_bw; // Bandwidth
|
||||||
|
|
||||||
//65536 -> 0.6M
|
//65536 -> 0.6M
|
||||||
//131072 -> 1.2M
|
//131072 -> 1.2M
|
||||||
|
|
||||||
@ -945,13 +976,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t s, lfsr32 = 0xABCDE;
|
int32_t lfsr32 = 0xABCDE;
|
||||||
int8_t re, im;
|
uint32_t s;
|
||||||
|
int8_t r, ir, re, im;
|
||||||
|
int64_t jammer_bw, jammer_center;
|
||||||
int feedback;
|
int feedback;
|
||||||
int32_t lfsr;
|
int32_t lfsr;
|
||||||
uint32_t sample_count;
|
uint32_t sample_count;
|
||||||
uint32_t aphase, phase, sphase;
|
uint32_t aphase, phase, sphase;
|
||||||
int32_t sample, frq;
|
int32_t sample, frq;
|
||||||
|
RetuneMessage message;
|
||||||
};
|
};
|
||||||
|
|
||||||
static BasebandProcessor* baseband_processor { nullptr };
|
static BasebandProcessor* baseband_processor { nullptr };
|
||||||
@ -1224,10 +1258,10 @@ int main(void) {
|
|||||||
baseband_processor = new LCRFSKProcessor();
|
baseband_processor = new LCRFSKProcessor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 17:
|
/*case 17:
|
||||||
direction = baseband::Direction::Transmit;
|
direction = baseband::Direction::Transmit;
|
||||||
baseband_processor = new ToneProcessor();
|
baseband_processor = new ToneProcessor();
|
||||||
break;
|
break;*/
|
||||||
|
|
||||||
case 18:
|
case 18:
|
||||||
direction = baseband::Direction::Transmit;
|
direction = baseband::Direction::Transmit;
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
FSKPacket = 7,
|
FSKPacket = 7,
|
||||||
TestResults = 8,
|
TestResults = 8,
|
||||||
TXDone = 9,
|
TXDone = 9,
|
||||||
|
Retune = 10,
|
||||||
MAX
|
MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -262,6 +263,16 @@ public:
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RetuneMessage : public Message {
|
||||||
|
public:
|
||||||
|
RetuneMessage(
|
||||||
|
) : Message { ID::Retune }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t freq = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class MessageHandlerMap {
|
class MessageHandlerMap {
|
||||||
public:
|
public:
|
||||||
using MessageHandler = std::function<void(const Message* const p)>;
|
using MessageHandler = std::function<void(const Message* const p)>;
|
||||||
|
@ -30,6 +30,13 @@ struct TouchADCFrame {
|
|||||||
uint32_t dr[8];
|
uint32_t dr[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct JammerRange {
|
||||||
|
bool active;
|
||||||
|
int64_t center;
|
||||||
|
int64_t width;
|
||||||
|
uint32_t duration;
|
||||||
|
};
|
||||||
|
|
||||||
/* NOTE: These structures must be located in the same location in both M4 and M0 binaries */
|
/* NOTE: These structures must be located in the same location in both M4 and M0 binaries */
|
||||||
struct SharedMemory {
|
struct SharedMemory {
|
||||||
MessageQueue baseband_queue;
|
MessageQueue baseband_queue;
|
||||||
@ -50,6 +57,8 @@ struct SharedMemory {
|
|||||||
uint8_t afsk_repeat;
|
uint8_t afsk_repeat;
|
||||||
uint32_t afsk_fmmod;
|
uint32_t afsk_fmmod;
|
||||||
bool afsk_transmit_done;
|
bool afsk_transmit_done;
|
||||||
|
|
||||||
|
JammerRange jammer_ranges[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SharedMemory& shared_memory;
|
extern SharedMemory& shared_memory;
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user