View Single Post
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#1
I recently got a HRM belt thingy (made by MagellanGPS) that I'd like to integrate to my system. The belt uses Bluetooth LE to communicate with a host controller so the first thing to do is to create a BTLE controller for it.

I found an article by @javispedro that describes how it can be done, and as I already have nodejs on my device I decided to use the "noble" npm to implement it.

My first rough idea is to have a small nodejs servlet script that connects to the HRM device and presents the gathered heartbeat data in a local socket. This way it is really easy to write a QML client for presentation or integrate it to a sportstracking application.


Prerequisities:
  • basic set of development utils, but of course everybody has these already: make, gcc, gcc-c++, rpmbuild, etc...
  • a somewhat recent nodejs version. I have v0.12.7 but probably anything newer than 0.10.something is OK
  • pkcon install bluez-libs-devel systemd-devel
  • npm install noble

That's all it takes really. You'll find some nice exmples under node_modules/noble/examples that give overview of the service discovery and use.

However, it seems that even though I can scan for devices and find the HRM belt, I cannot connect to it:

Code:
[root@Jolla examples]# 
[root@Jolla examples]# node advertisement-discovery.js 
peripheral discovered (eca6b680cd95 with address <ec:a6:b6:80:cd:95, random>, connectable true, RSSI -70:
	hello my local name is:
		HRM (Ver0.4)
	can I interest you in any of the following advertised services:
		["180d"]
The belt seemingly offers a service 180d which most probably is the heartbeat monitoring, but it stays in disconnected mode:

Code:
{ _noble: 
   { state: 'poweredOn',
     _bindings: 
      { _state: 'poweredOn',
        _addresses: [Object],
        _addresseTypes: [Object],
        _connectable: [Object],
        _pendingConnection: false,
        _connectionQueue: [],
        _handles: {},
        _gatts: {},
        _aclStreams: {},
        _hci: [Object],
        _gap: [Object],
        _events: [Object],
        onSigIntBinded: [Function],
        _scanServiceUuids: [] },
     _peripherals: { eca6b680cd95: [Circular] },
     _services: { eca6b680cd95: {} },
     _characteristics: { eca6b680cd95: {} },
     _descriptors: { eca6b680cd95: {} },
     _discoveredPeripheralUUids: [ 'eca6b680cd95' ],
     _events: 
      { warning: [Function],
        stateChange: [Function],
        discover: [Function] },
     _allowDuplicates: undefined },
  id: 'eca6b680cd95',
  uuid: 'eca6b680cd95',
  address: 'ec:a6:b6:80:cd:95',
  addressType: 'random',
  connectable: true,
  advertisement: 
   { localName: 'HRM (Ver0.4)',
     txPowerLevel: undefined,
     manufacturerData: undefined,
     serviceData: [],
     serviceUuids: [ '180d' ] },
  rssi: -70,
  services: null,
  state: 'disconnected' }
Does anybody have better experience on BTLE, aome advice on how the connection should be attempted?