oarcher / piotech

my custom components for esphome
18 stars 10 forks source link

esp8266_disable_ssl_support not working #16

Closed gabest11 closed 10 months ago

gabest11 commented 10 months ago

Thank for creating this, it's very useful for mqtt. It works on all my esp boards except this smart socket for some reason. esp8266: / board: esp8285 with 1M flash. I already had to use esp8266_disable_ssl_support to keep it under 50%, I don't think it's possible without it on a 1M board. Maybe it is worth mentioning in the readme, it took me some time to find this config option. Anyhow, the normal wireless ota update of esphome has no problem when it's in the same network as my server (IIS reverse proxy to a VM running home assistant).

[09:03:05][D][button:010]: 'bw_shp6_7_15a Firmware update' Pressed.
[09:03:05][D][ota_http:046]: Trying to connect to http://hassio.timbuktu.hu/local/esphome/bw_shp6_7_15a/firmware.bin
[09:03:05][E][ota_http:084]: Incorrect file size (-1) reported by http server (http status: -1). Aborting
[09:03:05][W][ota_http:065]: BACKEND->begin error: 255
[09:03:05][E][ota_http:133]: Abort http con
[09:03:05][D][main:105]: This message should be not displayed (reboot)

firmware.bin is not there, it contains my wifi credentials, but I can assure you even wget can download it.

wget -S http://hassio.timbuktu.hu/local/esphome/bw_shp6_7_15a/firmware.bin
--2023-11-16 10:10:54--  http://hassio.timbuktu.hu/local/esphome/bw_shp6_7_15a/firmware.bin
Resolving hassio.timbuktu.hu (hassio.timbuktu.hu)... 176.241.45.141
Connecting to hassio.timbuktu.hu (hassio.timbuktu.hu)|176.241.45.141|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Cache-Control: public, max-age=2678400
  Content-Length: 494752
  Content-Type: application/octet-stream
  Last-Modified: Thu, 16 Nov 2023 03:15:44 GMT
  Accept-Ranges: bytes
  ETag: "1797fc134225c000-78ca0"
  Server: Microsoft-IIS/10.0
  Referrer-Policy: no-referrer
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-Powered-By: ARR/3.0
  X-Powered-By: ASP.NET
  Date: Thu, 16 Nov 2023 09:10:54 GMT
Length: 494752 (483K) [application/octet-stream]
Saving to: 'firmware.bin'

firmware.bin              100%[=========================================>] 483.16K  --.-KB/s    in 0.02s

2023-11-16 10:10:54 (19.7 MB/s) - 'firmware.bin' saved [494752/494752]
gabest11 commented 10 months ago

I think this->stream_ptr_ = std::make_unique<WiFiClient>(); is skipped in OtaHttpArduino::http_init() when https is disabled. The ifdef logic is wrong.

oarcher commented 10 months ago

You are doubly right:

The last problem is probably solved in the disable_ssl branch. Can you check it ?

external_components:
  - source: github://oarcher/piotech@disable_ssl
gabest11 commented 10 months ago

Comfirmed. That one works. About the same firmware size.

oarcher commented 10 months ago

On my side, with a minimal config, the firmware size with ssl is 587K, and 480K without. So it only save ~100K.

I also mention https://github.com/oarcher/piotech/issues/15#issuecomment-1808779181 , where there is a solution to save ram (not flash)

gabest11 commented 10 months ago

That 100K saving is absolutely necessary for a 1M device. I'm running these plugs with minimal config and dependencies.

lib_deps =
    esphome/ESPAsyncTCP-esphome@2.0.0
    esphome/ESPAsyncWebServer-esphome@3.1.0
    DNSServer
    ESP8266WiFi
    ESP8266mDNS
    heman/AsyncMqttClient-esphome@2.0.0
    bblanchon/ArduinoJson@6.18.5
    ESP8266HTTPClient
    ${common.lib_deps}