RemoteWebViewClient icon indicating copy to clipboard operation
RemoteWebViewClient copied to clipboard

I have a problem during compilation after the addition of the keepalive functionality

Open Samurai1201 opened this issue 1 year ago • 8 comments

esphome:
  name: homeplate-01
  friendly_name: HomePlate 01

esp32:
  board: esp32-s3-devkitc-1
  flash_size: 16MB
  cpu_frequency: 240MHZ
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
      CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
      COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
    components:
      - name: "espressif/esp_websocket_client"
        ref: 1.5.0
      - name: "espressif/esp-dsp"
        ref: 1.7.0
      - name: "bitbank2/jpegdec"
        source: https://github.com/strange-v/jpegdec-esphome

external_components:
  - source: github://strange-v/RemoteWebViewClient@main
    components: [ remote_webview ]

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "XXXXXXXXXXXXXXXXXXXXX"

ota:
  - platform: esphome
    password: "XXXXXXXXXXXXXXXXXX"

wifi:
  XXXX
    
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
  XXXX

captive_portal:

i2c:
  frequency: 400kHz
  sda: 6
  scl: 5

touchscreen:
  - platform: ft63x6
    id: my_touchscreen
    interrupt_pin: 7
    transform:
      swap_xy: false
      mirror_y: true
      mirror_x: true

psram:
  speed: 80MHz

spi:
  - type: octal
    id: octal_spi
    clk_pin: 47
    data_pins:
      - 9
      - ignore_strapping_warning: true
        number: 46
      - ignore_strapping_warning: true
        number: 3
      - 8
      - 18
      - 17
      - 16
      - 15

display:
  - platform: mipi_spi
    id: w32_disp
    model: wt32-sc01-plus
    data_rate: 10MHz
    rotation: 180
    auto_clear_enabled: false
    update_interval: never

light:
  - platform: monochromatic
    id: display_backlight
    name: "Backlight"
    output: backlight_pwm
    initial_state: 
      brightness: 100%
    restore_mode:
      ALWAYS_ON

output:
  - platform: ledc
    pin: 
      ignore_strapping_warning: true
      number: GPIO45
    id: backlight_pwm

remote_webview:
  id: rwv
  display_id: w32_disp
  touchscreen_id: my_touchscreen
  device_id: esp32-4848s040-t1
  server: 192.168.178.109:8043
  url: http://192.168.178.97:8123/
  full_frame_tile_count: 1
  max_bytes_per_msg: 61440
  jpeg_quality: 85

Compilation fails with error message:

src/esphome/components/remote_webview/remote_webview.cpp:408:29: error: 'KeepalivePacket' is not a member of 'esphome::remote_webview::proto'
  408 |   uint8_t pkt[sizeof(proto::KeepalivePacket)];
      |                             ^~~~~~~~~~~~~~~
src/esphome/components/remote_webview/remote_webview.cpp:409:27: error: 'build_keepalive_packet' is not a member of 'esphome::remote_webview::proto'
  409 |   const size_t n = proto::build_keepalive_packet(pkt);
      |                           ^~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/remote_webview/remote_webview.cpp:409:50: error: 'pkt' was not declared in this scope
  409 |   const size_t n = proto::build_keepalive_packet(pkt);
      |                                                  ^~~
