Skip to content
Jack Lund edited this page Oct 16, 2013 · 7 revisions

Table of Contents

Class: Device

This is an event emitter with the following events:

Event: 'connect'

function(err, device) { }

Emitted on a connect if no callback is passed to the connect function.

Event: 'close'

function() { }

Emitted when the connection is closed, either by a call to the close method, or for some other reason.

Event: 'error'

function(err) { }

Emitted when there is a general error that doesn't have an associated callback.

Device.addNotificationListener(handle, callback)

  • handle Number
  • callback Function

Adds a listener for a notification on a specific handle. The callback is called every time there is a notification on that handle

Device.close()

Close the connection to the device. The Device object is no longer usable. A close event is emitted when the close is completed.

Device.findInformation(startHandle, endHandle, callback)

  • startHandle Number
  • endHandle Number
  • callback Function

Find type (UUID) information about the given handle range, between startHandle and endHandle inclusive. The callback returns a list containing objects with property handle containing the handle, and type, containing the UUID type.

Device.findService(type, callback)

  • type String
  • callback Function

Find a service with the given UUID. If the UUID is null, returns all services for the given device.

Device.findByTypeValue(startHandle, endHandle, type, value, callback)

  • startHandle Number
  • endHandle Number
  • type String
  • value Buffer
  • callback Function

Find an attribute with a given UUID and value within the range of handles provided. To search all handles, specify startHandle as 0 and endHandle as 0xFFFF.

Device.readByGroupType(startHandle, endHandle, groupType, callback)

  • startHandle Number
  • endHandle Number
  • groupType String
  • callback Function

Read the values of an attribute with the given group type (as determined by a higher-level specification, e.g., GATT) within the range of handles provided. To search all handles, specify startHandle as 0 and endHandle as 0xFFFF.

Device.readByType(startHandle, endHandle, type, callback)

  • startHandle Number
  • endHandle Number
  • type String
  • callback Function

Read the values of an attribute with a given UUID within the range of handles provided. To search all handles, specify startHandle as 0 and endHandle as 0xFFFF.

Device.readHandle(handle, callback)

  • handle Number
  • callback function

Read the value of an attribute with the given handle.

Device.writeCommand(handle, data, callback)

  • handle Number
  • data Buffer
  • callback Function

Write the given data to the attribute with the given handle

Clone this wiki locally