MQTT and Fez Panda III?

Dear friends,
I am a refugee from Netduino. I used MQTT (Paolo Patierno’s M2MQTT library) with the Netduino Plus 2 all the time and it was great. Tried it with my new Fez Panda III and nothing. I find some posts from 2-3 years ago about adapting to the way that Panda does its ethernet, but nothing seems to have materialized. Can anyone help ?
Thanks-

How did you add Ethernet? Please show more details.

I used a ENC28J60 board. Details in another (dumb) post https://www.ghielectronics.com/community/forum/topic?id=24479. Is there a different route to Ethernet that allows Panda III to support MQTT?

Once you have initialized Ethernet, can you ping your Panda?

Yes, I can. In the discussion from a couple of years ago, there was mention that MQTT doesn’t work because the Panda uses a GHI ethernet library instead of the .NETMF library. I don’t entirely understand this.
https://www.ghielectronics.com/community/forum/topic?id=11597
My code is below. It works fine on Netduino.

MQTTClient = new MqttClient("192.168.0.41");                  // instantiate the client, point to broker's ip address
MQTTClient.MqttMsgPublishReceived += client_MqttMsgPublishReceived;  // raised when a subscribed message is received            
MQTTClient.Connect(ModuleID);                                        // connect.  Module ID is unique string

The fail occurs on the 3rd line with error :
An unhandled exception of type ‘uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException’ occurred in M2Mqtt.NetMf.dll

That was on old Pandas. Yours users netmf networking so it should work.

More complete error…
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
A first chance exception of type ‘uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException’ occurred in M2Mqtt.NetMf.dll
An unhandled exception of type ‘uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException’ occurred in M2Mqtt.NetMf.dll

so my adapter initialization
Adapter = new EthernetENC28J60(GHI.Pins.FEZPandaIII.SpiBus.Spi1, GHI.Pins.FEZPandaIII.Gpio.D10, GHI.Pins.FEZPandaIII.Gpio.D9, GHI.Pins.FEZPandaIII.Gpio.D7);
should change to…?

If you can ping your device then this is done correctly.

And by ping I mean “ping 192.168…” from your command window.

Gus,
So is it correct to say that if it responds to pings, then it is using .NetMF libraries and should work with the M2MQTT library?
Thank you for your help-

@ w9ip - yes it should work. I do not understand why it would not.

I finally got MQTT to work with the Fez Panda III. Had to insert
Thread.Sleep(4000);
before MQTTClient.Connect(). I guess the Fez has some thinking to do before it’s ready to connect. Anything less than 4 seconds fails. Go figure.
Thanks, Gus, for your patience.

1 Like