*** [.pioenvs/homeplate-01/src/esphome/components/remote_webview/remote_webview.cpp.o] Error 1```

Samurai1201 avatar Sep 24 '25 15:09 Samurai1201

https://github.com/supremelucifer/RemoteWebViewClient

i forked it and changed the code so it works. U can use mine. In your yaml you should also change the text block with this: text:

------------------------------ dont forget to change your settings ------------------------

esphome:
  name: esp32-4848s040-t1
  friendly_name: ESP32-4848S040-T1
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    sdkconfig_options:
      COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
      CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
    components:
      - name: "espressif/esp_websocket_client"
        ref: 1.5.0
      - name: "espressif/esp-dsp"
        ref: 1.7.0
      - name: "bitbank2/jpegdec"
        source: https://github.com/strange-v/jpegdec-esphome

psram:
  mode: octal
  speed: 80MHz

external_components:
  - source:
      type: git
      url: https://github.com/supremelucifer/RemoteWebViewClient
      ref: main
    components: [ remote_webview ]

logger:
  hardware_uart: UART0

api:


ota:
  - platform: esphome
    password: "yourpassword"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

captive_portal:
    
spi:
  clk_pin: GPIO48
  mosi_pin: GPIO47

i2c:
  - id: bus_a
    sda: GPIO19
    scl: GPIO45

display:
  - platform: st7701s
    id: my_display
    show_test_card: False
    update_interval: never
    auto_clear_enabled: False
    spi_mode: MODE3
    data_rate: 2MHz
    color_order: RGB
    invert_colors: False
    dimensions:
      width: 480
      height: 480
    cs_pin: 39
    de_pin: 18
    hsync_pin: 16
    vsync_pin: 17
    pclk_pin: 21
    pclk_frequency: 12MHz
    pclk_inverted: False
    hsync_pulse_width: 8
    hsync_front_porch: 10
    hsync_back_porch: 20
    vsync_pulse_width: 8
    vsync_front_porch: 10
    vsync_back_porch: 10
    init_sequence:
      - 1
      - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x10]
      - [0xCD, 0x00]
    data_pins:
      red:
        - GPIO11
        - GPIO12
        - GPIO13
        - GPIO14
        - GPIO0
      green:
        - GPIO8
        - GPIO20
        - GPIO3
        - GPIO46
        - GPIO9
        - GPIO10
      blue:
        - GPIO4
        - GPIO5
        - GPIO6
        - GPIO7
        - GPIO15

touchscreen:
  platform: gt911
  transform:
    mirror_x: false
    mirror_y: false
  i2c_id: bus_a
  id: my_touchscreen
  display: my_display

output:
  - platform: ledc
    pin: GPIO38
    id: backlight_pwm

light:
  - platform: monochromatic
    output: backlight_pwm
    name: "Display Backlight"
    id: back_light
    restore_mode: ALWAYS_ON

remote_webview:
  id: rwv
  display_id: my_display
  touchscreen_id: my_touchscreen
  device_id: esp32-4848s040-t1
  server: <yourserverip>:8081
  url: <homeassistant dashboard link>
  full_frame_tile_count: 1
  max_bytes_per_msg: 61440
  jpeg_quality: 85

text:
  - platform: template
    id: rwv_url
    name: "URL"
    optimistic: true
    restore_value: false
    mode: TEXT
    min_length: 1
    set_action:
      - lambda: |-
          id(rwv).set_url(std::string(x.c_str()));
          ESP_LOGI("remote_webview", "URL set to: %s", x.c_str());

supremelucifer avatar Sep 27 '25 14:09 supremelucifer

Thanks @supremelucifer your fork helped me get past the same error. However, I ran into a new one:

Creating ESP32S3 image...
Successfully created ESP32S3 image.
Linking .pioenvs/guition-35-03/firmware.elf
/config/.esphome/platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pioenvs/guition-35-03/src/main.cpp.o:(.literal._ZNSt17_Function_handlerIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEZ5setupvEUlS5_E_E9_M_invokeERKSt9_Any_dataOS5_+0xc): undefined reference to `_ZN7esphome14remote_webview13RemoteWebView8open_urlERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
/config/.esphome/platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pioenvs/guition-35-03/src/main.cpp.o: in function `_ZNSt17_Function_handlerIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEZ5setupvEUlS5_E_E9_M_invokeERKSt9_Any_dataOS5_':
/config/remotewebview.yaml:57:(.text._ZNSt17_Function_handlerIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEZ5setupvEUlS5_E_E9_M_invokeERKSt9_Any_dataOS5_+0x1e): undefined reference to `_ZN7esphome14remote_webview13RemoteWebView8open_urlERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
collect2: error: ld returned 1 exit status
*** [.pioenvs/guition-35-03/firmware.elf] Error 1
========================= [FAILED] Took 53.60 seconds =========================

My YAML is like so (3 files):

esphome:
  name: "guition-35-03"
  friendly_name: "Remote Web View"

packages:
  common: !include git/common.yaml
  device: !include git/devices/JC3248W535.yaml

esp32:
  framework:
    components:
      - name: "espressif/esp_websocket_client"
        ref: 1.5.0
      - name: "espressif/esp-dsp"
        ref: 1.7.0
      - name: "bitbank2/jpegdec"
        source: https://github.com/strange-v/jpegdec-esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

captive_portal:

# external_components:
#   - source: github://strange-v/RemoteWebViewClient@main
#     components: [ remote_webview ]

