mikaelpatel / Cosa-MQTT

MQTT for Cosa Arduino OOP Framework
3 stars 2 forks source link

Create CosaMQTTsecureclient.ino #3

Open sehlstrom opened 9 years ago

sehlstrom commented 9 years ago

W5100 Ethernet Controller device drive example code; MQTT client switching imaginary NEXA switches on and off. The MQTT client connects to the MQTT broker using username/password. It also specifies a last will.

mikaelpatel commented 9 years ago

@sehlstrom

After having thought a bit more about this it would be better to simply update the current MQTTclient sketch with a configuration/ifdet so that it can be used both with and without connect parameters. That is basically what is the core of this update.

The suggested CosaMQTTsecureclient sketch add a bit to much to make it a good example; 1) the usage of String, 2) reference to NEXA but without any "real" code, etc.

In any case your suggestions open up for additional general processing patterns/sketches such as path string matching.

sehlstrom commented 9 years ago

@mikaelpatel

Yes, that would give a good outcome with the a little bit tricky settings being explained well enough.

However, the proposed sketch has one benefit over the existing MQTTclient: the client keeps service forever and also reconnects on any connection error. For my application of the Cosa-MQTT library, that has been absolutely crucial in order to be able to rely on the client. I would imagine that other users could benefit from such a solution as well.

mikaelpatel commented 9 years ago

@sehlstrom The initial issue https://github.com/mikaelpatel/Cosa-MQTT/issues/1 was about the parameters for connect. I understand your concern but I hope you understand that adding examples for all use cases is not possible.

Also an example sketch should be very clear on what it demonstrates and should not be a basis for "cut-and-paste" programming. This leads to the "dark side".