Nothing has been indexed for 0.10.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  bacnet:
    github: spider-gazelle/crystal-bacnet
    version: ~> 0.10.2

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.10.2. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

BACnet Support for Crystal Lang

CI

it supports

  • the IPv4 data link layer (BACnet/IP)
  • the websocket data link layer (BACnet/SC)

Installation

Add the dependency to your shard.yml:

dependencies:
  bacnet:
    github: spider-gazelle/crystal-bacnet

Usage


require "bacnet"
require "socket"

# ======================
# Create transport layer
# ======================
server = UDPSocket.new
server.bind "0.0.0.0", 0xBAC0

# ======================
# Hook up the client to the transport
# ======================
client = BACnet::Client::IPv4.new

client.on_transmit do |message, address|
  if address.address == Socket::IPAddress::BROADCAST
    # Broadcast this message, might need to be a unicast to a BBMD
  else
    server.send message, to: address
  end
end

spawn do
  # Feed data to the client
  loop do
    break if server.closed?
    bytes, client_addr = server.receive

    message = IO::Memory.new(bytes).read_bytes(BACnet::Message::IPv4)
    client.received message, client_addr
  end
end

# ======================
# Collect device information
# ======================
registry = BACnet::Client::DeviceRegistry.new(client)
registry.on_new_device do |device|
  puts "FOUND NEW DEVICE: #{device.vendor_name} #{device.name} #{device.model_name}"
end

# broadcast a who_is out onto the network
client.who_is