external_components:
  - source:
      type: git
      url: https://github.com/supremelucifer/RemoteWebViewClient
      ref: main
    components: [ remote_webview ]

remote_webview:
  id: rwv
  display_id: main_display
  touchscreen_id: main_touchscreen
  server: 192.168.2.10:8081
  url: https://google.com
  full_frame_tile_count: 1
  max_bytes_per_msg: 61440
  jpeg_quality: 85

text:
  - platform: template
    id: rwv_url
    name: "URL"
    optimistic: true
    restore_value: false
    mode: TEXT
    min_length: 1
    set_action:
      - lambda: |-
          if (!id(rwv).open_url(std::string(x.c_str()))) {
            id(rwv).set_url(std::string(x.c_str()));
            ESP_LOGI("remote_webview", "URL queued (not connected): %s", x.c_str());
          }

common.yaml:

esphome:
  min_version: 2024.11.0

logger:
  level: INFO

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

captive_portal:

web_server:
  port: 80

ota:
  - platform: esphome

api:
  on_client_connected:
    - globals.set:
        id: homeassistant_ip
        value: !lambda return client_address;

switch:
  - platform: restart
    name: Restart

binary_sensor:
  - platform: status
    name: Status

sensor:
  - id: wifi_signal_db
    name: WiFi Signal
    platform: wifi_signal
    update_interval: 60s
    entity_category: diagnostic

  - id: wifi_signal_strength
    name: WiFi Strength
    platform: copy
    source_id: wifi_signal_db
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "%"
    entity_category: diagnostic

text_sensor:
  - platform: wifi_info
    ip_address:
      name: IP Address
      entity_category: diagnostic
    ssid:
      name: Connected SSID
      entity_category: diagnostic
    mac_address:
      name: Mac Address
      entity_category: diagnostic

globals:
  - id: homeassistant_ip
    type: std::string

JC3248W535.yaml:

esphome:
  platformio_options:
    upload_speed: 921600
    board_build.flash_mode: dio
    board_build.f_flash: 80000000L
    board_build.f_cpu: 240000000L

esp32:
  board: esp32-s3-devkitc-1
  flash_size: 16MB
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y

psram:
  mode: octal
  speed: 80MHz # 120MHz is not supported and falls back to 40MHz

spi:
  - type: quad
    clk_pin: 47
    data_pins: [21, 48, 40, 39]

i2c:
  - sda: 4
    scl: 8

output:
  - id: gpio_backlight_pwm
    platform: ledc
    pin: 1

light:
  - id: backlight
    name: Backlight
    platform: monochromatic
    output: gpio_backlight_pwm
    restore_mode: ALWAYS_ON

display:
  - id: main_display
    platform: qspi_dbi
    dimensions:
      height: 480
      width: 320
    model: CUSTOM
    data_rate: 40MHz
    cs_pin:
      number: 45
      ignore_strapping_warning: true
    draw_from_origin: true
    update_interval: never
    auto_clear_enabled: false

touchscreen:
  - id: main_touchscreen
    platform: axs15231
    # on_touch:
    #   - lambda: |-
    #         ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
    #           touch.x,
    #           touch.y,
    #           touch.x_raw,
    #           touch.y_raw
    #         );

RyanEwen avatar Sep 29 '25 03:09 RyanEwen

Thank you very much for the help.

How did you get past the home assistant login screen? I cant seem to get bypass login to work properly.

Thanks a lot

Samurai1201 avatar Sep 29 '25 09:09 Samurai1201

FYI @supremelucifer I worked around my issue by making only one of the changes that you had made. Just editing the keepalive fn but keeping the open_url fn.

external_components:
  - source: github://RyanEwen/RemoteWebViewClient@main
    components: [ remote_webview ]

RyanEwen avatar Sep 29 '25 16:09 RyanEwen

Sorry, folks — for some reason, I didn’t get a notification about the issue. I’m working on a fix.

strange-v avatar Sep 29 '25 18:09 strange-v

protocol.h was out of sync. It’s fixed now, and I see no issues with the build. Please try again.

strange-v avatar Sep 29 '25 19:09 strange-v

I can confirm it works now (after adding refresh: 0s in the YAML) @strange-v - thank you

RyanEwen avatar Sep 29 '25 19:09 RyanEwen

@RyanEwen, thank you for the confirmation. I've updated the README with the correct usage of the external component from GitHub.

strange-v avatar Sep 29 '25 19:09 strange-v