Skip to content
Open
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
57 changes: 55 additions & 2 deletions ConfigSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ uint16_t ConfigSettings::calcNetRecSize() {
+ 5 // ETH.phyAddress
+ 5 // ETH.PWRPin
+ 5 // ETH.MDCPin
+ 5; // ETH.MDIOPin
+ 5 // ETH.MDIOPin
+ 5 // ETH.MOSIPin
+ 5 // ETH.MISOPin
+ 5 // ETH.SCLKPin
+ 5 // ETH.CSPin
+ 5 // ETH.INTPin
+ 5; // ETH.RSTPin
}
bool MQTTSettings::begin() {
this->load();
Expand Down Expand Up @@ -685,6 +691,12 @@ bool EthernetSettings::fromJSON(JsonObject &obj) {
if(obj.containsKey("PWRPin")) this->PWRPin = obj["PWRPin"];
if(obj.containsKey("MDCPin")) this->MDCPin = obj["MDCPin"];
if(obj.containsKey("MDIOPin")) this->MDIOPin = obj["MDIOPin"];
if(obj.containsKey("MOSIPin")) this->MOSIPin = obj["MOSIPin"];
if(obj.containsKey("MISOPin")) this->MISOPin = obj["MISOPin"];
if(obj.containsKey("SCLKPin")) this->SCLKPin = obj["SCLKPin"];
if(obj.containsKey("CSPin")) this->CSPin = obj["CSPin"];
if(obj.containsKey("INTPin")) this->INTPin = obj["INTPin"];
if(obj.containsKey("RSTPin")) this->RSTPin = obj["RSTPin"];
return true;
}
bool EthernetSettings::toJSON(JsonObject &obj) {
Expand All @@ -695,6 +707,12 @@ bool EthernetSettings::toJSON(JsonObject &obj) {
obj["PWRPin"] = this->PWRPin;
obj["MDCPin"] = this->MDCPin;
obj["MDIOPin"] = this->MDIOPin;
obj["MOSIPin"] = this->MOSIPin;
obj["MISOPin"] = this->MISOPin;
obj["SCLKPin"] = this->SCLKPin;
obj["CSPin"] = this->CSPin;
obj["INTPin"] = this->INTPin;
obj["RSTPin"] = this->RSTPin;
return true;
}
void EthernetSettings::toJSON(JsonResponse &json) {
Expand All @@ -705,6 +723,12 @@ void EthernetSettings::toJSON(JsonResponse &json) {
json.addElem("PWRPin", this->PWRPin);
json.addElem("MDCPin", this->MDCPin);
json.addElem("MDIOPin", this->MDIOPin);
json.addElem("MOSIPin", this->MOSIPin);
json.addElem("MISOPin", this->MISOPin);
json.addElem("SCLKPin", this->SCLKPin);
json.addElem("CSPin", this->CSPin);
json.addElem("INTPin", this->INTPin);
json.addElem("RSTPin", this->RSTPin);
}

bool EthernetSettings::usesPin(uint8_t pin) {
Expand All @@ -714,8 +738,19 @@ bool EthernetSettings::usesPin(uint8_t pin) {
else if(this->PWRPin == pin) return true;
else if(this->MDCPin == pin) return true;
else if(this->MDIOPin == pin) return true;
else if(this->MOSIPin == pin) return true;
else if(this->MISOPin == pin) return true;
else if(this->SCLKPin == pin) return true;
else if(this->CSPin == pin) return true;
else if(this->INTPin == pin) return true;
else if(this->RSTPin == pin) return true;
return false;
}
bool EthernetSettings::isSPIController() {
// W5500 is typically phyType value 6 or higher
// Check if phyType is W5500 (assuming value 6, adjust if needed)
return static_cast<uint8_t>(this->phyType) >= 6;
}
bool EthernetSettings::save() {
pref.begin("ETH");
pref.clear();
Expand All @@ -726,6 +761,12 @@ bool EthernetSettings::save() {
pref.putChar("PWRPin", this->PWRPin);
pref.putChar("MDCPin", this->MDCPin);
pref.putChar("MDIOPin", this->MDIOPin);
pref.putChar("MOSIPin", this->MOSIPin);
pref.putChar("MISOPin", this->MISOPin);
pref.putChar("SCLKPin", this->SCLKPin);
pref.putChar("CSPin", this->CSPin);
pref.putChar("INTPin", this->INTPin);
pref.putChar("RSTPin", this->RSTPin);
pref.end();
return true;
}
Expand All @@ -738,12 +779,24 @@ bool EthernetSettings::load() {
this->PWRPin = pref.getChar("PWRPin", this->PWRPin);
this->MDCPin = pref.getChar("MDCPin", this->MDCPin);
this->MDIOPin = pref.getChar("MDIOPin", this->MDIOPin);
this->MOSIPin = pref.getChar("MOSIPin", this->MOSIPin);
this->MISOPin = pref.getChar("MISOPin", this->MISOPin);
this->SCLKPin = pref.getChar("SCLKPin", this->SCLKPin);
this->CSPin = pref.getChar("CSPin", this->CSPin);
this->INTPin = pref.getChar("INTPin", this->INTPin);
this->RSTPin = pref.getChar("RSTPin", this->RSTPin);
pref.end();
return true;
}
void EthernetSettings::print() {
Serial.println("Ethernet Settings");
Serial.printf("Board:%d PHYType:%d CLK:%d ADDR:%d PWR:%d MDC:%d MDIO:%d\n", this->boardType, this->phyType, this->CLKMode, this->phyAddress, this->PWRPin, this->MDCPin, this->MDIOPin);
if(this->isSPIController()) {
Serial.printf("Board:%d PHYType:%d (SPI) MOSI:%d MISO:%d SCLK:%d CS:%d INT:%d RST:%d\n",
this->boardType, this->phyType, this->MOSIPin, this->MISOPin, this->SCLKPin, this->CSPin, this->INTPin, this->RSTPin);
} else {
Serial.printf("Board:%d PHYType:%d CLK:%d ADDR:%d PWR:%d MDC:%d MDIO:%d\n",
this->boardType, this->phyType, this->CLKMode, this->phyAddress, this->PWRPin, this->MDCPin, this->MDIOPin);
}
}
void ConfigSettings::printAvailHeap() {
Serial.print("Max Heap: ");
Expand Down
8 changes: 8 additions & 0 deletions ConfigSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ class EthernetSettings: BaseSettings {
int8_t PWRPin = ETH_PHY_POWER;
int8_t MDCPin = ETH_PHY_MDC;
int8_t MDIOPin = ETH_PHY_MDIO;
// SPI pins for W5500 and other SPI-based Ethernet controllers
int8_t MOSIPin = -1;
int8_t MISOPin = -1;
int8_t SCLKPin = -1;
int8_t CSPin = -1;
int8_t INTPin = -1;
int8_t RSTPin = -1;

bool begin();
bool fromJSON(JsonObject &obj);
Expand All @@ -107,6 +114,7 @@ class EthernetSettings: BaseSettings {
bool save();
void print();
bool usesPin(uint8_t pin);
bool isSPIController();
};
class IPSettings: BaseSettings {
public:
Expand Down
91 changes: 91 additions & 0 deletions FIRMWARE_UPLOAD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Upload Guide from Cursor

## Installing PlatformIO

1. **Install PlatformIO extension in Cursor**:
- Open extensions (Cmd+Shift+X / Ctrl+Shift+X)
- Search for "PlatformIO IDE"
- Install the official extension

2. **Wait for installation**:
- PlatformIO will automatically install necessary tools
- This may take a few minutes the first time

## Serial Port Configuration

1. **Connect your ESP32-S3** via USB
2. **Identify the port**:
- macOS: `/dev/cu.usbserial-*` or `/dev/cu.usbmodem*`
- Windows: `COM3`, `COM4`, etc.
- Linux: `/dev/ttyUSB0` or `/dev/ttyACM0`

3. **Uncomment and modify the line in `platformio.ini`**:
```ini
upload_port = /dev/cu.usbserial-XXXX ; Replace with your port
```

## Firmware Upload

### Method 1: Via PlatformIO Toolbar

1. Click on the **PlatformIO** icon in the left sidebar
2. In **PROJECT TASKS** → **esp32-s3-devkitc-1**
3. Click **Upload** (or **Build and Upload**)

### Method 2: Via Command Palette

1. Open command palette (Cmd+Shift+P / Ctrl+Shift+P)
2. Type "PlatformIO: Upload"
3. Select the `esp32-s3-devkitc-1` environment

### Method 3: Via Integrated Terminal

```bash
pio run --target upload
```

## LittleFS Filesystem Upload

**IMPORTANT**: After uploading the firmware, you must also upload the files from the `data/` folder (index.html, index.js, etc.)

### Via Command Palette

1. Command palette (Cmd+Shift+P / Ctrl+Shift+P)
2. Type "PlatformIO: Upload Filesystem Image"
3. Select the `esp32-s3-devkitc-1` environment

### Via Terminal

```bash
pio run --target uploadfs
```

## Verification

1. **Open serial monitor**:
- Command palette → "PlatformIO: Serial Monitor"
- Or PlatformIO icon → **Monitor**

2. **Check messages**:
- You should see "Startup/Boot...."
- And "File system mounted successfully"

3. **Connect to web interface**:
- Look for IP address in serial logs
- Or connect to WiFi "ESPSomfy RTS" if in AP mode

## Troubleshooting

### "Port not found" Error
- Verify ESP32 is properly connected
- Check port in `platformio.ini`
- On macOS/Linux, you may need permissions: `sudo chmod 666 /dev/cu.usbserial-*`

### Compilation Error
- Verify all libraries are installed
- PlatformIO installs them automatically, but you can force: `pio lib install`

### Filesystem Won't Upload
- Make sure firmware was uploaded first
- Verify the `data/` folder exists
- Some boards require manual reset before filesystem upload
2 changes: 2 additions & 0 deletions GitOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ void GitRepo::toJSON(JsonResponse &json) {

void GitUpdater::loop() {
if(!net.connected()) return;
// Skip OTA check for W5500 - HTTPClient has issues without WiFi event groups
if(settings.Ethernet.isSPIController()) return;
if(this->status == GIT_STATUS_READY) {
if(settings.checkForUpdate &&
(millis() > net.connectTime + 60000) && // Wait a minute before checking after connection.
Expand Down
Loading