[modbus] Typed send helpers; migrate in-tree callers off send() (#17859)

This commit is contained in:
Bonne Eggleston
2026-07-25 21:57:35 -10:00
committed by GitHub
parent 9dd7dcb06d
commit 98f2a0b4a4
11 changed files with 144 additions and 19 deletions
+21
View File
@@ -718,4 +718,25 @@ void Modbus::clear_rx_buffer_(const LogString *reason, bool warn, size_t bytes_t
}
}
void ModbusClientDevice::read_entities(EntityType entity_type, uint16_t start_address, uint16_t number_of_entities) {
switch (entity_type) {
case EntityType::HOLDING:
this->read_holding_registers(start_address, number_of_entities);
return;
case EntityType::INPUT_REGISTER:
this->read_input_registers(start_address, number_of_entities);
return;
case EntityType::COIL:
this->read_coils(start_address, number_of_entities);
return;
case EntityType::DISCRETE_INPUT:
this->read_discrete_inputs(start_address, number_of_entities);
return;
default:
ESP_LOGW(TAG, "Invalid entity type for read_entities: %d", (int) entity_type);
this->on_not_sent(); // every rejected send is signalled, like send_pdu()'s own refusals
return;
}
}
} // namespace esphome::modbus