UNPKG

@stoprocent/bleno

Version:

A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals

38 lines (29 loc) 829 B
const { EventEmitter } = require('events'); const Smp = require('./smp'); class AclStream extends EventEmitter { constructor (hci, handle, localAddressType, localAddress, remoteAddressType, remoteAddress) { super(); this._hci = hci; this._handle = handle; this.encypted = false; this._smp = new Smp(this, localAddressType, localAddress, remoteAddressType, remoteAddress); } write (cid, data) { this._hci.queueAclDataPkt(this._handle, cid, data); } push (handle, cid, data) { if (data) { this.emit('data', handle, cid, data); } else { this.emit('end', handle); } } pushEncrypt (encrypt) { this.encrypted = !!encrypt; this.emit('encryptChange', this.encrypted); } pushLtkNegReply () { this.emit('ltkNegReply'); } } module.exports = AclStream;