diff --git a/AGENTS.md b/AGENTS.md
index f40fabf..6c0847c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,32 +1,85 @@
# AGENTS.md
+Guidance for AI coding agents working in this repository. See
+ for the format. Human contributors should read
+[README.md](README.md) first, then [TUTORIAL.md](TUTORIAL.md).
+
## What this project is
-The Node.js edition of the BACnet **B-ASC** (Application Specific Controller)
-profile example: a complete minimal BACnet/IP device (DS-RP-B, DS-WP-B,
-DM-DCC-B, DM-DDB-B, DM-DOB-B) built on the CAS BACnet Stack's npm package.
-Part of the BACnet profile example series - the C++ sibling is
-BACnetProfileExample-B-ASC-CPP, and the two are kept diffable: same objects,
-names, section layout, and `BACnetStack_*` function names.
+A **tutorial** Node.js/TypeScript example that implements the BACnet
+**B-ASC** (Application Specific Controller) profile using the CAS BACnet
+Stack's npm package: a complete minimal BACnet/IP device (DS-RP-B, DS-WP-B,
+DM-DCC-B, DM-DDB-B, DM-DOB-B). Part of the BACnet profile example series - the
+C++ sibling is BACnetProfileExample-B-ASC-CPP, and the two are kept diffable:
+same objects, names, section layout, and `BACnetStack_*` function names. The
+top priority is that the code reads like a tutorial a customer can learn from
+and copy-paste. Favour clarity over cleverness.
## Layout
+This repository is self-contained:
+
- `main.ts` - the whole application, four numbered sections (§1 configuration,
§2 get callbacks, §2b set callbacks, §2c DCC callback, §3 main).
-- `common/` - VENDORED series helpers (SimpleUDP, CASExampleHelper, constants).
- Never edit here alone: a change must be swept to every sibling Node example
- and `COMMON_VERSION` bumped with a `common/CHANGELOG.md` entry.
-- `submodules/cas-bacnet-stack` - the stack, pinned by the series-wide gitlink;
- consumed via npm workspaces. Do not bump the pin in one example alone.
+- `common/` - the shared Node.js helper (SimpleUDP, CASExampleHelper,
+ constants), vendored in. Never edit here alone: a change must be swept to
+ every sibling Node example and `COMMON_VERSION` bumped with a
+ `common/CHANGELOG.md` entry.
+- `README.md` - what this example is. Keep it short and about THIS example
+ only.
+- `TUTORIAL.md` - how to extend and review the example. Long-form material
+ that would bloat the README belongs here.
+- `docs/PICS.md` - the Protocol Implementation Conformance Statement. Its
+ objects-and-properties section is GENERATED from `docs/objects.json`; do
+ not hand-edit between the `OBJECTS-PROPERTIES` markers.
+- `docs/objects.json` - the input to that generator. Update it in the same
+ change as any `main.ts` change that adds an object or a `Get*`/`Set*`
+ branch.
+- `submodules/cas-bacnet-stack` - the **CAS BACnet Stack** as a git submodule
+ (private; tracks `6.x-TestTool`), consumed via **npm workspaces**. Do not
+ bump the pin in one example alone. After cloning, run
+ `git submodule update --init --recursive`.
+
+The `PROFILE-TABLE` block in README.md is also generated, from the
+example-series repository's `docs/profile-table.md`. Edit it there, not here.
+
+## Build
+
+This is a **Node.js example, not a CMake project** - do not apply the C++
+sibling examples' CMake/SOURCE-mode build instructions here. The real build is
+one command, identical on every platform:
+
+```bash
+git submodule update --init --recursive # once, if not cloned with --recursive
+npm install # compiles the CAS BACnet Stack addon
+ # (node-gyp, 10-20 min first time) and
+ # builds the package's dist/ via its
+ # prepare script
+```
-## Build / run
+Windows needs Visual Studio 2022 Build Tools ("Desktop development with C++")
+plus Python (the standard node-gyp prerequisites) and a short project path;
+Linux/macOS need a C++17 toolchain. Do not reintroduce a CMake invocation, a
+prebuilt-library step, or a series-root build script into the documented
+build: a customer downloads this repository on its own and must be able to
+build it with the command above.
-- `npm install` - compiles the stack addon from the submodule source
- (10-20 min first time) and builds the package's `dist/` via its `prepare`.
-- `npm start [-- --port 47821 --deviceID N]` - run. `npm run typecheck` - tsc.
+## Run
+
+```bash
+npm start [-- --port 47821 --deviceID N] # run
+npm run typecheck # tsc --noEmit
+```
+
+Interactive keys while running: `h` help, `q` quit, up/down nudge Analog
+Input 1.
## Conventions
+- Device is named "Rainbow"; objects use the series' colour names; vendor id
+ 389.
+- Implement **only** the services and objects the B-ASC profile requires -
+ but expose **every required property** of each object.
- The application calls `LoadBACnetFunctions()` once, first, and checks it.
- Every `BACnetStack_*` setup call's return value is checked; failures print
which call failed and exit non-zero.
@@ -36,16 +89,32 @@ names, section layout, and `BACnetStack_*` function names.
`common/CASExampleHelper.ts` only - never re-derive it.
- Present tense only: no comment or doc references a previous version of this
example or of the stack.
+- **Never edit `common/` in this repo alone** - it is a vendored copy shared
+ by every Node example in the series, with its own version
+ (`COMMON_VERSION`) and changelog (`common/CHANGELOG.md`).
## How to verify a change
+There are no unit tests; verification is behavioural:
+
1. `npm run typecheck`.
2. Smoke: `npm start -- --port 47821` stays up past the ready banner (every
failed setup call exits 1, so "still running" proves registration).
3. Read back what you changed with a BACnet client (Who-Is, ReadProperty,
WriteProperty at two priorities + relinquish, DCC wrong/right password).
+4. If you changed the objects or their properties, regenerate
+ `docs/PICS.md` (`python tools/gen-objects-properties.py
+ BACnetProfileExample-B-ASC-Node` from the series root) and confirm no row
+ comes out flagged with ⚠.
+
+## Releasing
+
+Bump `APP_VERSION` in `main.ts` and add an entry to
+[CHANGELOG.md](CHANGELOG.md), then tag `vX.Y.Z`. The GitHub Actions workflow
+builds, typechecks, smoke-tests, and publishes a source release (there is no
+prebuilt binary - every install compiles the stack addon locally).
## License
-CC0-1.0 for the example; the stack submodule is a separately licensed
-commercial product.
+See [LICENSE](LICENSE). The CAS BACnet Stack is a separate, commercially
+licensed product and is not covered by it.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 55bc1a0..31fa11b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,18 @@ and this project adheres to
## [Unreleased]
+### Changed
+
+- Restructured the documentation: `README.md` is cut down to this example
+ only (series-framing, generic profile prose, and "Use this in your own
+ project" / "The interesting parts of main.ts" moved out); added
+ `TUTORIAL.md` (extending the example, who serves what, reviewing your
+ device, troubleshooting) and `docs/PICS.md` (a full ANSI/ASHRAE 135 Annex A
+ Protocol Implementation Conformance Statement) plus the `docs/objects.json`
+ input that generates its objects-and-properties tables. `AGENTS.md` updated
+ to match the new layout and to state plainly that this is a Node.js build,
+ not a CMake one.
+
### Added
- The complete B-ASC example application (`main.ts`): device 389003 ("Rainbow"),
diff --git a/README.md b/README.md
index 92a5bd2..4ebb3c7 100644
--- a/README.md
+++ b/README.md
@@ -1,73 +1,179 @@
# BACnet B-ASC (Application Specific Controller) - Node.js example
-A complete, minimal BACnet/IP device implementing the **B-ASC** device profile
-of ANSI/ASHRAE 135 Annex L, in TypeScript on Node.js, using the
-[CAS BACnet Stack](https://store.chipkin.com/). Part of the BACnet profile
-example series - one self-contained tutorial per device profile. This is the
-Node.js edition of
-[BACnetProfileExample-B-ASC-CPP](https://github.com/chipkin/BACnetProfileExample-B-ASC-CPP):
-same objects, same names, same section layout, same `BACnetStack_*` function
-names, so you can diff the two side by side and see exactly what is language
-and what is BACnet.
-
-> **Versions**: example v1.0.0, CAS BACnet Stack 6.x (`@chipkin/cas-bacnet-stack`
-> 6.1.0), Protocol_Revision = the stack default. Trust the program's start-up
-> banner, not this line.
-
-## Quickstart
+A minimal, copy-paste-friendly example showing how to implement the BACnet
+**B-ASC (Application Specific Controller)** device profile in TypeScript on
+Node.js, using the
+[CAS BACnet Stack](https://store.chipkin.com/services/stacks/bacnet-stack). It
+listens on **BACnet/IP (UDP 47808)**, answers **ReadProperty** and
+**WriteProperty**, accepts **DeviceCommunicationControl**, and is discoverable
+via **Who-Is / I-Am**.
-```bash
-git clone --recursive https://github.com/chipkin/BACnetProfileExample-B-ASC-Node.git
-cd BACnetProfileExample-B-ASC-Node
-npm install # compiles the CAS BACnet Stack from source - expect 10-20 minutes the first time
-npm start
-```
+**[Tagged source releases](https://github.com/chipkin/BACnetProfileExample-B-ASC-Node/releases)**
+- there is no prebuilt binary to download; `npm install` always compiles the
+CAS BACnet Stack addon locally (see [Build](#build) below).
-`npm install` builds the entire stack into a native Node addon (there is no
-prebuilt binary to ship). Windows needs the Visual Studio Build Tools + Python
-(the standard node-gyp prerequisites) and a reasonably short project path;
-Linux/macOS need a C++17 toolchain.
+- **[TUTORIAL.md](TUTORIAL.md)** - how to extend this example and how to review
+ it for conformance. Read it when you start turning this into your own device.
+- **[docs/PICS.md](docs/PICS.md)** - the Protocol Implementation Conformance
+ Statement: every object, every property, and who answers it.
-## What is a B-ASC (BACnet Application Specific Controller)?
+> **Versions:** this document describes **example v1.0.0**, built and verified
+> against the CAS BACnet Stack submodule pinned at `6.x-TestTool` @ `4a69c9eb`
+> (`package.json` calls this npm package **6.1.0**; the compiled API itself
+> reports **v6.0.0.0** - the program's own start-up banner is correct, this
+> line is not authoritative), at **Protocol_Revision 24**, with the vendored
+> Node `common/` helper at **v1.0.0**. Running the example prints the app and
+> API versions - if what it prints disagrees with this line, trust the
+> program and check `CHANGELOG.md`. It does not print Protocol_Revision or the
+> common helper version; read the former back with ReadProperty and check
+> `common/CHANGELOG.md` for the latter.
-An Application Specific Controller is a B-SA (Smart Actuator - report values
-and be commanded) plus **DeviceCommunicationControl**: a client can tell the
-device to stop initiating traffic, optionally for a limited time, optionally
-guarded by a password. In BIBB terms this example executes:
+## What is the B-ASC (Application Specific Controller) profile?
-| BIBB | Service | Meaning |
-|---|---|---|
-| DS-RP-B | ReadProperty | serve property reads |
-| DS-WP-B | WriteProperty | accept commands (priority array) |
-| DM-DCC-B | DeviceCommunicationControl | the B-ASC addition |
-| DM-DDB-B | Who-Is / I-Am | be discoverable |
-| DM-DOB-B | Who-Has / I-Have | objects discoverable by name |
+**B-ASC (BACnet Application Specific Controller)**, defined in Annex L of
+ANSI/ASHRAE 135, is a **B-SA (Smart Actuator)** - a device that reports values
+and accepts commands - plus **DeviceCommunicationControl**: a client can tell
+the device to stop initiating traffic, optionally for a limited time,
+optionally guarded by a password.
-Nothing else is enabled - no COV, no alarms, no scheduling, no trending, no
-ReadPropertyMultiple. Implementing exactly one profile is the point.
+A B-ASC device answers **ReadProperty** and **WriteProperty**, is
+discoverable, and executes **DeviceCommunicationControl**. This example
+implements exactly those capabilities and nothing more - no COV, no alarming,
+no scheduling, no trending, no ReadPropertyMultiple.
+
+**But it is still a full BACnet device.** Even a small profile must present
+the standard object model - a **Device** object, a **Network Port** object
+(every device needs one), its sensor objects, and its commandable output
+objects - and each object must expose all of its **required properties**. The
+CAS BACnet Stack generates most of those automatically (Object_Identifier,
+Object_Type, Status_Flags, Object_List, Protocol_*, Priority_Array's slot
+resolution when the stack owns it, ...); this example supplies the rest,
+including its own application-owned priority-array model for the three
+commandable outputs. [docs/PICS.md](docs/PICS.md) lists every property and who
+answers it.
## The device this example creates
-Device **389003** ("Rainbow"), vendor **389** (Chipkin), plus the series'
-standard objects:
+```
+Device 389003 "Rainbow" (Vendor 389 - Chipkin Automation Systems)
+ │
+ ├── Analog Input 1 "Bronze" Present_Value 21.5 (REAL, degrees Celsius; read-only)
+ ├── Binary Input 1 "Emerald" Present_Value inactive (read-only)
+ ├── Multi-State Input 1 "Hot Pink" Present_Value 1 (state 1..3; read-only)
+ ├── Analog Output 1 "Chartreuse" Present_Value 0.0 (REAL, percent; commandable, 16-slot priority array)
+ ├── Binary Output 1 "Fuchsia" Present_Value inactive (commandable, 16-slot priority array)
+ ├── Multi-State Output 1 "Indigo" Present_Value 1 (state 1..3; commandable, 16-slot priority array)
+ └── Network Port 1 "Vermilion" the BACnet/IP port (required on every device)
+```
-| Object | Name | What it demonstrates |
-|---|---|---|
-| Analog Input 1 | Bronze | a read-only value (21.5 °C; nudge with the arrow keys) |
-| Binary Input 1 | Emerald | a read-only contact |
-| Multi-State Input 1 | Hot Pink | states 1..3 with State_Text ("On"/"Off"/"Auto") |
-| Analog Output 1 | Chartreuse | commandable REAL (16-slot priority array) |
-| Binary Output 1 | Fuchsia | commandable active/inactive |
-| Multi-State Output 1 | Indigo | commandable state 1..3 with validation |
-| Network Port 1 | Vermilion | the BACnet/IP port's own configuration |
+## What this example supports
+
+The example implements exactly the capabilities below - and nothing more,
+which is the point of a profile example.
+
+### BIBBs (BACnet Interoperability Building Blocks)
+
+| BIBB | Description | Supported |
+|------|-------------|:---------:|
+| DS-RP-B | Data Sharing - ReadProperty - B | ✅ |
+| DS-WP-B | Data Sharing - WriteProperty - B | ✅ |
+| DM-DCC-B | Device Management - DeviceCommunicationControl - B | ✅ |
+| DM-DDB-B | Device Management - Dynamic Device Binding - B | ✅ |
+| DM-DOB-B | Device Management - Dynamic Object Binding - B | ✅ |
+
+### Services (executed / B-side)
+
+| Service | Notes |
+|---------|-------|
+| ReadProperty | Responds to property reads (DS-RP-B). |
+| WriteProperty | Accepts commands to the three output objects, priority-array semantics (DS-WP-B). |
+| DeviceCommunicationControl | Enable/disable-initiation, optional timed duration, optional password (DM-DCC-B). |
+| Who-Is / I-Am | Answers Who-Is with I-Am, and broadcasts an I-Am on start-up (DM-DDB-B). |
+| Who-Has / I-Have | Answers Who-Has with I-Have (DM-DOB-B). |
+
+### Object types
+
+| Object type | Instance | Name |
+|-------------|:--------:|------|
+| Device | 389003 | Rainbow |
+| Analog Input | 1 | Bronze |
+| Binary Input | 1 | Emerald |
+| Multi-state Input | 1 | Hot Pink |
+| Analog Output | 1 | Chartreuse |
+| Binary Output | 1 | Fuchsia |
+| Multi-state Output | 1 | Indigo |
+| Network Port | 1 | Vermilion |
+
+Every required property of every object, and who answers it, is in
+[docs/PICS.md](docs/PICS.md).
+
+## Requires the CAS BACnet Stack (licensed product)
+
+This example **builds against the CAS BACnet Stack, which is a commercial
+Chipkin product** - it is not free or open source, and there is no
+public/trial build. The stack is referenced here as the **private** git
+submodule `submodules/cas-bacnet-stack` (tracking the `6.x-TestTool` branch)
+and consumed as an **npm workspace**: `npm install` compiles it from source
+and builds the package's TypeScript layer. You can only fetch and build it
+once you have a CAS BACnet Stack license and access to that repository.
+
+**To get the CAS BACnet Stack (and access to build this example), contact
+Chipkin:** or
+sales@chipkin.com.
## What's in this repository
-| | |
-|---|---|
-| [`main.ts`](main.ts) | the whole tutorial - read it top to bottom; four numbered sections mirroring the C++ edition |
-| [`common/`](common) | vendored series plumbing: the UDP socket, the transport callbacks + 6-byte connection string, I-Am, CLI, constants |
-| `submodules/cas-bacnet-stack` | the CAS BACnet Stack (licensed product - see below), consumed as an npm workspace |
+This is a **self-contained** project. It ships:
+
+- `main.ts` - the example device.
+- `common/` - the shared Node.js helper (UDP, callbacks, CLI, keyboard)
+ vendored in.
+- `package.json` / `tsconfig.json` - the build, the same on Windows, Linux,
+ and macOS.
+- `docs/PICS.md` - the conformance statement.
+- `docs/objects.json` - the input to the objects-and-properties generator.
+- `submodules/cas-bacnet-stack/` - the **CAS BACnet Stack as a git submodule**
+ (private; requires a license - see above), consumed as an npm workspace. Its
+ sources compile into a native Node addon, so there is nothing to build, ship,
+ or install separately.
+
+## Prerequisites
+
+- Node.js `>=18.20.8 <=24.x` and npm.
+- A C++17 toolchain (node-gyp needs it to compile the stack addon).
+- Git (to fetch the stack submodule).
+
+### Windows
+
+- **Build tools** - Visual Studio 2022 Build Tools with the **"Desktop
+ development with C++"** workload, plus Python (the standard node-gyp
+ prerequisites). Newer Visual Studio versions are not supported by the
+ stack's current toolset.
+- Use a short project path - the stack's MSVC intermediate paths mirror its
+ source tree, and long paths can fail to compile.
+
+### Linux / macOS
+
+- Debian/Ubuntu: `sudo apt install build-essential python3 git`
+- macOS: `xcode-select --install`
+
+## Build
+
+npm only, and the same two commands on every platform:
+
+```bash
+git clone --recursive https://github.com/chipkin/BACnetProfileExample-B-ASC-Node.git
+cd BACnetProfileExample-B-ASC-Node
+
+npm install
+```
+
+Already cloned without `--recursive`? Run `git submodule update --init --recursive`
+first - the install needs the stack submodule.
+
+> **The first `npm install` takes 10-20 minutes** - it compiles the entire CAS
+> BACnet Stack into a native Node addon via node-gyp. Subsequent installs are
+> much faster once the addon is built.
## Run
@@ -78,57 +184,179 @@ npm start -- --deviceID 12345 # your own device instance
npm start -- --help
```
-Interactive keys: `h` help, `q` quit, `↑`/`↓` nudge Analog Input 1 so a client
-can watch the value change.
+Expected output:
-> Two red `Error:` lines can appear at start-up (a BACnet/SC "UUID has not
-> been set" notice and a self-heard-broadcast decode); both are benign.
+```
+BACnet B-ASC (Application Specific Controller) Example - Node v1.0.0
+CAS BACnet Stack v6.0.0.0
+FYI: listening on :47808 (broadcast )
+FYI: Device 389003 ("Rainbow") ready. Vendor ID 389. Press 'h' for help.
+```
+
+The device listens on UDP **47808** (BACnet/IP) by default. Allow that port
+through your firewall. To use a different port, pass `--port`.
+
+> **Two red `Error:` lines at start-up are expected and are not your bug** -
+> the stack's own debug logging (the device hearing its own broadcast I-Am,
+> and a one-time BACnet/SC UUID notice). [TUTORIAL.md](TUTORIAL.md#troubleshooting)
+> explains both.
+
+### Command-line options
+
+| Option | Default | Meaning |
+|--------|---------|---------|
+| `--port ` | `47808` | UDP port to listen on (BACnet/IP). |
+| `--deviceID ` | `389003` | The device's BACnet instance number (BACnet requires this to be configurable). |
+| `--help`, `-h` | - | Show usage and exit. |
+| `--version` | - | Print the example and stack versions, then exit. |
+
+### Interactive commands
+
+While the example runs, these keys are available:
+
+| Key | Action |
+|-----|--------|
+| `h` | Show the version information and this command list. |
+| `q` | Quit. |
+| up arrow | Increase Analog Input 1 (`Bronze`) by 1.1. |
+| down arrow | Decrease Analog Input 1 (`Bronze`) by 1.1. |
+
+The up/down keys change the live `Present_Value` of the analog input, so a
+client re-reading it sees the new value.
## Verify
-Discover the device with any BACnet client (for example the
-[CAS BACnet Explorer](https://store.chipkin.com/products/tools/cas-bacnet-explorer)):
-Who-Is answers with I-Am from device 389003 / vendor 389; every required
-property of every object reads back; WriteProperty to the three outputs obeys
-priority-array semantics (write NULL to relinquish); DeviceCommunicationControl
-with a wrong password answers `password-failure`.
-
-## The interesting parts of `main.ts`
-
-- **`LoadBACnetFunctions()` first.** The same load contract as every edition of
- this example: load once before any stack call, check the result, print
- `CASBACnetStackAdapter_LastError()` on failure.
-- **The stack pulls, the application owns.** The application owns the UDP
- socket, the device data, and the tick loop; the stack asks for datagrams and
- property values through callbacks. Out-parameters arrive as `Buffer`s:
- `value.writeFloatLE(21.5, 0)` is the Node spelling of `*value = 21.5f`.
-- **The commandable model** (`Commandable`, `CommandWrite`, `CommandRelinquish`)
- - a 16-slot priority array per output, falling back to Relinquish_Default.
-- **Silent traps, called out in comments where they live**: a `false` return
- from a Get callback usually substitutes a default instead of erroring; an
- OPTIONAL property served without `SetPropertyEnabled` answers
- unknown-property; the DCC callback has no default errorCode; and there are
- TWO networkType enumerations (ipv4 = 5 for the Network Port object, IP = 0
- for the message callbacks).
+Use a BACnet client such as the
+[**CAS BACnet Explorer**](https://store.chipkin.com/products/tools/cas-bacnet-explorer):
-## Requires the CAS BACnet Stack (licensed product)
+1. **Discover** - send a **Who-Is**. The device replies with **I-Am** from
+ instance **389003** (vendor **389**). It also broadcasts an I-Am at
+ start-up.
+2. **Browse the object model** - the device shows eight objects: the Device
+ (`Rainbow`), the three read-only inputs, the three commandable outputs, and
+ the Network Port (`Vermilion`). Reading the Device's `Object_List` returns
+ all eight.
+3. **Read the Device** - ReadProperty `389003` -> `Object_Name` returns
+ `"Rainbow"`; `Description` returns the profile description string.
+4. **Read a sensor** - ReadProperty Analog Input `1` -> `Present_Value`
+ returns `21.5`; `Units` returns `degrees-Celsius`. Repeat for Binary Input
+ `1` (`"Emerald"`) and Multi-State Input `1` (`"Hot Pink"`, has
+ `Number_Of_States` = 3).
+5. **Command an output** - WriteProperty Analog Output `1`'s `Present_Value`
+ at priority 8, then read it back; write `NULL` at priority 8 to relinquish
+ and confirm it falls back to `Relinquish_Default`. Repeat with Binary
+ Output `1` and Multi-State Output `1`; an out-of-range Multi-State write is
+ rejected `value-out-of-range`.
+6. **DeviceCommunicationControl** - send DCC with the wrong password and
+ confirm `password-failure`; with the right password, confirm
+ disable-initiation / enable behaves as documented in
+ [docs/PICS.md](docs/PICS.md).
+
+For a property-by-property review against the conformance statement, see
+[TUTORIAL.md](TUTORIAL.md).
+
+## The BACnet profile example series
+
+
+The CAS BACnet Stack supports every standardized device profile in ASHRAE 135-2024 Annex L, and there is one example repository per profile. Pick the profile your device claims, then the language you build in.
+
+### Controllers (Annex L.4)
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-SS** Smart Sensor | [B-SS-CPP](https://github.com/chipkin/BACnetProfileExample-B-SS-CPP) | — |
+| **B-SA** Smart Actuator | [B-SA-CPP](https://github.com/chipkin/BACnetProfileExample-B-SA-CPP) | — |
+| **B-ASC** Application Specific Controller | [B-ASC-CPP](https://github.com/chipkin/BACnetProfileExample-B-ASC-CPP) | [B-ASC-Node](https://github.com/chipkin/BACnetProfileExample-B-ASC-Node) |
+| **B-AAC** Advanced Application Controller | [B-AAC-CPP](https://github.com/chipkin/BACnetProfileExample-B-AAC-CPP) | — |
+| **B-BC** Building Controller | [B-BC-CPP](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP) | — |
+
+### Life safety controllers (Annex L.5)
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-LSC** Life Safety Controller | [B-LSC-CPP](https://github.com/chipkin/BACnetProfileExample-B-LSC-CPP) 🚧 | — |
+| **B-ALSC** Advanced Life Safety Controller | [B-ALSC-CPP](https://github.com/chipkin/BACnetProfileExample-B-ALSC-CPP) | — |
+
+### Access control controllers (Annex L.6)
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-ACC** Access Control Controller | [B-ACC-CPP](https://github.com/chipkin/BACnetProfileExample-B-ACC-CPP) | — |
+| **B-AACC** Advanced Access Control Controller | [B-AACC-CPP](https://github.com/chipkin/BACnetProfileExample-B-AACC-CPP) | — |
+
+### Lighting controllers (Annex L.11)
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-LD** Lighting Device | [B-LD-CPP](https://github.com/chipkin/BACnetProfileExample-B-LD-CPP) | — |
+| **B-LS** Lighting Supervisor | [B-LS-CPP](https://github.com/chipkin/BACnetProfileExample-B-LS-CPP) | — |
+
+### Elevator controllers (Annex L.13)
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-EM** Elevator Monitor | [B-EM-CPP](https://github.com/chipkin/BACnetProfileExample-B-EM-CPP) | — |
+| **B-EC** Elevator Controller | [B-EC-CPP](https://github.com/chipkin/BACnetProfileExample-B-EC-CPP) | — |
+| **B-AEC** Advanced Elevator Controller | [B-AEC-CPP](https://github.com/chipkin/BACnetProfileExample-B-AEC-CPP) | — |
-The CAS BACnet Stack is a commercial Chipkin product, included as the private
-git submodule `submodules/cas-bacnet-stack` (tracking the `6.x-TestTool`
-branch) and consumed as an npm workspace - `npm install` compiles it from
-source and builds the package's TypeScript layer. You need a licence to fetch
-and build it: or sales@chipkin.com.
+### Authentication and authorization (Annex L.14)
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-AS** Authorization Server | [B-AS-CPP](https://github.com/chipkin/BACnetProfileExample-B-AS-CPP) | — |
+
+### Miscellaneous (Annex L.7, combinable with any one family)
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-BBMD** Broadcast Management Device | [B-BBMD-CPP](https://github.com/chipkin/BACnetProfileExample-B-BBMD-CPP) | — |
+| **B-ACDC** Access Control Door Controller | [B-ACDC-CPP](https://github.com/chipkin/BACnetProfileExample-B-ACDC-CPP) | — |
+| **B-ACCR** Access Control Credential Reader | [B-ACCR-CPP](https://github.com/chipkin/BACnetProfileExample-B-ACCR-CPP) | — |
+| **B-RTR** Router | [B-RTR-CPP](https://github.com/chipkin/BACnetProfileExample-B-RTR-CPP) | — |
+| **B-GW** Gateway | [B-GW-CPP](https://github.com/chipkin/BACnetProfileExample-B-GW-CPP) | — |
+| **B-DAP** Device Address Proxy | [B-DAP-CPP](https://github.com/chipkin/BACnetProfileExample-B-DAP-CPP) | — |
+| **B-SCHUB** BACnet/SC Hub | [B-SCHUB-CPP](https://github.com/chipkin/BACnetProfileExample-B-SCHUB-CPP) | — |
+| **B-GENERAL** General device (Annex L.8) | *(satisfied by every example above)* | — |
+
+### Operator interfaces and workstations (Annex L.1–L.3, L.9–L.10, L.12)
+
+Client-side profiles.
+
+| Profile | C++ | Node.js |
+|---|---|---|
+| **B-OD** Operator Display | [B-OD-CPP](https://github.com/chipkin/BACnetProfileExample-B-OD-CPP) | — |
+| **B-OWS** Operator Workstation | planned | — |
+| **B-AWS** Advanced Operator Workstation | planned | — |
+| **B-XAWS** Extended Advanced Operator Workstation | planned | — |
+| **B-LSAP** Life Safety Annunciator Panel | planned | — |
+| **B-LSWS** Life Safety Workstation | planned | — |
+| **B-ALSWS** Advanced Life Safety Workstation | planned | — |
+| **B-ACSD** Access Control Security Display | planned | — |
+| **B-ACWS** Access Control Workstation | planned | — |
+| **B-AACWS** Advanced Access Control Workstation | planned | — |
+| **B-LOD** Lighting Operator Display | planned | — |
+| **B-ALWS** Advanced Lighting Workstation | planned | — |
+| **B-LCS** Lighting Control Station | planned | — |
+| **B-ALCS** Advanced Lighting Control Station | planned | — |
+| **B-ED** Elevator Display | planned | — |
+| **B-EWS** Elevator Workstation | planned | — |
+| **B-AEWS** Advanced Elevator Workstation | planned | — |
-## Use this in your own project
+🚧 = in progress. Profile definitions: ANSI/ASHRAE 135-2024 Annex L. BIBB definitions: Annex K. Get the stack: .
+
-Copy the shape, not the identity: get your own vendor ID from ASHRAE, pick your
-own device instance, and replace everything marked
-`CHANGE ALL OF THIS BEFORE YOU SHIP` in `main.ts` §1. Keep: the
-`LoadBACnetFunctions()` guard, the application-owned socket +
-`RegisterCommonCallbacks()` shape, the commandable model, and the habit of
-checking every `BACnetStack_*` return value.
+## References
-## License
+- **ANSI/ASHRAE Standard 135** (BACnet) - the protocol standard. Object model
+ (Clause 12), services (Clause 15), BACnet/IP (Annex J), device profiles
+ (Annex L). Purchase / preview via the [ASHRAE store](https://www.ashrae.org/technical-resources/standards-and-guidelines).
+- **What is BACnet?** - Chipkin's introduction:
+ .
+- **CAS BACnet Stack** - product page and documentation:
+ .
+- **CAS BACnet Explorer** - client for testing this device:
+ .
+- **Shared helper used by this example** - [`common/README.md`](common/README.md).
-The example source code is [CC0-1.0](LICENSE) (public domain). The CAS BACnet
-Stack submodule is licensed separately.
+See also [TUTORIAL.md](TUTORIAL.md), [docs/PICS.md](docs/PICS.md),
+[CHANGELOG.md](CHANGELOG.md), and [AGENTS.md](AGENTS.md).
diff --git a/TUTORIAL.md b/TUTORIAL.md
new file mode 100644
index 0000000..9fd97a3
--- /dev/null
+++ b/TUTORIAL.md
@@ -0,0 +1,268 @@
+# Tutorial - extending and reviewing the B-ASC example
+
+[README.md](README.md) says what this example *is*. This document is the
+*how*: how to extend it into your own device, who serves which property, how
+to review the result for conformance, and what goes wrong when you get it
+subtly right.
+
+Read this once before you start changing `main.ts`. The most expensive
+mistake in this example is silent, and the section it lives in is
+[Add a second analog input](#add-a-second-analog-input).
+
+- [Extending the example](#extending-the-example)
+- [What each object type needs you to serve](#what-each-object-type-needs-you-to-serve)
+- [Who serves what: the application or the stack?](#who-serves-what-the-application-or-the-stack)
+- [Reviewing your device](#reviewing-your-device)
+- [Troubleshooting](#troubleshooting)
+
+## Extending the example
+
+The example is intentionally small so it's easy to change.
+
+**Change a sensor's value or name** - edit the constants / callbacks in
+`main.ts` (e.g. `g_analogInput1Value`, or the `"Bronze"` string in
+`GetPropertyCharacterString`).
+
+**Change the device identity before you ship** - vendor ID, vendor name,
+model name, description, firmware revision and device name are all in the
+`CHANGE ALL OF THIS BEFORE YOU SHIP` block at the top of `main.ts` §1, with a
+per-field note on each saying what to change it to. That block is the
+authoritative checklist; it is in the source rather than here so it cannot be
+skipped by someone who only reads the code. Keep the
+`LoadBACnetFunctions()` guard, the application-owned socket +
+`RegisterCommonCallbacks()` shape, the commandable model
+(`Commandable`/`CommandWrite`/`CommandRelinquish`), and the habit of checking
+every `BACnetStack_*` return value - those are the parts of the shape, not the
+identity, and every sibling example (Node or C++) keeps them too.
+
+### Add a second analog input
+
+Read this whole recipe before starting - the last step is the one that is
+easy to miss and the one BTL will fail you for.
+
+> **Why there are four edits, not three - and why skipping one is SILENT.**
+> Most of the `GetProperty*` callbacks match on **both** object type *and*
+> instance (`objectInstance === ANALOG_INPUT_INSTANCE`), so a new instance
+> falls through every one of them. `GetPropertyBool`'s `Out_Of_Service` branch
+> is the exception: it matches on `propertyIdentifier` alone, so
+> `Out_Of_Service` works for a new instance for free.
+>
+> Here is the part that matters, and it is the opposite of what most people
+> assume: falling through a callback does **not** reliably produce an error.
+> The stack errors only for the few properties it refuses to invent -
+> `Present_Value`, `Number_Of_States`, `Relinquish_Default`, `Local_Date`,
+> `Local_Time`, and a Network Port's `APDU_Length`. For everything else it
+> **silently substitutes a default**:
+>
+> | Property | If you forget to serve it | Loud? |
+> |---|---|:--:|
+> | `Present_Value` | Error (`value-not-initialized` on a non-commandable object) | yes |
+> | `Object_Name` | reads back as the literal string **`"undefined"`** | **no** |
+> | `Units` | reads back as **`no-units` (95)** | **no** |
+> | `Out_Of_Service` | served on property alone - works by accident | n/a |
+>
+> **Doesn't the `errorCode` out-Buffer fix this?** Only if you use it, and
+> only where it is right to. Each `GetProperty*`/`SetProperty*` callback
+> receives an `errorCode: Buffer` that the stack pre-seeds with `success` and
+> reads only when you return `false`, so you *can* turn any decline into a
+> chosen BACnet error. But writing an error code on the catch-all breaks the
+> device: the stack's decline-and-fabricate path is what answers required
+> properties an application is not expected to serve - the Device's
+> `Max_APDU_Length_Accepted`, `APDU_Timeout` and `Number_Of_APDU_Retries`
+> among them. Write `errorCode` only where *this device* knows the read or
+> write is wrong; `main.ts` does it for out-of-range writes
+> (`SetPropertyEnumerated`, `SetPropertyUnsignedInteger`) and for
+> `DeviceCommunicationControl`'s password check. The **DCC callback is the
+> sharpest version of this trap**: the stack pre-seeds `errorCode` with
+> `success`, so a `return false` that forgets to write an error code puts the
+> absurd "Error Class SERVICES, Error Code success" on the wire instead of
+> `password-failure`.
+>
+> It is worse than "wrong value": the object's `Property_List` **still
+> advertises `Units` (117)**. So the object actively claims to have the
+> property, and then answers with a default. Nothing on the wire says you
+> forgot anything.
+>
+> So a half-added object does not look broken; it looks **healthy**. Add two
+> of them and both report `Object_Name "undefined"` - duplicate object names
+> inside one device, which is a spec violation and a hard BTL failure that
+> every scan tool will render as a perfectly good object. **"It scanned OK"
+> is exactly the failure mode, not evidence against it.**
+
+```ts
+// 1) a new instance number (in §1 Configuration).
+// Naming: a second object of a type is " 2" - so Analog Input 2 is
+// "Bronze 2", NOT a new colour. Each object TYPE owns one colour series-wide.
+const ANALOG_INPUT_2_INSTANCE = 2; // "Bronze 2"
+let g_analogInput2Value = 23.1; // its live value
+
+// 2) add the object (in main(), next to the other BACnetStack_AddObject calls).
+// Check the return, like every other stack call in this file.
+if (!BACnetStack_AddObject(g_deviceInstance, OBJECT_TYPE_ANALOG_INPUT, ANALOG_INPUT_2_INSTANCE)) {
+ console.error("Error: Failed to add Analog Input 2 (Bronze 2).");
+ process.exit(1);
+}
+
+// 3) serve its Present_Value + Object_Name:
+// GetPropertyReal: AI/2 + Present_Value -> value.writeFloatLE(g_analogInput2Value, 0)
+// GetPropertyCharacterString: AI/2 + Object_Name -> text("Bronze 2")
+
+// 4) DO NOT SKIP: serve its Units, in GetPropertyEnumerated.
+// Units is a REQUIRED property of an Analog Input. The existing check reads
+// `objectInstance === ANALOG_INPUT_INSTANCE`, which is instance 1 - so
+// without this, reading Analog Input 2's Units returns no-units(95) instead
+// of erroring, and the object is NON-CONFORMANT. It will still appear in
+// Object_List and its Present_Value will read back perfectly, so the device
+// looks healthy right up until BTL certification.
+// GetPropertyEnumerated: AI/2 + Units -> value.writeUInt32LE(ENGINEERING_UNITS_DEGREES_CELSIUS, 0)
+```
+
+Then re-run the README's Verify steps **against Analog Input 2**, not just
+Analog Input 1 - read every required property and **diff it against Analog
+Input 1**. Any property that comes back `"undefined"`, `no-units`, or `0`
+where object 1 returns something real is a step you missed. Because the
+failure is silent (see the table above), this diff is the only thing that
+catches it.
+
+### Add a second commandable output
+
+The same shape as above, plus the commandable plumbing every output needs:
+
+1. A new instance number and a new `Commandable` (`makeCommandable(defaultValue)`).
+2. `BACnetStack_AddObject` for the new instance.
+3. Extend `GetCommandable(objectType, objectInstance)` to recognise the new
+ `{type, instance}` pair - **carry the pair, never match on type alone**,
+ or a second output silently aliases the first's priority array.
+4. Serve `Present_Value`, `Priority_Array` (per-slot, `useArrayIndex`),
+ `Relinquish_Default`, and whichever type-specific required property the
+ object needs (`Units` for Analog, `Polarity` for Binary,
+ `Number_Of_States` for Multi-State) in the matching `Get*` callback.
+5. Enable the commandable plumbing in `main()`:
+ `SetPropertyEnabled(..., PRIORITY_ARRAY, true)`,
+ `SetPropertyEnabled(..., RELINQUISH_DEFAULT, true)`,
+ `SetPropertyWritable(..., PRESENT_VALUE, true)`.
+6. Route writes through the matching `Set*` callback, validating before
+ calling `CommandWrite` - an out-of-range value should get
+ `ERROR_CODE_VALUE_OUT_OF_RANGE`, not silent acceptance.
+7. Route `NULL` writes through `SetPropertyNull` - that is a relinquish, not
+ a write of the value zero.
+
+## What each object type needs you to serve
+
+The application must serve every REQUIRED property the stack does not
+generate. It differs per type - this is the checklist, so you do not have to
+infer it:
+
+| Object type | You must serve | Plus |
+|---|---|---|
+| Analog Input | `Present_Value` (Real), `Object_Name`, `Units` | - |
+| Binary Input | `Present_Value` (Enumerated), `Object_Name` | `Polarity` |
+| Multi-State Input | `Present_Value` (Unsigned), `Object_Name` | `Number_Of_States` |
+| Analog Output | `Present_Value`, `Priority_Array`, `Relinquish_Default`, `Object_Name`, `Units` | commandable plumbing (§5 above) |
+| Binary Output | `Present_Value`, `Priority_Array`, `Relinquish_Default`, `Object_Name` | `Polarity`, commandable plumbing |
+| Multi-State Output | `Present_Value`, `Priority_Array`, `Relinquish_Default`, `Object_Name` | `Number_Of_States`, commandable plumbing |
+
+For the three commandable outputs, `Present_Value` and `Priority_Array` are
+served by the **application's own priority-array model**
+(`CommandRead`/`CommandWrite`/`CommandRelinquish` in `main.ts` §1), not
+generated by the stack - this example does not use the stack's built-in
+commandable support. `Current_Command_Priority` is the one commandable
+property the stack still computes for you.
+
+## Who serves what: the application or the stack?
+
+The single most common question when reading this file is "who answers this
+property?" For Analog Output 1, the whole picture:
+
+| Property | Served by | How |
+|---|---|---|
+| `Object_Identifier` | **stack** | generated from the object you added |
+| `Object_Type` | **stack** | generated |
+| `Object_List` | **stack** | generated (Device object) |
+| `Property_List` | **stack** | generated |
+| `Status_Flags` | **stack** | generated |
+| `Event_State` | **stack**, sort of | no intrinsic alarming here, so nothing serves it - it reads `normal` only because `normal` is the enumeration's zero value and the stack substitutes a datatype default. Correct by coincidence, not design. |
+| `Out_Of_Service` | **you** | `GetPropertyBool` - matched on property alone |
+| `Present_Value` | **you** | `GetPropertyReal`, resolving `CommandRead(g_analogOutput1)` |
+| `Priority_Array` | **you**, slot by slot | `GetPropertyBool` answers whether a slot is NULL; `GetPropertyReal` (with `useArrayIndex`) answers a set slot's value |
+| `Relinquish_Default` | **you** | `GetPropertyReal` |
+| `Current_Command_Priority` | **stack** | computed from the priority array the stack itself tracks in parallel |
+| `Object_Name` | **you** | `GetPropertyCharacterString` |
+| `Units` | **you** | `GetPropertyEnumerated` |
+
+Every object, not just this one, is in [docs/PICS.md](docs/PICS.md).
+
+Two more traps worth calling out explicitly, both silent:
+
+- **Two `networkType` enumerations.** The Network Port object's
+ `NETWORK_PORT_NETWORK_TYPE_IPV4` (5) is *not* the same enumeration as the
+ message-callback `NETWORK_TYPE_IP` (0) used elsewhere in the stack's API.
+ Mixing them up compiles and often "looks" fine until a client reads
+ `Network_Type` and gets a nonsensical value.
+- **The DCC callback has no default `errorCode`.** Unlike the `Get*`/`Set*`
+ callbacks (which the stack pre-seeds with a value that is safe to leave
+ alone on most declines), `DeviceCommunicationControl`'s `errorCode` Buffer
+ is pre-seeded with `success` - see the callout in
+ [Add a second analog input](#add-a-second-analog-input) above.
+
+Going beyond this (COV, alarms, scheduling) means implementing a richer
+profile - see the series table in [README.md](README.md).
+
+## Reviewing your device
+
+After you have changed anything, review it against the conformance statement
+rather than against "it looked fine in the explorer":
+
+1. Regenerate [docs/PICS.md](docs/PICS.md) after editing `docs/objects.json`
+ (see [Keeping the PICS honest](#keeping-the-pics-honest) below). A ⚠ row is
+ a required property nothing serves.
+2. Read **every** property listed for **every** object with a BACnet client,
+ and compare the value against the PICS. `"undefined"`, `no-units` and `0`
+ are the three shapes a missed callback takes.
+3. Diff a new object of a type against the existing one of that type. Anything
+ that differs and shouldn't is a callback that matched on instance.
+4. Exercise WriteProperty on all three outputs at two different priorities,
+ then relinquish (write `NULL`) each priority and confirm the object falls
+ through to the next set priority or to `Relinquish_Default`.
+5. Send an out-of-range write to Binary Output 1 or Multi-State Output 1 and
+ confirm `value-out-of-range`, not silent acceptance.
+6. Exercise DeviceCommunicationControl with a wrong password (expect
+ `password-failure`) and with the correct one (expect the disable/enable
+ cycle to work, and confirm the stack itself now rejects further requests
+ while communication is disabled).
+
+### Keeping the PICS honest
+
+`docs/PICS.md` is partly generated. `docs/objects.json` describes each object
+and who serves which property; the series tool regenerates the object tables
+from it plus the stack's own `docs/property-profile-reference.md` at the
+pinned commit:
+
+```bash
+python tools/gen-objects-properties.py BACnetProfileExample-B-ASC-Node # rewrite
+python tools/gen-objects-properties.py BACnetProfileExample-B-ASC-Node --check # fail if stale
+```
+
+(That tool lives in the example-series repository, not in this one. If you
+only have this repository, edit the generated block by hand and keep it
+matching the callbacks in `main.ts`.)
+
+When you add an object or a property to `main.ts`, update `docs/objects.json`
+in the same change and regenerate. The `app` list is what the callbacks
+serve; `accepted` is for a required property you deliberately leave to the
+stack's default, and each one needs a justification. Anything required, not
+in `app` and not in `accepted`, comes out as a ⚠ row - that is a defect, not a
+feature.
+
+## Troubleshooting
+
+| Symptom | Cause / fix |
+|---------|-------------|
+| On start-up the app prints two red `Error:` lines but the device works | **Expected - this is not your bug.** Two benign sources, both from the stack's own debug logging: (1) the device receives its **own** broadcast I-Am and logs a decode cascade - any BACnet/IP device that listens for broadcasts hears itself; (2) a one-time *"UUID has not been set. A UUID must be set for the BACnetSC device to start."* - the stack starts a BACnet/SC datalink this IP-only example never configures. It appears once and does not spam. |
+| `npm install` fails with `MSB...` / `unknown version undefined` on Windows | The stack's supported Windows toolset is Visual Studio 2022 (v143) Build Tools. A newer Visual Studio release is not detected correctly by node-gyp. Install VS 2022 Build Tools with the "Desktop development with C++" workload. |
+| `npm install` fails to find a C++ compiler on Linux/macOS | Install a C++17 toolchain first: `sudo apt install build-essential python3 git` (Debian/Ubuntu) or `xcode-select --install` (macOS). |
+| First `npm install` seems stuck for minutes | Normal - node-gyp is compiling the whole stack into a native addon. Only the first install (or one after `submodules/cas-bacnet-stack` changes) is slow. |
+| `Cannot find module '@chipkin/cas-bacnet-stack'` when running `npm start` | The npm workspace link (`node_modules/@chipkin/cas-bacnet-stack`) is missing or stale - often left over from a different clone path. Run `npm install` again from this repository's root so npm relinks the workspace. |
+| App prints *"could not bind UDP port 47808"* | Another BACnet program is already using 47808. Stop it, or run with `--port `. |
+| Client sends Who-Is but sees no I-Am | Firewall is blocking UDP 47808, or the client and device are on different subnets (Who-Is is a broadcast). Allow the port; test on the same subnet first. |
+| WriteProperty returns `password-failure` even with no password sent | `DCC_PASSWORD` in `main.ts` §1 is non-empty. The callback compares by byte length and content (`Buffer.equals`), not by string equality, so an empty configured password still requires the request to carry a zero-length password, not a missing one. |
diff --git a/docs/PICS.md b/docs/PICS.md
new file mode 100644
index 0000000..fca14c6
--- /dev/null
+++ b/docs/PICS.md
@@ -0,0 +1,271 @@
+# BACnet Protocol Implementation Conformance Statement (PICS)
+
+For the **BACnet B-ASC (Application Specific Controller) Node.js example** -
+see [README.md](../README.md).
+
+> This is the PICS **for the example as shipped**. It describes a tutorial
+> device announcing itself as a Chipkin demo, not a product. When you turn this
+> example into your own device, this document is one of the things you rewrite:
+> the vendor, model and version rows all come from the
+> `CHANGE ALL OF THIS BEFORE YOU SHIP` block at the top of `main.ts`. The
+> example has **not** been submitted for BTL certification.
+
+## 1. Product description
+
+| | |
+|---|---|
+| **Vendor Name** | Chipkin Automation Systems |
+| **Vendor Identifier** | 389 |
+| **Product Name** | CAS BACnet Stack B-ASC Example |
+| **Product Model Number** | CAS BACnet Stack B-ASC Example |
+| **Application Software Version** | 1.0.0 |
+| **Firmware Revision** | 1.0.0 |
+| **BACnet Protocol Version** | 1 |
+| **BACnet Protocol Revision** | 24 (`BACNET_PROTOCOL_REVISION` in the stack's `CASBACnetStackOptions.h` at the pinned commit; the example's start-up banner does not print it - read it back with ReadProperty to confirm) |
+
+**Product Description:** a minimal BACnet/IP device built on the CAS BACnet
+Stack's Node.js/TypeScript package. It presents three read-only input objects
+and three commandable output objects (Analog, Binary, Multi-State), answers
+ReadProperty and WriteProperty for every required property of every object,
+accepts DeviceCommunicationControl, and is discoverable by Who-Is / I-Am and
+Who-Has / I-Have. It is a tutorial for implementers of the B-ASC profile.
+
+## 2. BACnet standardized device profile (Annex L)
+
+**B-ASC - BACnet Application Specific Controller.**
+
+This device claims exactly one profile. Because the B-ASC requirements are a
+superset of B-GENERAL's, a conformant B-ASC device also satisfies
+**B-GENERAL** (Annex L.8); that is subsumption, not a second claim.
+
+## 3. BIBBs supported (Annex K)
+
+| BIBB | Description |
+|---|---|
+| DS-RP-B | Data Sharing - ReadProperty - B |
+| DS-WP-B | Data Sharing - WriteProperty - B |
+| DM-DCC-B | Device Management - DeviceCommunicationControl - B |
+| DM-DDB-B | Device Management - Dynamic Device Binding - B |
+| DM-DOB-B | Device Management - Dynamic Object Binding - B |
+
+No other BIBBs are supported. In particular this device does **not** support
+DS-RPM-B (ReadPropertyMultiple), DS-COV-B, any alarm and event (AE-*) BIBB,
+scheduling (SCHED-*), or trending (T-*).
+
+## 4. Application services supported
+
+| Service | Initiate | Execute |
+|---|:---:|:---:|
+| ReadProperty | no | **yes** |
+| WriteProperty | no | **yes** |
+| DeviceCommunicationControl | no | **yes** |
+| Who-Is | no | **yes** |
+| I-Am | **yes** | - |
+| Who-Has | no | **yes** |
+| I-Have | **yes** | - |
+
+An unsolicited I-Am is broadcast to the local subnet at start-up, as well as in
+response to Who-Is.
+
+Any other confirmed service is rejected. That rejection is part of the profile
+boundary, not a limitation to work around.
+
+## 5. Segmentation capability
+
+Segmentation is **not supported** in either direction
+(`Segmentation_Supported` = `no-segmentation`). `Max_APDU_Length_Accepted` is
+1476 octets, the BACnet/IP maximum.
+
+## 6. Standard object types supported
+
+No object is dynamically creatable or deletable. `Present_Value` is writable
+on the three output objects only; every other object and property is
+read-only.
+
+| Object type | Instance | Object_Name | Optional properties supported |
+|---|:---:|---|---|
+| Device | 389003 | Rainbow | Description |
+| Analog Input | 1 | Bronze | - |
+| Binary Input | 1 | Emerald | - |
+| Multi-state Input | 1 | Hot Pink | State_Text |
+| Analog Output | 1 | Chartreuse | - |
+| Binary Output | 1 | Fuchsia | - |
+| Multi-state Output | 1 | Indigo | - |
+| Network Port | 1 | Vermilion | - |
+
+The device instance is configurable at run time with `--deviceID` (BACnet
+requires the device instance to be configurable).
+
+## 7. Data link layer options
+
+**BACnet/IP (Annex J)**, UDP port 47808 (0xBAC0) by default, configurable at
+run time with `--port`.
+
+BBMD is not supported, Foreign Device registration is not supported, and
+BACnet/SC, MS/TP, Ethernet (Annex H) and PTP are not supported.
+
+## 8. Device address binding
+
+Static device binding is **not supported**. The device answers Who-Is/Who-Has
+and does not initiate any confirmed request, so it never needs to bind a peer.
+
+## 9. Networking options
+
+None. The device is not a router, not a BBMD, and does not register as a
+foreign device.
+
+## 10. Character sets supported
+
+UTF-8 (ANSI X3.4). Supporting a character set does not imply the device can
+handle data in all character sets.
+
+## 11. Objects and properties
+
+
+Every object this example creates, and every REQUIRED property of each (per ANSI/ASHRAE 135-2024 clause 12 and the stack's `docs/property-profile-reference.md`), plus the optional properties the example turns on. **Served by** says who answers a ReadProperty: the **stack** generates it, or the **app** serves it from a `GetProperty*` callback in `main.cpp`. A ⚠ row is a required property the app does not serve and the stack would fill with a default - that is a defect, not a feature.
+
+### Device 389003 "Rainbow" - the device itself; the instance is configurable with --deviceID. The stack rows are device-wide facts only the stack knows - the protocol version and revision it implements, the services and object types it was configured with, the live object list and address-binding table. The accepted rows are the stack's configured defaults for APDU limits, segmentation, system status and database revision; an application that answered them from its own constants could contradict the stack, so this example does not
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| System_Status | BACnetDeviceStatus | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Vendor_Name | CharacterString | app | no |
+| Vendor_Identifier | Unsigned16 | app | no |
+| Model_Name | CharacterString | app | no |
+| Firmware_Revision | CharacterString | app | no |
+| Application_Software_Version | CharacterString | app | no |
+| Description *(optional, enabled)* | CharacterString | app | no |
+| Protocol_Version | Unsigned | stack | no |
+| Protocol_Revision | Unsigned | stack | no |
+| Protocol_Services_Supported | BACnetServicesSupported | stack | no |
+| Protocol_Object_Types_Supported | BACnetObjectTypesSupported | stack | no |
+| Object_List | BACnetARRAY[N] of BACnetObjectIdentifier | stack | no |
+| Max_APDU_Length_Accepted | Unsigned | stack default, accepted (`CAS_BACNET_DEVICE_DEFAULT_MAX_APDU_LENGTH_ACCEPTED`) | no |
+| Segmentation_Supported | BACnetSegmentation | stack default, accepted (`BACnetSegmentation::noSegmentation`) | no |
+| APDU_Timeout | Unsigned | stack default, accepted (`CAS_BACNET_DEVICE_DEFAULT_APDU_TIMEOUT`) | no |
+| Number_Of_APDU_Retries | Unsigned | stack default, accepted (`CAS_BACNET_DEVICE_DEFAULT_NUMBER_OF_APDU_RETRIES`) | no |
+| Device_Address_Binding | BACnetLIST of BACnetAddressBinding | stack | no |
+| Database_Revision | Unsigned | stack default, accepted (Generic UnsignedInteger default: `0`) | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+
+### Analog Input 1 "Bronze" - REAL, degrees Celsius; starts at 21.5; read-only
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| Present_Value | Real | app | no |
+| Status_Flags | BACnetStatusFlags | stack | no |
+| Event_State | BACnetEventState | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Out_Of_Service | Boolean | app | no |
+| Units | BACnetEngineeringUnits | app | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+
+### Binary Input 1 "Emerald" - starts inactive; read-only
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| Present_Value | BACnetBinaryPV | app | no |
+| Status_Flags | BACnetStatusFlags | stack | no |
+| Event_State | BACnetEventState | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Out_Of_Service | Boolean | app | no |
+| Polarity | BACnetPolarity | app | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+
+### Multi-state Input 1 "Hot Pink" - state 1 of 3: On, Off, Auto; read-only
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| Present_Value | Unsigned | app | no |
+| Status_Flags | BACnetStatusFlags | stack | no |
+| Event_State | BACnetEventState | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Out_Of_Service | Boolean | app | no |
+| Number_Of_States | Unsigned | app | no |
+| State_Text *(optional, enabled)* | BACnetARRAY[N] of CharacterString | app | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+
+### Analog Output 1 "Chartreuse" - commandable REAL, percent; 16-slot priority array, Relinquish_Default 0.0; the application resolves the priority array itself (CommandRead/CommandWrite/CommandRelinquish) rather than relying on the stack's own commandable support, so Present_Value and Priority_Array are served by the app, not generated
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| Present_Value | Real | app | yes |
+| Status_Flags | BACnetStatusFlags | stack | no |
+| Event_State | BACnetEventState | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Out_Of_Service | Boolean | app | no |
+| Units | BACnetEngineeringUnits | app | no |
+| Priority_Array | BACnetARRAY[16] of BACnetOptionalReal | app | no |
+| Relinquish_Default | Real | app | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+| Current_Command_Priority | BACnetOptionalUnsigned | stack | no |
+
+### Binary Output 1 "Fuchsia" - commandable active/inactive; 16-slot priority array, Relinquish_Default inactive; same application-owned priority array as Analog Output 1
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| Present_Value | BACnetBinaryPV | app | yes |
+| Status_Flags | BACnetStatusFlags | stack | no |
+| Event_State | BACnetEventState | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Out_Of_Service | Boolean | app | no |
+| Polarity | BACnetPolarity | app | no |
+| Priority_Array | BACnetARRAY[16] of BACnetOptionalBinaryPV | app | no |
+| Relinquish_Default | BACnetBinaryPV | app | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+| Current_Command_Priority | BACnetOptionalUnsigned | stack | no |
+
+### Multi-state Output 1 "Indigo" - commandable state 1..3, validated on write; 16-slot priority array, Relinquish_Default state 1; same application-owned priority array as Analog Output 1
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| Present_Value | Unsigned | app | yes |
+| Status_Flags | BACnetStatusFlags | stack | no |
+| Event_State | BACnetEventState | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Out_Of_Service | Boolean | app | no |
+| Number_Of_States | Unsigned | app | no |
+| Priority_Array | BACnetARRAY[16] of BACnetOptionalUnsigned | app | no |
+| Relinquish_Default | Unsigned | app | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+| Current_Command_Priority | BACnetOptionalUnsigned | stack | no |
+
+### Network Port 1 "Vermilion" - BACnet/IP; Network_Type and Protocol_Level are set from BACnetStack_AddNetworkPortObjectWithNetworkNumber()'s arguments (IPv4, BACnet Application) at start-up, not a GetProperty callback like the object's other app-served rows; Changes_Pending is likewise computed and answered natively by the stack's Network Port object. Reliability has no fault condition this example detects, so it is accepted at the generic default (normal)
+
+| Property | Datatype | Served by | Writable |
+|---|---|---|:---:|
+| Object_Identifier | BACnetObjectIdentifier | stack | no |
+| Object_Name | CharacterString | app | no |
+| Object_Type | BACnetObjectType | stack | no |
+| Status_Flags | BACnetStatusFlags | stack | no |
+| Reliability | BACnetReliability | stack default, accepted (Generic Enumerated default: `0`) | no |
+| Out_Of_Service | Boolean | app | no |
+| Network_Type | BACnetNetworkType | app | no |
+| Protocol_Level | BACnetProtocolLevel | app | no |
+| Changes_Pending | Boolean | app | no |
+| Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no |
+
+
+
+## 12. References
+
+- ANSI/ASHRAE Standard 135-2024, Annex A (PICS template), Annex K (BIBBs),
+ Annex L (device profiles), Clause 12 (object types).
+- [README.md](../README.md) - what this example is and how to build it.
+- [TUTORIAL.md](../TUTORIAL.md) - how to extend it, and how to keep this
+ document honest when you do.
diff --git a/docs/objects.json b/docs/objects.json
new file mode 100644
index 0000000..00130f5
--- /dev/null
+++ b/docs/objects.json
@@ -0,0 +1,174 @@
+{
+ "objects": [
+ {
+ "type": "Device",
+ "instance": 389003,
+ "name": "Rainbow",
+ "app": [
+ "Object_Name",
+ "Description",
+ "Vendor_Name",
+ "Vendor_Identifier",
+ "Model_Name",
+ "Firmware_Revision",
+ "Application_Software_Version"
+ ],
+ "enabled": [
+ "Description"
+ ],
+ "writable": [],
+ "accepted": [
+ "System_Status",
+ "Max_APDU_Length_Accepted",
+ "Segmentation_Supported",
+ "APDU_Timeout",
+ "Number_Of_APDU_Retries",
+ "Database_Revision"
+ ],
+ "note": "the device itself; the instance is configurable with --deviceID. The stack rows are device-wide facts only the stack knows - the protocol version and revision it implements, the services and object types it was configured with, the live object list and address-binding table. The accepted rows are the stack's configured defaults for APDU limits, segmentation, system status and database revision; an application that answered them from its own constants could contradict the stack, so this example does not",
+ "stack": [
+ "Object_List",
+ "Protocol_Version",
+ "Protocol_Revision",
+ "Protocol_Services_Supported",
+ "Protocol_Object_Types_Supported",
+ "Device_Address_Binding"
+ ]
+ },
+ {
+ "type": "Analog Input",
+ "instance": 1,
+ "name": "Bronze",
+ "app": [
+ "Present_Value",
+ "Object_Name",
+ "Units",
+ "Out_Of_Service"
+ ],
+ "enabled": [],
+ "writable": [],
+ "accepted": [
+ "Event_State"
+ ],
+ "note": "REAL, degrees Celsius; starts at 21.5; read-only"
+ },
+ {
+ "type": "Binary Input",
+ "instance": 1,
+ "name": "Emerald",
+ "app": [
+ "Present_Value",
+ "Object_Name",
+ "Polarity",
+ "Out_Of_Service"
+ ],
+ "enabled": [],
+ "writable": [],
+ "accepted": [
+ "Event_State"
+ ],
+ "note": "starts inactive; read-only"
+ },
+ {
+ "type": "Multi-state Input",
+ "instance": 1,
+ "name": "Hot Pink",
+ "app": [
+ "Present_Value",
+ "Object_Name",
+ "Number_Of_States",
+ "Out_Of_Service",
+ "State_Text"
+ ],
+ "enabled": [
+ "State_Text"
+ ],
+ "writable": [],
+ "accepted": [
+ "Event_State"
+ ],
+ "note": "state 1 of 3: On, Off, Auto; read-only"
+ },
+ {
+ "type": "Analog Output",
+ "instance": 1,
+ "name": "Chartreuse",
+ "app": [
+ "Present_Value",
+ "Object_Name",
+ "Units",
+ "Out_Of_Service",
+ "Priority_Array",
+ "Relinquish_Default"
+ ],
+ "enabled": [],
+ "writable": [
+ "Present_Value"
+ ],
+ "accepted": [
+ "Event_State"
+ ],
+ "note": "commandable REAL, percent; 16-slot priority array, Relinquish_Default 0.0; the application resolves the priority array itself (CommandRead/CommandWrite/CommandRelinquish) rather than relying on the stack's own commandable support, so Present_Value and Priority_Array are served by the app, not generated"
+ },
+ {
+ "type": "Binary Output",
+ "instance": 1,
+ "name": "Fuchsia",
+ "app": [
+ "Present_Value",
+ "Object_Name",
+ "Polarity",
+ "Out_Of_Service",
+ "Priority_Array",
+ "Relinquish_Default"
+ ],
+ "enabled": [],
+ "writable": [
+ "Present_Value"
+ ],
+ "accepted": [
+ "Event_State"
+ ],
+ "note": "commandable active/inactive; 16-slot priority array, Relinquish_Default inactive; same application-owned priority array as Analog Output 1"
+ },
+ {
+ "type": "Multi-state Output",
+ "instance": 1,
+ "name": "Indigo",
+ "app": [
+ "Present_Value",
+ "Object_Name",
+ "Number_Of_States",
+ "Out_Of_Service",
+ "Priority_Array",
+ "Relinquish_Default"
+ ],
+ "enabled": [],
+ "writable": [
+ "Present_Value"
+ ],
+ "accepted": [
+ "Event_State"
+ ],
+ "note": "commandable state 1..3, validated on write; 16-slot priority array, Relinquish_Default state 1; same application-owned priority array as Analog Output 1"
+ },
+ {
+ "type": "Network Port",
+ "instance": 1,
+ "name": "Vermilion",
+ "app": [
+ "Object_Name",
+ "Out_Of_Service",
+ "Network_Type",
+ "Protocol_Level",
+ "Changes_Pending"
+ ],
+ "enabled": [],
+ "writable": [],
+ "accepted": [
+ "Reliability"
+ ],
+ "note": "BACnet/IP; Network_Type and Protocol_Level are set from BACnetStack_AddNetworkPortObjectWithNetworkNumber()'s arguments (IPv4, BACnet Application) at start-up, not a GetProperty callback like the object's other app-served rows; Changes_Pending is likewise computed and answered natively by the stack's Network Port object. Reliability has no fault condition this example detects, so it is accepted at the generic default (normal)"
+ }
+ ]
+}
diff --git a/main.ts b/main.ts
index 1756d1d..f6a3d24 100644
--- a/main.ts
+++ b/main.ts
@@ -125,11 +125,19 @@ const APP_VERSION = "1.0.0";
// 389003, see the series' device-instance table) so several examples can run
// on one subnet. Overridable at runtime with --deviceID, as BACnet requires.
let g_deviceInstance = 389003;
-const VENDOR_IDENTIFIER = 389; // Chipkin Automation Systems
-const DEVICE_NAME = "Rainbow";
-const DEVICE_DESCRIPTION = "BACnet B-ASC (Application Specific Controller) example - Node.js";
-const VENDOR_NAME = "Chipkin Automation Systems";
-const MODEL_NAME = "CAS BACnet Stack B-ASC Example";
+const VENDOR_IDENTIFIER = 389; // Chipkin Automation Systems - replace with the vendor ID ASHRAE assigns you.
+// Object_Name must be UNIQUE across the whole BACnet internetwork - two
+// devices with the same name is a spec violation, and it is the exact,
+// silent failure mode this series warns about elsewhere in this file (see
+// the "SILENT TRAP" comments below and TUTORIAL.md). Here it is a
+// compile-time constant, which is fine for a single running copy of this
+// example; a real product must make it per-unit configurable (serial
+// number, DIP switches, a config file, or a --deviceName argument) so two
+// units never boot with the same name.
+const DEVICE_NAME = "Rainbow"; // replace with your product's per-unit device name.
+const DEVICE_DESCRIPTION = "BACnet B-ASC (Application Specific Controller) example - Node.js"; // replace with your product's description.
+const VENDOR_NAME = "Chipkin Automation Systems"; // replace with your company's name.
+const MODEL_NAME = "CAS BACnet Stack B-ASC Example"; // replace with your product's model name.
// DM-DCC-B: the password a client must present with DeviceCommunicationControl.
// Empty string = accept requests that carry no password (and requests carrying