Skip to content

BLE Central examples for nRF51 #166

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

Closed
netkruzer opened this issue Jun 10, 2017 · 18 comments
Closed

BLE Central examples for nRF51 #166

netkruzer opened this issue Jun 10, 2017 · 18 comments

Comments

@netkruzer
Copy link

I see that nRF51 chips support Central and Peripheral modes in SoftDevice 130 v2.0.1 but I don't see any examples for a Central/Master BLE device that can connect to other nRF51 or nRF52 chips.

Does anyone have an example for BLE Central to scan and connect to other devices?

@S3ler
Copy link

S3ler commented Jun 13, 2017

I am very interested in such an example, too.
Unfortunately I could not find any arduino-BLECentral library or similiar.
But:

All the relevant Nordic SoftDevice (S110, S130, S132) header files are included build path when a SoftDevice is selected

So it should be possible to use one of Nordic Semiconductor's central device examples as a starting point.

@netkruzer
Copy link
Author

Are you just able to run Nordic examples directly from the Arduino IDE without​ modification?

I need to give that a try.

@S3ler
Copy link

S3ler commented Jun 14, 2017

Today I tried to run the Nordic example directly from the Arduino IDE and my result is:
Runs without modification? Clearly not! The examples use a lot of files from Nordic's SDK not included in the core/nRF5/SDK/components/softdevice/s130/headers folder. I even tried to build my own Arduino library including these files, but I could not make it work.

Now I am trying to build a Simple BLE Scanner example based on the Heart Rate Monitor example from the nRF5 SDK 12.3.0

I will update my comment when I have new results.

Update: The problem seems to remain the same - you somehow have to include most of the Nordic's SDK files. Maybe it is easier to use RedBearLab's Central Device example for their RedBear Nanos or arduino-BLEPeriphal as a starting point for solution.

The RedBearLab's project contains a lot of Nordic's SDK and uses SoftDevice S130.

@dlabun
Copy link
Collaborator

dlabun commented Jun 15, 2017

As far as I know Sandeep has not built a Central / Master version of his BLE library. This core is really only intended to get the basic features like SPI and I2C working, the Bluetooth master or ANT capabilities still require you to build your own library.

@S3ler
Copy link

S3ler commented Jun 15, 2017

Ok, i tried to insert Nordic's SDK into the sandeepmistry/arduino-nRF5 repository.

But now I am really stuck, I get the compilation error:

In file included from ~/.arduino15/packages/sandeepmistry/hardware/nRF5/0.3.0/cores/nRF5/SDK/components/libraries/atomic_fifo/app_atfifo.c:41:0:
~/.arduino15/packages/sandeepmistry/hardware/nRF5/0.3.0/cores/nRF5/SDK/components/libraries/atomic_fifo/app_atfifo_internal.h:61:9: note: #pragma message: value of __CORTEX_M: (0x00U)
 #pragma message "value of __CORTEX_M: " STR(__CORTEX_M)
         ^
~/.arduino15/packages/sandeepmistry/hardware/nRF5/0.3.0/cores/nRF5/SDK/components/libraries/atomic_fifo/app_atfifo_internal.h:62:2: error: #error Unsupported core version
 #error Unsupported core version
  ^
exit status 1

There are multiple checks like this:

#if ((__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)) == 0
#error Unsupported core version
#endif

But I do not have a clue how to improve the __CORTEX_M value. I am sure it is related with the gcc-arm-none-eabi toolchain an the -mcpu=cortex-m0 compile flag.

Update: Ok the big problem is: all files on the SDK/components are included and build. Many of these files are not needed and not buildable without proper definitions and the right file includes.
My solution including everything tries to build the source-files which are only for the nRF52 too.
This creates too many compilation error.

@dlabun
Copy link
Collaborator

dlabun commented Jun 17, 2017

This core is using an older version of the Nordic SDK, it's either 9 or 10... I am not 100% of the version but it's definitely not compatible with SDK v12.

@sandeepmistry
Copy link
Owner

This should be possible with the older S130/S132 SoftDevice. There's some discussion on scanning here sandeepmistry/arduino-BLEPeripheral#155 with @floe.

It would be nicer to see a NordicBLE library made that has the same API as the Arduino 101's CurieBLE: https://github.com/01org/corelibs-arduino101/tree/master/libraries/CurieBLE

@S3ler
Copy link

S3ler commented Jun 18, 2017

I have now an overview over the Nordic SDK and used Eclipse CDT including a ST-Link V2 to program my Waveshare BLE400 board.
@dlabun Can we move to Nordic SDK version 12.3.0? This includes Softdevice S130 and is the last Nordic SDK version supporting nRF51822 (see release notes), so there should not be further core migrations in the future?
@sandeepmistry Thank you for these links i will take a deeper look into them, especially the CureBLE API. Would you be ok with adding Nordic's SDK into the project (directly within git or via post install download script)?
If yes: I can think of writing a wrapper around Nordic's SDK with the same API as CurieBLE.

Give me your opinions on my idea.

@sandeepmistry
Copy link
Owner

@S3ler

Can we move to Nordic SDK version 12.3.0? This includes Softdevice S130 and is the last Nordic SDK version supporting nRF51822 (see release notes), so there should not be further core migrations in the future?

Please submit a pull request to do so.

Would you be ok with adding Nordic's SDK into the project (directly within git or via post install download script)?

I don't think it is really needed, plus it has a non-open source license.

@dmikhalsky
Copy link

CentralRole support was added in arduino.org's fork of the library
https://github.com/arduino-org/arduino-core-nrf52/blob/master/libraries/BLE/examples/Central/

@kriswiner
Copy link

Is someone planning to add the BLECentral component to Mistry's Arduino core so that we can use it just like we use BLEPeripheral? Not sure how to do this myself. Or maybe this is straightforward to use as is. I tried but had a lot of compile errors, etc. just from the fact I have no idea what I am doing.

Anyway, I would love to be able to use the central role examples in the Primo version of the nRF52 core with the core reposited here (which works for my custom nRF52 boards) if some knowledgeable person could explain how to do so. Thanks.

@dmikhalsky
Copy link

I am totally with you on that. I tried many different approaches but nothing worked so it seems some cde alterations are needed.
As I can see. Primo's fork relies heavily on Nordic SDK

@dlabun
Copy link
Collaborator

dlabun commented Sep 20, 2017

There was a pretty big discussion about this months ago (last year maybe?) and it was decided not to add BLE support directly to the core. Personally, I am not working on anything BLE related because I am working with the ANT related features.

@dmikhalsky
Copy link

Will ANT implementation include Central role or whatever it's called in ANT specification?

@dlabun
Copy link
Collaborator

dlabun commented Sep 20, 2017

Using ANT requires a license from Garmin so I won't be publishing my code related to ANT.

@kriswiner
Copy link

kriswiner commented Sep 20, 2017 via email

@dlabun
Copy link
Collaborator

dlabun commented Sep 3, 2018

Closing due to lack of activity

@dlabun dlabun closed this as completed Sep 3, 2018
@TrailBee47
Copy link

last time I used nrf51 as central I used redbear labs library may be one can try that I will see if I could do it. with Sandeep's core. it has same nrf51 support and ble examples for central. https://github.com/RedBearLab/nRF51822-Arduino/tree/S130/arduino-1.6.x/hardware/RBL/RBL_nRF51822/libraries/BLE_Examples/examples/BLE_CentralTest

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

No branches or pull requests

7 participants