Capped max entries per Freqman file to 30 due to RAM issue

Capped max files in Soundboard to 54 and removed CTCSS options due to
same issue
Splitted files for jammer ranges
Bugfix: Mismatch between filename and category name in Freqman
Bugfix: Freqman file parsing strstr()'s might have gone out of buffer
Updated binary
This commit is contained in:
furrtek 2017-12-11 02:40:43 +00:00
parent 2d01822cdb
commit 70c7646743
11 changed files with 134 additions and 57 deletions

View File

@ -43,25 +43,27 @@ bool load_freqman_file(std::string& file_stem, freqman_db &db) {
char * line_end;
std::string description;
rf::Frequency frequency_a, frequency_b;
char file_data[256];
char file_data[257];
freqman_entry_type type;
db.entries.clear();
db.clear();
auto result = freqman_file.open("FREQMAN/" + file_stem + ".TXT");
if (result.is_valid())
return false;
while (1) {
// Read a 256 bytes block from file
freqman_file.seek(file_position);
memset(file_data, 0, 256);
memset(file_data, 0, 257);
auto read_size = freqman_file.read(file_data, 256);
if (read_size.is_error())
return false; // Read error
file_position += sizeof(file_data);
file_position += 256;
// Reset line_start to beginning of buffer
line_start = file_data;
if (!strstr(file_data, "f=") && !strstr(file_data, "a="))
@ -102,18 +104,20 @@ bool load_freqman_file(std::string& file_stem, freqman_db &db) {
} else
description = "-";
db.entries.push_back({ frequency_a, frequency_b, description, type });
db.push_back({ frequency_a, frequency_b, description, type });
n++;
if (n >= FREQMAN_MAX_PER_FILE) return true;
line_start = line_end + 1;
if (line_start - file_data >= 256) break;
}
if (read_size.value() != sizeof(file_data))
return true; // End of file
if (read_size.value() != 256)
break; // End of file
file_position -= (file_data + sizeof(file_data) - line_start);
// Restart at beginning of last incomplete line
file_position -= (file_data + 256 - line_start);
}
return true;
@ -127,8 +131,8 @@ bool save_freqman_file(std::string& file_stem, freqman_db &db) {
if (!create_freqman_file(file_stem, freqman_file))
return false;
for (size_t n = 0; n < db.entries.size(); n++) {
auto& entry = db.entries[n];
for (size_t n = 0; n < db.size(); n++) {
auto& entry = db[n];
frequency_a = entry.frequency_a;

View File

@ -30,8 +30,8 @@
#define __FREQMAN_H__
#define FREQMAN_DESC_MAX_LEN 30
#define FREQMAN_MAX_PER_FILE 50
#define FREQMAN_MAX_PER_FILE_STR "50"
#define FREQMAN_MAX_PER_FILE 30
#define FREQMAN_MAX_PER_FILE_STR "30"
using namespace ui;
using namespace std;
@ -55,9 +55,7 @@ struct freqman_entry {
freqman_entry_type type { };
};
struct freqman_db {
std::vector<freqman_entry> entries;
};
using freqman_db = std::vector<freqman_entry>;
std::vector<std::string> get_freqman_files();
bool load_freqman_file(std::string& file_stem, freqman_db &db);

View File

@ -82,7 +82,7 @@ void FreqManBaseView::populate_categories() {
options_category.set_options(categories);
options_category.set_selected_index(0);
options_category.on_change = [this](size_t, int32_t category_id) {
options_category.on_change = [this](size_t category_id, int32_t) {
if (on_change_category)
on_change_category(category_id);
};
@ -94,14 +94,14 @@ void FreqManBaseView::change_category(int32_t category_id) {
current_category_id = category_id;
if (!load_freqman_file(file_list[current_category_id], database))
if (!load_freqman_file(file_list[categories[current_category_id].second], database))
error_ = ERROR_ACCESS;
else
refresh_list();
}
void FreqManBaseView::refresh_list() {
if (!database.entries.size()) {
if (!database.size()) {
if (on_refresh_widgets)
on_refresh_widgets(true);
} else {
@ -110,9 +110,9 @@ void FreqManBaseView::refresh_list() {
menu_view.clear();
for (size_t n = 0; n < database.entries.size(); n++) {
for (size_t n = 0; n < database.size(); n++) {
menu_view.add_item({
freqman_item_string(database.entries[n], 26),
freqman_item_string(database[n], 26),
ui::Color::white(),
nullptr,
[this](){
@ -127,33 +127,33 @@ void FreqManBaseView::refresh_list() {
}
void FrequencySaveView::save_current_file() {
if (database.entries.size() > FREQMAN_MAX_PER_FILE) {
if (database.size() > FREQMAN_MAX_PER_FILE) {
nav_.display_modal(
"Error", "Too many entries, maximum is\n" FREQMAN_MAX_PER_FILE_STR ". Trim list ?",
YESNO,
[this](bool choice) {
if (choice) {
database.entries.resize(FREQMAN_MAX_PER_FILE);
save_freqman_file(file_list[current_category_id], database);
database.resize(FREQMAN_MAX_PER_FILE);
save_freqman_file(file_list[categories[current_category_id].second], database);
}
nav_.pop();
}
);
} else {
save_freqman_file(file_list[current_category_id], database);
save_freqman_file(file_list[categories[current_category_id].second], database);
nav_.pop();
}
}
void FrequencySaveView::on_save_name() {
text_prompt(nav_, &desc_buffer, 28, [this](std::string * buffer) {
database.entries.push_back({ value_, 0, *buffer, SINGLE });
database.push_back({ value_, 0, *buffer, SINGLE });
save_current_file();
});
}
void FrequencySaveView::on_save_timestamp() {
database.entries.push_back({ value_, 0, live_timestamp.string(), SINGLE });
database.push_back({ value_, 0, live_timestamp.string(), SINGLE });
save_current_file();
}
@ -166,8 +166,8 @@ FrequencySaveView::FrequencySaveView(
desc_buffer.reserve(28);
// Todo: add back ?
/*for (size_t n = 0; n < database.entries.size(); n++) {
if (database.entries[n].value == value_) {
/*for (size_t n = 0; n < database.size(); n++) {
if (database[n].value == value_) {
error_ = ERROR_DUPLICATE;
break;
}
@ -225,7 +225,7 @@ FrequencyLoadView::FrequencyLoadView(
on_select_frequency = [&nav, this]() {
nav_.pop();
auto& entry = database.entries[menu_view.highlighted()];
auto& entry = database[menu_view.highlighted_index()];
if (entry.type == RANGE) {
// User chose a frequency range entry
@ -243,16 +243,16 @@ FrequencyLoadView::FrequencyLoadView(
}
void FrequencyManagerView::on_edit_freq(rf::Frequency f) {
database.entries[menu_view.highlighted()].frequency_a = f;
save_freqman_file(file_list[current_category_id], database);
database[menu_view.highlighted_index()].frequency_a = f;
save_freqman_file(file_list[categories[current_category_id].second], database);
refresh_list();
}
void FrequencyManagerView::on_edit_desc(NavigationView& nav) {
text_prompt(nav, &desc_buffer, 28, [this](std::string * buffer) {
database.entries[menu_view.highlighted()].description = *buffer;
database[menu_view.highlighted_index()].description = *buffer;
refresh_list();
save_freqman_file(file_list[current_category_id], database);
save_freqman_file(file_list[categories[current_category_id].second], database);
});
}
@ -266,8 +266,8 @@ void FrequencyManagerView::on_new_category(NavigationView& nav) {
}
void FrequencyManagerView::on_delete() {
database.entries.erase(database.entries.begin() + menu_view.highlighted());
save_freqman_file(file_list[current_category_id], database);
database.erase(database.begin() + menu_view.highlighted_index());
save_freqman_file(file_list[categories[current_category_id].second], database);
refresh_list();
}
@ -282,7 +282,7 @@ void FrequencyManagerView::refresh_widgets(const bool v) {
}
FrequencyManagerView::~FrequencyManagerView() {
//save_freqman_file(file_list[current_category_id], database);
//save_freqman_file(file_list[categories[current_category_id].second], database);
}
FrequencyManagerView::FrequencyManagerView(
@ -321,14 +321,14 @@ FrequencyManagerView::FrequencyManagerView(
};
button_edit_freq.on_select = [this, &nav](Button&) {
auto new_view = nav.push<FrequencyKeypadView>(database.entries[menu_view.highlighted()].frequency_a);
auto new_view = nav.push<FrequencyKeypadView>(database[menu_view.highlighted_index()].frequency_a);
new_view->on_changed = [this](rf::Frequency f) {
on_edit_freq(f);
};
};
button_edit_desc.on_select = [this, &nav](Button&) {
desc_buffer = database.entries[menu_view.highlighted()].description;
desc_buffer = database[menu_view.highlighted_index()].description;
on_edit_desc(nav);
};

View File

@ -119,7 +119,7 @@ void SoundBoardView::play_sound(uint16_t id) {
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable();
tone_key_index = options_tone_key.selected_index();
tone_key_index = 0; //options_tone_key.selected_index();
divider = (1536000 / sounds[id].sample_rate) - 1;
@ -164,19 +164,22 @@ void SoundBoardView::refresh_buttons(uint16_t id) {
show_infos(id);
}
void SoundBoardView::change_page(Button& button, const KeyEvent key) {
bool SoundBoardView::change_page(Button& button, const KeyEvent key) {
// Stupid way to find out if the button is on the sides
if (button.screen_pos().x() < 32) {
if ((key == KeyEvent::Left) && (page > 0)) {
page--;
refresh_buttons(button.id);
return true;
}
} else if (button.screen_pos().x() > 120) {
if ((key == KeyEvent::Right) && (page < max_page - 1)) {
page++;
refresh_buttons(button.id);
return true;
}
}
return false;
}
SoundBoardView::SoundBoardView(
@ -210,7 +213,7 @@ SoundBoardView::SoundBoardView(
else
sounds[c].title = "-";
c++;
if (c == 108) break; // Limit to 108 files (6 pages)
if (c == 54) break; // Limit to 54 files (3 pages)
}
}
}
@ -221,10 +224,10 @@ SoundBoardView::SoundBoardView(
max_page = (max_sound + 18 - 1) / 18; // 3 * 6 = 18 buttons per page
add_children({
&labels,
&field_frequency,
&number_bw,
&text_kHz,
&options_tone_key,
//&options_tone_key,
&text_title,
&text_page,
&text_duration,
@ -234,8 +237,8 @@ SoundBoardView::SoundBoardView(
&button_exit
});
tone_keys_populate(options_tone_key);
options_tone_key.set_selected_index(0);
//tone_keys_populate(options_tone_key);
//options_tone_key.set_selected_index(0);
const auto button_fn = [this](Button& button) {
tx_mode = NORMAL;
@ -247,8 +250,7 @@ SoundBoardView::SoundBoardView(
};
const auto button_dir = [this](Button& button, const KeyEvent key) {
this->change_page(button, key);
return false;
return change_page(button, key);
};
// Generate buttons

View File

@ -75,7 +75,7 @@ private:
std::unique_ptr<WAVFileReader> reader { };
sound sounds[108]; // 6 pages * 18 buttons
sound sounds[54]; // 3 pages * 18 buttons
uint32_t max_sound { };
uint8_t max_page { };
@ -109,29 +109,28 @@ private:
void do_random();
void show_infos(uint16_t id);
void change_page(Button& button, const KeyEvent key);
bool change_page(Button& button, const KeyEvent key);
void refresh_buttons(uint16_t id);
void play_sound(uint16_t id);
void prepare_audio();
void on_ctcss_changed(uint32_t v);
Labels labels {
{ { 10 * 8, 4 }, "BW: kHz", Color::light_grey() }
};
FrequencyField field_frequency {
{ 0, 4 },
};
NumberField number_bw {
{ 10 * 8, 4 },
{ 13 * 8, 4 },
3,
{1, 150},
{ 1, 150 },
1,
' '
};
Text text_kHz {
{ 13 * 8, 4, 8 * 8, 16 },
"k CTCSS:"
};
OptionsField options_tone_key {
{ 21 * 8, 4 },
8,
@ -153,7 +152,7 @@ private:
};
ProgressBar pbar {
{ 9 * 8, 30 * 8, 19 * 8, 16 }
{ 9 * 8, 30 * 8, 20 * 8, 16 }
};
Checkbox check_loop {

Binary file not shown.

8
sdcard/FREQMAN/GSM.TXT Normal file
View File

@ -0,0 +1,8 @@
a=935000000,b=945000000,d=GSM900 Orange FR
a=1808000000,b=1832000000,d=GSM1800 Orange FR
a=950000000,b=960000000,d=GSM900 SFR FR
a=1832000000,b=1853000000,d=GSM1800 SFR FR
a=925000000,b=935000000,d=GSM900 Bouygues FR
a=1858000000,b=1880000000,d=GSM1800 Bouygues FR
a=945000000,b=950000000,d=GSM Free FR
a=921000000,b=925000000,d=GSM-R FR

View File

@ -0,0 +1,6 @@
a=1880000000,b=1900000000,d=DECT
a=162930000,b=162970000,d=PMV AFSK
a=433050000,b=434790000,d=ISM 433
a=868000000,b=868200000,d=ISM 868
a=1574920000,b=1575920000,d=GPS L1
a=1226600000,b=1228600000,d=GPS L2

View File

@ -0,0 +1,13 @@
a=2401000000,b=2423000000,d=WLAN 2.4G CH1
a=2406000000,b=2428000000,d=WLAN 2.4G CH2
a=2411000000,b=2433000000,d=WLAN 2.4G CH3
a=2416000000,b=2438000000,d=WLAN 2.4G CH4
a=2421000000,b=2443000000,d=WLAN 2.4G CH5
a=2426000000,b=2448000000,d=WLAN 2.4G CH6
a=2431000000,b=2453000000,d=WLAN 2.4G CH7
a=2436000000,b=2458000000,d=WLAN 2.4G CH8
a=2441000000,b=2463000000,d=WLAN 2.4G CH9
a=2446000000,b=2468000000,d=WLAN 2.4G CH10
a=2451000000,b=2473000000,d=WLAN 2.4G CH11
a=2456000000,b=2478000000,d=WLAN 2.4G CH12
a=2461000000,b=2483000000,d=WLAN 2.4G CH13

View File

@ -0,0 +1,28 @@
a=5170000000,b=5190000000,d=WLAN 5G CH36
a=5170000000,b=5210000000,d=WLAN 5G CH38
a=5190000000,b=5210000000,d=WLAN 5G CH40
a=5170000000,b=5250000000,d=WLAN 5G CH42
a=5210000000,b=5230000000,d=WLAN 5G CH44
a=5210000000,b=5250000000,d=WLAN 5G CH46
a=5230000000,b=5250000000,d=WLAN 5G CH48
a=5170000000,b=5330000000,d=WLAN 5G CH50
a=5250000000,b=5270000000,d=WLAN 5G CH52
a=5250000000,b=5290000000,d=WLAN 5G CH54
a=5270000000,b=5290000000,d=WLAN 5G CH56
a=5250000000,b=5330000000,d=WLAN 5G CH58
a=5290000000,b=5310000000,d=WLAN 5G CH60
a=5290000000,b=5330000000,d=WLAN 5G CH62
a=5310000000,b=5330000000,d=WLAN 5G CH64
a=5490000000,b=5510000000,d=WLAN 5G CH100
a=5490000000,b=5530000000,d=WLAN 5G CH102
a=5510000000,b=5530000000,d=WLAN 5G CH104
a=5490000000,b=5570000000,d=WLAN 5G CH106
a=5530000000,b=5550000000,d=WLAN 5G CH108
a=5530000000,b=5570000000,d=WLAN 5G CH110
a=5550000000,b=5570000000,d=WLAN 5G CH112
a=5490000000,b=5650000000,d=WLAN 5G CH114
a=5570000000,b=5590000000,d=WLAN 5G CH116
a=5570000000,b=5610000000,d=WLAN 5G CH118
a=5590000000,b=5610000000,d=WLAN 5G CH120
a=5570000000,b=5650000000,d=WLAN 5G CH122
a=5610000000,b=5630000000,d=WLAN 5G CH124

View File

@ -0,0 +1,19 @@
a=5610000000,b=5650000000,d=WLAN 5G CH126
a=5630000000,b=5650000000,d=WLAN 5G CH128
a=5650000000,b=5670000000,d=WLAN 5G CH132
a=5650000000,b=5690000000,d=WLAN 5G CH134
a=5670000000,b=5690000000,d=WLAN 5G CH136
a=5650000000,b=5730000000,d=WLAN 5G CH138
a=5690000000,b=5710000000,d=WLAN 5G CH140
a=5690000000,b=5730000000,d=WLAN 5G CH142
a=5710000000,b=5730000000,d=WLAN 5G CH144
a=5735000000,b=5755000000,d=WLAN 5G CH149
a=5735000000,b=5775000000,d=WLAN 5G CH151
a=5755000000,b=5775000000,d=WLAN 5G CH153
a=5735000000,b=5815000000,d=WLAN 5G CH155
a=5775000000,b=5795000000,d=WLAN 5G CH157
a=5775000000,b=5815000000,d=WLAN 5G CH159
a=5795000000,b=5815000000,d=WLAN 5G CH161
a=5815000000,b=5835000000,d=WLAN 5G CH165
a=5835000000,b=5855000000,d=WLAN 5G CH169
a=5855000000,b=5875000000,d=WLAN 5G CH173