Skip to content

Add support for Adafruit Feather M0 Bluefruit LE to StandardFirmataBLE #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 15, 2018

Conversation

cstawarz
Copy link
Contributor

These changes add support for the Adafruit Feather M0 Bluefruit LE board to StandardFirmataBLE. They should also work with other Bluefruit LE boards/modules that communicate with the nRF51822 via SPI, although I've only tested the Feather M0. The changes require a few small modifications to the Adafruit BluefruitLE nRF51 package (pull request: adafruit/Adafruit_BluefruitLE_nRF51#43).

I also moved the configuration of the BLE connection and flush intervals to bleConfig.h and updated the connection interval values for the Arduino 101 (which, as of Intel Curie Boards package v2.0.2, must be given in units of milliseconds, not 1.25ms).

I tested the changes on both an Arduino 101 and a Feather M0 Bluefruit LE.

These are hardware-specific settings, so they don't belong with the hardware-agnostic code in StandardFirmataBLE.ino.  For Arduino 101, specify connection intervals in milliseconds, as expected by BLEPeripheral::setConnectionInterval in Intel Curie Boards package v2.0.2.
…ly other Bluefruit LE boards/modules that communicate with the nRF51822 via SPI) to StandardFirmataBLE
@soundanalogous
Copy link
Member

Thanks! I'll try to find time to look at this more closely over the weekend.

@@ -772,14 +768,7 @@ void setup()
Firmata.attach(START_SYSEX, sysexCallback);
Firmata.attach(SYSTEM_RESET, systemResetCallback);

stream.setLocalName(FIRMATA_BLE_LOCAL_NAME);
Copy link
Member

@soundanalogous soundanalogous Mar 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can live with this change, but the reason I used these setters initially was to avoid tightly coupling defines in bleConfig.h with the BLE stream classes. The only reason your change here works is all the code in BLEStream is in the header file, otherwise BLEStream would have been precompiled and the defines in bleConfig.h would not be available due to the weird way the Arduino linker works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I was trying to simplify things, but I didn't consider this issue. I'll add the setters back.

@soundanalogous
Copy link
Member

Overall LGTM, I had one comment about removal of some setters.

@soundanalogous
Copy link
Member

I think you may also need to add the Adafruit Feather M0 Bluefruit LE to Boards.h unless it's pin compatible with an existing M0 board already defined (my hunch is that it is not).

* Test script: https://gist.github.com/soundanalogous/927360b797574ed50e27
*/
#ifdef _VARIANT_ARDUINO_101_X_
// After conversion to units of 1.25ms, both values must be between
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove all the comments here since the user doesn't need to be concerned with the conversion anymore. I'd just update the comments on lines 34 and 35 to say // 8ms and // 30ms like you did for the Bluefruit configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's still useful to know that, under the hood, the values are converted to multiples of 1.25ms -- if only to explain why using the value 8 actually gets you an interval of 7.5ms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sgtm

@cstawarz
Copy link
Contributor Author

cstawarz commented Apr 4, 2018

I think you may also need to add the Adafruit Feather M0 Bluefruit LE to Boards.h unless it's pin compatible with an existing M0 board already defined

The Feather M0 masquerades as an Arduino Zero. Its variant.h even defines _VARIANT_ARDUINO_ZERO_. This appears warranted, as the pin mappings look to be identical to the Zero's.

The only difference I see is that the Feather has two more analog inputs (A6 and A7). However, those inputs don't follow the digital_pin=analog_pin+14 numbering that A0-A5 do, and the analogInputToDigitalPin macro defined in variant.h doesn't handle them. Personally, I'm OK with ignoring them.

@cstawarz
Copy link
Contributor Author

This should be good to go now. Thanks!

@soundanalogous
Copy link
Member

Ok, I'll confirm on my Arduino 101 just to make sure there were no unexpected regressions.

@soundanalogous soundanalogous merged commit 240e564 into firmata:master Apr 15, 2018
@cstawarz cstawarz deleted the bluefruit_le_spi branch April 23, 2018 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants