BlueFruit52: indications?

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jevada
 
Posts: 194
Joined: Fri Dec 15, 2017 5:29 am

BlueFruit52: indications?

Post by jevada »

I am writing a Cycling Power service on an nRF52 Feather that requires a response when writing to its control point. If I understand the spec (see here) correctly, this respons basically is an indication with a response in its payload. How do I send an indication from the bluefruit library?

(Hmm... perhaps this is not the right subforum to post this question. Please move if appropriate).

User avatar
bigwheels
 
Posts: 13
Joined: Sun Dec 17, 2017 11:30 pm

Re: BlueFruit52: indications?

Post by bigwheels »

I have the Bluefruit nRF52 set up as a peripheral where I write to the peripheral from my central. I've not read any values from the nRF52, but I believe the code/commands you'll need can be found here:

API reference: https://learn.adafruit.com/bluefruit-nr ... acteristic
HRM example: https://github.com/adafruit/Adafruit_nR ... om_hrm.ino

If your central is expecting to read the value of a characteristic broadcast by the nRF52, I'd imagine you'd set the following property for your characteristic, BLECharacteristic.setProperties(CHR_PROPS_READ) and then trigger the broadcast using BLECharacteristic.read().

Or if your central is expecting to be notified of updated values, use BLECharacteristic.setProperties(CHR_PROPS_NOTIFY), and BLECharacteristic.notify()

I don't know the full code and exact syntax as I haven't done this, but the resources above should allow you to figure it out.

User avatar
jevada
 
Posts: 194
Joined: Fri Dec 15, 2017 5:29 am

Re: BlueFruit52: indications?

Post by jevada »

Thanks mate, I am aware of those pages. They do not provide information on indications.

An indication basically is a notification, but than with expecting an acknowledgement from the central. The CHR_PROPS_INDICATE attribute is known in the API, but in contrary to a BLECharacteristic::notify() method, there seems to be no BLECharacteristic::indicate() or something like that.

A control point (if I read the spec correctly) basically is a write/indicate pair. The control point can be used to execute a command on the peripheral that responds through an indication once it has excecuted the mentioned command.

For example, looking at the Cycling Power Control Point (spec here) there's an opcode 0x15 meaning "Request Factory Calibration Date". The explanation reads: "The response to this control point is Op Code 0x20 followed by the appropriate Response Value, including the value of the Factory calibration date in the Response Parameter.".

So the central writes to the control point with opcode "0x15", after which the peripheral responds by sending an indication "0x20" followed by the value of the requested calibration date. For this, we need indications, not notifications.

User avatar
bigwheels
 
Posts: 13
Joined: Sun Dec 17, 2017 11:30 pm

Re: BlueFruit52: indications?

Post by bigwheels »

yep - you're right. Indicate needed, but looks like no Indicate() in the Bluefruit library. I wonder if the adafruit guys haven't gotten to that yet, as the nRF52 is new and evolving. Check with Nordic?

User avatar
hathach
 
Posts: 1271
Joined: Tue Apr 23, 2013 1:02 am

Re: BlueFruit52: indications?

Post by hathach »

hi there,

thank you for asking the question, so far we haven't working on any service that has indicate ( so we left it until now).
We just did a quick modification to add indicate API to 0.8.x branch

https://github.com/adafruit/Adafruit_nR ... tree/0.8.x

It is mostly the same as notify() API

https://github.com/adafruit/Adafruit_nR ... tic.h#L151

Let's me know if it works for you. Once you confirm it works we will release it as 0.8.2

User avatar
jevada
 
Posts: 194
Joined: Fri Dec 15, 2017 5:29 am

Re: BlueFruit52: indications?

Post by jevada »

Thanks. I followed the recipe described in the git repo but it just kills my development environment. When done, it will no longer recognize the Feather nRF52 board at all. Is it enough to just copy ~/Adafruit_nRF52_Arduino/libraries/Bluefruit52Lib/src/BleCharacteristic.* or do I run into a lot of inconsistency problems than? I am on 0.8.1 now....

User avatar
hathach
 
Posts: 1271
Joined: Tue Apr 23, 2013 1:02 am

Re: BlueFruit52: indications?

Post by hathach »

please follow the guide to manual install BSP via git

https://learn.adafruit.com/bluefruit-nr ... sp-via-git

User avatar
jevada
 
Posts: 194
Joined: Fri Dec 15, 2017 5:29 am

Re: BlueFruit52: indications?

Post by jevada »

Allright, first impression is it works. I didn't extensively test it, so I don't know for example what happens if the respons is not ack'd but it's enough for me.

Thanks!

User avatar
hathach
 
Posts: 1271
Joined: Tue Apr 23, 2013 1:02 am

Re: BlueFruit52: indications?

Post by hathach »

Thanks, that is enough for it to be included in the next release.
We could fix bugs later (they appear anyway). Please let's everyone here know if you find one.

User avatar
jevada
 
Posts: 194
Joined: Fri Dec 15, 2017 5:29 am

Re: BlueFruit52: indications?

Post by jevada »

Will do.

In the meantime, I'm mightily impressed with the support you guys deliver! Top notch guys!

User avatar
hathach
 
Posts: 1271
Joined: Tue Apr 23, 2013 1:02 am

Re: BlueFruit52: indications?

Post by hathach »

we just release 0.8.2 with indicate API. There is also a new example to demonstrate how to use it (basically the same as notify API).

https://github.com/adafruit/Adafruit_nR ... om_htm.ino

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”