Ryan Malloy 2aaa6e32a5 Rename library from AutoWire to K-Line
Library dir: lib/AutoWire/ -> lib/KLine/
Site title, docs, CLAUDE.md, platformio.ini all updated.
All 4 firmware environments build clean.
2026-02-13 08:31:34 -07:00

53 lines
1.4 KiB
C++

// BMW I/K-Bus interface — backward-compatible facade
// Delegates everything to KLineTransport + IbusHandler.
#include "IbusEsp32.h"
IbusEsp32::IbusEsp32()
: _transport(),
_handler(_transport) {}
void IbusEsp32::begin(HardwareSerial& serial, int8_t rxPin, int8_t txPin,
int8_t ledPin, uint8_t uartNum) {
KLineConfig config;
config.baud = IBUS_BAUD;
config.framing = IBUS_FRAMING;
config.idleTimeoutUs = IBUS_IDLE_TIMEOUT_US;
config.idleCheckUs = IBUS_IDLE_CHECK_US;
config.packetGapMs = IBUS_PACKET_GAP_MS;
config.txInvert = true;
config.checksumType = CHECKSUM_XOR;
_transport.begin(serial, rxPin, txPin, ledPin, uartNum, config);
}
void IbusEsp32::run() {
_transport.drainUart();
_handler.process();
_transport.run();
}
void IbusEsp32::write(const uint8_t* message, uint8_t size) {
_handler.write(message, size);
}
void IbusEsp32::onPacket(PacketCallback callback) {
_handler.onPacket(callback);
}
void IbusEsp32::setFilterEnabled(bool enabled) {
_handler.setFilterEnabled(enabled);
}
void IbusEsp32::setFilterAddress(uint8_t addr) {
_handler.setFilterAddress(addr);
}
void IbusEsp32::setFilterAddresses(const uint8_t* addrs, uint8_t count) {
_handler.setFilterAddresses(addrs, count);
}
uint8_t IbusEsp32::calculateChecksum(const uint8_t* data, uint8_t length) {
return KLineTransport::checksumXor(data, length);
}