oxan / esphome-stream-server

Stream server (serial-to-wifi bridge) for ESPHome
Other
201 stars 86 forks source link

ESPHome ≥2021.10.0 compatibility #7

Closed bojanpotocnik closed 3 years ago

bojanpotocnik commented 3 years ago

Today I updated ESPHome to 2021.10.2 which caused compilation using this library to fail. I mistakenly thought that this is the fault, however even after adding

esphome:
  libraries:
    - AsyncTCP

plenty of errors were present. Then I discovered UART component was changed.

Draft until I find replacement for network_get_address().c_str() which is also not found anymore, and because this is quick fix to get my Zigbee working.

Builds on https://github.com/oxan/esphome-stream-server/pull/4 , resolves https://github.com/oxan/esphome-stream-server/issues/6 .

bojanpotocnik commented 3 years ago

Tested on @tube0013 (https://github.com/oxan/esphome-stream-server/issues/6) Zigbee coordinators and it works fine

...

external_components:
  # - source: github://oxan/esphome-stream-server
  # - source: github://ayufan-research/esphome-stream-server@buffer-send
  - source: github://bojanpotocnik/esphome-stream-server@esphome_2021.10.2

uart:
  id: uart_bus
  rx_pin: GPIO5
  tx_pin: GPIO17
  baud_rate: 115200
  rx_buffer_size: 2048

stream_server:
  uart_id: uart_bus
  port: 6638
bojanpotocnik commented 3 years ago

Can anyone test on older ESPHome version? I've already updated all my devices...

jeroen85 commented 3 years ago

Can anyone test on older ESPHome version? I've already updated all my devices...

Don't have older version, but at least it works with the current 10.3 release. Thanks!

jakvot commented 3 years ago

It will not compile in 2021.9.3:

external_components:
  - source: github://bojanpotocnik/esphome-stream-server@esphome_2021.10.2
INFO Reading configuration config/esplink01.yaml...
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d config/esplink01
Processing esplink01 (board: esp01_1m; framework: arduino; platform: platformio/espressif8266@2.6.2)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 3.20704.0 (2.7.4) 
 - tool-esptool 1.413.0 (4.13) 
 - tool-esptoolpy 1.20800.0 (2.8.0) 
 - toolchain-xtensa 2.40802.200502 (4.8.2)
Library Manager: Installing Update
Library Manager: Already installed, built-in library
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <ESP8266WiFi> 1.0
|-- <ESPAsyncWebServer-esphome> 1.3.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|   |-- <ArduinoJson-esphomelib> 5.13.3
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <ArduinoJson-esphomelib> 5.13.3
|-- <noise-c> 0.1.3
|   |-- <libsodium> 1.10018.1
|-- <DNSServer> 1.1.1
|   |-- <ESP8266WiFi> 1.0
Compiling .pioenvs/esplink01/src/esphome/components/adc/adc_sensor.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/api/util.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/captive_portal/captive_portal.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/json/json_util.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/logger/logger.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/ota/ota_component.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/restart/restart_switch.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/sensor/automation.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/sensor/filter.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/sensor/sensor.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling .pioenvs/esplink01/src/esphome/components/stream_server/stream_server.cpp.o
In file included from src/esphome/components/stream_server/stream_server.cpp:17:0:
src/esphome/components/stream_server/stream_server.h:26:75: error: missing binary operator before token "("
 #if defined(ESPHOME_VERSION_CODE) && (ESPHOME_VERSION_CODE >= VERSION_CODE(2021, 10, 0))
                                                                           ^
In file included from src/esphome/components/stream_server/stream_server.cpp:17:0:
src/esphome/components/stream_server/stream_server.h:38:75: error: missing binary operator before token "("
 #if defined(ESPHOME_VERSION_CODE) && (ESPHOME_VERSION_CODE >= VERSION_CODE(2021, 10, 0))
                                                                           ^
*** [.pioenvs/esplink01/src/esphome/components/stream_server/stream_server.cpp.o] Error 1
oxan commented 3 years ago

I've added fixes for all my remaining comments to the branch, it now seems to compile cleanly on both old and new ESPHome. Code-wise I think this is fine now, thanks for working on this!

I haven't actually ran it on an ESP yet though, so I would appreciate it if everyone could test this again now.

jakvot commented 3 years ago

Compiled on 10.3 and 9.3, both run fine on ESP-01.

Please check this warning from 9.3, also (patch) vs path:

In file included from src/esphome/core/log.h:10:0,
                 from src/esphome/components/stream_server/stream_server.cpp:19:
src/esphome/core/macros.h:3:0: warning: "VERSION_CODE" redefined [enabled by default]
 #define VERSION_CODE(major, minor, patch) ((major) << 16 | (minor) << 8 | (patch))
 ^
In file included from src/esphome/components/stream_server/stream_server.cpp:17:0:
src/esphome/components/stream_server/stream_server.h:25:0: note: this is the location of the previous definition
 #define VERSION_CODE(major, minor, patch) ((major << 16) | (minor << 8) | path)
 ^
oxan commented 3 years ago

Please check this warning from 9.3, also (patch) vs path:

Thanks, fixed.

bojanpotocnik commented 3 years ago

@oxan thank you for taking your time and completing this! Considering the amount of commits and the final diff in this PR, do you intend to squash these commits and merge (or push directly) as one?

oxan commented 3 years ago

Considering the amount of commits and the final diff in this PR, do you intend to squash these commits and merge (or push directly) as one?

Yes, I've squashed this.