This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Arduino encryption nRF51822

Hi there!

I use RedBearLabs Nano (nRF51822) for at setup where I've developed BLE code in Arduino to communicate with apps on both iOS and Android.

Now I need to ensure the communication with encryption.

I've read these to threads for encrypting stuff with nRF51822:

devzone.nordicsemi.com/.../ devzone.nordicsemi.com/.../

I'm not sure how to use your C-based SDK from the Arduino environment - can you please enlighten me?

If this is not possible or advisable, can you please tell me which environment you'll recommend for OSX? I've looked at both mbed, CrossStudio for ARM and tried to use the stand alone GCC compiler (so far no luck - I seem to be missing the make files from the SDK 9 download). But no options is as easy to use as Arduino.

Or perhaps Bluetooth Developer Studio Beta is the way forward (and where do I get my hands on that)?

Looking forward to hearing your reply, hoping that you can tell me that using your SDK from Arduino is easy! :)

Best regards, Henrik, Denmark

Files in folder: /sdk9/examples/peripheral/blinky/pca10028/blank/armgcc: image description

hrs.hex

Parents
  • If you want to encrypt all traffic, you may want to use Bluetooth Low Energy's "Bonding" mechanism. Typically bonded devices exchange encryption keys on their first connection (creating the "bond" between devices). Successive connections use these keys to encrypt traffic. It looks like there is support for Bonding from Red Bear Labs. You may just have to increase the security level on a single characteristic (via the requireSecurity() method with an argument like SECURITY_MODE_ENCRYPTION_NO_MITM). When you try to access that characteristic you will create a bonding request (your mobile device will probably pop up a dialog asking if you want to Pair with the device). Note that the bonding request only happens once unless you go into your mobile devices settings and erase it.

    The Bluetooth Developer Studio Beta may not be what you need (yet). It allows you to build services in a GUI and then export them to Nordic's C-based API (rather than doing all the details programmatically). You have to be a Bluetooth SIG member to get access, but it's available at the free level of membership. I think the Developer Studio will drastically improve the creation and documentation of new services. It will also improve development time (by avoiding simple programming errors). The last time I tried it, it just wasn't quite ready for regular use.

Reply
  • If you want to encrypt all traffic, you may want to use Bluetooth Low Energy's "Bonding" mechanism. Typically bonded devices exchange encryption keys on their first connection (creating the "bond" between devices). Successive connections use these keys to encrypt traffic. It looks like there is support for Bonding from Red Bear Labs. You may just have to increase the security level on a single characteristic (via the requireSecurity() method with an argument like SECURITY_MODE_ENCRYPTION_NO_MITM). When you try to access that characteristic you will create a bonding request (your mobile device will probably pop up a dialog asking if you want to Pair with the device). Note that the bonding request only happens once unless you go into your mobile devices settings and erase it.

    The Bluetooth Developer Studio Beta may not be what you need (yet). It allows you to build services in a GUI and then export them to Nordic's C-based API (rather than doing all the details programmatically). You have to be a Bluetooth SIG member to get access, but it's available at the free level of membership. I think the Developer Studio will drastically improve the creation and documentation of new services. It will also improve development time (by avoiding simple programming errors). The last time I tried it, it just wasn't quite ready for regular use.

Children
  • Thanks for your replies, I'll work a bit longer with it and revert.

    Until then:

    @hungbui, It's been a long while since I did any "real" C programming. I looked for the Makefiles in the example project folders themselves, but didn't see any. I'll try it once more, and revert!

    @bsiever, OK I'll forget Bluetooth Developer Studio for now. I tried once to include the nRF API in Arduino but with no luck. The code simply didn't compile. It'd be really helpful if someone had a sample project or step-by-step guide on how to use a C-based SDK like nRF51822 together with the Arduino tool - for newbies like me!?

    Best, Henrik

  • @Henrik: Next time please reply as comment under the answers, don't create separate answer, because "answer" should be used as the answer for the question you ask, not as the reply to others.

    Could you take a screenshot of an nRF51 SDK v9.0 example folder and update it to your question ? For example screenshot of this folder \examples\peripheral\blinky\pca10028\blank\armgcc ?

  • @hungbui - got it, updated the question with a screendump. I thought PCA10028 was a specific board, but that isn't so?

    I if somehow can build/use the SDK as a library with Arduino (www.arduino.cc/.../libraries) it'd be perfect! :)

  • As you can see in your screenshot, the makefile is there. Yes the PCA10028 is a specific board, but it has the same nF51822 chip as on the Redbearlab module. So you need to modify the GPIO pin to match with your board. In addition, the chip on the RedBearLab could be a different variant, which has only 16kB RAM when the one on the PCA10028 has 32kB RAM. You need to modify IRAM1 to match with the smaller size of RAM.

  • Hi @hungbui - my blinky_gcc_nrf51.ld file looks like this now:

    /* START */ SEARCH_DIR(.) GROUP(-lgcc -lc -lnosys)

    MEMORY { FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 }

    INCLUDE "gcc_nrf51_common.ld" /* END */

    1: I've changed the RAM size to 16KB, but I'm not sure if the Origin(s) are correctly set?

    2: Futhermore I'm not sure where to set the GPIO pin?

    3: Thirdly, the folder content from SDK 9 seem much different from the guide found here: redbearlab.com/nrf51822-sdk, perhaps the guide isn't at all usable with nRF SDK 9.x?

    I managed to build the HRS and merge it with s110_softdevice.hex using srec_cat tool. The resulting hrs.hex file results in a fail.txt containing "SWD ERROR". Nothing much to follow :-( The compiled hrs.hex is attached to my initial question.

Related