Skip to content

Commit

Permalink
Merge pull request #64 from danielkucera/update24
Browse files Browse the repository at this point in the history
big update
  • Loading branch information
danielkucera authored Feb 4, 2024
2 parents be7bb38 + 92a70c0 commit e22015e
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 74 deletions.
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- count the turns between these positions and set the trimmer in the middle position with D1 blinking
- if you have adjusted the trimmer, disconnect and connect the adapter to bus again
- search for WiFi networks, you should see network with name "esp-eBus"
- connect to the network - a configuration page should open automatically
- connect to the network - a configuration page should open automatically, default password is: ebusebus
- configure your WiFi network settings (SSID, password)
- after reboot, you should be able to run `ping esp-ebus.local` successfully from a computer in your network (if your network is correctly configured for mDNS)
- to verify there are bytes being received by the adapter, you can connect to `esp-ebus.local` port `3334` using telnet - you should see unreadable binary data
Expand Down Expand Up @@ -138,15 +138,15 @@ There are following options:
- heavier option - it will compile the firmware from source code and upload using internall tooling
- [using espota.py](#espotapy)
- lightweight - just needs OTA script and precompiled firmware file
- physically using a USB-TTL adaptor
- physically using a USB-TTL adaptor or device USB port (HW v5.0+)

### web interface
- [reset device](#config-reset) to access config portal
- connect to the esp-eBus WiFi network
- click blue `Update` button
- open web interface of the device by IP or on: http://esp-ebus.local
- find the update link
- upload correct firmware file (see hardware revisions)
- click red `Update` button
- wait for restart, reconnect to adapter and configure WiFi
- click `Update` button
- wait for restart, reconnect to adapter and configure WiFi if not connected automatically
- in case you cannot open web interface, [reset device](#config-reset) to access it

### platform.io
- clone this repository using git
Expand Down Expand Up @@ -179,7 +179,19 @@ Uploading: [============================================================] 100% D
16:33:31 [INFO]: Result: OK
```

### upgrading using USB-TTL adaptor
### upgrading over USB (HW v5.0+)
- this version has built-in USB serial interface
- download `firmware-fullflash-*` firmware from https://github.com/danielkucera/esp8266-arduino-ebus/releases
- connect `PROG` and `GND`
- connect adapter to a PC using USB-A - USB-C cable
- you should see a new serial port
- flash the firmware to address 0x0 using either one of tools:
- Web based: https://adafruit.github.io/Adafruit_WebSerial_ESPTool/
- Windows: using Flash Download Tools from https://www.espressif.com/en/support/download/other-tools
- Linux esptool.py: `esptool.py write_flash 0x0 firmware-fullflash-*`


### upgrading over USB-TTL adaptor (before HW v5.0)
You will need an USB-TTL adaptor (dongle) which suports 3V3 voltage levels and has 3V3 voltage output pin
- download firmware bin file from https://github.com/danielkucera/esp8266-arduino-ebus/releases
- download NodeMCU PyFlasher from https://github.com/marcelstoer/nodemcu-pyflasher/releases
Expand Down
7 changes: 4 additions & 3 deletions fullflash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

OF=firmware-fullflash-HW_v5.x.bin

dd if=.pio/build/esp32-c3/bootloader.bin of=$OF
dd if=.pio/build/esp32-c3/partitions.bin of=$OF bs=1 seek=$((0x8000))
dd if=$HOME/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin of=$OF bs=1 seek=$((0xe000))
tr '\0' '\377' < /dev/zero | dd bs=1 count=$((0x10000)) of=$OF
dd if=.pio/build/esp32-c3/bootloader.bin of=$OF conv=notrunc
dd if=.pio/build/esp32-c3/partitions.bin of=$OF bs=1 seek=$((0x8000)) conv=notrunc
dd if=$HOME/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin of=$OF bs=1 seek=$((0xe000)) conv=notrunc
dd if=.pio/build/esp32-c3/firmware.bin of=$OF bs=1 seek=$((0x10000))

21 changes: 17 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
[env]
framework = arduino
lib_deps =
https://github.com/tzapu/WiFiManager#v2.0.14-beta
https://github.com/prampec/IotWebConf#v3.2.1
extra_scripts =
pre:auto_firmware_version.py
monitor_filters = esp32_exception_decoder

[env:esp12e]
platform = espressif8266
Expand All @@ -23,8 +24,11 @@ upload_speed = 921600
build_flags =
-DRESET_PIN=5
-DTX_DISABLE_PIN=5
-DBusSer=Serial
-DDebugSer=Serial1

lib_deps =
https://github.com/tzapu/WiFiManager#v2.0.14-beta
${env.lib_deps}
https://github.com/marvinroger/ESP8266TrueRandom
vshymanskyy/Preferences@^2.1.0

Expand All @@ -38,21 +42,30 @@ extends = env:esp12e
build_flags =
-DRESET_PIN=5
-DTX_DISABLE_PIN=2
-DBusSer=Serial
-DDebugSer=Serial1

[env:esp12e-v3-ota]
extends = env:esp12e-v3
upload_port = esp-ebus.local
upload_protocol = espota

[env:esp32-c3]
platform = espressif32
platform = espressif32@6.5.0
board = esp32-c3-devkitm-1
build_flags =
-DRESET_PIN=20
-DPWM_PIN=6
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
-DBusSer=Serial1
-DDebugSer=Serial
-DSTATUS_LED_PIN=3

monitor_filters = esp32_exception_decoder

lib_deps =
https://github.com/tzapu/WiFiManager#v2.0.14-beta
${env.lib_deps}
https://github.com/guido4096/espsoftwareserial.git#add-startbit-timestamp

[env:esp32-c3-ota]
Expand Down
2 changes: 1 addition & 1 deletion src/arbitration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Arbitration::result Arbitration::start(BusState& busstate, uint8_t master, unsig
if (timeSinceStartBit > 4456 || Bus.available())
{
// if we are too late, don't try to participate and retry next round
DEBUG_LOG("ARB LATE 0x%02x %lu us\n", Serial.peek(), timeSinceStartBit);
DEBUG_LOG("ARB LATE 0x%02x %lu us\n", BusSer.peek(), timeSinceStartBit);
return late;
}
#if USE_ASYNCHRONOUS
Expand Down
24 changes: 12 additions & 12 deletions src/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ void BusType::begin() {

#if USE_SOFTWARE_SERIAL
#if defined(ESP32)
Serial.begin(2400, SERIAL_8N1, -1, UART_TX); // used for writing
BusSer.begin(2400, SERIAL_8N1, -1, UART_TX); // used for writing
#elif defined(ESP8266)
Serial.begin(2400, SERIAL_8N1, SERIAL_TX_ONLY, UART_TX);
BusSer.begin(2400, SERIAL_8N1, SERIAL_TX_ONLY, UART_TX);
#endif
mySerial.enableStartBitTimeStampRecording(true);
mySerial.enableTx(false);
mySerial.enableIntTx(false);
mySerial.begin(2400, SWSERIAL_8N1, UART_RX, -1, false, RXBUFFERSIZE); // used for reading
#else
Serial.setRxBufferSize(RXBUFFERSIZE);
BusSer.setRxBufferSize(RXBUFFERSIZE);
#if defined(ESP32)
Serial.begin(2400, SERIAL_8N1, UART_RX, UART_TX); // used for writing
Serial.setRxFIFOFull(1);
BusSer.begin(2400, SERIAL_8N1, UART_RX, UART_TX); // used for writing
BusSer.setRxFIFOFull(1);
#elif defined(ESP8266)
Serial.begin(2400);
BusSer.begin(2400);
#endif
#endif

Expand All @@ -145,7 +145,7 @@ void BusType::begin() {
}

void BusType::end() {
Serial.end();
BusSer.end();
#if USE_SOFTWARE_SERIAL
mySerial.end();
#endif
Expand All @@ -161,11 +161,11 @@ void BusType::end() {


int BusType::availableForWrite() {
return Serial.availableForWrite();
return BusSer.availableForWrite();
}

size_t BusType::write(uint8_t symbol) {
return Serial.write(symbol);
return BusSer.write(symbol);
}

bool BusType::read(data& d) {
Expand All @@ -178,8 +178,8 @@ bool BusType::read(data& d) {
receive(symbol, mySerial.readStartBitTimeStamp());
}
#else
if (Serial.available()){
uint8_t symbol = Serial.read();
if (BusSer.available()){
uint8_t symbol = BusSer.read();
receive(symbol, micros());
}
#endif
Expand All @@ -196,7 +196,7 @@ int BusType::available() {
#if USE_SOFTWARE_SERIAL
return mySerial.available();
#else
return Serial.available();
return BusSer.available();
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ bool handleNewClient(WiFiServer &server, WiFiClient clients[]) {
int i;
for (i = 0; i < MAX_SRV_CLIENTS; i++) {
if (!clients[i]) { // equivalent to !serverClients[i].connected()
clients[i] = server.available();
clients[i] = server.accept();
clients[i].setNoDelay(true);
break;
}
}

// No free/disconnected slot so reject
if (i == MAX_SRV_CLIENTS) {
server.available().println("busy");
server.accept().println("busy");
// hints: server.available() is a WiFiClient with short-term scope
// when out of scope, a WiFiClient will
// - flush() - all data will be sent
Expand Down
Loading

0 comments on commit e22015e

Please sign in to comment.