Skip to content

Commit

Permalink
macro definition #ifdef ENABLE_SOFTAP (#1698)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
nliaudat and jomjol authored Dec 27, 2022
1 parent 39a02c6 commit fca37ee
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions code/components/jomjol_flowcontroll/ClassFlowControll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion code/components/jomjol_helper/Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 15 additions & 2 deletions code/include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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
4 changes: 3 additions & 1 deletion code/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down
14 changes: 6 additions & 8 deletions code/main/softAP.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion code/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fca37ee

Please sign in to comment.