clang-format: configmanager.cpp, globals.h, gpsread.cpp
This commit is contained in:
parent
0cbfb1c354
commit
4466889a18
@ -18,7 +18,7 @@ esp_err_t err;
|
|||||||
|
|
||||||
// populate cfg vars with factory settings
|
// populate cfg vars with factory settings
|
||||||
void defaultConfig() {
|
void defaultConfig() {
|
||||||
cfg.lorasf = LORASFDEFAULT; // 7-12, initial lora spreadfactor defined in paxcounter.conf
|
cfg.lorasf = LORASFDEFAULT; // 7-12, initial lora sf, see pacounter.conf
|
||||||
cfg.txpower = 15; // 2-15, lora tx power
|
cfg.txpower = 15; // 2-15, lora tx power
|
||||||
cfg.adrmode = 1; // 0=disabled, 1=enabled
|
cfg.adrmode = 1; // 0=disabled, 1=enabled
|
||||||
cfg.screensaver = 0; // 0=disabled, 1=enabled
|
cfg.screensaver = 0; // 0=disabled, 1=enabled
|
||||||
@ -26,8 +26,11 @@ void defaultConfig() {
|
|||||||
cfg.countermode = 0; // 0=cyclic, 1=cumulative, 2=cyclic confirmed
|
cfg.countermode = 0; // 0=cyclic, 1=cumulative, 2=cyclic confirmed
|
||||||
cfg.rssilimit = 0; // threshold for rssilimiter, negative value!
|
cfg.rssilimit = 0; // threshold for rssilimiter, negative value!
|
||||||
cfg.sendcycle = SEND_SECS; // payload send cycle [seconds/2]
|
cfg.sendcycle = SEND_SECS; // payload send cycle [seconds/2]
|
||||||
cfg.wifichancycle = WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
|
cfg.wifichancycle =
|
||||||
cfg.blescantime = BLESCANINTERVAL / 10; // BT channel scan cycle duration [seconds/100], default 1 (= 10ms)
|
WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
|
||||||
|
cfg.blescantime =
|
||||||
|
BLESCANINTERVAL /
|
||||||
|
10; // BT channel scan cycle [seconds/100], default 1 (= 10ms)
|
||||||
cfg.blescan = 1; // 0=disabled, 1=enabled
|
cfg.blescan = 1; // 0=disabled, 1=enabled
|
||||||
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
|
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
|
||||||
cfg.vendorfilter = 1; // 0=disabled, 1=enabled
|
cfg.vendorfilter = 1; // 0=disabled, 1=enabled
|
||||||
@ -64,9 +67,10 @@ void eraseConfig() {
|
|||||||
nvs_erase_all(my_handle);
|
nvs_erase_all(my_handle);
|
||||||
nvs_commit(my_handle);
|
nvs_commit(my_handle);
|
||||||
nvs_close(my_handle);
|
nvs_close(my_handle);
|
||||||
ESP_LOGI(TAG, "Done");}
|
ESP_LOGI(TAG, "Done");
|
||||||
else {
|
} else {
|
||||||
ESP_LOGW(TAG, "NVS erase failed"); }
|
ESP_LOGW(TAG, "NVS erase failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// save current configuration from RAM to NVRAM
|
// save current configuration from RAM to NVRAM
|
||||||
@ -79,52 +83,69 @@ void saveConfig() {
|
|||||||
size_t required_size;
|
size_t required_size;
|
||||||
char storedversion[10];
|
char storedversion[10];
|
||||||
|
|
||||||
if( nvs_get_str(my_handle, "version", storedversion, &required_size) != ESP_OK || strcmp(storedversion, cfg.version) != 0 )
|
if (nvs_get_str(my_handle, "version", storedversion, &required_size) !=
|
||||||
|
ESP_OK ||
|
||||||
|
strcmp(storedversion, cfg.version) != 0)
|
||||||
nvs_set_str(my_handle, "version", cfg.version);
|
nvs_set_str(my_handle, "version", cfg.version);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "lorasf", &flash8) != ESP_OK || flash8 != cfg.lorasf )
|
if (nvs_get_i8(my_handle, "lorasf", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.lorasf)
|
||||||
nvs_set_i8(my_handle, "lorasf", cfg.lorasf);
|
nvs_set_i8(my_handle, "lorasf", cfg.lorasf);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "txpower", &flash8) != ESP_OK || flash8 != cfg.txpower )
|
if (nvs_get_i8(my_handle, "txpower", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.txpower)
|
||||||
nvs_set_i8(my_handle, "txpower", cfg.txpower);
|
nvs_set_i8(my_handle, "txpower", cfg.txpower);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "adrmode", &flash8) != ESP_OK || flash8 != cfg.adrmode )
|
if (nvs_get_i8(my_handle, "adrmode", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.adrmode)
|
||||||
nvs_set_i8(my_handle, "adrmode", cfg.adrmode);
|
nvs_set_i8(my_handle, "adrmode", cfg.adrmode);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "screensaver", &flash8) != ESP_OK || flash8 != cfg.screensaver )
|
if (nvs_get_i8(my_handle, "screensaver", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.screensaver)
|
||||||
nvs_set_i8(my_handle, "screensaver", cfg.screensaver);
|
nvs_set_i8(my_handle, "screensaver", cfg.screensaver);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "screenon", &flash8) != ESP_OK || flash8 != cfg.screenon )
|
if (nvs_get_i8(my_handle, "screenon", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.screenon)
|
||||||
nvs_set_i8(my_handle, "screenon", cfg.screenon);
|
nvs_set_i8(my_handle, "screenon", cfg.screenon);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "countermode", &flash8) != ESP_OK || flash8 != cfg.countermode )
|
if (nvs_get_i8(my_handle, "countermode", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.countermode)
|
||||||
nvs_set_i8(my_handle, "countermode", cfg.countermode);
|
nvs_set_i8(my_handle, "countermode", cfg.countermode);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "sendcycle", &flash8) != ESP_OK || flash8 != cfg.sendcycle )
|
if (nvs_get_i8(my_handle, "sendcycle", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.sendcycle)
|
||||||
nvs_set_i8(my_handle, "sendcycle", cfg.sendcycle);
|
nvs_set_i8(my_handle, "sendcycle", cfg.sendcycle);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "wifichancycle", &flash8) != ESP_OK || flash8 != cfg.wifichancycle )
|
if (nvs_get_i8(my_handle, "wifichancycle", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.wifichancycle)
|
||||||
nvs_set_i8(my_handle, "wifichancycle", cfg.wifichancycle);
|
nvs_set_i8(my_handle, "wifichancycle", cfg.wifichancycle);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "blescantime", &flash8) != ESP_OK || flash8 != cfg.blescantime )
|
if (nvs_get_i8(my_handle, "blescantime", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.blescantime)
|
||||||
nvs_set_i8(my_handle, "blescantime", cfg.blescantime);
|
nvs_set_i8(my_handle, "blescantime", cfg.blescantime);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "blescanmode", &flash8) != ESP_OK || flash8 != cfg.blescan )
|
if (nvs_get_i8(my_handle, "blescanmode", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.blescan)
|
||||||
nvs_set_i8(my_handle, "blescanmode", cfg.blescan);
|
nvs_set_i8(my_handle, "blescanmode", cfg.blescan);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "wifiant", &flash8) != ESP_OK || flash8 != cfg.wifiant )
|
if (nvs_get_i8(my_handle, "wifiant", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.wifiant)
|
||||||
nvs_set_i8(my_handle, "wifiant", cfg.wifiant);
|
nvs_set_i8(my_handle, "wifiant", cfg.wifiant);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "vendorfilter", &flash8) != ESP_OK || flash8 != cfg.vendorfilter )
|
if (nvs_get_i8(my_handle, "vendorfilter", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.vendorfilter)
|
||||||
nvs_set_i8(my_handle, "vendorfilter", cfg.vendorfilter);
|
nvs_set_i8(my_handle, "vendorfilter", cfg.vendorfilter);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "rgblum", &flash8) != ESP_OK || flash8 != cfg.rgblum )
|
if (nvs_get_i8(my_handle, "rgblum", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.rgblum)
|
||||||
nvs_set_i8(my_handle, "rgblum", cfg.rgblum);
|
nvs_set_i8(my_handle, "rgblum", cfg.rgblum);
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "gpsmode", &flash8) != ESP_OK || flash8 != cfg.gpsmode )
|
if (nvs_get_i8(my_handle, "gpsmode", &flash8) != ESP_OK ||
|
||||||
|
flash8 != cfg.gpsmode)
|
||||||
nvs_set_i8(my_handle, "gpsmode", cfg.gpsmode);
|
nvs_set_i8(my_handle, "gpsmode", cfg.gpsmode);
|
||||||
|
|
||||||
if( nvs_get_i16(my_handle, "rssilimit", &flash16) != ESP_OK || flash16 != cfg.rssilimit )
|
if (nvs_get_i16(my_handle, "rssilimit", &flash16) != ESP_OK ||
|
||||||
|
flash16 != cfg.rssilimit)
|
||||||
nvs_set_i16(my_handle, "rssilimit", cfg.rssilimit);
|
nvs_set_i16(my_handle, "rssilimit", cfg.rssilimit);
|
||||||
|
|
||||||
err = nvs_commit(my_handle);
|
err = nvs_commit(my_handle);
|
||||||
@ -153,7 +174,8 @@ void loadConfig() {
|
|||||||
open_storage();
|
open_storage();
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGW(TAG, "Error (%d) opening NVS handle, storing defaults", err);
|
ESP_LOGW(TAG, "Error (%d) opening NVS handle, storing defaults", err);
|
||||||
saveConfig(); } // saves factory settings to NVRAM
|
saveConfig();
|
||||||
|
} // saves factory settings to NVRAM
|
||||||
else {
|
else {
|
||||||
int8_t flash8 = 0;
|
int8_t flash8 = 0;
|
||||||
int16_t flash16 = 0;
|
int16_t flash16 = 0;
|
||||||
@ -164,7 +186,8 @@ void loadConfig() {
|
|||||||
nvs_get_str(my_handle, "version", cfg.version, &required_size);
|
nvs_get_str(my_handle, "version", cfg.version, &required_size);
|
||||||
ESP_LOGI(TAG, "NVRAM settings version = %s", cfg.version);
|
ESP_LOGI(TAG, "NVRAM settings version = %s", cfg.version);
|
||||||
if (strcmp(cfg.version, PROGVERSION)) {
|
if (strcmp(cfg.version, PROGVERSION)) {
|
||||||
ESP_LOGI(TAG, "migrating NVRAM settings to new version %s", PROGVERSION);
|
ESP_LOGI(TAG, "migrating NVRAM settings to new version %s",
|
||||||
|
PROGVERSION);
|
||||||
nvs_close(my_handle);
|
nvs_close(my_handle);
|
||||||
migrateVersion();
|
migrateVersion();
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ extern char display_lora[], display_lmic[];
|
|||||||
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
||||||
extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters
|
extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters
|
||||||
extern std::set<uint16_t> macs;
|
extern std::set<uint16_t> macs;
|
||||||
extern hw_timer_t * channelSwitch; // hardware timer used for wifi channel switching
|
extern hw_timer_t
|
||||||
|
*channelSwitch; // hardware timer used for wifi channel switching
|
||||||
extern xref2u1_t rcmd_data; // buffer for rcommand results size
|
extern xref2u1_t rcmd_data; // buffer for rcommand results size
|
||||||
extern u1_t rcmd_data_size; // buffer for rcommand results size
|
extern u1_t rcmd_data_size; // buffer for rcommand results size
|
||||||
|
@ -28,8 +28,7 @@ void gps_loop(void * pvParameters) {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
if (cfg.gpsmode)
|
if (cfg.gpsmode) {
|
||||||
{
|
|
||||||
#if defined GPS_SERIAL
|
#if defined GPS_SERIAL
|
||||||
|
|
||||||
// serial connect to GPS device
|
// serial connect to GPS device
|
||||||
|
Loading…
Reference in New Issue
Block a user