Networking 101

Anyone have good resources for a total noob on networking with NetMF? Hopefully some hello-world tutorials that shed light on concepts.

I am trying to establish best practices for getting a simple network of tiny devices (using Xbee, nordic nrf24, maybe BT 4.0 in the future, etc) talking. I don’t know anything about protocols like TCP, UDP, RLP, etc. I know enough to get by with UART.

M2Mqtt works great for 802.11 with a full .net micro networking stack, but I am interested in tiny RF devices… they don’t communicate over tcp or http, right? The hype with Mqtt seems to fall flat as soon as you talk about tiny devices that don’t have an IP address or sockets or tcp/http, are not on ethernet or 802.11 wifi - but ironically the whole point of Mqtt is IoT, right? Am I missing something? So then I noticed it has an interface IMqttNetworkChannel, presumably to allow you to plug in your own networking, but I have no idea how to implement it, as it appears to stream network data verses event based send/receive (i.e http request/response, or simple serial send/receive - [em]I don’t mess with the bits, I just send strings and they magically appear across devices[/em] :slight_smile: ).

Anyway, I am willing to “level up” my understanding, but not sure where to start. I typically take on a little project like implementing the above mentioned interface for xbee, for example. But found myself wondering “How do I use System.Net.Sockets on an Xbee that expects Gadgeteer.Sockets? And how are these related, if at all?”

I have planned to do an tutorial based article about Networking with NETMF over x-mas.
Means, I can start earliest in 2 weeks.
So far there is no start to finish tutorial/sample on networking.
That’s why I want to write one.

3 Likes

Super helpful guys, thanks.

I do like some things about Mqtt as far as the high level use for building the apps to be aware of the goings on around them. I will struggle a bit to figure out what low level networking will go underneath, that is where I hit the realization I have some learning to do.

Right now I have a working prototype that looks like this:

Cloud based Mqtt <-ethernet-> Spider “Broker” <-xbee-> Cerberus “sensor”

It’s pretty slick, but a total hack. The spider runs M2Mqtt client to talk to the cloud based Mqtt server via ethernet. Then it “relays” all messages across an xbee network that also uses ‘Mqtt-like’ data over serial UART. And vice-versa, the xbee sensors can publish to the Spider, which then relays that out to the cloud. Also btw, it works with nordic nRF24 devices too, so my Spider is actually relaying communication across xbee, nordic, and IP based Mqtt.

On the gadgeteer “network” side with xbee RF, I don’t think my simple serial messaging is the right lower level solution here. It doesn’t ‘stream’, there is no ‘socket’ usage, and I was not able to make use of M2Mqtt library for these clients since I don’t have a channel implemented for xbee (or nordic, or anything else).

Reinhard, power to you if you get your tutorial put together. I fully intend to publish my Spider + xbee + nordic broker to github for everyone, as I think it is pretty darn useful. But I want it to be less of a hack before I mislead the community. :slight_smile:

1 Like

@ dapug - I did a video showing MQTT with Gadgeteer/NetMF and posted source etc here https://www.ghielectronics.com/community/codeshare/entry/896

As to with stuff like xBee, there are examples of it out there

http://rijware.com/zigbee-and-mqtt/

Not a bad intro to Gadgeteer and xbee can be found here

Got to admit that while I have some xbee boards here, I’ve been liking Justin’s RF Pipe

https://www.ghielectronics.com/community/creations/entry/12

But heck ya a Networking 101 would be great!!

1 Like

@ Duke Nukem, your tutorial is awesome. I saw that before I took on my endeavor.

The problem I had was that the Mqtt clients were IP based (all clients/sensors would need to be a Spider with RS21 Wifi, eek!). The real trick is to get a netmf (Spider) [em]broker[/em] established that can connect to IP Mqtt as a client, and act as a server for all the local xbees in the PAN. Much like the example in the rijware link you posted, except instead of a OpenWRT mini-router, you’d use a Spider. Then again, maybe I missed something in your video.

Edit: your video was super helpful for me to see M2Mqtt in action, as well as discovering handy tools like TT3. Thank you!

Bottom Line:
I want to create an out-of-box solution for the community so we dont have to roll our own every time we want to spin up a nifty little cloud connected Mqtt based PAN. That, and my prototype so far is flexible/extensible in that i can run super cheap nrf24l01+ in addition to xbee, allowing xbee and nordic devices to talk to each other through the Spider, which is AWESOME.

2 Likes

@ dapug - Have you considered trying with an ESP8266? For about $3 you could use IP. I’ve yet to see a NETMF example using it but since its only a serial interface it should be fairly trivial to implement.

Hi @ dapug
I’m the developer of M2Mqtt library :slight_smile:
Aa you said this library works only with TCP/IP capable devices. For other types of networking protocols like Zigbee there is the MQTT-SN protocol but you can’t obtain it implementing a new class for IMqttNerworkChannel interface.
The MQTT-SN specification is completely different from MQTT starting from packet format.
AFAIK until now there isn’t such implementation.
However, if you want more information about M2Mqtt you can find them of the official web site http://www.m2mqtt.net

For any other information I’m here :slight_smile:

Paolo

3 Likes

@ ianlee74, Whoa! Possible game changer here, thanks for mentioning. I’m totally going to include this in my options.

@ ppatierno, thanks for the clarification. In fact, I read up on MQTT-SN and realized it is indeed quite different. I also concluded it is non-trivial to implement, and there is no C# library for it today.

Userful article on MQTT-SN
http://blog.zuehlke.com/en/iot-for-tiny-devices-lets-talk-mqtt-sn/

What I built:
MqttLite. It is basically a way to send topics/messages through ANY protocol. Unlike MQTT-SN, it actually follows the patterns of MQTT, same topic/message approach, but lacks a lot of the full MQTT stuff like streaming through sockets, etc. I currently use simple serial communications (through xbee and nordic) from the sensors to a gadgeteer Spider that has both xbee and nordic radios, and from there I RELAY them through your excellent M2Mqtt library. Right now it doesn’t have important things implemented such as Qos, but I might get to that.