mirror of
https://github.com/oxan/esphome-stream-server.git
synced 2026-08-26 21:37:16 +00:00
Move default port to config schema
This commit is contained in:
@@ -39,7 +39,7 @@ CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(StreamServerComponent),
|
||||
cv.Optional(CONF_PORT): cv.port,
|
||||
cv.Optional(CONF_PORT, default=6638): cv.port,
|
||||
cv.Optional(CONF_BUFFER_SIZE, default=128): cv.All(
|
||||
cv.positive_int, validate_buffer_size
|
||||
),
|
||||
@@ -52,8 +52,7 @@ CONFIG_SCHEMA = (
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
if CONF_PORT in config:
|
||||
cg.add(var.set_port(config[CONF_PORT]))
|
||||
cg.add(var.set_port(config[CONF_PORT]))
|
||||
cg.add(var.set_buffer_size(config[CONF_BUFFER_SIZE]))
|
||||
|
||||
await cg.register_component(var, config)
|
||||
|
||||
@@ -61,6 +61,7 @@ protected:
|
||||
};
|
||||
|
||||
esphome::uart::UARTComponent *stream_{nullptr};
|
||||
uint16_t port_;
|
||||
size_t buf_size_;
|
||||
|
||||
std::unique_ptr<uint8_t[]> buf_{};
|
||||
@@ -68,6 +69,5 @@ protected:
|
||||
size_t buf_tail_{0};
|
||||
|
||||
std::unique_ptr<esphome::socket::Socket> socket_{};
|
||||
uint16_t port_{6638};
|
||||
std::vector<Client> clients_{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user