Recently I needed to interface with a Bluetooth LE device that contained a serial interface. I was already experienced with BluetoothSocket programming with serial devices, but after a quick try out with the device, I realised I had no idea of how to approach programming Bluetooth LE devices.
Rather than try and attempt the task with the device I had, which had virtually no documentation, I thought an easier route to learn BLE would be to purchase a BLE device specifically designed for developers wanting to learn BLE programming. I purchased an inexpensive Texas Instruments CC2650 SensorTag (about $US30) and proceeded to work through their documentation and other example java code I found on the internet.
The result here is not actually a tutorial, but a VS solution containing two projects demonstrating how to program the TI SensorTag. Each project contains a Word doc that describes each project, the docs also contains links to the CC2650 SensorTag documentation and links to the source code of a couple of very good BLE videos. More than enough to get any Xamarin programmer into BLE.
Both projects in the solution achieve exactly the same result, it is how they get there that is important from a Xamarin or C# point of view.
The first project – Android Weather Station is more or less a direct port of the code from the video, simply translated from Java to C#. In other words, it has a very similar style to many of the other projects you may find in monodroid-sample-master, e.g. BluetoothLeGatt. That is OK, because you have to start somewhere when converting to C#, but if you aren’t familiar with Java, the end result doesn’t look very C# like.
The second project – Xamarin Weather Station attempts to correct that, hence the name change.
Learning to program BLE devices is not a trivial task, so please follow the recommendations given in the two Word docs which hopefully may shorten your learning curve.
You can download the solution from the following link https://www.glmsoftware.com/XamarinProjects/WeatherApp.zip