Skip to content

Commit

Permalink
use firstboot variable for first config
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkucera committed Oct 7, 2023
1 parent 419a548 commit 8a2af73
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ void reset(){
}

void reset_config() {
WiFiManager wifiManager(Serial1); // Send debug on Serial1
wifiManager.resetSettings();
preferences.clear();
reset();
}

Expand Down Expand Up @@ -196,6 +195,8 @@ void saveParamsCallback () {
}

void setup() {
preferences.begin("esp-ebus", false);

check_reset();

#ifdef ESP32
Expand All @@ -211,24 +212,25 @@ void setup() {

disableTX();

preferences.begin("esp-ebus", false);

#ifdef PWM_PIN
ledcSetup(PWM_CHANNEL, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(PWM_PIN, PWM_CHANNEL);
#endif

set_pwm(preferences.getUInt("pwm_value", 130));

if (preferences.getBool("firstboot", true)){
preferences.putBool("firstboot", false);
WiFi.begin(DEFAULT_AP, DEFAULT_PASS);
}

WiFi.enableAP(false);
WiFi.begin();

#ifdef ESP32
WiFi.onEvent(on_connected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);
#endif

wifiManager.preloadWiFi(DEFAULT_AP, DEFAULT_PASS);

wifiManager.setSaveParamsCallback(saveParamsCallback);
wifiManager.addParameter(&param_pwm_value);

Expand Down

0 comments on commit 8a2af73

Please sign in to comment.