2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.herzborg.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.io.transport.serial.SerialPortManager;
17 import org.openhab.core.thing.Bridge;
18 import org.openhab.core.thing.ThingStatus;
19 import org.openhab.core.thing.ThingStatusDetail;
22 * The {@link SerialBusHandler} implements specific handling for Herzborg serial bus,
23 * connected directly via a serial port.
25 * @author Pavel Fedin - Initial contribution
28 public class SerialBusHandler extends BusHandler {
29 private SerialBusConfiguration config = new SerialBusConfiguration();
31 public SerialBusHandler(Bridge bridge, SerialPortManager portManager) {
32 super(bridge, new SerialBus(portManager));
36 public void initialize() {
37 config = getConfigAs(SerialBusConfiguration.class);
39 Bus.Result result = ((SerialBus) bus).initialize(config.port);
41 if (result.code == ThingStatusDetail.NONE) {
42 updateStatus(ThingStatus.ONLINE);
44 updateStatus(ThingStatus.OFFLINE, result.code, result.message);
49 public void dispose() {