Trouble with: setAdvertising heart_rate #2078
Replies: 23 comments
-
Posted at 2016-12-14 by Bennr I have been trying to advertise as various things from the Puck, but the only things I can get to show up as being described properly in nRF are the examples, Temperature and Battery Life. I can't get blood pressure or environmental sensing to show up. I think you have to provide a byte array as data which has some required parameters for some services, but I don't know how to tell what data it needs or how to give it to it! The eddystone example works too, and that has a load of bytes in an array.
I don't really understand the gatt spec website either. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams If I just do:
Then when I disconnect and re-scan in nRF connect I see:
And if I do:
I see:
So Puck.js seems to be advertising everything just fine. Is it possible that the heart rate service isn't meant to be an advertisement, but is meant to be a service that you add with
It seems more likely it's a service, since you maybe don't want to broadcast your heartrate to anyone that's listening? You can always click @gomako: I'm pretty sure that blood pressure will be a service, not advertising. In |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy I've been reading through an older thread on BT on this forum and I've come to the same thought, that heart_rate should be a service not an advertisement. I'm going to give that a try now. I took that route to start with, but didn't have much luck…that said, it was 18 hours ago, so maybe my brain has soaked up more of the GATT spec! Will report back. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy Aside, @gfwilliams do you have any tips on debugging? Because when I apply the new service, it blows away the Nordic UART so I can't redeploy without pulling the battery and resetting. If I use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy Quick update:
Note that the value is totally wrong. I'm also trying to connect from a webpage, which doesn't discover that this device has heart_rate (I think it's filtering on the service), but baby steps! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams You'll need to use the format of data that's specified here: https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.heart_rate_measurement.xml Looks a bit cryptic, so it might be easier to copy some data values from someone else's example code? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy @gfwilliams yeah, I've been reading through the specs (and parsing existing data). I know (hmm "know", not sure that's accurate!) that sending a value of I was thinking something like this:
Which does kinda work, but I also believe the device needs to advertise it has heart_rate services - which this doesn't seem to be doing, otherwise filtering for the service doesn't seem to work (or certainly the demo page I'm working from doesn't see it) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy Oh, also note that I've tried sending the following - none really work:
…which does suggest I'm basically making it up as I go along! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy @gfwilliams I think I've found an adafruit example that I might be able to use as documentation, except I think I need to know where the bit flags for the For example, if I have I've been poking around the C files, but I'm not familiar with the code at all. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams When you send I think you probably want: Those flags are for the characteristic itself (rather than the data) - I really don't think you need to delve that deeply - where's the adafruit example code? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by Bennr @gfwilliams Ah right, yeah I see the distinction between advertising and service now. Will follow this thread with interest, as I think this has such a lot of potential. If you do manage to decode the GATT specs @remy it would be good to hear about it! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy Looking at this:
I'm not 100% sure how to represent the value I'm guessing that properties is one of the flags like |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams
I'm sure that'd be in Adafruit's docs somewhere? It's not something you should really try and figure out from Puck.js's source. And yes, 00-40 sure sounds like it should be That also fits with the spec I posted earlier. It'd mean:
And 0x40 is 64. So a heart rate of 64 BPM |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy Quick update, I'm able to read heart rate of 40bpm (with contact detected) and body sensor location: wrist on nRF. But it's not advertising (yet). Here's the code (because I'm not tracking changes!):
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy Quick update, I've got the
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams Ahh, right. So you have 3 specific things:
Unfortunately Puck.js doesn't let you define advertised services right now - but you managed to find a way around it by explicitly setting the raw advertising data, so it looks like you're sorted :) I've filed a bug and I'll try and add the ability to set advertised services at some point in the future. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy One really weird thing I do see, is if I redeploy the code, the service no longer advertises correctly (it's like it completely resets). I'm having to do a hard reset on the puck to get back to advertising. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams You'd definitely have to disconnect and reconnect for it to take effect (since Espruino would think the services have changed and the only way to change the services on nRF52 is for Espruino to totally reset the Bluetooth stack, which it can only do when nothing is connected). It might be that the automatic BLE reset means that the data set in Can you try sticking |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by remy Yeah, putting the Still a bit weird that the name isn't set, though I can see it on the nRF Connect app if I explicitly read the value, but my browser (via webBT) is still reading the old "Pluck 1234" value. Not a biggie though. Now seeing if I can add some more services to this poor little puck! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams Ok, thanks - I'll add that to my To Do list then. You're not seeing the name because you're specifying raw BLE advertising data which doesn't have the name specified in it. If you added the right sequence of bytes to specify a name then you'd be able to do that as well. My guess is anything that's still showing a name just has it cached. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-15 by @gfwilliams Ok, this is now done and will be in 1v92. You can do:
to start advertising the heart rate service. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-15 by renebohne very cool, thanks! Looking forward to 1v92 for my puck :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-12-13 by remy
I'm trying to make a little game with the puck, and the first part of my plan is to advertise the puck as a heart_rate monitor (service: 0x180D).
When I check the puck after a deploy with the Android nRF Connect app, it doesn't list heart_rate as a service.
When I compare to my Pebble, I can see it explicitly listed under flags & services.
The odd thing is I can advertise as a temperature gauge - but it's entirely possible I'm making mistakes.
This is my code:
Temperate correctly shows as 30c (in nRF connect), but the heart_rate is missing.
Any ideas/help?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions