6static const char *
const TAG =
"one_wire";
8static const uint8_t DALLAS_MODEL_DS18S20 = 0x10;
9static const uint8_t DALLAS_MODEL_DS1822 = 0x22;
10static const uint8_t DALLAS_MODEL_DS18B20 = 0x28;
11static const uint8_t DALLAS_MODEL_DS1825 = 0x3B;
12static const uint8_t DALLAS_MODEL_DS28EA00 = 0x42;
22 ESP_LOGE(TAG,
"1-wire bus is held low");
30 this->
write8(ONE_WIRE_ROM_SELECT);
46 this->
write8(ONE_WIRE_ROM_SEARCH);
50 auto *address8 =
reinterpret_cast<uint8_t *
>(&
address);
51 if (
crc8(address8, 7) != address8[7]) {
69 case DALLAS_MODEL_DS18S20:
70 return LOG_STR(
"DS18S20");
71 case DALLAS_MODEL_DS1822:
72 return LOG_STR(
"DS1822");
73 case DALLAS_MODEL_DS18B20:
74 return LOG_STR(
"DS18B20");
75 case DALLAS_MODEL_DS1825:
76 return LOG_STR(
"DS1825");
77 case DALLAS_MODEL_DS28EA00:
78 return LOG_STR(
"DS28EA00");
80 return LOG_STR(
"Unknown");
86 ESP_LOGW(tag,
" Found no devices!");
88 ESP_LOGCONFIG(tag,
" Found devices:");
virtual void reset_search()=0
Reset the device search.
const std::vector< uint64_t > & get_devices()
Return the list of found devices.
std::vector< uint64_t > devices_
bool skip()
Write a command to the bus that addresses all devices by skipping the ROM.
void dump_devices_(const char *tag)
log the found devices
virtual int reset_int()=0
Bus Reset.
bool reset_()
Reset the bus, should be done before all write operations.
virtual void write64(uint64_t val)=0
Write a 64 bit unsigned integer to the bus. LSB first.
bool select(uint64_t address)
Select a specific address on the bus for the following command.
const LogString * get_model_str(uint8_t model)
Get the description string for this model.
virtual void write8(uint8_t val)=0
Write a word to the bus. LSB first.
void search()
Search for 1-Wire devices on the bus.
virtual uint64_t search_int()=0
Search for a 1-Wire device on the bus. Returns 0 if all devices have been found.
const uint8_t ONE_WIRE_ROM_SEARCH
const uint8_t ONE_WIRE_ROM_SELECT
uint8_t crc8(const uint8_t *data, uint8_t len, uint8_t crc, uint8_t poly, bool msb_first)
Calculate a CRC-8 checksum of data with size len.
char * format_hex_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length)
Format byte array as lowercase hex to buffer (base implementation).