Skip to content

feat: schedule/calendar write#69

Merged
robertsLando merged 33 commits intobacnet-js:masterfrom
EveGun:feature/schedule-calendar-write
Feb 25, 2026
Merged

feat: schedule/calendar write#69
robertsLando merged 33 commits intobacnet-js:masterfrom
EveGun:feature/schedule-calendar-write

Conversation

@EveGun
Copy link
Contributor

@EveGun EveGun commented Feb 19, 2026

Summary

This PR ports schedule/calendar write compatibility from the legacy node-bacstack implementation into @bacnet-js/client, and adds write examples for manual validation.

Source reference:

What changed

  • Added specialized encode paths in WriteProperty.encode for:
  • WEEKLY_SCHEDULE
  • EXCEPTION_SCHEDULE
  • EFFECTIVE_PERIOD
  • DATE_LIST
  • Added dedicated payload encoders in src/lib/services/WriteProperty.ts for weekly schedule, exception schedule, effective period, and calendar date list.
  • Added stricter validation before encoding:
  • weekly schedule must have exactly 7 day arrays
  • exception schedule priority must be in range 1..16
  • DATERANGE entries must contain exactly 2 dates
  • WEEKNDAY values are validated (including wildcard 0xff)
  • raw date byte input (year/month/day/wday) is validated
  • Added write examples:
  • examples/write-schedule-weekly.ts
  • examples/write-schedule-exception.ts
  • examples/write-schedule-period.ts
  • examples/write-calendar-datelist.ts
  • Updated example CLI behavior so target accepts host[:port], with optional local bind port as separate argument.
  • Added/extended unit tests in test/unit/service-write-property.spec.ts for schedule/calendar write compatibility and failure cases.

Type consistency

  • Kept the existing public writeProperty contract unchanged.
  • Invalid payloads now fail fast with explicit validation errors instead of encoding malformed APDUs.

Validation

  • npm run lint ✅
  • npm run test:unit ✅
  • Docker-based compliance tests executed successfully in local environment ✅
  • Manually validated against a WAGO PFC200 device ✅

Notes

  • Manually validated write behavior against WAGO PFC200 schedule/calendar objects. Full roundtrip tested.
  • Emulator-related legacy hacks are intentionally not included in this PR.
  • Schedule/calendar compatibility payloads are currently supported in writeProperty only. writePropertyMultiple is unchanged and does not yet support these specialized payload shapes.
  • This is the same PR as i closed. The issues I was investigating came from the decoder, not the encoder. Separate PR follows

@robertsLando robertsLando requested a review from Copilot February 19, 2026 07:27
@robertsLando
Copy link
Member

@EveGun changes look good to me, let's see if copilot detects something :) Thanks for your PRs 🙏🏼

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for writing BACnet schedule and calendar properties (WEEKLY_SCHEDULE, EXCEPTION_SCHEDULE, EFFECTIVE_PERIOD, and DATE_LIST) to the @bacnet-js/client library. The implementation ports functionality from the legacy node-bacstack library, adding specialized encoding paths for these complex property types that require custom payload structures beyond simple application data arrays.

Changes:

  • Added specialized encoding methods in WriteProperty service for schedule/calendar properties with validation
  • Introduced new TypeScript types for schedule/calendar payload structures in src/lib/types.ts
  • Added comprehensive unit tests covering both successful encoding and validation failure scenarios
  • Provided four example files demonstrating write operations for each supported property type

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/lib/services/WriteProperty.ts Core implementation with specialized encoding methods and validation logic for schedule/calendar properties
src/lib/types.ts New type definitions for schedule/calendar payload structures
src/lib/client.ts Updated signature to accept new payload types
test/unit/service-write-property.spec.ts Added 19 new test cases covering encoding and validation
examples/write-schedule-weekly.ts Example demonstrating weekly schedule write
examples/write-schedule-exception.ts Example demonstrating exception schedule write
examples/write-schedule-period.ts Example demonstrating effective period write
examples/write-calendar-datelist.ts Example demonstrating calendar date list write

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Accept BACnet DATE day marker values (32/33/34) in generic DATE encoding and schedule/calendar WriteProperty encoding. Add focused unit tests for both code paths.
Extend existing day-marker tests to assert support for BACnet raw DATE day values 32, 33 and 34 in both generic ASN.1 app-data encoding and WriteProperty exception schedule encoding.
@EveGun EveGun marked this pull request as draft February 23, 2026 08:05
@robertsLando
Copy link
Member

@EveGun I see you marked this as draft now, was it intended?

@EveGun EveGun marked this pull request as ready for review February 23, 2026 08:57
@EveGun
Copy link
Contributor Author

EveGun commented Feb 23, 2026

@robertsLando Yes, but ready again now.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

@EveGun
Copy link
Contributor Author

EveGun commented Feb 25, 2026

@robertsLando maybe run CI again? Looks like coveralls failed at some external http calls.

@robertsLando
Copy link
Member

@EveGun Coveralls it's failing in many others projects I own, seems it's an issue with their server so no issues here 🙏🏼

Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Well done! 💪🏼

@robertsLando robertsLando merged commit 82a060a into bacnet-js:master Feb 25, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants