Skip to content

Station2 - #12

Open
Floridae242 wants to merge 12 commits into
mainfrom
station2
Open

Station2#12
Floridae242 wants to merge 12 commits into
mainfrom
station2

Conversation

@Floridae242

Copy link
Copy Markdown
Collaborator

No description provided.

Pinont and others added 10 commits November 29, 2025 13:30
feat: Add initial M5Paper activity selection UI, other M5Stack device…
ตอนนี้รอstickC เลยทำเป็นแบบกดechoแล้วส่งrequestไปcore2 แต่เขียนให้รับค่าrequestจากmatrixไว้แล้ว
ให้echo request to core2
Copilot AI review requested due to automatic review settings December 9, 2025 03:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Station2 functionality to a Web3 Showcase IoT project, implementing an authentication system using M5Stack devices. The changes introduce communication between multiple ESP32-based devices (M5StickPlus2, Atom Matrix, Atom Echo, Core2) via WiFi, HTTP, ESP-NOW, and BLE protocols.

Key Changes:

  • Implementation of Station2 authentication workflow across Matrix, Echo, and Core2 monitor devices
  • Addition of M5StickPlus2 wearable device code for user identity and coin management
  • Configuration of shared networking protocols and IP address mappings
  • Integration of BLE-based proximity detection and ESP-NOW messaging

Reviewed changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
m5stickplus2/m5stickplus2.ino StickPlus2 wearable device handling user registration, authentication status, and coin balance
Station2-Matrix/src/main.cpp Atom Matrix sensor triggering authentication via button press and WiFi scanning
Station2-Matrix/src/main(matrix-2).cpp Alternative Matrix implementation using BLE scanning and ESP-NOW communication
Station2-Echo/src/main.cpp Atom Echo audio controller playing authentication and transaction sounds
Station2-Echo/echo1/echo1.ino Alternative Echo implementation with ESP-NOW state machine for sound sequences
Station2-Core2/src/main.cpp Core2 monitor displaying authentication status and user information
Station2-Matrix/lib/ProjectShared/config.h Shared network configuration including IP addresses and endpoints
Station2-Matrix/include/ShowcaseProtocol.h Protocol definitions for ESP-NOW messaging with checksums
Station2-Matrix/platformio.ini PlatformIO configuration for Matrix with M5Atom dependencies
Station2-Echo/platformio.ini PlatformIO configuration for Echo with M5Unified library
Station2-Core2/platformio.ini PlatformIO configuration for Core2 with async web server
M5Paper/M5Paper.ino E-paper interface for activity selection and coin earning
Atom_echo/Atom_echo.ino Standalone Echo device with I2S audio and ESP-NOW trigger
Atom-matrix Standalone Matrix with BLE scanning and proximity-based authentication
.gitignore Standard macOS .DS_Store exclusion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

String alertText = "Waiting for Identity...";

// --- UI DATA ---
// ตัวแปรสำหรับเก็บ MAC Address ของตัวเอง (ใช้ในการอ้างอิงสำหรับ Atom Matrix ใน Station 2)

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The comment uses inconsistent naming for M5Stack devices. Line 21 refers to "StickC-Plus2" but other parts of the codebase and the file structure use "StickPlus2" (without the hyphen). Consider using consistent naming throughout the codebase.

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +106
server.on(ENDPOINT_PLAY_AUTH, HTTP_POST, handlePlayAuth);
server.on(ENDPOINT_PLAY_TX_SUCCESS, HTTP_POST, handlePlayTx);
server.on(ENDPOINT_RESET_USER, HTTP_POST, handleSystemReset);

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

The endpoints ENDPOINT_PLAY_TX_SUCCESS and ENDPOINT_RESET_USER are referenced but not defined in config.h. This will cause compilation errors. The config.h file only defines ENDPOINT_HEARTBEAT, ENDPOINT_SET_USER, ENDPOINT_SET_AUTH, ENDPOINT_RESET_GLOBAL, ENDPOINT_EARN_COIN, ENDPOINT_SPEND_COIN, and ENDPOINT_GET_ORDER.

Copilot uses AI. Check for mistakes.
Serial.begin(115200);

// กำหนด Static IP
WiFi.config(IP_ATOM_ECHO, IP_CORE2, IPAddress(255, 255, 255, 0));

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent IP address usage. Line 91 references IP_CORE2 which is not defined in config.h. According to the config.h file, the correct IP address constant for the Core2 station is IP_STATION1_AP. This will cause a compilation error.

