Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Firmware/factoryTest/FactoryTest_wMenu/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
compile_commands.json
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yukti's solution worked: (ignore \r in the line reader and only terminate on \n. )
Side effect in the Arduino IDE we need to wait until it timeout 25s but it is successfully connecting to the wifi now.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#define DEVICE_UNDER_TEST "SN: LB0008" //A Serial Number
#define PROG_NAME "FactoryTest_wMenu"
#define FIRMWARE_VERSION "v0.4.5.1"
#define FIRMWARE_VERSION "v0.4.6.1"
/*
------------------------------------------------------------------------------
File: FactoryTest_wMenu.ino
Project: Krake / GPAD v2 – Factory Test Firmware
Document Type: Source Code (Factory Test)
Document ID: KRAKE-FT-ESP32-FT01
Version: v0.4.5.1
Date: 2026-03-17
Version: v0.4.6.1
Date: 2026-03-31
Author(s): Nagham Kheir, Public Invention
Status: Draft
------------------------------------------------------------------------------
Expand Down Expand Up @@ -58,6 +58,9 @@ Revision History:
| | | | RC debounce C602 on PCB. internalPullup=false. |
| | | | Requires: OneButton lib from Library Manager. |
|v0.4.5.1 | 2026-3-23 | Yukti | Fixed DFPlayer ACK handling |
|v0.4.5.2 | 2026-3-24 | Yukti | Added MAC address display to splash screen |
|v0.4.6.0 | 2026-3-31 | Yukti | Migrate to PlatformIO (#352) |
|v0.4.6.1 | 2026-4-01 | Yukti | Ignore CR characters in serial input |
----------------------------------------------------------------------------------------|
Overview:
- Repeatable factory test sequence for ESP32-WROOM-32D Krake/GPAD v2 boards.
Expand Down Expand Up @@ -258,7 +261,8 @@ static bool readLineOrMenuAbort(String& out, uint32_t timeoutMs = 15000) {
while (Serial.available()) {
char c = Serial.read();

if (c == '\n' || c == '\r') {
if (c == '\r') continue; // skip CR; LF terminates (handles CRLF from PlatformIO)
if (c == '\n') {
out.trim();
if (out.length() == 1 && isMenuKey(out[0])) {
g_pendingCmd = up(out[0]);
Expand Down Expand Up @@ -377,7 +381,6 @@ static void printBanner() {
}

void splashserial(void) {
//Serial splash
Serial.println(F("===================== Serial Splash ===================="));
Serial.println(PROG_NAME);
Serial.print(VERSION);
Expand All @@ -386,6 +389,8 @@ void splashserial(void) {
Serial.print(F("Compiled at: "));
Serial.println(F(__DATE__ " " __TIME__)); //compile date that is used for a unique identifier
Serial.println(LICENSE);
Serial.print(F("MAC (STA): "));
Serial.println(WiFi.macAddress());
Serial.println(F("======================================================="));
}

Expand Down Expand Up @@ -723,16 +728,20 @@ static bool initDFPlayer() {
pinMode(DF_BUSY_IN, INPUT_PULLUP);

dfSerial.begin(9600, SERIAL_8N1, DF_RXD2, DF_TXD2);

delay(300);

if (!dfPlayer.begin(dfSerial, false, true)) {
Serial.println(F("DFPlayer not detected (begin failed)."));
Serial.println(F("DFPlayer not detected (check connections)."));
dfState = DF_FAIL;
return false;
}
else {
Serial.println(F("DFPlayer detected."));
}

dfPlayer.setTimeOut(1000);
dfPlayer.enableACK(); // ← restore ACK for the rest of the session
//dfPlayer.enableACK(); // ← restore ACK for the rest of the session
dfPlayer.outputDevice(DFPLAYER_DEVICE_SD);
delay(1200);

Expand All @@ -747,6 +756,7 @@ static bool initDFPlayer() {
return true;
}


// Put this OUTSIDE of runTest_DFPlayer() (global scope).
// Call it when dfPlayer.available() is true.
void printDetail(uint8_t type, int value) {
Expand Down Expand Up @@ -940,9 +950,11 @@ static bool runTest_WifiAP() {
static bool runTest_WifiSTA() {
Serial.println(F("\n[8] Wi-Fi STA (manual SSID/PASS)"));

WiFi.disconnect(false, true); // erase stored NVS credentials while driver is still alive
WiFi.mode(WIFI_OFF); // full radio off (handles AP→STA transition cleanly)
delay(200);
WiFi.mode(WIFI_STA);
WiFi.disconnect(true, true);
delay(300);
delay(200);

flushSerialRx();

Expand Down Expand Up @@ -970,6 +982,7 @@ static bool runTest_WifiSTA() {

Serial.print(F("Connecting to: "));
Serial.println(ssid);
WiFi.persistent(false); // do not save test credentials to NVS flash
WiFi.begin(ssid.c_str(), pass.c_str());

uint32_t start = millis();
Expand Down Expand Up @@ -1373,12 +1386,11 @@ void setup() {

//Mount LittleFS at boot so ElegantOTA can use it immediately
g_littleFsMounted = LittleFS.begin(true);
if (!g_littleFsMounted) {
Serial.println(F("WARNING: LittleFS mount failed at boot."));
} else {
Serial.println(F("LittleFS mounted OK."));
}
Serial.println(g_littleFsMounted ? F("[boot] LittleFS... OK") : F("[boot] WARNING: LittleFS mount failed."));

WiFi.mode(WIFI_STA);
delay(100);
Serial.println(F("[boot] WiFi init... OK"));
WiFi.mode(WIFI_OFF);
delay(50);

Expand Down
28 changes: 28 additions & 0 deletions Firmware/factoryTest/FactoryTest_wMenu/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
src_dir = FactoryTest_wMenu

[env:esp32dev]
platform = espressif32@^6.12.0
board = esp32dev
board_build.filesystem = littlefs
framework = arduino
monitor_speed = 115200
build_flags =
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
lib_deps =
marcoschwartz/LiquidCrystal_I2C@^1.1.4
dfrobot/DFRobotDFPlayerMini@^1.0.6
esp32async/AsyncTCP@^3.4.10
esp32async/ESPAsyncWebServer@^3.7.3
ayushsharma82/ElegantOTA@^3.1.7
mathertel/OneButton@^2.6.2