Skip to content

Complete BLE(Central) Module #474

Open
@nova0821

Description

@nova0821

Complete BLE(Central) Module

Reference to node.js ble module - noble under MIT License.
(https://github.com/sandeepmistry/noble)

  • JS API (ble)
    • ble.startScanning()
    • ble.stopScanning()
  • JS Event (ble)
    • ble.on('stateChange')
    • ble.on('scanStart')
    • ble.on('scanStop')
    • ble.on('discover'): return peripheral JS object with callback function.
peripheral = {
  id: "<id>",
  address: "<BT address">,
  addressType: "<BT address type>", // Bluetooth Address type (public, random, or unknown) 
  connectable: <connectable>, // true or false, or undefined if not known
  advertisement: {
    localName: "<name>",
    txPowerLevel: <int>,
    serviceUuids: ["<service UUID>", ...],
    serviceSolicitationUuid: ["<service solicitation UUID>", ...],
    manufacturerData: <Buffer>,
    serviceData: [
        {
            uuid: "<service UUID>"
            data: <Buffer>
        },
        ...
    ]
  },
  rssi: <rssi>
};

ble.on('discover', callback(peripheral));
  • JS API (peripheral)
    • peripheral.connect()
    • peripheral.disconnect()
    • peripheral.updateRssi()
    • peripheral.discoverServices(): return services JS object with callback function.
    • peripheral.discoverAllServicesAndCharacteristics() : return services and characteristic.
    • peripheral.readHandle()
    • peripheral.writeHandle()
  • JS Event (peripheral)
    • peripheral.once('connect')
    • peripheral.once('disconnect')
    • peripheral.once('rssiUpdate')
    • peripheral.once('servicesDiscover')
  • JS API (service)
    • service.discoverIncludedServices()
    • service.discoverCharacteristics()
  • JS Event (service)
    • service.once('includedServicesDiscover')
    • service.once('characteristicsDiscover')
characteristic = {
  uuid: "<uuid>",
   // properties: 'broadcast', 'read', 'writeWithoutResponse', 'write', 'notify', 'indicate', 'authenticatedSignedWrites', 'extendedProperties'
  properties: [...]
};

service.once('characteristicsDiscover', callback(characteristics));
  • JS API (characteristic)
    • characteristic.read()
    • characteristic.write()
    • characteristic.broadcast()
    • characteristic.subscribe()
    • characteristic.unsubscribe()
    • characteristic.discoverDescriptors()
  • JS Event (characteristic)
    • characteristic.on('data')
    • characteristic.once('read')
    • characteristic.once('write')
    • characteristic.once('broadcast')
    • characteristic.once('notify')
    • characteristic.once('descriptorsDiscover'
descriptor = {
  uuid: '<uuid>'
};

characteristic.once('descriptorsDiscover', callback(descriptors));
  • JS API (descriptor)
    • descriptor.readValue()
    • descriptor.writeValue()
  • JS Event (descriptor)
    • descriptor.once('valueRead')
    • descriptor.once('valueWrite')
  • x86 linux
  • arm-linux on Raspberry Pi
  • arm-nuttx on STM32F4-discovery
  • Create document

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions