As initially planned starting wifi only when needed, at change to HTTP mode.
Tested this on breakout board: ESP32 is not getting hot anymore!
Also optimized timeout: only notify "forgot to turn off" when battery is below certain
threshold (e.g. disable when charger is connected over night)
main:
- dont start wifi at startup anymore
- remove double-initialization of nvs
already initialized in wifi.c, thus removed some code
- optimize comments, logging
control:
- timeout "forgot to turn off": Add battery threshold
- start/stop wifi when switching to/from HTTP mode
wifi:
- split init function to separate functions for NVS and NETIF (more clear in main)
- optimize log output at nvs init (moved from main)
- rename start/stop functions, formatting
23 lines
582 B
C
23 lines
582 B
C
#pragma once
|
|
|
|
//TODO: currently wifi names and passwords are configured in wifi.c -> move this to config?
|
|
|
|
//initialize nvs-flash and netif (needed for both AP and CLIENT)
|
|
//both functions have to be run once at startup
|
|
void wifi_initNvs();
|
|
void wifi_initNetif();
|
|
|
|
|
|
//function to start an access point (config in wifi.c)
|
|
void wifi_start_ap(void);
|
|
//function to disable/stop access point
|
|
void wifi_stop_ap(void);
|
|
|
|
//function to connect to existing wifi network (config in wifi.c)
|
|
void wifi_start_client(void);
|
|
//function to disable/deinit client
|
|
void wifi_stop_client(void);
|
|
|
|
|
|
|