2022-04-15 08:43:44 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
* Copyright (C) 2022 Arjan Onwezen
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __APP_SETTINGS_H__
|
|
|
|
#define __APP_SETTINGS_H__
|
|
|
|
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "file.hpp"
|
|
|
|
#include "string_format.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
class app_settings {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
#define SETTINGS_OK 0 // settings found
|
|
|
|
#define SETTINGS_UNABLE_TO_LOAD -1 // settings (file) not found
|
|
|
|
#define SETTINGS_UNABLE_TO_SAVE -2 // unable to save settings
|
|
|
|
#define SETTINGS_DISABLED -3 // load/save settings disabled in settings
|
|
|
|
|
|
|
|
|
2022-05-13 08:38:04 -04:00
|
|
|
|
2022-04-15 08:43:44 -04:00
|
|
|
struct AppSettings {
|
|
|
|
uint32_t baseband_bandwidth;
|
2022-05-13 08:38:04 -04:00
|
|
|
uint32_t channel_bandwidth;
|
2022-04-15 08:43:44 -04:00
|
|
|
uint8_t lna;
|
2022-05-13 08:38:04 -04:00
|
|
|
uint8_t modulation;
|
2022-04-15 08:43:44 -04:00
|
|
|
uint8_t rx_amp;
|
|
|
|
uint32_t rx_frequency;
|
|
|
|
uint32_t sampling_rate;
|
2022-05-13 08:38:04 -04:00
|
|
|
uint8_t tx_amp;
|
|
|
|
uint32_t tx_frequency;
|
|
|
|
uint8_t tx_gain;
|
2022-04-15 08:43:44 -04:00
|
|
|
uint8_t vga;
|
|
|
|
};
|
|
|
|
|
|
|
|
int load(std::string application, AppSettings* settings);
|
|
|
|
int save(std::string application, AppSettings* settings);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-05-13 08:38:04 -04:00
|
|
|
#define MAX_FILE_CONTENT_SIZE 1000
|
2022-04-15 08:43:44 -04:00
|
|
|
|
2022-05-13 08:38:04 -04:00
|
|
|
char file_content[MAX_FILE_CONTENT_SIZE] = {};
|
2022-04-15 08:43:44 -04:00
|
|
|
std::string file_path = "";
|
|
|
|
std::string folder = "SETTINGS";
|
|
|
|
int rc = SETTINGS_OK;
|
2022-05-13 08:38:04 -04:00
|
|
|
File settings_file { };
|
|
|
|
long long int setting_value {} ;
|
|
|
|
|
|
|
|
long long int read_long_long(char* file_content, const char* setting_text);
|
2022-04-15 08:43:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
}; // class app_settings
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif/*__APP_SETTINGS_H__*/
|