Skip to content

Commit 2ebb656

Browse files
authored
Drop dedicated SimRa mode, simply enable Bluetooth for SimRa (#327)
Implements #325
1 parent 9b66734 commit 2ebb656

5 files changed

Lines changed: 10 additions & 18 deletions

File tree

docs/software/firmware/obs_cfg.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ relevant put the order of the array content.
7272
"privacyConfig": 10,
7373
// Active preset - always 0 as of today
7474
"selectedPreset": 0,
75-
// Selects if the SimRa mode is activated
76-
"simRa": false,
7775
// Password of your Wi-Fi where the OBS should log into in server mode
7876
"wifiPassword": "swordfish",
7977
// SSID of your Wi-Fi where the OBS should log into in server mode

src/OpenBikeSensorFirmware.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void setup() {
249249
sdCount++;
250250
obsDisplay->showTextOnGrid(2,
251251
obsDisplay->currentLine(), "SD... error " + String(sdCount));
252-
if (config.simRaMode || button.read() == HIGH || sdCount > 10) {
252+
if (button.read() == HIGH || sdCount > 10) {
253253
break;
254254
}
255255
delay(200);
@@ -280,7 +280,7 @@ void setup() {
280280
triggerServerMode = true;
281281
}
282282

283-
if (button.read() == HIGH || (!config.simRaMode && displayError != 0) || triggerServerMode) {
283+
if (button.read() == HIGH || triggerServerMode) {
284284
obsDisplay->showTextOnGrid(2, obsDisplay->newLine(), "Start Server");
285285
ESP_ERROR_CHECK_WITHOUT_ABORT(
286286
esp_bt_mem_release(ESP_BT_MODE_BTDM)); // no bluetooth at all here.
@@ -339,9 +339,7 @@ void setup() {
339339
sensorManager->pollDistancesAlternating();
340340
reportBluetooth();
341341
gps.showWaitStatus(obsDisplay);
342-
if (button.read() == HIGH
343-
|| (config.simRaMode && !gps.moduleIsAlive()) // no module && simRaMode
344-
) {
342+
if (button.read() == HIGH) {
345343
log_d("Skipped get GPS...");
346344
obsDisplay->showTextOnGrid(2, obsDisplay->currentLine(), "...skipped");
347345
break;

src/config.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const String ObsConfig::PROPERTY_OBS_NAME = String("obsName");
3939
const String ObsConfig::PROPERTY_NAME = String("name");
4040
const String ObsConfig::PROPERTY_BLUETOOTH = String("bluetooth");
4141
const String ObsConfig::PROPERTY_OFFSET = String("offset");
42-
const String ObsConfig::PROPERTY_SIM_RA = String("simRa");
4342
const String ObsConfig::PROPERTY_WIFI_SSID = String("wifiSsid");
4443
const String ObsConfig::PROPERTY_WIFI_PASSWORD = String("wifiPassword");
4544
const String ObsConfig::PROPERTY_PORTAL_URL = String("portalUrl");
@@ -139,7 +138,6 @@ void ObsConfig::makeSureSystemDefaultsAreSet() {
139138
JsonObject data = jsonData["obs"][0];
140139
ensureSet(data, PROPERTY_OBS_NAME, "OpenBikeSensor-" + String((uint16_t)(ESP.getEfuseMac() >> 32), 16));
141140
ensureSet(data, PROPERTY_NAME, "default");
142-
ensureSet(data, PROPERTY_SIM_RA, false);
143141
ensureSet(data, PROPERTY_BLUETOOTH, false);
144142
data[PROPERTY_OFFSET][0] = data[PROPERTY_OFFSET][0] | 35;
145143
data[PROPERTY_OFFSET][1] = data[PROPERTY_OFFSET][1] | 35;
@@ -207,6 +205,12 @@ bool ObsConfig::setProperty(int profile, String const &key, T const &value) {
207205
return true; // value == oldValue;
208206
}
209207

208+
bool ObsConfig::setProperty(int profile, String const &key, bool const &value) {
209+
auto oldValue = jsonData["obs"][profile][key];
210+
jsonData["obs"][profile][key] = value;
211+
return value == oldValue;
212+
}
213+
210214
bool ObsConfig::setProperty(int profile, String const &key, int const &value) {
211215
auto oldValue = jsonData["obs"][profile][key];
212216
jsonData["obs"][profile][key] = value;
@@ -368,7 +372,6 @@ void ObsConfig::fill(Config &cfg) const {
368372
cfg.confirmationTimeWindow = getProperty<int>(PROPERTY_CONFIRMATION_TIME_SECONDS);
369373
cfg.privacyConfig = getProperty<int>(PROPERTY_PRIVACY_CONFIG);
370374
cfg.bluetooth = getProperty<bool>(PROPERTY_BLUETOOTH);
371-
cfg.simRaMode = getProperty<bool>(PROPERTY_SIM_RA);
372375
cfg.privacyAreas.clear();
373376
if (selectedProfile != 0) { // not sure if we ever support PAs per profile.
374377
for (int i = 0; i < jsonData["obs"][selectedProfile][PROPERTY_PRIVACY_AREA].size(); i++) {
@@ -414,7 +417,6 @@ void ObsConfig::parseOldJsonDocument(DynamicJsonDocument &doc) {
414417
setProperty(0, PROPERTY_CONFIRMATION_TIME_SECONDS, doc["confirmationTimeWindow"] | 5);
415418
setProperty(0, PROPERTY_PRIVACY_CONFIG, doc["privacyConfig"] | AbsolutePrivacy);
416419
setProperty(0, PROPERTY_BLUETOOTH, doc["bluetooth"] | false);
417-
setProperty(0, PROPERTY_SIM_RA, doc["simRaMode"] | false);
418420

419421
int numPrivacyAreas = doc["numPrivacyAreas"] | 0;
420422
// Append new values to the privacy-vector

src/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ struct Config {
7272
char obsUserID[64];
7373
uint displayConfig;
7474
bool bluetooth;
75-
bool simRaMode;
7675
int privacyConfig;
7776
int confirmationTimeWindow;
7877
std::vector<PrivacyArea> privacyAreas;
@@ -100,6 +99,7 @@ class ObsConfig {
10099

101100
bool setProperty(int profile, const String &key, std::string const &value);
102101
bool setProperty(int profile, const String &key, String const &value);
102+
bool setProperty(int profile, const String &key, bool const &value);
103103
bool setProperty(int profile, const String &key, int const &value);
104104
template<typename T> bool setProperty(int profile, const String &key, T const &value);
105105
bool setOffsets(int profile, std::vector<int> const &value);

src/configServer.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,6 @@ static const char* const configIndex =
343343
"<input name='obsUserID' placeholder='API Key' value='{userId}' >"
344344
"<h3>Operation</h3>"
345345
"Enable Bluetooth <input type='checkbox' name='bluetooth' {bluetooth}>"
346-
"<hr>"
347-
"SimRa Mode <input type='checkbox' name='simRaMode' {simRaMode}>"
348346
"<input type=submit class=btn value=Save>";
349347

350348
static const char* const privacyIndexPostfix =
@@ -1155,8 +1153,6 @@ static void handleConfigSave(HTTPRequest * req, HTTPResponse * res) {
11551153
atoi(getParameter(params, "confirmationTimeWindow").c_str()));
11561154
theObsConfig->setProperty(0, ObsConfig::PROPERTY_BLUETOOTH,
11571155
(bool) (getParameter(params, "bluetooth") == "on"));
1158-
theObsConfig->setProperty(0, ObsConfig::PROPERTY_SIM_RA,
1159-
(bool) (getParameter(params, "simRaMode") == "on"));
11601156
theObsConfig->setProperty(0, ObsConfig::PROPERTY_PORTAL_TOKEN,
11611157
getParameter(params, "obsUserID"));
11621158
theObsConfig->setProperty(0, ObsConfig::PROPERTY_PORTAL_URL,
@@ -1227,8 +1223,6 @@ static void handleConfig(HTTPRequest *, HTTPResponse * res) {
12271223

12281224
html = replaceHtml(html, "{bluetooth}",
12291225
theObsConfig->getProperty<bool>(ObsConfig::PROPERTY_BLUETOOTH) ? "checked" : "");
1230-
html = replaceHtml(html, "{simRaMode}",
1231-
theObsConfig->getProperty<bool>(ObsConfig::PROPERTY_SIM_RA) ? "checked" : "");
12321226

12331227
const uint privacyConfig = (uint) theObsConfig->getProperty<int>(
12341228
ObsConfig::PROPERTY_PRIVACY_CONFIG);

0 commit comments

Comments
 (0)