From 848f1a3c545d2821fa726a1dfd7225df10ae91f6 Mon Sep 17 00:00:00 2001 From: Sebastian Wendel Date: Sat, 14 Sep 2024 00:13:00 +0200 Subject: [PATCH] working serial stream --- .reuse/dep5 | 21 -------------------- README.md | 3 ++- REUSE.toml | 16 +++++++++++++++ esphome.yaml | 56 +++++++++++++++++++++++++++++++++++----------------- 4 files changed, 56 insertions(+), 40 deletions(-) delete mode 100644 .reuse/dep5 create mode 100644 REUSE.toml diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index bb3233c..0000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,21 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: mushlab-iot -Upstream-Contact: Sebastian Wendel -Source: https://code.curious.bio/curious.bio/mushlab-iot - -Files: hardware/* -Copyright: (C) 2023 Sebastian Wendel -License: CERN-OHL-S-2.0 - -Files: - .gitea - .vscode - .editorconfig - .envrc - .gitignore - flake.* - nix/* - software/* -Copyright: (C) 2023 Sebastian Wendel -License: GPL-3.0-or-later - diff --git a/README.md b/README.md index c11d99a..a505b4d 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,5 @@ - https://github.com/jeelabs/esp-link - https://github.com/esphome/aioesphomeapi -- https://openwrt.org/docs/guide-user/hardware/esp8266-serial-bridge \ No newline at end of file +- https://openwrt.org/docs/guide-user/hardware/esp8266-serial-bridge +- https://github.com/tube0013/tube_gateways/tree/main \ No newline at end of file diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 0000000..2403d5f --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,16 @@ +version = 1 +SPDX-PackageName = "esp-bmc" +SPDX-PackageSupplier = "Sebastian Wendel " +SPDX-PackageDownloadLocation = "https://code.srx.digital/srx/esp-bmc" + +[[annotations]] +path = "hardware/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "(C) 2024 Sebastian Wendel" +SPDX-License-Identifier = "CERN-OHL-S-2.0" + +[[annotations]] +path = [".gitea", ".vscode", ".envrc", ".gitignore", "flake.**", "nix/**", "software/**"] +precedence = "aggregate" +SPDX-FileCopyrightText = "(C) 2024 Sebastian Wendel" +SPDX-License-Identifier = "MIT" diff --git a/esphome.yaml b/esphome.yaml index b6c897f..7d5bd2f 100644 --- a/esphome.yaml +++ b/esphome.yaml @@ -18,6 +18,11 @@ web_server: api: password: !secret api_password + on_client_connected: + - uart.write: "reboot\r\n" + - logger.log: + format: "Client %s connected to API with IP %s" + args: ["client_info.c_str()", "client_address.c_str()"] ota: - platform: esphome @@ -43,22 +48,37 @@ wifi: # gateway: 10.0.0.1 # subnet: 255.255.255.0 +external_components: + - source: github://oxan/esphome-stream-server + +stream_server: + uart_id: node0_uart + port: 8000 + uart: - - id: uart_1 - tx_pin: 1 - rx_pin: 2 - baud_rate: 115200 - debug: - direction: BOTH - after: - delimiter: "\n" - # dummy_receiver: false - # sequence: - # - lambda: UARTDebug::log_string(direction, bytes); + - id: node0_uart + rx_pin: GPIO16 + tx_pin: GPIO17 + baud_rate: 57600 + # debug: + # direction: BOTH + # after: + # delimiter: "\n" + # sequence: + # - lambda: UARTDebug::log_string(direction, bytes); + +button: + - name: node0_reboot + platform: uart + data: "\r\n\r\nreboot -f\r\n" + + - name: node0_shutdown + platform: uart + data: "\r\n\r\nshutdown -h\r\n" select: - - id: change_baud_rate - name: Baud rate + - id: change_baudrate + name: node0_baudrate platform: template options: - "2400" @@ -77,10 +97,10 @@ select: icon: mdi:swap-horizontal set_action: - lambda: |- - id(uart_1).flush(); + id(node0_uart).flush(); uint32_t new_baud_rate = stoi(x); - ESP_LOGD("change_baud_rate", "Changing baud rate from %i to %i",id(uart_1).get_baud_rate(), new_baud_rate); - if (id(uart_1).get_baud_rate() != new_baud_rate) { - id(uart_1).set_baud_rate(new_baud_rate); - id(uart_1).load_settings(); + ESP_LOGD("change_baud_rate", "Changing baud rate from %i to %i",id(node0_uart).get_baud_rate(), new_baud_rate); + if (id(node0_uart).get_baud_rate() != new_baud_rate) { + id(node0_uart).set_baud_rate(new_baud_rate); + id(node0_uart).load_settings(); }