ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
one_wire.h
Go to the documentation of this file.
1#pragma once
2
3#include "one_wire_bus.h"
5#include "esphome/core/log.h"
6
7namespace esphome {
8namespace one_wire {
9
10#define LOG_ONE_WIRE_DEVICE(this) \
11 ESP_LOGCONFIG(TAG, " Address: %s (%s)", this->get_address_name().c_str(), \
12 LOG_STR_ARG(this->bus_->get_model_str(this->address_ & 0xff)));
13
15 public:
18 void set_address(uint64_t address) { this->address_ = address; }
19
20 void set_index(uint8_t index) { this->index_ = index; }
21
24 void set_one_wire_bus(OneWireBus *bus) { this->bus_ = bus; }
25
27 const std::string &get_address_name();
28
29 protected:
30 static constexpr uint8_t INDEX_NOT_SET = 255;
31
32 uint64_t address_{0};
34 OneWireBus *bus_{nullptr};
35 std::string address_name_;
36
40
43 bool send_command_(uint8_t cmd);
44};
45
46} // namespace one_wire
47} // namespace esphome
uint8_t address
Definition bl0906.h:4
static constexpr uint8_t INDEX_NOT_SET
Definition one_wire.h:30
OneWireBus * bus_
pointer to OneWireBus instance
Definition one_wire.h:34
void set_index(uint8_t index)
Definition one_wire.h:20
void set_address(uint64_t address)
store the address of the device
Definition one_wire.h:18
bool send_command_(uint8_t cmd)
send command on the bus
Definition one_wire.cpp:14
void set_one_wire_bus(OneWireBus *bus)
store the pointer to the OneWireBus to use
Definition one_wire.h:24
const std::string & get_address_name()
Helper to create (and cache) the name for this sensor. For example "0xfe0000031f1eaf29".
Definition one_wire.cpp:8
bool check_address_or_index_()
find an address if necessary should be called from setup
Definition one_wire.cpp:21
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7