{"_id":"@csllc/mb-conn-noble-mac","_rev":"2-177c990fb24262b5ffda4aa9a32cba3f","name":"@csllc/mb-conn-noble-mac","dist-tags":{"latest":"1.2.0"},"versions":{"1.1.0":{"name":"@csllc/mb-conn-noble-mac","version":"1.1.0","author":{"url":"http://wwww.icloud.com/","name":"Bill Glase","email":"bglase@icloud.com"},"license":"MIT","_id":"@csllc/mb-conn-noble-mac@1.1.0","maintainers":[{"name":"gfang","email":"gfang@controls.com"},{"name":"cwalden-cs","email":"cwalden@controls.com"},{"name":"sean.kudrna.cs","email":"skudrna@controls.com"},{"name":"incuiti","email":"incuiti@icloud.com"},{"name":"dayaeger","email":"dyaeger@controls.com"}],"dist":{"shasum":"03e0a1aee90620c929d3b9cb7c847db929bf56f6","tarball":"https://registry.npmjs.org/@csllc/mb-conn-noble-mac/-/mb-conn-noble-mac-1.1.0.tgz","fileCount":14,"integrity":"sha512-hTARIJHrNJhxi0dZoZw6i3WyGigT+PYcsqEpD0lPQeoXqHoYYGgJpyS5Mdt57CupcKZaoK7gB9W1iUvH7gBzrA==","signatures":[{"sig":"MEQCIG0VI61Bl1K1s4BLnjADvUlZEd6uk+YSKdXDNDx/sMGIAiAHVTzu8DoFB4pQ/y076RbTetKrMK6kGgcVWeu6y9zo/w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23302},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"gitHead":"0fd150c83012da8251a2da724a25b4dd1692b3ce","scripts":{"lint":"eslint","test":"node --experimental-vm-modules ../../node_modules/.bin/jest","build":"tsc","clean":"rm -rf dist/*","watch":"tsc --watch","preversion":"npm run clean && npm run build","type:check":"tsc -p tsconfig.json --noEmit","postversion":"git push --follow-tags"},"_npmUser":{"name":"incuiti","email":"incuiti@icloud.com"},"_npmVersion":"10.9.4","description":"MODBUS BLE connection for macOS using noble-mac and CoreBluetooth","directories":{},"_nodeVersion":"22.21.1","dependencies":{"eventemitter3":"^4.0.7","@csllc/blejs-types":"*","@csllc/modbus-types":"*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.4.6","typescript":"^5.3.2","@types/jest":"^29.5.11"},"optionalDependencies":{"noble-mac":"Timeular/noble-mac"},"_npmOperationalInternal":{"tmp":"tmp/mb-conn-noble-mac_1.1.0_1775514958540_0.2051995322424094","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@csllc/mb-conn-noble-mac","version":"1.2.0","publishConfig":{"access":"public"},"description":"MODBUS BLE connection for macOS using noble-mac and CoreBluetooth","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"type:check":"tsc -p tsconfig.json --noEmit","clean":"rm -rf dist/*","build":"tsc","watch":"tsc --watch","preversion":"npm run clean && npm run build","postversion":"git push --follow-tags","test":"node --experimental-vm-modules ../../node_modules/.bin/jest","lint":"eslint"},"author":{"name":"Bill Glase","email":"bglase@icloud.com","url":"http://wwww.icloud.com/"},"license":"MIT","dependencies":{"@csllc/modbus-types":"*","@csllc/blejs-types":"*","eventemitter3":"^4.0.7"},"optionalDependencies":{"noble-mac":"Timeular/noble-mac"},"devDependencies":{"@types/jest":"^29.5.11","jest":"^29.7.0","ts-jest":"^29.4.6","typescript":"^5.3.2"},"_id":"@csllc/mb-conn-noble-mac@1.2.0","gitHead":"6a9bd507f0aa9f94936f8dee3b8c5fd1cfaa84ea","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-R8gGCeW16Ao9hJl6aPdPk+l4iXiyOQRmUxXEbD/alJWGzK485V0DTgMGbj1ykps4hzmF/7nIv0W9Bc33TpbVjw==","shasum":"51c1dcc6cecd41cd9dae5ffdd458647f729e01d8","tarball":"https://registry.npmjs.org/@csllc/mb-conn-noble-mac/-/mb-conn-noble-mac-1.2.0.tgz","fileCount":14,"unpackedSize":23712,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAC+wu8x/ik7SPEp1dwl3AkddIKauundQcKdhZdDFSo2AiAh4gKau2DlRhgHDUlMUeu8hK4L6wymSFmnAGvbhu3WaA=="}]},"_npmUser":{"name":"incuiti","email":"incuiti@icloud.com"},"directories":{},"maintainers":[{"name":"gfang","email":"gfang@controls.com"},{"name":"cwalden-cs","email":"cwalden@controls.com"},{"name":"sean.kudrna.cs","email":"skudrna@controls.com"},{"name":"incuiti","email":"incuiti@icloud.com"},{"name":"dayaeger","email":"dyaeger@controls.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mb-conn-noble-mac_1.2.0_1775615705122_0.6332022563052604"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-06T22:35:58.427Z","modified":"2026-04-08T02:35:05.467Z","1.1.0":"2026-04-06T22:35:58.684Z","1.2.0":"2026-04-08T02:35:05.271Z"},"author":{"name":"Bill Glase","email":"bglase@icloud.com","url":"http://wwww.icloud.com/"},"license":"MIT","description":"MODBUS BLE connection for macOS using noble-mac and CoreBluetooth","maintainers":[{"name":"gfang","email":"gfang@controls.com"},{"name":"cwalden-cs","email":"cwalden@controls.com"},{"name":"sean.kudrna.cs","email":"skudrna@controls.com"},{"name":"incuiti","email":"incuiti@icloud.com"},{"name":"dayaeger","email":"dyaeger@controls.com"}],"readme":"# @csllc/mb-conn-noble-mac\n\nMODBUS-over-BLE connection package for macOS, using [noble-mac](https://github.com/Timeular/noble-mac) and Apple's CoreBluetooth API.\n\n> **Not production-ready.** This package is intended for testing MODBUS-over-BLE functionality on macOS during development. Apple's Bluetooth stack and APIs evolve with each macOS release, and noble-mac's compatibility with future versions is not guaranteed. For production deployments, consider `@csllc/mb-conn-noble-ble` (which uses `@abandonware/noble`) or a React Native solution with `@csllc/rn-mb-ble`.\n\n## Why noble-mac?\n\nStandard Noble (`@abandonware/noble`) communicates with macOS Bluetooth via an undocumented XPC protocol that Apple can change at any time. `noble-mac` uses the official CoreBluetooth API instead, which tends to be more stable across macOS updates. The trade-off is that `noble-mac` is less actively maintained and may lag behind Noble's feature set.\n\n## Exported Interface\n\n### `BleConnection`\n\nA `Connection` subclass (from `@csllc/modbus-types`) that bridges BLE transparent UART characteristics to the MODBUS connection API.\n\n```typescript\nimport { BleConnection } from '@csllc/mb-conn-noble-mac';\n\nconst connection = new BleConnection(ble, peripheral, rxChar, txChar);\nawait connection.open(); // subscribes to UART RX notifications\nawait connection.write(buf); // writes to UART TX characteristic\nawait connection.close(); // unsubscribes and disconnects\n```\n\n- **`open()`** — Subscribes to the UART RX characteristic. Incoming BLE notifications are converted to `ArrayBuffer` and emitted as `'data'` events, feeding `IpTransport` automatically.\n- **`write(data: ArrayBuffer)`** — Forwards bytes to the UART TX characteristic via BLE write. Emits a `'write'` event.\n- **`close()`** — Unsubscribes from RX notifications and disconnects the peripheral. Emits `'close'`.\n- **`isOpen()`** — Returns `true` if the connection is active.\n- **`destroy()`** — Closes the connection (if open) and removes all event listeners.\n\nEvents: `'open'`, `'close'`, `'data'`, `'write'`, `'error'`\n\n### `NobleMacBleManager`\n\nImplements the `Ble` interface from `@csllc/blejs-types`, wrapping noble-mac. Can be used directly or passed to `BleConnection` and `BleDongle`.\n\n```typescript\nimport { NobleMacBleManager } from '@csllc/mb-conn-noble-mac';\n\nawait NobleMacBleManager.initialize();\nawait NobleMacBleManager.startScan([], (peripheral) => { ... });\nawait NobleMacBleManager.connect(peripheral);\nconst chars = await NobleMacBleManager.findCharacteristics(peripheral, serviceUuid, wanted);\n```\n\n### `scan(serviceUuids?, duration?)`\n\nConvenience function that initializes noble-mac, scans for peripherals, and returns an array of `BleConnectionInfo` objects.\n\n```typescript\nimport { scan } from '@csllc/mb-conn-noble-mac';\n\nconst peripherals = await scan(['180a'], 5000);\n// [{ id: '...', type: 'ble', peripheralId: '...', name: 'CS1816' }]\n```\n\n### `BleConnectionInfo`\n\n```typescript\ninterface BleConnectionInfo {\n  id: string; // unique identifier\n  type: 'ble'; // connection type discriminator\n  peripheralId: string; // BLE peripheral ID\n  name?: string; // advertised local name\n}\n```\n\n## Usage with MODBUS\n\n```typescript\nimport { createMaster } from '@csllc/modbus-types';\nimport { BleConnection, NobleMacBleManager } from '@csllc/mb-conn-noble-mac';\nimport { BleDongle, DONGLE_UUIDS } from '@csllc/cs1816';\n\n// 1. Initialize and connect\nawait NobleMacBleManager.initialize();\nawait NobleMacBleManager.startScan([], cb);\n// ... find peripheral ...\nawait NobleMacBleManager.connect(peripheral);\n\n// 2. Discover UART characteristics\nconst chars = await NobleMacBleManager.findCharacteristics(\n  peripheral,\n  DONGLE_UUIDS.uuidUartService,\n  [\n    { name: 'rx', characteristic: DONGLE_UUIDS.uuidRx, required: true },\n    { name: 'tx', characteristic: DONGLE_UUIDS.uuidTx, required: true },\n  ],\n);\n\n// 3. Create the MODBUS stack\nconst connection = new BleConnection(\n  NobleMacBleManager,\n  peripheral,\n  chars.get('rx')!,\n  chars.get('tx')!,\n);\nconst master = createMaster({\n  transport: { type: 'ip', connection },\n  defaultUnit: 1,\n});\nconst dongle = new BleDongle(NobleMacBleManager, master, {});\n\n// 4. Open and use\nawait connection.open();\n```\n\n## Platform Support\n\n- **macOS**: Primary target. Uses CoreBluetooth via noble-mac.\n- **Linux/Windows**: noble-mac falls back to standard Noble on non-Mac platforms, but this is untested. Use `@csllc/mb-conn-noble-ble` instead.\n","readmeFilename":"README.md"}