BACnet.Protocol.Services.Protocol protocol (bacstack v0.1.0-dev.1)

Copy Markdown View Source

This protocol defines the common interface that all BACnet service modules (both confirmed and unconfirmed) must implement.

It allows the rest of the stack to treat services uniformly when encoding them into APDUs, determining whether they require a reply, and extracting their service choice name.

Every concrete service module (for example BACnet.Protocol.Services.ReadProperty, BACnet.Protocol.Services.IAm, etc.) implements this protocol via a defimpl block at the bottom of the file. The protocol is what enables the generic BACnet.Protocol.Services.Protocol.to_apdu/2 calls used throughout the client and stack layers.

Summary

Types

t()

All the types that implement this protocol.

Functions

Whether the service is of type confirmed or unconfirmed.

Get the service name atom.

Get a service request APDU for this service.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

confirmed?(service)

@spec confirmed?(t()) :: boolean()

Whether the service is of type confirmed or unconfirmed.

get_name(service)

@spec get_name(t()) :: atom()

Get the service name atom.

to_apdu(service, request_data)

Get a service request APDU for this service.

For confirmed service requests, the following keys default to specific values, if not specified:

  • segmented_response_accepted: true
  • max_segments: :more_than_64
  • max_apdu: 1476
  • invoke_id: 0

These keys can be overriden through request_data. request_data may be ignored for unconfirmed services.

When setting max_segments, do not use :unspecified because it makes it for the server unable to determine if the response is transmittable or not. Thus :unspecified might be as low as maximum two segments. For that reason, always use a specific max segments or :more_than_64.