|Contents of the BLE112 development kit.|
I recently started working on Bluetooth 4.0 development, or Bluetooth Low Energy (BLE from now on), and started doing so with BlueGiga's turnkey module and its Developer's Kit, the BLEDK112. There are a ton of options out there and if you're interested head on to this blog post to get started, you'll get an idea of what you can get and the overall feel of the road; this guy has taken the time to write and keep a great post alive and I'm very grateful since its already helped me plenty and inspired me to write this. You should know most of this solutions work on Texas Instruments's CC2540 bluetooth smart single mode module, one that, while empirical and supplied with maybe the best technical support, requires a development environment that goes for roughly 1500€ a piece, if you wanted to develop any serious application on it. It should also be noted that the CC2540 is only a transceiver with a MCU while turnkey modules already have an antenna and some other cool stuff.
The purpose of this post is to get whoever has purchased one of BlueGiga's DKs started and manage to compile your own code, I've found that the documentation, while some of the best available in comparison to the rest, falls short at times. So on to the point. What you'll need in order to get started, aside from the DK obviously:
- TI's SmartRF Flassh Programmer.
- Technical documentation available at BlueGiga's website, specially the BGScript developer's guide.
- Software pack available at BlueGiga's website, containing the compiler, a PC application to control your USB bluetooth dongle, a host of already compiled examples and more.
|blegui2 software. It will help you control your USB dongle.|
One of the main drawbacks of using BG's kit is the need to use their somewhat lacking proprietary script, the BGScript; but it might as well be one of the biggest highlights, since it's the only thing standing between you and having to fork over a truckload of cash for TI's IAR Embedded Workstation.
From the software pack you'll be able to get several examples and use them along with the blegui2.exe program, available in the bin folder, which uses the dongle to discover and connect with your test board. This is nice for starters, to see the thing working.
When it turns nasty is when you try to write your own code, so far I've only written a simple hello world-like code but what was actually painstaking was to get it compiled and into your board. Nowhere does it say, or at least I failed to find it, how to compile or what files you need. If you look closely into the example folders you'll notice some .xml files, and the .bgs script. What I would suggest is copying a set of these files onto a different folder and overwriting the .bgs script.
A quick run down of the .xml files:
- hardware.xml: Define which hardware units, like the GPIOs, the timer clock and such, your script will use. Example programs in the developer's guide will help you figure out how to use this file.
- attributes.xml: Define constants here.
- gatt.xml: Usage profiles can be defined here, there's documentation on that but I haven't checked it out yet.
- cdc.xml: Not sure what this does but it's related to the USB dongle.
- project.xml: This, I take it, is sort of like a C makefile. If you open it you'll notice it mentions all the other files, including the .bgs source code. Make sure it all adds up.
If you're on Windows, as I am, you'll need to either add the bgbuild executable to your %PATH%, which is rather flaky since you'll have to add most of the other files in the bin folder and the api folder, I wouldn't recommend this since it works almost as often as it does not, or just copy the contents of your project folder to the bin folder of the software pack and then open a command window into it and write the following command:
bgbuild.exe project.xml out.hex
Afterwards all you need to do is connect the CC debugger to your test board like this:
Open TI's SmartRF Flash Programmer and browse your file system for the recently generated out.hex. Click "Perform Action" and you're done.
To test it out open blegui2 with your USB dongle connected, click attach once it turns up and then start. To the right you should see your test board with its SSID, MAC address, Tx power and some other stats; connect to it and you can check whatever services you've got running.
I hope this was helpful and keep in mind I'm still new at this, both BLE and blogging, any comments or constructive criticism will be considered.