ultimatedarktower 2.3.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -46
- package/README.md +85 -56
- package/dist/esm/index.mjs +274 -246
- package/dist/src/UltimateDarkTower.d.ts +21 -6
- package/dist/src/UltimateDarkTower.js +39 -41
- package/dist/src/UltimateDarkTower.js.map +1 -1
- package/dist/src/adapters/NodeBluetoothAdapter.js.map +1 -1
- package/dist/src/adapters/WebBluetoothAdapter.js.map +1 -1
- package/dist/src/udtBleConnection.d.ts +4 -4
- package/dist/src/udtBleConnection.js +13 -12
- package/dist/src/udtBleConnection.js.map +1 -1
- package/dist/src/udtBluetoothAdapter.d.ts +2 -2
- package/dist/src/udtBluetoothAdapterFactory.js.map +1 -1
- package/dist/src/udtCommandFactory.d.ts +6 -0
- package/dist/src/udtCommandFactory.js +26 -22
- package/dist/src/udtCommandFactory.js.map +1 -1
- package/dist/src/udtCommandQueue.d.ts +2 -2
- package/dist/src/udtCommandQueue.js +2 -3
- package/dist/src/udtCommandQueue.js.map +1 -1
- package/dist/src/udtConstants.d.ts +1 -8
- package/dist/src/udtConstants.js +6 -6
- package/dist/src/udtConstants.js.map +1 -1
- package/dist/src/udtHelpers.js +8 -9
- package/dist/src/udtHelpers.js.map +1 -1
- package/dist/src/udtLogger.d.ts +1 -0
- package/dist/src/udtLogger.js +24 -2
- package/dist/src/udtLogger.js.map +1 -1
- package/dist/src/udtTowerCommands.d.ts +2 -2
- package/dist/src/udtTowerCommands.js +17 -14
- package/dist/src/udtTowerCommands.js.map +1 -1
- package/dist/src/udtTowerResponse.d.ts +9 -5
- package/dist/src/udtTowerResponse.js +5 -6
- package/dist/src/udtTowerResponse.js.map +1 -1
- package/dist/src/udtTowerState.js +4 -4
- package/dist/src/udtTowerState.js.map +1 -1
- package/package.json +18 -15
package/CHANGELOG.md
CHANGED
|
@@ -6,109 +6,163 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [3.0.0] - 2026-03-24
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **`onBatteryLevelNotify` now fires on every battery response** — The callback is no longer gated by battery logging settings, ensuring internal battery state and UI indicators always stay current regardless of log configuration.
|
|
14
|
+
- **Renamed battery notification properties to battery logging properties** — `batteryNotifyEnabled` → `batteryLogEnabled`, `batteryNotifyFrequency` → `batteryLogFrequency`, `batteryNotifyOnValueChangeOnly` → `batteryLogOnChangeOnly`. The new names clarify that these properties control the library's internal log output, not the `onBatteryLevelNotify` callback.
|
|
15
|
+
- **`lights()` now sends a single command instead of per-light commands** — Previously sent individual `setLEDStateful` commands for each light (up to 24 commands), which could overflow the tower's buffer. Now accumulates all light changes into one state packet sent as a single command.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **Battery indicator not updating when battery logging set to NONE** — The Tower Status battery display now always updates regardless of the battery logging setting.
|
|
20
|
+
- **Battery `[RCVD]` log lines ignoring "Changes" filter** — The generic `[UDT][BLE][RCVD] BATTERY_READING` log line was not respecting `batteryLogOnChangeOnly`. Battery responses now skip the generic RCVD log and are logged exclusively by the dedicated battery logging block, which correctly respects all three logging properties.
|
|
21
|
+
- **Ledge and base light effects not looping** — Effects like "breathe" played once and faded away on ledge and base lights because their `loop` flag was hardcoded to `false`. All light types now set `loop` based on whether the effect is active (`effect !== LIGHT_EFFECTS.off`), matching the behaviour of `allLightsOn()`.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **Battery logging properties documented in API_REFERENCE.md** — `batteryLogEnabled`, `batteryLogFrequency`, and `batteryLogOnChangeOnly` are now documented with descriptions, types, defaults, and usage examples.
|
|
26
|
+
|
|
27
|
+
## [2.5.0] - 2026-03-23
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **`markSealBroken()` method** — Marks a seal as broken in software tracking without sending hardware commands. Enables restoring game state (e.g., resuming a saved game).
|
|
32
|
+
- **`markSealRestored()` method** — Marks a seal as unbroken in software tracking without sending hardware commands. Enables undoing a seal break or restoring individual seals.
|
|
33
|
+
- **`brokenSeals` config option** — Accepts an array of `SealIdentifier` in `UltimateDarkTowerConfig` to initialize seal state at construction time.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- **Improved seal management documentation** — API_REFERENCE.md now explains that seals are physical plastic covers on the tower (12 total), that seal state is tracked purely in software (not by firmware), and documents all new seal state management APIs.
|
|
38
|
+
|
|
39
|
+
## [2.4.0] - 2026-03-19
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- **Migrated project baseline to Node.js 18+** — Updated `engines.node` to `>=18.0.0`, aligned CI matrix validation to Node 18 and 20, and refreshed contributing guidance to reflect active runtime support.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- **Cleared development-tooling security advisories without permanent overrides** — Upgraded direct dev dependencies (`ts-jest`, `@typescript-eslint/parser`, `@typescript-eslint/eslint-plugin`, and `esbuild`) so the lockfile now resolves patched transitive versions for `minimatch`, `ajv`, `js-yaml`, and `flatted` without retaining temporary npm `overrides`. Full `npm audit` now reports zero vulnerabilities while preserving the existing Jest, ESLint, and build configuration.
|
|
48
|
+
- **Stabilised `ts-jest` coverage resolution after dependency cleanup** — Added an explicit `jest-util` devDependency so `ts-jest` can resolve its runtime helper consistently during Jest coverage runs.
|
|
49
|
+
- **Adjusted BLE device-info fallback for newer lint rules** — Removed an unused catch binding in `readDeviceInformation()` so the code remains compatible with the stricter `@typescript-eslint` rules introduced by the dependency upgrades.
|
|
50
|
+
- **Started staged modernization dependency refresh** — Updated core dev tooling to current non-breaking lines (`typescript` to `^5.9.3`, `prettier` to `3.8.1`, `@types/node` to `^24.12.0`, `@types/jest` to `^30.0.0`, and `@stoprocent/noble` to `^2.3.17`) and revalidated with full CI and `npm audit`.
|
|
51
|
+
- **Consolidated duplicate ESLint configuration files** — Unified lint configuration into `.eslintrc.js` and removed `.eslintrc.json` to reduce rule drift and prepare cleanly for future ESLint major migration work.
|
|
52
|
+
- **Updated Node matrix CI for active support policy** — CI matrix now validates Node 18 and 20 only, matching the new runtime baseline.
|
|
53
|
+
- **Added ESLint flat-config preview path for staged migration** — Added `eslint.config.mjs` and preview scripts (`lint:flat:preview`) so ESLint 9 compatibility can be tested incrementally while the current CI lint path remains unchanged.
|
|
54
|
+
- **Achieved ESLint rule parity between legacy and flat-config paths** — Updated `eslint.config.mjs` to include `js.configs.recommended` (base ESLint rules) and explicitly disable `no-unused-vars` in favour of `@typescript-eslint/no-unused-vars` with argument patterns, ensuring both `npm run lint` and `npm run lint:flat:preview` produce identical output (86 warnings). Both lint paths now feature full parity for future seamless migration to ESLint 9.
|
|
55
|
+
- **Upgraded Jest toolchain toward current major** — Upgraded `jest` and `jest-util` to the 30.x line and aligned Jest type definitions to `@types/jest` 30.x while keeping `ts-jest` on latest available stable 29.x until a compatible 30.x release is published.
|
|
56
|
+
|
|
57
|
+
## [2.3.1] - 2026-03-09
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- **Troubleshooting modal in TowerController example** — A "Troubleshooting" button now appears in the TowerController web app button bar. Clicking it opens a modal overlay displaying the full Restoration Games troubleshooting guide (tower jams, disconnects, firmware errors 133/257, and battery specifications). The modal can be dismissed via the close button, clicking the backdrop, or pressing Escape. The button is visually de-emphasised (reduced opacity, smaller text, extra left margin) to indicate it is secondary to Connect/Disconnect/Calibrate.
|
|
62
|
+
|
|
9
63
|
## [2.3.0] - 2026-02-23
|
|
10
64
|
|
|
11
65
|
### Added
|
|
12
66
|
|
|
13
|
-
-
|
|
67
|
+
- **`allLightsOn(effect?)` and `allLightsOff()` convenience methods** — Turns all 24 tower LEDs on or off with a single command packet. `allLightsOn` accepts an optional `effect` parameter (default: `LIGHT_EFFECTS.on`); `allLightsOff` is a convenience wrapper around `allLightsOn(LIGHT_EFFECTS.off)`. Both preserve existing drum, beam, and audio state.
|
|
14
68
|
|
|
15
69
|
### Changed
|
|
16
70
|
|
|
17
|
-
-
|
|
71
|
+
- **Public audio volume API now clamps inputs to 0–3** — The `volume` parameter accepted by `playSoundStateful`, `breakSeal`, and related methods is now clamped to the range 0–3 (0=loudest, 1=medium, 2=quiet, 3=softest/mute) before being sent to the tower. The tower's 4-bit device field accepts 0–15, but the firmware only defines behaviour for 0–3; out-of-range inputs now silently clamp rather than producing undefined tower behaviour. If you were passing values outside 0–3, update them to the equivalent in-range value.
|
|
18
72
|
|
|
19
73
|
## [2.2.0] - 2026-02-20
|
|
20
74
|
|
|
21
75
|
### Fixed
|
|
22
76
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
77
|
+
- **`setLEDStateful` stale-state accumulation** — `setLEDStateful` never called `setTowerState`, so `onTowerStateUpdate` callbacks were never fired for LED changes and any code calling it in a loop (including `lights()`) risked reading stale state if `this.currentTowerState` was replaced between iterations. State is now updated explicitly before the command is sent.
|
|
78
|
+
- **`cleanup()` reconnect hazard** — `cleanup()` called `disconnect()` which fired `onTowerDisconnect`, meaning a reconnect-on-disconnect handler could call `connect()` on an instance mid-teardown. `isDisposed` is now set before any disconnect logic runs so the callback cannot re-enter `connect()`.
|
|
79
|
+
- **`cleanup()` not idempotent** — Calling `cleanup()` more than once would re-run the full teardown sequence. It now returns early if the instance is already disposed.
|
|
80
|
+
- **`MockBluetoothAdapter.cleanup()` leaving callbacks registered** — The mock adapter's `cleanup()` now clears all three event callbacks, matching the behaviour of `NodeBluetoothAdapter`.
|
|
27
81
|
|
|
28
82
|
### Changed
|
|
29
83
|
|
|
30
|
-
-
|
|
84
|
+
- **`connect()` throws after disposal** — Calling `connect()` on a `UdtBleConnection` instance after `cleanup()` now throws `Error: UdtBleConnection instance has been disposed and cannot reconnect`. Use `disconnect()` for reversible disconnection.
|
|
31
85
|
|
|
32
86
|
## [2.1.3] - 2026-02-19
|
|
33
87
|
|
|
34
88
|
### Fixed
|
|
35
89
|
|
|
36
|
-
-
|
|
90
|
+
- **`@stoprocent/noble` not loading in ESM build** — In Node.js ESM contexts, `require` is not defined, causing esbuild's `__require` shim to silently fail and leave `noble` as `undefined`. The ESM bundle now injects `import{createRequire}from'module';const require=createRequire(import.meta.url);` as a banner so `@stoprocent/noble` loads correctly via CJS `require` within the ESM module.
|
|
37
91
|
|
|
38
92
|
## [2.1.2] - 2026-02-19
|
|
39
93
|
|
|
40
94
|
### Fixed
|
|
41
95
|
|
|
42
|
-
-
|
|
96
|
+
- **ESM named imports broken** — `import { UltimateDarkTower } from 'ultimatedarktower'` previously threw `SyntaxError: The requested module does not provide an export named 'UltimateDarkTower'` in Node.js ESM projects because the `"import"` export condition pointed to the CommonJS build. The package now ships a true ES Module bundle so named imports work correctly.
|
|
43
97
|
|
|
44
98
|
### Added
|
|
45
99
|
|
|
46
|
-
-
|
|
100
|
+
- **ESM build** (`dist/esm/index.mjs`) — a native ES Module bundle produced by esbuild, included in the published package alongside the existing CommonJS build
|
|
47
101
|
|
|
48
102
|
### Changed
|
|
49
103
|
|
|
50
|
-
-
|
|
51
|
-
-
|
|
104
|
+
- `package.json` `exports["import"]` condition now points to `dist/esm/index.mjs` instead of the CommonJS output; `exports["require"]` is unchanged
|
|
105
|
+
- `package.json` `files` now includes `dist/esm/**/*`
|
|
52
106
|
|
|
53
107
|
## [2.1.1] - 2026-02-19
|
|
54
108
|
|
|
55
109
|
### Added
|
|
56
110
|
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
111
|
+
- Integration test for tower calibration using Node.js Bluetooth adapter, located in `tests/integration/calibration.integration.ts`
|
|
112
|
+
- `npm run test:integration` script to run integration tests requiring real hardware
|
|
113
|
+
- Integration tests are now organized under `tests/integration/` and are not run by default with unit tests or during publish
|
|
60
114
|
|
|
61
115
|
## [2.1.0] - 2026-02-19
|
|
62
116
|
|
|
63
117
|
### Added
|
|
64
118
|
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
119
|
+
- **Public Tower State Types** — Exported `TowerState`, `Light`, `Layer`, `Drum`, `Audio`, and `Beam` type interfaces for direct tower state manipulation
|
|
120
|
+
- **Tower State Utilities** — Exported `rtdt_unpack_state`, `rtdt_pack_state`, `isCalibrated`, and `createDefaultTowerState` for converting between `TowerState` objects and binary tower data
|
|
121
|
+
- **Differential Readings** — Exported `parseDifferentialReadings` function and `ParsedDifferentialReadings` type for parsing tower sensor data
|
|
122
|
+
- **`TowerResponseConfig` Type** — Exported interface for controlling which tower responses are logged via `logTowerResponseConfig`
|
|
69
123
|
|
|
70
124
|
### Changed
|
|
71
125
|
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
126
|
+
- **`TowerResponseConfig`** — Moved from private interface in `UltimateDarkTower.ts` to exported interface in `udtTowerResponse.ts`
|
|
127
|
+
- **`shouldLogResponse`** — Updated parameter type from `any` to `TowerResponseConfig` for type safety
|
|
128
|
+
- **Controller Example** — Updated imports to use the package index instead of internal module paths
|
|
75
129
|
|
|
76
130
|
## [2.0.0] - 2025-02-18
|
|
77
131
|
|
|
78
132
|
### Added
|
|
79
133
|
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
134
|
+
- **Node.js Support** — `NodeBluetoothAdapter` using `@stoprocent/noble` for BLE communication in Node.js environments (macOS, Linux, Windows)
|
|
135
|
+
- **Platform Auto-Detection** — `BluetoothAdapterFactory` automatically selects the correct adapter based on the runtime environment (browser vs Node.js vs Electron)
|
|
136
|
+
- **`BluetoothPlatform` Enum** — Explicit platform selection via `BluetoothPlatform.WEB`, `BluetoothPlatform.NODE`, or `BluetoothPlatform.AUTO`
|
|
137
|
+
- **`IBluetoothAdapter` Interface** — Public adapter interface for implementing custom Bluetooth adapters (React Native, Cordova, etc.)
|
|
138
|
+
- **Platform-Agnostic Error Types** — `BluetoothConnectionError`, `BluetoothDeviceNotFoundError`, `BluetoothNotAvailableError`, `BluetoothCharacteristicError`, `BluetoothAdapterError` for consistent error handling across platforms
|
|
139
|
+
- **Node.js CLI Example** — Interactive command-line example application (`examples/node/`)
|
|
140
|
+
- **Adapter Layer Tests** — Unit tests for `NodeBluetoothAdapter`, `WebBluetoothAdapter`, `BluetoothAdapterFactory`, `UdtBleConnection`, and error types
|
|
87
141
|
|
|
88
142
|
### Changed
|
|
89
143
|
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
144
|
+
- **`udtBleConnection`** — Refactored to use `IBluetoothAdapter` interface instead of direct Web Bluetooth API calls, enabling multi-platform support
|
|
145
|
+
- **`UltimateDarkTower` Constructor** — Now accepts `UltimateDarkTowerConfig` with optional `platform` or `adapter` properties for platform selection
|
|
146
|
+
- **Peer Dependency** — Updated `@stoprocent/noble` peer dependency from `^1.15.0` to `^2.0.0`
|
|
93
147
|
|
|
94
148
|
## [1.0.0] - 2025-08-18
|
|
95
149
|
|
|
96
150
|
### Added
|
|
97
151
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
152
|
+
- Initial release
|
|
153
|
+
- Web Bluetooth support for Chrome, Edge, and Samsung Internet
|
|
154
|
+
- Tower control API (lights, sounds, drum rotation)
|
|
155
|
+
- Glyph position tracking with automatic updates on drum rotation
|
|
156
|
+
- Seal management for game mechanics
|
|
157
|
+
- Tower state management and validation
|
|
158
|
+
- Multi-layered disconnect detection (heartbeat, GATT events, command timeout)
|
|
159
|
+
- Callback-based event system for tower events
|
|
160
|
+
- Comprehensive logging system with multiple outputs
|
|
161
|
+
- Battery monitoring with low battery warnings
|
|
162
|
+
- TypeScript definitions and type safety
|
|
163
|
+
- Tower Controller example web app
|
|
164
|
+
- Tower Game ("The Tower's Challenge") example web app
|
|
165
|
+
- Complete API reference documentation
|
|
112
166
|
|
|
113
167
|
[2.3.0]: https://github.com/ChessMess/UltimateDarkTower/compare/v2.2.0...v2.3.0
|
|
114
168
|
[2.2.0]: https://github.com/ChessMess/UltimateDarkTower/compare/v2.1.3...v2.2.0
|
package/README.md
CHANGED
|
@@ -12,51 +12,51 @@ I have spent many hours reverse engineering the Tower's protocol in order to cre
|
|
|
12
12
|
|
|
13
13
|
## Table of Contents
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
15
|
+
- [UltimateDarkTower](#ultimatedarktower)
|
|
16
|
+
- [Table of Contents](#table-of-contents)
|
|
17
|
+
- [Features](#features)
|
|
18
|
+
- [Live Examples](#live-examples)
|
|
19
|
+
- [Installation](#installation)
|
|
20
|
+
- [Browser / Web Applications](#browser--web-applications)
|
|
21
|
+
- [Node.js Applications](#nodejs-applications)
|
|
22
|
+
- [Quick Start](#quick-start)
|
|
23
|
+
- [Browser (auto-detected)](#browser-auto-detected)
|
|
24
|
+
- [Node.js (auto-detected)](#nodejs-auto-detected)
|
|
25
|
+
- [Explicit Platform Selection](#explicit-platform-selection)
|
|
26
|
+
- [Custom Adapter (React Native, etc.)](#custom-adapter-react-native-etc)
|
|
27
|
+
- [Documentation](#documentation)
|
|
28
|
+
- [📖 Complete API Reference](#-complete-api-reference)
|
|
29
|
+
- [Key Topics Covered:](#key-topics-covered)
|
|
30
|
+
- [Development](#development)
|
|
31
|
+
- [Building and Testing](#building-and-testing)
|
|
32
|
+
- [Project Structure](#project-structure)
|
|
33
|
+
- [Platform Support](#platform-support)
|
|
34
|
+
- [Built-in Support (auto-detected)](#built-in-support-auto-detected)
|
|
35
|
+
- [Custom Adapter Support](#custom-adapter-support)
|
|
36
|
+
- [Browser Support](#browser-support)
|
|
37
|
+
- [Known Issues](#known-issues)
|
|
38
|
+
- [Community](#community)
|
|
39
39
|
|
|
40
40
|
## Features
|
|
41
41
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
42
|
+
- **Multi-Platform Bluetooth** - Works in browsers (Web Bluetooth), Node.js (`@stoprocent/noble`), Electron, and React Native via custom adapters
|
|
43
|
+
- **Bluetooth Connection Management** - Reliable connection with automatic monitoring and disconnect detection
|
|
44
|
+
- **Tower Control** - Complete control over lights, sounds, and drum rotation
|
|
45
|
+
- **Game State Tracking** - Track glyph positions, broken seals, and skull counts
|
|
46
|
+
- **Event System** - Callback-based event handling for tower events
|
|
47
|
+
- **ESM + CJS** - Ships both an ES Module build and a CommonJS build; works with `import` and `require` without configuration
|
|
48
|
+
- **TypeScript Support** - Full TypeScript definitions and type safety
|
|
49
|
+
- **Comprehensive Logging** - Multi-output logging system for debugging
|
|
50
|
+
- **Battery Monitoring** - Real-time battery level tracking and low battery warnings
|
|
51
|
+
- **Extensible Adapter Pattern** - Implement `IBluetoothAdapter` for custom platforms
|
|
52
52
|
|
|
53
53
|
## Live Examples
|
|
54
54
|
|
|
55
55
|
Try the library in action! Just power on your Tower and visit:
|
|
56
56
|
|
|
57
|
-
-
|
|
57
|
+
- **[Tower Controller](https://chessmess.github.io/UltimateDarkTower/dist/examples/controller/TowerController.html)** - Replicates official app functionality and gives examples of library functionality.
|
|
58
58
|
|
|
59
|
-
-
|
|
59
|
+
- **[Tower Game](https://chessmess.github.io/UltimateDarkTower/dist/examples/game/TowerGame.html)** - "The Tower's Challenge" - a complete game using just the tower
|
|
60
60
|
|
|
61
61
|
_Requires Web Bluetooth support (Chrome, Edge, Samsung Internet). For iOS, use the [Bluefy app](https://apps.apple.com/us/app/bluefy-web-ble-browser/id1492822055)._
|
|
62
62
|
|
|
@@ -119,7 +119,7 @@ import UltimateDarkTower, { IBluetoothAdapter } from 'ultimatedarktower';
|
|
|
119
119
|
|
|
120
120
|
class MyCustomAdapter implements IBluetoothAdapter {
|
|
121
121
|
// Implement all IBluetoothAdapter methods
|
|
122
|
-
// See
|
|
122
|
+
// See API_REFERENCE.md for the full interface
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
const tower = new UltimateDarkTower({ adapter: new MyCustomAdapter() });
|
|
@@ -127,22 +127,22 @@ const tower = new UltimateDarkTower({ adapter: new MyCustomAdapter() });
|
|
|
127
127
|
|
|
128
128
|
## Documentation
|
|
129
129
|
|
|
130
|
-
### 📖 [Complete API Reference](
|
|
130
|
+
### 📖 [Complete API Reference](API_REFERENCE.md)
|
|
131
131
|
|
|
132
132
|
Comprehensive documentation with TypeScript examples, best practices, and troubleshooting guides.
|
|
133
133
|
|
|
134
134
|
### Key Topics Covered:
|
|
135
135
|
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
136
|
+
- **Multi-Platform Setup** - Configuration for Web, Node.js, Electron, and React Native
|
|
137
|
+
- **Connection Management** - Connecting, disconnecting, and monitoring connection health
|
|
138
|
+
- **Bluetooth Adapters** - Custom adapter interface for extending platform support
|
|
139
|
+
- **Tower Control** - Detailed coverage of all tower commands (lights, sounds, rotation)
|
|
140
|
+
- **Glyph System** - Automatic tracking of glyph positions as towers rotate
|
|
141
|
+
- **Seal Management** - Breaking seals and tracking game state
|
|
142
|
+
- **Event Handling** - Callback system for tower events
|
|
143
|
+
- **Logging System** - Multi-output logging for debugging and monitoring
|
|
144
|
+
- **Best Practices** - Performance tips, error handling, and common patterns
|
|
145
|
+
- **Troubleshooting** - Solutions for common issues and debugging techniques
|
|
146
146
|
|
|
147
147
|
## Integration Testing
|
|
148
148
|
|
|
@@ -154,14 +154,43 @@ To run the calibration integration test:
|
|
|
154
154
|
npm run test:integration
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
157
|
+
- This will connect to the tower, perform a full calibration sequence, and print the resulting glyph positions.
|
|
158
|
+
- The test will fail if the tower is not available or calibration does not complete within 60 seconds.
|
|
159
|
+
- Integration tests are not included in automated test runs or npm publish.
|
|
160
|
+
|
|
161
|
+
### Lights Integration Test
|
|
162
|
+
|
|
163
|
+
The lights integration test validates the `allLightsOn` and `allLightsOff` API methods using real tower hardware.
|
|
164
|
+
|
|
165
|
+
**Test steps:**
|
|
166
|
+
|
|
167
|
+
- Turns all 24 LEDs on (solid effect) for 2 seconds
|
|
168
|
+
- Turns all 24 LEDs on (breathe effect) for 3 seconds
|
|
169
|
+
- Turns all 24 LEDs off
|
|
170
|
+
|
|
171
|
+
**How to run:**
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm run test:integration:lights
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Prerequisites:**
|
|
178
|
+
|
|
179
|
+
- Tower must be powered on and in Bluetooth range
|
|
180
|
+
- `@stoprocent/noble` must be installed
|
|
181
|
+
|
|
182
|
+
**Visual verification:**
|
|
183
|
+
|
|
184
|
+
- All lights on (solid) for 2 seconds
|
|
185
|
+
- All lights breathe effect for 3 seconds
|
|
186
|
+
- All lights off
|
|
187
|
+
|
|
188
|
+
See [API_REFERENCE.md](API_REFERENCE.md) for API details on `allLightsOn` and `allLightsOff`.
|
|
160
189
|
|
|
161
190
|
**Prerequisites:**
|
|
162
191
|
|
|
163
|
-
-
|
|
164
|
-
-
|
|
192
|
+
- Tower must be powered on and in Bluetooth range
|
|
193
|
+
- `@stoprocent/noble` must be installed (it is a peer dependency)
|
|
165
194
|
|
|
166
195
|
## Development
|
|
167
196
|
|
|
@@ -242,10 +271,10 @@ examples/
|
|
|
242
271
|
|
|
243
272
|
## Known Issues
|
|
244
273
|
|
|
245
|
-
-
|
|
246
|
-
-
|
|
274
|
+
- **Sounds** - Sounds show as command complete which is true even though the sound itself has not completed. This is just the way the tower works. I'll have to add time lengths to each at some point, just don't use the command complete response as a way of thinking the associated sound has finished playing and you can play another sound.
|
|
275
|
+
- **Light Sequences** - Same as sound for lights that play for a duration.
|
|
247
276
|
|
|
248
|
-
> See [
|
|
277
|
+
> See [API_REFERENCE.md](API_REFERENCE.md) for performance best practices and workarounds.
|
|
249
278
|
|
|
250
279
|
## Community
|
|
251
280
|
|