ESPHome  2024.12.2
one_wire.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "one_wire_bus.h"
4 #include "esphome/core/helpers.h"
5 #include "esphome/core/log.h"
6 
7 namespace esphome {
8 namespace 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 
22  void set_one_wire_bus(OneWireBus *bus) { this->bus_ = bus; }
23 
25  const std::string &get_address_name();
26 
27  std::string unique_id();
28 
29  protected:
30  uint64_t address_{0};
31  OneWireBus *bus_{nullptr};
32  std::string address_name_;
33 
36  bool check_address_();
37 
40  bool send_command_(uint8_t cmd);
41 };
42 
43 } // namespace one_wire
44 } // namespace esphome
void set_address(uint64_t address)
store the address of the device
Definition: one_wire.h:18
void set_one_wire_bus(OneWireBus *bus)
store the pointer to the OneWireBus to use
Definition: one_wire.h:22
bool check_address_()
find an address if necessary should be called from setup
Definition: one_wire.cpp:23
const std::string & get_address_name()
Helper to create (and cache) the name for this sensor. For example "0xfe0000031f1eaf29".
Definition: one_wire.cpp:8
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint8_t address
Definition: bl0906.h:211
OneWireBus * bus_
pointer to OneWireBus instance
Definition: one_wire.h:31
bool send_command_(uint8_t cmd)
send command on the bus
Definition: one_wire.cpp:16
stm32_cmd_t * cmd
Definition: stm32flash.h:96