macro definition #ifdef ENABLE_SOFTAP (#1698)

* macro definition #ifdef ENABLE_SOFTAP

* Update platformio.ini

* softap define in define.h

* Update platformio.ini

* #define WLAN_CONFIG_FILE "/sdcard/wlan.ini"

Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com>
This commit is contained in:
Nicolas Liaudat
2022-12-27 19:04:29 +01:00
committed by GitHub
parent 39a02c6d6d
commit fca37ee699
6 changed files with 28 additions and 15 deletions

View File

@@ -549,7 +549,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
if ((toUpper(splitted[0]) == "RSSITHREASHOLD") && (splitted.size() > 1))
{
if (ChangeRSSIThreashold("/sdcard/wlan.ini", atoi(splitted[1].c_str())))
if (ChangeRSSIThreashold(WLAN_CONFIG_FILE, atoi(splitted[1].c_str())))
{
// reboot necessary so that the new wlan.ini is also used !!!
fclose(pfile);
@@ -562,7 +562,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
if ((toUpper(splitted[0]) == "HOSTNAME") && (splitted.size() > 1))
{
if (ChangeHostName("/sdcard/wlan.ini", splitted[1]))
if (ChangeHostName(WLAN_CONFIG_FILE, splitted[1]))
{
// reboot necessary so that the new wlan.ini is also used !!!
fclose(pfile);

View File

@@ -335,7 +335,7 @@ bool CopyFile(string input, string output)
input = FormatFileName(input);
output = FormatFileName(output);
if (toUpper(input).compare("/SDCARD/WLAN.INI") == 0)
if (toUpper(input).compare(WLAN_CONFIG_FILE) == 0)
{
ESP_LOGD(TAG, "wlan.ini kann nicht kopiert werden!");
return false;

View File

@@ -23,8 +23,12 @@
#define CAMERA_MODEL_AI_THINKER
#define BOARD_ESP32CAM_AITHINKER
//server_GPIO + server_file
//server_GPIO + server_file + SoftAP
#define CONFIG_FILE "/sdcard/config/config.ini"
//ClassFlowControll + Main + SoftAP
#define WLAN_CONFIG_FILE "/sdcard/wlan.ini"
//main
#define __SD_USE_ONE_LINE_MODE__
@@ -112,7 +116,6 @@
#define WIFI_FAIL_BIT BIT1
//ClassFlowCNNGeneral
//ready for translateion
#define Analog_error 3
#define AnalogToDigtalFehler 0.8
#define Digital_Uncertainty 0.2
@@ -122,6 +125,8 @@
#define Digital_Transition_Area_Forward 9.7 // Pre-run zero crossing only happens from approx. 9.7 onwards
//#define DEBUG_DETAIL_ON
@@ -251,4 +256,12 @@
#endif //USE_PWM_LEDFLASH
//softAP
#ifdef ENABLE_SOFTAP
#define EXAMPLE_ESP_WIFI_SSID "AI-on-the-Edge"
#define EXAMPLE_ESP_WIFI_PASS ""
#define EXAMPLE_ESP_WIFI_CHANNEL 11
#define EXAMPLE_MAX_STA_CONN 1
#endif // ENABLE_SOFTAP
#endif // ifndef defines_h

View File

@@ -39,7 +39,9 @@
#include "../../include/defines.h"
//#include "server_GPIO.h"
#ifdef ENABLE_SOFTAP
#include "softAP.h"
#endif //ENABLE_SOFTAP
extern const char* GIT_TAG;
extern const char* GIT_REV;
@@ -182,7 +184,7 @@ extern "C" void app_main(void)
#endif
char *ssid = NULL, *passwd = NULL, *hostname = NULL, *ip = NULL, *gateway = NULL, *netmask = NULL, *dns = NULL; int rssithreashold = 0;
LoadWlanFromFile("/sdcard/wlan.ini", ssid, passwd, hostname, ip, gateway, netmask, dns, rssithreashold);
LoadWlanFromFile(WLAN_CONFIG_FILE, ssid, passwd, hostname, ip, gateway, netmask, dns, rssithreashold);
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "WLAN-Settings - RSSI-Threashold: " + to_string(rssithreashold));

View File

@@ -1,5 +1,7 @@
#ifdef ENABLE_SOFTAP
//if ENABLE_SOFTAP = disabled, set CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n in sdkconfig.defaults to save 28k of flash
#include "../../include/defines.h"
#include "softAP.h"
@@ -34,10 +36,6 @@
If you'd rather not, just change the below entries to strings with
the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
*/
#define EXAMPLE_ESP_WIFI_SSID "AI-on-the-Edge"
#define EXAMPLE_ESP_WIFI_PASS ""
#define EXAMPLE_ESP_WIFI_CHANNEL 11
#define EXAMPLE_MAX_STA_CONN 1
bool isConfigINI = false;
bool isWlanINI = false;
@@ -102,7 +100,7 @@ void SendHTTPResponse(httpd_req_t *req)
message += "Please follow the below instructions.<p>";
httpd_resp_send_chunk(req, message.c_str(), strlen(message.c_str()));
isWlanINI = FileExists("/sdcard/wlan.ini");
isWlanINI = FileExists(WLAN_CONFIG_FILE);
if (!isConfigINI)
{
@@ -267,7 +265,7 @@ esp_err_t config_ini_handler(httpd_req_t *req)
}
};
FILE* configfilehandle = fopen("/sdcard/wlan.ini", "w");
FILE* configfilehandle = fopen(WLAN_CONFIG_FILE, "w");
if (ssid.length())
ssid = "ssid = \"" + ssid + "\"\n";
@@ -474,8 +472,8 @@ httpd_handle_t start_webserverAP(void)
void CheckStartAPMode()
{
isConfigINI = FileExists("/sdcard/config/config.ini");
isWlanINI = FileExists("/sdcard/wlan.ini");
isConfigINI = FileExists(CONFIG_FILE);
isWlanINI = FileExists(WLAN_CONFIG_FILE);
if (!isConfigINI or !isWlanINI)
{

View File

@@ -32,4 +32,4 @@ debug_tool = esp-prog
; Enable and adapt for logging over USB
;upload_port = /dev/ttyUSB0
upload_port =com3
;upload_port =com3