Suggested change
WiFi.config(IP_ATOM_ECHO, IP_CORE2, IPAddress(255, 255, 255, 0));
WiFi.config(IP_ATOM_ECHO, IP_STATION1_AP, IPAddress(255, 255, 255, 0));

Copilot uses AI. Check for mistakes.

// 2. RSSI Trigger: ตรวจจับสัญญาณ StickC
static unsigned long lastScan = 0;
if (millis() - lastScan > 3000 && !isAuthInProgress) { // Scan ทุก 3 วิ

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The comment on line 80 suggests this is a "3 วิ" (3 second) scan interval, but the actual code checks for a 3000ms (3 second) interval. The Thai comment is correct, but it would be clearer to note that "3 วิ" = "3000ms" for consistency.

Suggested change
if (millis() - lastScan > 3000 && !isAuthInProgress) { // Scan ทุก 3 วิ
if (millis() - lastScan > 3000 && !isAuthInProgress) { // Scan ทุก 3 วิ (3000ms)

Copilot uses AI. Check for mistakes.
http.setTimeout(2000);

// 1. สั่ง Atom Echo เล่นเสียง
http.begin("http://" + IP_ATOM_ECHO.toString() + ENDPOINT_PLAY_AUTH);

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

The endpoint ENDPOINT_PLAY_AUTH is referenced but not defined in config.h. This will cause a compilation error. The config.h file only defines ENDPOINT_HEARTBEAT, ENDPOINT_SET_USER, ENDPOINT_SET_AUTH, ENDPOINT_RESET_GLOBAL, ENDPOINT_EARN_COIN, ENDPOINT_SPEND_COIN, and ENDPOINT_GET_ORDER.

Copilot uses AI. Check for mistakes.
}

void handleSystemReset(AsyncWebServerRequest *request) {
M5.Speaker.end(); // หยุดเสียงที่กำลังเล่น

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

The M5.Speaker.end() method is called to stop the speaker, but according to the M5Atom documentation, the correct method is M5.Speaker.stop(). This inconsistency with the proper API usage may cause unexpected behavior.

Copilot uses AI. Check for mistakes.
M5.dis.drawpix(0, 0x000000); delay(200);
}
// เชื่อมต่อแล้ว (ไฟสีเขียวแวบหนึ่ง)
WiFi.config(IP_ATOM_MATRIX_S2, IP_STATION1_AP, NETMASK, IP_STATION1_AP);

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

The IP address mapping is inconsistent. Line 58 references IP_ATOM_MATRIX_S2 which is not defined in config.h. The config.h file defines IP_ATOM_MATRIX instead. This will cause a compilation error.

Suggested change
WiFi.config(IP_ATOM_MATRIX_S2, IP_STATION1_AP, NETMASK, IP_STATION1_AP);
WiFi.config(IP_ATOM_MATRIX, IP_STATION1_AP, NETMASK, IP_STATION1_AP);

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +5
#include <M5Atom.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ESPAsyncWebServer.h>
#include "config.h"

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

Missing #include <HTTPClient.h> at the top of the file. The code uses HTTPClient class in lines 23-39 but doesn't include the necessary header file, which will cause compilation errors.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +55
HTTPClient http;
// Notify Core2 (Monitor)
http.begin(String("http://") + IP_CORE2.toString() + ENDPOINT_SET_AUTH);
http.POST("{}");
http.end();

// Notify StickC-Plus2 (Wearable)
http.begin(String("http://") + IP_STICKC.toString() + ENDPOINT_SET_AUTH);
http.POST("{}");
http.end();

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

The endpoint ENDPOINT_PLAY_AUTH is used but not defined in config.h. Additionally, the referenced IP addresses IP_CORE2 and IP_STICKC don't exist in config.h - the correct names are IP_STATION1_AP and IP_STICKC respectively. This will cause compilation errors.

Copilot uses AI. Check for mistakes.
esp_wifi_set_channel(1, WIFI_SECOND_CHAN_NONE);

if (esp_now_init() != ESP_OK) {
Serial.println("ESR-NOW Init Failed");

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

Typo in error message: "ESR-NOW" should be "ESP-NOW". This is inconsistent with the rest of the codebase which correctly uses "ESP-NOW".

Suggested change
Serial.println("ESR-NOW Init Failed");
Serial.println("ESP-NOW Init Failed");

Copilot uses AI. Check for mistakes.
bkmintra and others added 2 commits December 9, 2025 14:09
Refactor main.cpp to include ESP-NOW functionality and improve authentication display.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants