mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 06:37:38 +03:00
Compare commits
4 Commits
127b1e59fc
...
5687a22c4f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5687a22c4f | ||
|
|
78d6e5931c | ||
|
|
dac11c3fdd | ||
|
|
90446b31b0 |
@ -102,13 +102,18 @@ After flashing the new features, it’s recommended to capture detailed logs fro
|
||||
First, make sure all required Python packages are installed:
|
||||
|
||||
```python
|
||||
python3 -m pip install serial colorama matplotlib
|
||||
python3 -m pip install pyserial colorama matplotlib
|
||||
```
|
||||
after that run the script:
|
||||
```sh
|
||||
# For Linux
|
||||
# This was tested on Debian and should work on most Linux systems.
|
||||
python3 scripts/debugging_monitor.py
|
||||
|
||||
# For macOS
|
||||
python3 scripts/debugging_monitor.py /dev/cu.usbmodem2101
|
||||
```
|
||||
This was tested on Debian and should work on most Linux systems. Minor adjustments may be required for Windows or macOS.
|
||||
Minor adjustments may be required for Windows.
|
||||
|
||||
## Internals
|
||||
|
||||
|
||||
@ -11,7 +11,19 @@
|
||||
#include "fontIds.h"
|
||||
|
||||
namespace {
|
||||
constexpr const char* HOSTNAME = "crosspoint";
|
||||
// Generate hostname dynamically based on device MAC address
|
||||
String getDeviceHostname() {
|
||||
static String deviceHostname;
|
||||
if (deviceHostname.length() == 0) {
|
||||
uint64_t chipId = ESP.getEfuseMac();
|
||||
// Extract last 6 hex digits (24 bits) for serial number
|
||||
uint32_t serialNum = (uint32_t)(chipId & 0xFFFFFF);
|
||||
char hostname[32];
|
||||
snprintf(hostname, sizeof(hostname), "XTeinkX4-%06X", serialNum);
|
||||
deviceHostname = String(hostname);
|
||||
}
|
||||
return deviceHostname;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void CalibreConnectActivity::taskTrampoline(void* param) {
|
||||
@ -94,9 +106,9 @@ void CalibreConnectActivity::startWebServer() {
|
||||
state = CalibreConnectState::SERVER_STARTING;
|
||||
updateRequired = true;
|
||||
|
||||
if (MDNS.begin(HOSTNAME)) {
|
||||
if (MDNS.begin(getDeviceHostname().c_str())) {
|
||||
// mDNS is optional for the Calibre plugin but still helpful for users.
|
||||
Serial.printf("[%lu] [CAL] mDNS started: http://%s.local/\n", millis(), HOSTNAME);
|
||||
Serial.printf("[%lu] [CAL] mDNS started: http://%s.local/\n", millis(), getDeviceHostname().c_str());
|
||||
}
|
||||
|
||||
webServer.reset(new CrossPointWebServer());
|
||||
|
||||
@ -19,10 +19,24 @@ namespace {
|
||||
// AP Mode configuration
|
||||
constexpr const char* AP_SSID = "CrossPoint-Reader";
|
||||
constexpr const char* AP_PASSWORD = nullptr; // Open network for ease of use
|
||||
constexpr const char* AP_HOSTNAME = "crosspoint";
|
||||
constexpr uint8_t AP_CHANNEL = 1;
|
||||
constexpr uint8_t AP_MAX_CONNECTIONS = 4;
|
||||
|
||||
// Static cached hostname for the device
|
||||
static String deviceHostname;
|
||||
|
||||
// Generate hostname dynamically based on device MAC address
|
||||
String getDeviceHostname() {
|
||||
if (deviceHostname.length() == 0) {
|
||||
// Extract last 6 hex digits (24 bits) for serial number
|
||||
uint32_t serialNum = (uint32_t)(ESP.getEfuseMac() & 0xFFFFFF);
|
||||
char hostname[32];
|
||||
snprintf(hostname, sizeof(hostname), "XTeinkX4-%06X", serialNum);
|
||||
deviceHostname = String(hostname);
|
||||
}
|
||||
return deviceHostname;
|
||||
}
|
||||
|
||||
// DNS server for captive portal (redirects all DNS queries to our IP)
|
||||
DNSServer* dnsServer = nullptr;
|
||||
constexpr uint16_t DNS_PORT = 53;
|
||||
@ -181,8 +195,8 @@ void CrossPointWebServerActivity::onWifiSelectionComplete(const bool connected)
|
||||
exitActivity();
|
||||
|
||||
// Start mDNS for hostname resolution
|
||||
if (MDNS.begin(AP_HOSTNAME)) {
|
||||
Serial.printf("[%lu] [WEBACT] mDNS started: http://%s.local/\n", millis(), AP_HOSTNAME);
|
||||
if (MDNS.begin(getDeviceHostname().c_str())) {
|
||||
Serial.printf("[%lu] [WEBACT] mDNS started: http://%s.local/\n", millis(), getDeviceHostname().c_str());
|
||||
}
|
||||
|
||||
// Start the web server
|
||||
@ -234,8 +248,8 @@ void CrossPointWebServerActivity::startAccessPoint() {
|
||||
Serial.printf("[%lu] [WEBACT] IP: %s\n", millis(), connectedIP.c_str());
|
||||
|
||||
// Start mDNS for hostname resolution
|
||||
if (MDNS.begin(AP_HOSTNAME)) {
|
||||
Serial.printf("[%lu] [WEBACT] mDNS started: http://%s.local/\n", millis(), AP_HOSTNAME);
|
||||
if (MDNS.begin(getDeviceHostname().c_str())) {
|
||||
Serial.printf("[%lu] [WEBACT] mDNS started: http://%s.local/\n", millis(), getDeviceHostname().c_str());
|
||||
} else {
|
||||
Serial.printf("[%lu] [WEBACT] WARNING: mDNS failed to start\n", millis());
|
||||
}
|
||||
@ -439,7 +453,7 @@ void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
|
||||
startY += 6 * 29 + 3 * LINE_SPACING;
|
||||
// Show primary URL (hostname)
|
||||
std::string hostnameUrl = std::string("http://") + AP_HOSTNAME + ".local/";
|
||||
std::string hostnameUrl = std::string("http://") + getDeviceHostname().c_str() + ".local/";
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, startY + LINE_SPACING * 3, hostnameUrl.c_str(), true, EpdFontFamily::BOLD);
|
||||
|
||||
// Show IP address as fallback
|
||||
@ -468,7 +482,7 @@ void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, startY + LINE_SPACING * 2, webInfo.c_str(), true, EpdFontFamily::BOLD);
|
||||
|
||||
// Also show hostname URL
|
||||
std::string hostnameUrl = std::string("or http://") + AP_HOSTNAME + ".local/";
|
||||
std::string hostnameUrl = std::string("or http://") + getDeviceHostname().c_str() + ".local/";
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 3, hostnameUrl.c_str());
|
||||
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 4, "Open this URL in your browser");
|
||||
|
||||
@ -520,7 +520,7 @@ void WifiSelectionActivity::renderNetworkList() const {
|
||||
const auto height = renderer.getLineHeight(UI_10_FONT_ID);
|
||||
const auto top = (pageHeight - height) / 2;
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, top, "No networks found");
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, top + height + 10, "Press OK to scan again");
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, top + height + 10, "Press Connect to scan again");
|
||||
} else {
|
||||
// Calculate how many networks we can display
|
||||
constexpr int startY = 60;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user