The next release of the community beaglebone BSP gets a Windows Embedded Compact 2013 image along with an Internet of Things (IoT) sample code using the M2MQTT library. The WEC2013 demo image on Codeplex now includes the M2MQTT client library built in. To show a real world IoT working example I have included a Visual Studio 2013 sample project.

The Internet of Things has been getting a lot of press lately, but at its core it just remote communication with a network enabled device. Something we in the embedded world have been doing for years. It seems the marketing people just love to invent new terms for the same old things (SoT). I say this tongue-in-cheek of course, IoT can be much more and I am sure we will be hearing more in the months and years to come.

So to use the sample do the following:

  • Download the WEC2013 beaglebone release.
  • Prepare the uSD card (see documentation on the Codeplex site)
  • Make sure the WEC2013 Application Builder plugin is installed on your Visual Studio 2013 hosted machine.
  • Install the WEC2013 Beaglebone SDK included in the release package.
  • Install the sample in your VS2013 projects folder.
  • Build all projects in the sample solution.

Several things to note. First, the client side M2MQTT library is already preinstalled (see MQTT Client library component for Windows Embedded Compact) in the demo image so you only need a reference to the assembly in the device’s project. I have included the assembly (M2Mqtt.dll) in a subdirectory under the SDK’s install path. This is typically C:\Program Files\Windows CE Tools\SDKs\WEC2013 Beaglebone SDK\Managedreference but may be slightly different on your machine. You should set the “Copy Local” property for this reference to False, again, because it is already installed.

Second, you may need to tweak the configuration files (M2MQTT_test.cfg.xml in the device project and/or the App.config in the desktop project) to point to the M2MQTT’s network “broker”. The broker code is included (see https://mqttbroker.codeplex.com/) and can be run locally on the device, the desktop or any other node on the network. To keep it simple I would suggest running the broker on the device along with the sample app. I have included both projects to build the broker targeting the desktop using the full framework or the device using the Compact Framework 3.9.

Third, to debug on the device side you need to initially run the “conmanclient3.exe” app on the device to allow Visual Studio’s debugger to attach to the device over Ethernet and to allow download.

After everything is debugged you can actually place the M2MQTT_test.cfg.xml,M2MQTT_test.exe,GnatMQ.dll and MqttBrokerServerNetCf39.exe files in a \Startup folder on the uSD card to have everything execute on power up. Any .exe or .bat file found in the StartUp folder will automatically launch on start up.

Now lets break down the application. The goal was to show how the M2MQTT messaging protocol uses the TCP/IP transport to transfer data. To that end I selected several data types that simulate various sensor data from the device and commands sent from the PC host. The commands I use control the leds on the Beaglebone so we have immediate visual feedback. We can command the leds to turn on, off or to blink.remotely. In the real world the same I/O could be used to control relays, turning fans on or off, or what ever you can dream of. To simulate sensor data produced by the device and consumed by the PC, I use a simple elapsed timer. The timer starts running at program start up and can be reset at any time ether locally or remotely.

The device’s UI and the controlling PC’s UI is designed to look the same so it doesn’t matter if the user is interacting with the device locally, remotely from the other side of the building or on the other side of the world, the experience is the same.

 

Device UI:

M2MDEVICE  

 

Desktop UI:

M2MDesktop