You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by Huynh Minh Quang <qu...@vng.com.vn.INVALID> on 2016/02/19 04:10:44 UTC
[BLE] Questions about BLE on Apache Mynewt
Dear Sir/Madam,
First, I see that Apache Mynewt is the excellent RTOS and I would like
to use Apache Mynewt for my BLE module using Nordict NRF51822 IC (this
already working with mbed contribution). So, I wonder where can I find
the documentation, user manual, tool-chain, complier or something like
that to developer my module with Mynewt. Can you help me to figure out
what I have to do?
Sorry about my languages, I'm not an native speaker.
Thanks and best regards,
Quang Huynh Minh
Re: [BLE] Questions about BLE on Apache Mynewt
Posted by Sterling Hughes <st...@apache.org>.
Hi Quang,
No problem, that's exciting!
Documentation on Mynewt is located here:
http://mynewt.incubator.apache.org/documentation/
It's good that you're working on the Nordic platform, we've spent a lot
of time supporting that chip.
We are currently in the middle of our first beta -- if you are looking
to adopt, I would say it's probably best to get started next Monday /
Tuesday, as we'll be revving the documentation between now and then to
reflect some of the changes. I've also attached some preliminary
instructions on how to use the Nordic chipsets.
If you have any questions or comments while you're trying to get Mynewt
up & running: don't hesitate to ask the list. We'll find the feedback
very useful, and help debug any issues you have.
Best,
Sterling
STEPS:
# 1. Create the "mynewt" directory in your home directory.
[ccollins@ccollins-mac:~]$ mkdir ~/mynewt
# 2. Grab the larva repository from the apache server.
[ccollins@ccollins-mac:~]$ cd ~/mynewt
[ccollins@ccollins-mac:~/mynewt]$ git clone
https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva.git larva
Cloning into 'larva'...
remote: Counting objects: 14729, done.
remote: Compressing objects: 100% (4408/4408), done.
remote: Total 14729 (delta 8765), reused 14556 (delta 8620)
Receiving objects: 100% (14729/14729), 3.83 MiB | 4.22 MiB/s, done.
Resolving deltas: 100% (8765/8765), done.
Checking connectivity... done.
[ccollins@ccollins-mac:~/mynewt]$ cd larva
[ccollins@ccollins-mac:~/mynewt/larva]$
# 3. Create some required newt targets by running the attached
# "create-targets.sh" script (this step assumes the script is in the
# current directory).
[ccollins@ccollins-mac:~/mynewt/larva]$ ./create-targets.sh
Creating target bleprph-nrf51-16kbram
Target bleprph-nrf51-16kbram successfully created!
Target bleprph-nrf51-16kbram successfully set arch to cortex_m0
Target bleprph-nrf51-16kbram successfully set bsp to hw/bsp/nrf51dk
Target bleprph-nrf51-16kbram successfully set compiler to
arm-none-eabi-m0
Target bleprph-nrf51-16kbram successfully set project to bleprph
Target bleprph-nrf51-16kbram successfully set compiler_def to debug
Target bleprph-nrf51-16kbram successfully set cflags to
-DNIMBLE_OPT_ROLE_CENTRAL=0 -DNIMBLE_OPT_ROLE_OBSERVER=0
-DNIMBLE_OPT_GATT_DISC_ALL_DSCS=0 -DNIMBLE_OPT_GATT_READ=0
-DNIMBLE_OPT_GATT_READ_UUID=0 -DNIMBLE_OPT_GATT_READ_LONG=0
-DNIMBLE_OPT_GATT_READ_MULT=0 -DNIMBLE_OPT_GATT_WRITE_NO_RSP=0
-DNIMBLE_OPT_GATT_SIGNED_WRITE=0 -DNIMBLE_OPT_GATT_WRITE=0
-DNIMBLE_OPT_GATT_WRITE_LONG=0 -DNIMBLE_OPT_GATT_WRITE_RELIABLE=0
Creating target bletiny-nrf51-16kbram
Target bletiny-nrf51-16kbram successfully created!
Target bletiny-nrf51-16kbram successfully set arch to cortex_m0
Target bletiny-nrf51-16kbram successfully set bsp to
hw/bsp/nrf51dk-16kbram
Target bletiny-nrf51-16kbram successfully set compiler to
arm-none-eabi-m0
Target bletiny-nrf51-16kbram successfully set project to bletiny
Target bletiny-nrf51-16kbram successfully set compiler_def to debug
Target bletiny-nrf51-16kbram successfully set cflags to
-DNIMBLE_OPT_ROLE_CENTRAL=0 -DNIMBLE_OPT_ROLE_OBSERVER=0
-DNIMBLE_OPT_GATT_DISC_ALL_DSCS=0 -DNIMBLE_OPT_GATT_READ=0
-DNIMBLE_OPT_GATT_READ_UUID=0 -DNIMBLE_OPT_GATT_READ_LONG=0
-DNIMBLE_OPT_GATT_READ_MULT=0 -DNIMBLE_OPT_GATT_WRITE_NO_RSP=0
-DNIMBLE_OPT_GATT_SIGNED_WRITE=0 -DNIMBLE_OPT_GATT_WRITE=0
-DNIMBLE_OPT_GATT_WRITE_LONG=0 -DNIMBLE_OPT_GATT_WRITE_RELIABLE=0
Creating target boot-nrf51-16kbram
Target boot-nrf51-16kbram successfully created!
Target boot-nrf51-16kbram successfully set arch to cortex_m0
Target boot-nrf51-16kbram successfully set bsp to
hw/bsp/nrf51dk-16kbram
Target boot-nrf51-16kbram successfully set compiler to
arm-none-eabi-m0
Target boot-nrf51-16kbram successfully set project to boot
Target boot-nrf51-16kbram successfully set compiler_def to
optimized
# 4. Now you should have four newt targets (bin2img,
# bleprph-nrf51-16kbram, bletiny-nrf51-16kbram, and boot-nrf51-16kbram).
# Make sure they are all there.
[ccollins@ccollins-mac:~/mynewt/larva]$ newt target show
bin2img
arch=sim
bsp=hw/bsp/native
compiler=sim
compiler_def=debug
name=bin2img
project=bin2img
bleprph-nrf51-16kbram
arch=cortex_m0
bsp=hw/bsp/nrf51dk
cflags=-DNIMBLE_OPT_ROLE_CENTRAL=0
-DNIMBLE_OPT_ROLE_OBSERVER=0 -DNIMBLE_OPT_GATT_DISC_ALL_DSCS=0
-DNIMBLE_OPT_GATT_READ=0 -DNIMBLE_OPT_GATT_READ_UUID=0
-DNIMBLE_OPT_GATT_READ_LONG=0 -DNIMBLE_OPT_GATT_READ_MULT=0
-DNIMBLE_OPT_GATT_WRITE_NO_RSP=0 -DNIMBLE_OPT_GATT_SIGNED_WRITE=0
-DNIMBLE_OPT_GATT_WRITE=0 -DNIMBLE_OPT_GATT_WRITE_LONG=0
-DNIMBLE_OPT_GATT_WRITE_RELIABLE=0
compiler=arm-none-eabi-m0
compiler_def=debug
name=bleprph-nrf51-16kbram
project=bleprph
bletiny-nrf51-16kbram
arch=cortex_m0
bsp=hw/bsp/nrf51dk-16kbram
cflags=-DNIMBLE_OPT_ROLE_CENTRAL=0
-DNIMBLE_OPT_ROLE_OBSERVER=0 -DNIMBLE_OPT_GATT_DISC_ALL_DSCS=0
-DNIMBLE_OPT_GATT_READ=0 -DNIMBLE_OPT_GATT_READ_UUID=0
-DNIMBLE_OPT_GATT_READ_LONG=0 -DNIMBLE_OPT_GATT_READ_MULT=0
-DNIMBLE_OPT_GATT_WRITE_NO_RSP=0 -DNIMBLE_OPT_GATT_SIGNED_WRITE=0
-DNIMBLE_OPT_GATT_WRITE=0 -DNIMBLE_OPT_GATT_WRITE_LONG=0
-DNIMBLE_OPT_GATT_WRITE_RELIABLE=0
compiler=arm-none-eabi-m0
compiler_def=debug
name=bletiny-nrf51-16kbram
project=bletiny
boot-nrf51-16kbram
arch=cortex_m0
bsp=hw/bsp/nrf51dk-16kbram
compiler=arm-none-eabi-m0
compiler_def=optimized
name=boot-nrf51-16kbram
project=boot
# 5. Build the bin2img utility.
[ccollins@ccollins-mac:~/mynewt/larva]$ newt target build bin2img
Building target bin2img (project = bin2img)
[compiler-output...]
Successfully run!
# 6. Build the bootloader.
[ccollins@ccollins-mac:~/mynewt/larva]$ newt target build
boot-nrf51-16kbram
Building target boot-nrf51-16kbram (project = boot)
[compiler-output...]
Successfully run!
# 7. Build the bleprph-nrf51-16kbram target.
[ccollins@ccollins-mac:~/mynewt/larva]$ newt target build
bleprph-nrf51-16kbram
Building target bleprph-nrf51-16kbram (project = bleprph)
[compiler-output...]
Successfully run!
# 8. Plug a USB cable (or similar) into your nRF51 board to gain access
# to the debugger.
# 9. Upload the boot loader to your board.
[ccollins@ccollins-mac:~/mynewt/larva]$ newt target download
boot-nrf51-16kbram
Downloading with
/Users/ccollins/mynewt/larva/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
# 10. Upload the bleprph application to your board.
[ccollins@ccollins-mac:~/mynewt/larva]$ newt target download
bleprph-nrf51-16kbram
Downloading with
/Users/ccollins/mynewt/larva/hw/bsp/nrf51dk/nrf51dk_download.sh
# 11. Reset your board; it should now be advertising with a BD address
# of 0a:0a:0a:0a:0a:0a and a name of "nimble-bleprph".
You can now connect to your device with a BLE central. A good mac OS X
application for doing this is LightBlue
(https://itunes.apple.com/us/app/lightblue/id639944780?mt=12). However,
see the first note in the "notes" section below before trying this.
The other application (bletiny) also turns your board into a BLE
peripheral, but it offers more control. To use bletiny, repeat steps 7
and 10 above, but substitute bletiny-nrf51-16kbram as the target name.
Bletiny commands are entered via a serial port on the board. For a list
of bletiny commands, see:
https://issues.apache.org/jira/browse/MYNEWT-21?focusedCommentId=15143463&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15143463
NOTES:
1. Some Apple BLE software has a bug in it which causes an immediate
disconnect. To use the nimble stack with LightBlue (and perhaps other
Apple products), you will need to disable the BLE 4.2 data length
extension feature in the nimble stack. You can do this by changing the
following line at the top of net/nimble/controller/src/ble_ll.c from:
#define BLE_LL_CFG_FEAT_DATA_LEN_EXT
To:
#undef BLE_LL_CFG_FEAT_DATA_LEN_EXT
After making this change, you will need to rebuild bleprph and upload it
to your board again (steps 7 and 10).
2. The newt tool uses bin2img internally for generating images. You
only have to build bin2img once.
3. You only need to build and upload the boot loader once, even if you make
modifications to the application code.
4. By default, the bleprph and bletiny applications support the
following three services:
* GAP (0x1800)
* GATT (0x1801)
* Alert Notification (0x1811)
To view or modify the supported services, see one of the following files
(depending on which application you wish to run):
* project/bleprph/src/gatt_svr.c
* project/bletiny/src/periph.c
On 2/18/16 7:10 PM, Huynh Minh Quang wrote:
> Dear Sir/Madam,
> First, I see that Apache Mynewt is the excellent RTOS and I would like
> to use Apache Mynewt for my BLE module using Nordict NRF51822 IC (this
> already working with mbed contribution). So, I wonder where can I find
> the documentation, user manual, tool-chain, complier or something like
> that to developer my module with Mynewt. Can you help me to figure out
> what I have to do?
> Sorry about my languages, I'm not an native speaker.
>
> Thanks and best regards,
> Quang Huynh Minh
>