-
Notifications
You must be signed in to change notification settings - Fork 6
latest version #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
latest version #19
Changes from all commits
2007a15
ad4fe20
0e96883
c9e5682
e7aaa08
7f80374
56c1f79
2625ca2
80577e7
8a3694a
7cc36cc
51e6955
4a2c20e
4e072f6
e154afd
743914e
dae1472
c6d8552
9bcdf7c
7782410
b6c30bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
|
|
||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #ifndef CONFIG_H | ||
| #define CONFIG_H | ||
|
|
||
| #include <Arduino.h> | ||
|
|
||
| // --- SoftAP Configuration (Hosted by Station 1) --- | ||
| const char* AP_SSID = "Web3_Showcase_AP"; | ||
| const char* AP_PASSWORD = NULL; // Open network for easy Captive Portal | ||
|
|
||
| // --- IP Address Mapping --- | ||
| // Gateway (Station 1) must be x.x.x.1 | ||
| IPAddress IP_STATION1_AP(192, 168, 4, 1); // Core2: Identity & AP | ||
| IPAddress IP_STATION2_MON(192, 168, 4, 2); // Core2: Auth Monitor | ||
| IPAddress IP_RESET_MON(192, 168, 4, 3); // Core Basic: System Monitor & Reset | ||
|
|
||
| IPAddress IP_STICKC(192, 168, 4, 10); // Wearable | ||
| IPAddress IP_ATOM_MATRIX(192, 168, 4, 20); // S2/S4 Sensor | ||
| IPAddress IP_ATOM_ECHO(192, 168, 4, 30); // Sound | ||
| IPAddress IP_PAPER_S3(192, 168, 4, 40); // Earn | ||
| IPAddress IP_PAPER_S4(192, 168, 4, 50); // Spend | ||
|
|
||
| IPAddress NETMASK(255, 255, 255, 0); | ||
|
|
||
| // --- Endpoints --- | ||
| #define ENDPOINT_HEARTBEAT "/heartbeat" | ||
| #define ENDPOINT_SET_USER "/set_user" | ||
| #define ENDPOINT_SET_AUTH "/set_auth" | ||
| #define ENDPOINT_RESET_GLOBAL "/reset_global" | ||
|
|
||
| // Earn และ Spend | ||
| #define ENDPOINT_EARN_COIN "/earn_coin" | ||
| #define ENDPOINT_SPEND_COIN "/spend_coin" | ||
|
|
||
| // Station 4 Order System | ||
| #define ENDPOINT_GET_ORDER "/get_order" | ||
| #define ENDPOINT_SEND_ORDER "/send_order" | ||
|
|
||
| // Audio Endpoints | ||
| #define ENDPOINT_PLAY_AUTH "/play_auth" | ||
| #define ENDPOINT_PLAY_TX "/play_tx" | ||
|
|
||
| #endif // CONFIG_H | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,149 @@ | ||||||||
| #include <M5Unified.h> | ||||||||
| #include <WiFi.h> | ||||||||
| #include <AsyncTCP.h> | ||||||||
| #include <ESPAsyncWebServer.h> | ||||||||
| #include <qrcode.h> | ||||||||
| #include <HTTPClient.h> | ||||||||
|
|
||||||||
| // 1. กำหนดค่า SoftAP | ||||||||
|
||||||||
| const char *ssid = "Web3Showcase_AP"; | ||||||||
|
||||||||
| const char *ssid = "Web3Showcase_AP"; | |
| const char *ssid = "Web3_Showcase_AP"; |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded password "12345678" is a weak password and poses a security risk. For a production system or public demonstration, this password is easily guessable and should be replaced with a stronger password. Consider using a more complex password or making it configurable.
| const char *password = "12345678"; | |
| // TODO: For production, make the password configurable and do not hardcode it in source code. | |
| const char *password = "w3Showcase!2024#ap"; |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The STICKC_IP is hardcoded as "192.168.4.2" which conflicts with the IP address mapping defined in all config.h files where IP_STICKC is defined as 192.168.4.10. This mismatch will cause the Core2 to send requests to the wrong IP address, preventing communication with the StickC device.
| const char* STICKC_IP = "192.168.4.2"; | |
| const char* STICKC_IP = "192.168.4.10"; |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The endpoint "/set_username" is used here but does not match any endpoint definition in the config files. According to the config files, the user endpoint is defined as ENDPOINT_SET_USER with value "/set_user". This mismatch will cause communication failures between Core2 and StickC.
| String url = "http://" + String(STICKC_IP) + ":" + String(STICKC_PORT) + "/set_username"; | |
| String url = "http://" + String(STICKC_IP) + ":" + String(STICKC_PORT) + "/set_user"; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,196 @@ | ||||||||||||||||
| #include <M5Unified.h> | ||||||||||||||||
| #include <WiFi.h> | ||||||||||||||||
| #include <AsyncTCP.h> | ||||||||||||||||
| #include <ESPAsyncWebServer.h> | ||||||||||||||||
| #include <BLEDevice.h> | ||||||||||||||||
| #include <BLEUtils.h> | ||||||||||||||||
| #include <BLEServer.h> | ||||||||||||||||
| #include <esp_gap_ble_api.h> // เพิ่ม Library นี้สำหรับเปลี่ยนชื่อแบบ Fast Mode | ||||||||||||||||
|
||||||||||||||||
|
|
||||||||||||||||
| // --- CONFIGURATION --- | ||||||||||||||||
| const char *SSID_AP = "Web3Showcase_AP"; | ||||||||||||||||
|
||||||||||||||||
| const char *SSID_AP = "Web3Showcase_AP"; | |
| const char *SSID_AP = "Web3_Showcase_AP"; |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded password "12345678" is a weak password and poses a security risk. For a production system or public demonstration, this password is easily guessable and should be replaced with a stronger password. Consider using a more complex password or making it configurable.
| const char *PASSWORD_AP = "12345678"; | |
| // Set WiFi AP password: Change this for production use! | |
| #ifndef PASSWORD_AP_VALUE | |
| #define PASSWORD_AP_VALUE "w3Showcase!2024" | |
| #endif | |
| const char *PASSWORD_AP = PASSWORD_AP_VALUE; |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming inconsistency. The variable is named "authenStatus" but should be "authStatus" or "authenticationStatus" for clarity. The abbreviation "authen" is non-standard; the standard abbreviation is "auth".
| String authenStatus = "X"; | |
| String authStatus = "X"; |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name is inconsistent: the endpoint expects "amount" but the handler uses "value" to extract the parameter. This will cause the coin amount to not be received correctly. Line 120 should use "amount" instead of "value" to match the POST data being sent from Station3's paper.ino at line 120.
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message refers to "value" parameter but the actual parameter name should be "amount" based on how the endpoint is used in Station3/paper/paper.ino. This inconsistency will be confusing when debugging. The error message should say "Missing amount Parameter" to match the expected parameter name.
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The endpoint "/set_username" is used here but does not match any endpoint definition in the config files. According to the config files, the user endpoint is defined as ENDPOINT_SET_USER with value "/set_user". This mismatch will cause communication failures between Core2 and StickC. The endpoint should be updated to match the config definition.
| stickCServer.on("/set_username", HTTP_POST, handleUsername); | |
| stickCServer.on("/set_username", HTTP_GET, handleUsername); | |
| stickCServer.on("/set_user", HTTP_POST, handleUsername); | |
| stickCServer.on("/set_user", HTTP_GET, handleUsername); |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The endpoint used here is "/add_coin" but in all config.h files, the endpoint for earning coins is defined as ENDPOINT_EARN_COIN with value "/earn_coin". This inconsistency between the endpoint definition and usage will cause HTTP requests to fail. The code should use the endpoint defined in the config files or update the endpoint name to match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Open network for easy Captive Portal" but the AP_PASSWORD is actually set to NULL, not a comment. The comment is misleading as it describes what should happen when using an open network, but doesn't clearly state that this IS an open network configuration. Consider clarifying to "NULL = Open network for easy Captive Portal" to make it explicit.