mbed OS for the nrf51822

A project log for Bluetooth Gamepad Phone Case

A bluetooth gamepad integrated into a phone case.

MaaveMaave 02/05/2018 at 00:160 Comments

After way too much struggling I'm abandoning nrf5 SDK in favor of mbed OS. The Nordic tutorials are sorely lacking. The example code doesn't help since I don't have in-depth knowledge of BLE packet structure. Even if I persist and get it working, the barrier to entry will make it more difficult as a community project: harder to maintain, contribute to, or fork. Meanwhile mbed OS supports the nrf51822 and is MUCH easier. 

I was tuned-in thanks to this project, which code-wise is doing exactly what I need.
it's using mbed to simplify everything and a BLE_HID library

Starting a project:

-sign up for
-new project
-when it asks for a board, follow the link, find "nrf51822" which is 16k (use the BLE checkbox in the filters on the left)
-click, add
-create a new test project. My template was BLE_Button, you can use whatever you want
-hit Compile. It'll compile (rather quickly!) and provide a flashable .hex file
-download the file, load and run it with gdb
it works!

Importing the BLE HID library
-click Import
-Libraries tab
-search "BLE"
-find "BLE_HID", double click to import into project

bam done, start coding. Code samples for the BLE HID can be found on github: 

So far I've only used mbed's online IDE and compiler. It's not mind blowing but it's better than Notepad. There is a project gcc4mbed which I can try later with Eclipse, but right now my focus is on getting a prototype.

There are a few versions of mbed OS availble right now. The 16k nrf51822 chips require mbed OS 2 (mbed classic) due to limited RAM. I don't think it will impact the project at all, it seems like the latest OS features are intended for networked/IoT applications. mbed classic has plenty of features and has already simplified my job.

Ozan's arcade controller code is already working but I'm going to try rewriting it from scratch so that

a) I learn C++,mbed, and the HID library

b) I can license the code myself (instead of being a derivative of ARM Ltd's Apache-licensed code)

The code is so straight-forward that I can't reasonably re-write it. I'll just make it a derivative work.

Onward to victory!