Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket.write not writing commands #159

Open
k-bharath-7 opened this issue Nov 13, 2022 · 1 comment
Open

Socket.write not writing commands #159

k-bharath-7 opened this issue Nov 13, 2022 · 1 comment

Comments

@k-bharath-7
Copy link

k-bharath-7 commented Nov 13, 2022

OS: Ubuntu 20.04
Node version: v16.18.1 / v12.12.0 / v10.15.3
node-bluetooth-hci-socket: v0.5.3-8

The following code is used to crearte le conn with the bluetooth device but this is not working and connection is not created. This is used in @abandonware/noble package.

const { minInterval = 0x0006, maxInterval = 0x000c, latency = 0x0000, timeout = 0x00c8 } = parameters;

  const cmd = Buffer.alloc(29);

  // header
  cmd.writeUInt8(HCI_COMMAND_PKT, 0);
  cmd.writeUInt16LE(LE_CREATE_CONN_CMD, 1);

  // length
  cmd.writeUInt8(0x19, 3);

  // data
  cmd.writeUInt16LE(0x0060, 4); // interval
  cmd.writeUInt16LE(0x0030, 6); // window
  cmd.writeUInt8(0x00, 8); // initiator filter

  cmd.writeUInt8(addressType === 'random' ? 0x01 : 0x00, 9); // peer address type
  (Buffer.from(address.split(':').reverse().join(''), 'hex')).copy(cmd, 10); // peer address

  cmd.writeUInt8(0x00, 16); // own address type

  cmd.writeUInt16LE(minInterval, 17); // min interval
  cmd.writeUInt16LE(maxInterval, 19); // max interval
  cmd.writeUInt16LE(latency, 21); // latency
  cmd.writeUInt16LE(timeout, 23); // supervision timeout
  cmd.writeUInt16LE(0x0004, 25); // min ce length
  cmd.writeUInt16LE(0x0006, 27); // max ce length

  debug("create le conn - writing:", ${cmd.toString('hex')});
  this._socket.write(cmd);
@rzr
Copy link

rzr commented Apr 12, 2024

Is this issue also present on latest release of:

https://www.npmjs.com/package/@abandonware/bluetooth-hci-socket/v/0.5.3-12

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

No branches or pull requests

2 participants