ela-compil
BACnet
C#

.NET library for BACnet :satellite:

Last updated Jul 6, 2026
247
Stars
106
Forks
5
Issues
0
Stars/day
Attention Score
84
Language breakdown
C# 100.0%
โ–ธ Files click to expand
README

.NET library for BACnet

build NuGet Downloads License: MIT

BACnet logo

BACnet (ASHRAE 135) is the standard communication protocol for building-automation systems โ€” HVAC, lighting, access control, and metering. This library is a standalone BACnet stack for .NET: add a NuGet package and talk to BACnet devices from your own code, or expose your application as a BACnet device.

Features

  • Transports โ€” BACnet/IP (UDP, IPv4 & IPv6) with BBMD and foreign-device registration; BACnet/Ethernet (pcap); MS/TP and PTP over a serial port
  • Client and device (server) roles โ€” send requests and/or answer them from your own object model
  • Discovery โ€” Who-Is / I-Am and Who-Has / I-Have, including across routers
  • Data access โ€” ReadProperty, WriteProperty, ReadPropertyMultiple, WritePropertyMultiple, ReadRange
  • Change of Value โ€” SubscribeCOV / SubscribeProperty and COV notifications
  • Scheduling โ€” typed read/write of Schedule and Calendar properties (WeeklySchedule, ExceptionSchedule, DateList, EffectivePeriod), plus example Schedule/Calendar objects implementing the standard behavior
  • Alarms & events โ€” event/alarm notifications, alarm summary, and acknowledgement
  • More services โ€” object create/delete, atomic file read/write, device-communication-control, reinitialize, time synchronization
  • Segmentation of large requests and responses
  • Complete ASN.1 encode/decode of the BACnet APDU set, covered by a test suite verified against ASHRAE 135 Annex F

Packages

Core stack โ€” pure-managed BACnet/IP, MS/TP & PTP protocol, encode/decode. No native dependencies. pcap-based BACnet/Ethernet (ISO 8802-3) transport (SharpPcap / PacketDotNet). Physical serial-port transport (System.IO.Ports) for MS/TP and PTP. Optional bridge to route the stack's logs to Common.Logging.

Supported target frameworks

| Package | net48 | netstandard2.0 | net8.0 | net10.0 | |---------|:-----:|:--------------:|:------:|:-------:| | BACnet (core) | โœ… | โœ… | โœ… | โœ… | | BACnet.Ethernet | โœ… | โ€” | โœ… | โœ… | | BACnet.Serial | โœ… | โ€” | โœ… | โœ… | | BACnet.Logging.CommonLogging | โœ… | โœ… | โœ… | โœ… |

netstandard2.0 covers .NET 6/7 and other runtimes.

Install

dotnet add package BACnet

optional native transports:

dotnet add package BACnet.Ethernet dotnet add package BACnet.Serial

Getting started

A minimal Who-Is device discovery over BACnet/IP:

using System.IO.BACnet;

var client = new BacnetClient(new BacnetIpUdpProtocolTransport(0xBAC0));

client.OnIam += (sender, adr, deviceId, maxApdu, seg, vendorId) => Console.WriteLine($"Found device {deviceId} at {adr}");

client.Start();

client.WhoIs();

Console.ReadLine();

On a host with several network interfaces (e.g. Hyper-V/WSL/Docker virtual adapters), tell the
transport which one to bind by passing its IP โ€” otherwise it throws an error listing the candidates:
new BacnetIpUdpProtocolTransport(0xBAC0, localEndpointIp: "192.168.1.50").

The Examples/ folder has runnable samples โ€” basic read/write, a device/server, COV subscription, alarm/event handling, BBMD, a serial device, and more.

Logging

The stack uses Microsoft.Extensions.Logging. By default logging is a no-op; wire a factory once and everything logs through it:

using Microsoft.Extensions.Logging;

BacnetLogging.Factory = LoggerFactory.Create(b => b.AddConsole());

Console, Serilog, NLog, and log4net all work via their MEL providers. If you already use Common.Logging, add the BACnet.Logging.CommonLogging package and call b.AddCommonLogging().

Upgrading from 3.x to 4.0

4.0 has a few breaking changes โ€” see MIGRATION.md for details:

  • Logging moved from Common.Logging to Microsoft.Extensions.Logging (the Log property is now ILogger).
  • Native transports split into optional packages: pcap โ†’ BACnet.Ethernet, serial โ†’ BACnet.Serial.
The MS/TP and PTP protocols stay in the core; use SerialTransport.Mstp(...) / .Ptp(...) from BACnet.Serial.
  • Interface selection is explicit when the host has multiple network interfaces. In that case
BacnetIpUdpProtocolTransport no longer picks one for you โ€” Start() throws and lists the candidates. Pass the interface IP: new BacnetIpUdpProtocolTransport(0xBAC0, localEndpointIp: "192.168.1.50").
  • Renamed the misspelled enum member BacnetRejectReason.RECOGNIZEDSERVICE to UNRECOGNIZEDSERVICE (value unchanged).
  • Scheduling types are spec-shaped now: the old BACnetCalendarEntry and BacnetweekNDay are replaced by
BacnetCalendarEntry / BacnetWeekNDay, and schedule properties decode into typed values (BacnetDailySchedule, BacnetSpecialEvent) instead of opaque nested constructs.

GitHub Packages

Releases are also published to GitHub Packages. To restore from there, add the source https://nuget.pkg.github.com/ela-compil/index.json (a GitHub PAT with read:packages is required).

Credits & history

The stack was originally developed by Morten Kvistgaard โ€” with significant contributions from F. Chaxel, Steve Karg, and the BACnet Stack (in C) โ€” as part of YABE (Yet Another BACnet Explorer). This repository was forked from the YABE SourceForge SVN and is maintained here by Jakub Bartkowiak and the Ela-compil team as an independent library on NuGet; it is a separate codebase from YABE (YABE keeps its own copy of the stack).

Trademarks

"BACnet" and the BACnet logo are registered trademarks of ASHRAE (the American Society of Heating, Refrigerating and Air-Conditioning Engineers, Inc.). This project is an independent, community-maintained implementation of the BACnet protocol; it is not affiliated with, endorsed by, or sponsored by ASHRAE or BACnet International. The name and logo are used only to identify the protocol this library implements.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท ela-compil/BACnet ยท Updated daily from GitHub