BLE-Shield goes NetDuino2

Hello everyone,

as promised I tested the BLE-Shield with NetDuino2. As expected the Shields worked without any big problems on this platform as well. I spent about an hour with @tamberg to get my initial code cleaned up and he and Etan Kissling showed my how clean C# code as to look like 🙂 Finally I added an additional folder called “netmf” to my BLE-Shield github repository where you can now find a complete Microsoft Visual C# 2010 Express project which has been tested with a NetDuino2 board running .NET Micro Framework SDK v4.2.

The complete code is not longer than the code snipped shown below:

using System;
using System.IO.Ports;
using System.Text;
using System.Threading;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware.Netduino;

public class Program
    public static void Main()
        Debug.Print("BLE Shield");
        var port = SerialPorts.COM1; // using D0 & D1         
        //var port = SerialPorts.COM2; // using D2 & D3         
        var bleShield = new SerialPort(port, 19200, 
            Parity.None, 8, StopBits.None);

        bleShield.DataReceived += (sender, args) =>         
            var receiveBuffer = new byte[16];
            int bytesReceived = bleShield.Read(receiveBuffer, 0,

            if (bytesReceived > 0) {                 
                Debug.Print("Bytes received: " + bytesReceived);                 
                Debug.Print(new String
        while (true) {             
            var random = new Random();             
            var sendBuffer = new byte[4];             
            bleShield.Write(sendBuffer, 0, sendBuffer.Length);             
Please contact me if you encounter any problems of have some comment regarding C#. Please keep in mind that this is my first C# app.