maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Jolla1 & TOH (https://talk.maemo.org/forumdisplay.php?f=56)
-   -   Accessing Bluetooth LE devices (https://talk.maemo.org/showthread.php?t=96321)

juiceme 2016-01-05 18:34

Accessing Bluetooth LE devices
 
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?

Zeta 2016-01-05 21:09

Re: Accessing Bluetooth LE devices
 
Quote:

Originally Posted by juiceme (Post 1493774)
The belt seemingly offers a service 180d which most probably is the heartbeat monitoring

It is : https://developer.bluetooth.org/gatt...vicesHome.aspx
and more details here : https://developer.bluetooth.org/gatt...heart_rate.xml

If you don't yet know this website, you can bookmark it. It is the official developer documentation, listing all profiles, services, descriptors and characteristics, and is really well done : https://developer.bluetooth.org/gatt/Pages/default.aspx

For the NodeJS or Jolla specifics, I can not help however, I have only used it a bit through Qt Bluetooth libs found in newer releases (with mixed results) on other targets.


All times are GMT. The time now is 23:58.

vBulletin® Version 3.8.8