tube0013 / esphome-stream-server-v2

Custom Component for ESPHome enabling Serial over TCP
33 stars 25 forks source link

Compilation error on d1_mini: SO_RCVTIMEO not declared #1

Closed bjw-s closed 1 year ago

bjw-s commented 1 year ago

Hi!

I was trying to use this component instead of the one provided by https://github.com/oxan/esphome-stream-server to expose the uart on one of my Wemos D1 mini boards. Unfortunately I am getting an error when compiling the firmware:

src/esphome/components/stream_server/stream_server.cpp: In member function 'virtual void StreamServerComponent::setup()':
src/esphome/components/stream_server/stream_server.cpp:48:43: error: 'SO_RCVTIMEO' was not declared in this scope; did you mean 'LWIP_SO_RCVTIMEO'?
   48 |     this->socket_->setsockopt(SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
      |                                           ^~~~~~~~~~~
      |                                           LWIP_SO_RCVTIMEO
Compiling .pioenvs/hallway_p1reader/src/esphome/components/time/real_time_clock.cpp.o
Compiling .pioenvs/hallway_p1reader/src/esphome/components/uart/uart.cpp.o
*** [.pioenvs/hallway_p1reader/src/esphome/components/stream_server/stream_server.cpp.o] Error 1

This is on a fresh build of the following config:

esphome:
  name: hallway_p1reader
  platform: ESP8266
  board: d1_mini

web_server:
  id: component_web_server
  port: 80

logger:
  id: component_logger
  baud_rate: 0
  level: INFO

mqtt:
  broker: !secret 'mqtt_host'
  username: !secret 'mqtt_user'
  password: !secret 'mqtt_pwd'
  port: 1883

ota:
  id: component_ota

time:
- platform: sntp
  timezone: CET-1CEST,M3.5.0,M10.5.0/3
  id: time_sntp
  update_interval: 15min
  servers:
  - 0.pool.ntp.org
  - 1.pool.ntp.org
  - 2.pool.ntp.org

switch:
- platform: restart
  id: switch_restart
  name: Hallway - P1 Reader Restart
  disabled_by_default: false
  entity_category: config
  icon: mdi:restart

api:
  reboot_timeout: 0s
  port: 6053

wifi:
  id: component_wifi
  networks:
  - ssid: !secret 'wifi_ssid'
    password: !secret 'wifi_pwd'

external_components:
- source:
    url: https://github.com/tube0013/esphome-stream-server-v2.git
    type: git

uart:
- id: uart_bus
  rx_pin:
    number: 3
    mode:
      input: true
      analog: false
      output: false
      open_drain: false
      pullup: false
      pulldown: false
    inverted: false
  baud_rate: 115200
  rx_buffer_size: 1024
  stop_bits: 1
  data_bits: 8
  parity: NONE

stream_server:
- id: ss
  uart_id: uart_bus
  port: 8088

binary_sensor:
- platform: stream_server
  stream_server: ss
  name: Hallway - P1 Reader Serial Connected

When using https://github.com/oxan/esphome-stream-server I don't see this error with the same config.

tube0013 commented 1 year ago

This version is more focused on esp32 (Ethernet boards) and 8266 was not tested/considered. I don't have the resources to support anything else. I will welcome PRs that can make it work without degrading the esp32 experience.

bjw-s commented 1 year ago

No worries, I primarily wanted to verify if it was/wasn't intentional :) I may try my hand at a PR, but I'm not super well versed in C so no idea how long it will take me 😅

tube0013 commented 1 year ago

I updated the Readme to specify the projects focus on ESP32 for now.

MattWestb commented 1 year ago

I was testing V2 with ESPHome 2022.8.0 and is getting the same error. Then ESPHome suggesting using LWIP_SO_RCVTIMEO i was editing line: https://github.com/tube0013/esphome-stream-server-v2/blob/30d3ed24c541ce22457328e4ee8768e8cbfd93a8/components/stream_server/stream_server.cpp#L48-L49 to using LWIP_SO_RCVTIMEO instead of SO_RCVTIMEO and i can compiling the firmware and its starting OK.

I have only testing it with one IKEA GU10 WS2 and looks working OK. The problem i must using one temporary hardware (D1 Mini) that is not soldered so it little insecure hardware connections.

@bjw-s Can you also testing if you can getting it working or if i have making somthing bad ?

MattWestb commented 1 year ago

I have updating ESPHome to 2022.10.2 and can compiling and flashing the firmware and look working OK.

Haw adding one new LIDL magnet and the new large motion sensor (both IAS Zone devices) and looks working OK then being added thru one IKEA GU10 WS2.

Was having some disconnecting problem yesterday the adding the device to HA and it was using the ESPHome API with encryption so i was deleting it from HA and running "standalone" and trying adding it later if its stable.

MattWestb commented 1 year ago

@tube0013 My ESP82XX have working very good for many weeks now but i was playing around and was finding that i was having two Zignee networks on PAN-ID = not good.

So i was trying re configuring the network in ZHA and it was not working (very likely time out). Then was deleting the ZHA and rebooting HA and trying adding the ESPHome streamserver but the same problem. Was taking one other network attached NCP down (hacked tuya / LIDL ZBGW) and adding it in the test and it was working OK. Changing the config to ESPHome and it was working OK but with wrong network.

I cant adding or re configuring the network attached EZSP NCP with HA 2022.11.X but it was working OK before. Do you have the same problems with ESPHome with ESP32 ???

I was able deleting the network by taking ZHA down and sending one leave with bellows CLI in the HA container and also deleting all backups in Zigbee.db so not rolling back the last backup with bad network settings and then staring (Z)HA. Starting HA and its forming one new network with the settings from (Z)HA config with good PAN-ID and Extended PAN-ID = no network conflicts longer :-))).

bjw-s commented 1 year ago

@MattWestb I don't think support questions should go in this issue.

As stated, the goal of this project for now is to only support ESP32. Unfortunately I don't have the time required to create and test a PR, so I'm closing the issue.