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

56 lines
1.4 KiB
C++

#pragma once
// BMW I/K-Bus interface — backward-compatible facade
// Wraps KLineTransport + IbusHandler so existing sketches need zero changes.
// For new code, use KLineTransport + IbusHandler (or KLineObd2) directly.
#include <Arduino.h>
#include <functional>
#include "KLineTransport.h"
#include "IbusHandler.h"
// Re-export library defaults for existing config.h compatibility
#ifndef IBUS_BAUD
#define IBUS_BAUD 9600
#endif
#ifndef IBUS_FRAMING
#define IBUS_FRAMING SERIAL_8E1
#endif
#ifndef IBUS_IDLE_TIMEOUT_US
#define IBUS_IDLE_TIMEOUT_US 1500
#endif
#ifndef IBUS_IDLE_CHECK_US
#define IBUS_IDLE_CHECK_US 250
#endif
#ifndef IBUS_PACKET_GAP_MS
#define IBUS_PACKET_GAP_MS 10
#endif
#ifndef IBUS_UART_NUM
#define IBUS_UART_NUM 1
#endif
class IbusEsp32 {
public:
using PacketCallback = std::function<void(const uint8_t* packet, uint8_t length)>;
IbusEsp32();
void begin(HardwareSerial& serial, int8_t rxPin, int8_t txPin,
int8_t ledPin = -1, uint8_t uartNum = IBUS_UART_NUM);
void run();
void write(const uint8_t* message, uint8_t size);
void onPacket(PacketCallback callback);
void setFilterEnabled(bool enabled);
void setFilterAddress(uint8_t addr);
void setFilterAddresses(const uint8_t* addrs, uint8_t count);
static uint8_t calculateChecksum(const uint8_t* data, uint8_t length);
private:
KLineTransport _transport;
IbusHandler _handler;
};