So to get BLE running we need the following:
Raspberry Pi running Wheezy (Debian 7)
There’s a few different way to figure out what distribution you have. You can do:
I’m sure there are other ways. Here are the results for all 3:Inateck Bluetooth 4.0 dongle
This is the exact one I bought. Let me just say that apparently it *really* matters which one you get. It obviously has to support BLE (Bluetooth 4.0). This was specifically recommended by the Raspberry Pi people.
The bluetooth stack
This is just the standard bluetooth tools that you can install from the Wheezy repository. There may be some version issues that I try to address below.
nodejs and npm
NodeJS AKA Node, is a javascript engine that powers Bleno, which is the platform I’m planning on using to deploy BLE peripherals. These were kind of a pain to install. I go into details about that below.
bleno
Bleno is a great resource making BLE enabled apps. It does a great job at abstracting away a lot of the details into a relatively easy to use javascript driven library. It also has some examples that really help to give you a starting point for writing your own peripherals.
Here we go:
- Install the ‘bluetooth stack’ that comes with Wheezy. This was the first source of frustration. The version of bluez that shipped with Wheezy was 4.99x. The current version of bluez is 5.x, and that is what ships with Jessie. I guess there is some sort of problem with bleno due to a GATT server that is enabled by default in the 5.x version. It’s hard to tell if that was ever resolved or not by reading the conversations that went on on the Bleno site. If you are using Jessie, look into installing a lower version of Bluez.
- After all that installs, you have to make sure bluetoothd is not running. Apparently this interferes with Bleno as well. To turn it off once do: To make that persist after a reboot you have to do:
- Install nodejs and npm: https://chip.hackster.io/inmyorbit/connect-a-mobile-application-to-your-c-h-i-p-using-ble-96fe96 This just downloads the pre-built binaries and copies them into /usr/local/. The nice thing about doing it this way is if you want to try out a different version, all you have to do is find the version number you want and change it. If you do these steps again, it will just overwrite the old one. (Ref:
- Update gcc and g++ to 4.9. This is crucial and Bleno will NOT install without doing this. It was very confusing because on Jessie, the Bleno install worked right away. On Wheezy, I was getting these weird compile errors that I wasn’t getting before. I was able to track the problem down to the c++ compiler, which is outdated on Wheezy. Then I found these instructions to update it and it magically just worked (I’m not a c++ guy so it wasn’t obvious to me).
- Now you are ready to install Bleno:
- And that’s it! Now you should be able to run the Bleno test peripheral
This is what Bleno looks like on the pi (peripheral) side:
And this is what it looks like on the iOS side. When lightBlue loads, you should see a service that corresponds to your pi’s hostname:
If you tap the one with your hostname, it will discover services on your pi. You should see one service with a long UUID of all F’s ending with a number, and a bunch of Characteristics that have the same naming convention.
Then you should be able to connect to the Characteristics and get a good sense of what Bleno can do.
In my next post, I’ll describe my efforts to write my own service and characteristics.