Jammer ramp mode

Jammer range splitting, hopping. Only 1MHz wide splits for now.
This commit is contained in:
furrtek 2015-11-14 03:44:49 +01:00
parent 66de53744e
commit bcbad4629f
7 changed files with 148 additions and 37 deletions

View File

@ -535,6 +535,11 @@ int main(void) {
const auto message = static_cast<const TXDoneMessage*>(p);
(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 };

View File

@ -98,13 +98,31 @@ void JammerView::updfreq(uint8_t id, rf::Frequency f) {
std::string bw;
for (c = 0; c < 3; c++) {
if (c == 0) center = (range1_min + range1_max) / 2;
if (c == 1) center = (range2_min + range2_max) / 2;
if (c == 2) center = (range3_min + range3_max) / 2;
if (c == 0) {
center = (range1_min + range1_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 == 1) bw = to_string_dec_int(abs(range2_max - range2_min) / 1000, 5);
if (c == 2) bw = to_string_dec_int(abs(range3_max - range3_min) / 1000, 5);
if (c == 0) {
range1_width = abs(range1_max - range1_min) / 1000;
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_hz100 = to_string_dec_int((center / 100) % 10000, 4, '0');
@ -132,6 +150,7 @@ JammerView::JammerView(
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
{
static constexpr Style style_val {
.font = font::fixed_8x16,
.background = Color::green(),
@ -151,7 +170,6 @@ JammerView::JammerView(
};
transmitter_model.set_modulation(18);
transmitter_model.set_tuning_frequency(persistent_memory::tuned_frequency());
add_children({ {
&text_type,
@ -211,24 +229,45 @@ JammerView::JammerView(
nav.push(new_view);
};
button_transmit.on_select = [this,&transmitter_model](Button&){
/*uint16_t c;
ui::Context context;
button_transmit.on_select = [this,&transmitter_model](Button&) {
uint8_t i = 0;
rf::Frequency t, range_lower;
make_frame();
shared_memory.afsk_samples_per_bit = 228000/persistent_memory::afsk_bitrate();
shared_memory.afsk_phase_inc_mark = persistent_memory::afsk_mark_freq()*(65536*1024)/2280;
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];
context().message_map[Message::ID::Retune] = [this, &transmitter_model](const Message* const p) {
const auto message = static_cast<const RetuneMessage*>(p);
if (message->freq > 0) {
transmitter_model.set_tuning_frequency(message->freq);
}
};
for (i = 0; i < 16; i++) {
shared_memory.jammer_ranges[i].active = false;
}
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5; // DEFAULT
text_status.set("Send...");*/
if (range1_min > range1_max) {
t = range1_min;
range1_min = range1_max;
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) {
jamming = false;

View File

@ -51,13 +51,20 @@ private:
rf::Frequency range3_min;
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 {
bool active;
rf::Frequency min;
rf::Frequency max;
} rangepreset;
const rangepreset range_presets[8][3] = {
const rangepreset range_presets[9][3] = {
// Orange
{{ true, 935000000, 945000000 }, // GSM 900
{ true, 1808000000, 1832000000 }, // GSM 1800
@ -99,6 +106,11 @@ private:
// ISM 433
{{ true, 433050000, 434790000 }, // BW: 0.2%
{ false, 0, 0 },
{ false, 0, 0 }},
// Reims 164
{{ true, 164000000 - 200000, 164000000 + 200000}, // BW: 400kHz
{ false, 0, 0 },
{ false, 0, 0 }}
};
@ -164,7 +176,7 @@ private:
};
OptionsField options_preset {
{ 10 * 8, 3 * 16 },
8,
9,
{
{ "Orange ", 0 },
{ "SFR ", 1 },
@ -174,6 +186,7 @@ private:
{ "DECT ", 5 },
{ "Optifib ", 6 },
{ "ISM 433 ", 7 },
{ "Reims ", 8 },
}
};

View File

@ -851,7 +851,7 @@ private:
TXDoneMessage message;
};
class ToneProcessor : public BasebandProcessor {
/*class ToneProcessor : public BasebandProcessor {
public:
void execute(buffer_c8_t buffer) override {
@ -887,7 +887,7 @@ private:
uint32_t sample_count;
uint32_t aphase, phase, sphase;
int32_t sample, sig, frq;
};
};*/
#define POLY_MASK_32 0xB4BCD35C
@ -918,19 +918,50 @@ public:
sample = sintab[(aphase & 0x03FF0000)>>16];*/
if (s >= 10) {
if (sample < 128)
sample++;
else
sample = -127;
// Duration timer
//
if (s >= 10000) { //shared_memory.jammer_ranges[ir].duration
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 {
s++;
}
//FM
frq = sample << 17; // Bandwidth
// Ramp
/*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
//131072 -> 1.2M
@ -945,13 +976,16 @@ public:
}
private:
int32_t s, lfsr32 = 0xABCDE;
int8_t re, im;
int32_t lfsr32 = 0xABCDE;
uint32_t s;
int8_t r, ir, re, im;
int64_t jammer_bw, jammer_center;
int feedback;
int32_t lfsr;
uint32_t sample_count;
uint32_t aphase, phase, sphase;
int32_t sample, frq;
RetuneMessage message;
};
static BasebandProcessor* baseband_processor { nullptr };
@ -1224,10 +1258,10 @@ int main(void) {
baseband_processor = new LCRFSKProcessor();
break;
case 17:
/*case 17:
direction = baseband::Direction::Transmit;
baseband_processor = new ToneProcessor();
break;
break;*/
case 18:
direction = baseband::Direction::Transmit;

View File

@ -43,6 +43,7 @@ public:
FSKPacket = 7,
TestResults = 8,
TXDone = 9,
Retune = 10,
MAX
};
@ -262,6 +263,16 @@ public:
int n = 0;
};
class RetuneMessage : public Message {
public:
RetuneMessage(
) : Message { ID::Retune }
{
}
int64_t freq = 0;
};
class MessageHandlerMap {
public:
using MessageHandler = std::function<void(const Message* const p)>;

View File

@ -30,6 +30,13 @@ struct TouchADCFrame {
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 */
struct SharedMemory {
MessageQueue baseband_queue;
@ -50,6 +57,8 @@ struct SharedMemory {
uint8_t afsk_repeat;
uint32_t afsk_fmmod;
bool afsk_transmit_done;
JammerRange jammer_ranges[16];
};
extern SharedMemory& shared_memory;

Binary file not shown.