Since this is my first "quasi-professional" project that I actually
want others to use, I wanted there to be decent quality documentation
for all the functions and structs that the end user would need to use.
I had tried Doxygen before but never had much luck, mostly because
I didn't bother to put in the effort to read the documentation closely.
So this time around I did, and the output so far looks quite good
and has a lot of detail about the functions, and the two typedef
structs that are key to everything working.
Added code to check if wifi is connected before allowing the TCP
connection to be attempted. Similar code for mqtt_connect, checking
if we have a valid TCP connection to the server. Waiting for
wifi uses a new global timer. These changes affected the indentation
of huge chunks of the code, as they got wrapped in ifs.
We now take advantage of the void *reverse pointer in the espconn
struct to point to the mqtt_session_t that is active. This is a nice
touch that Espressif added, so you can access arbitrary data from
within callbacks. This will allow us to (soon) have user callbacks
to deal with MQTT messages.
Also added license notices to all the source code files.
Fixed the bug in PUBLISH. Tested with Adafruit IO and data
can be published successfully! This was the original goal of
this project -- being able to blindly fire values at Adafruit
and not having to worry about receiving data. However, I've
widened the scope of the project, and want to eventually do a
full MQTT implementation per the spec.
The basic receive functionality looks at what type of message
is receieved, and then prints out basic messages depending on
what the payload is. Mostly useful as a debugging tool, but
it can easily be expanded. This should probably be split out
into its own function at some point.
strtoarr.py: Because of the weird bug that makes passing string
pointers impossible with the ESP8266, strings have to be stored
as hex arrays and then passed as a pointer. This is a pain for
the user, so I've written a basic script which will take two
arguments: the string to be encoded, and the variable name
to be used. It then spits out C code which can be copied
and pasted into the user code. This saves a bunch of time, and
because it spits them out as static const, it also tells the
compiler to store them in flash (as far as I can tell).
As mentioned, it has now been tested with Adafruit IO. There
are a few more functions in the "user" area of the file. These
are only for debugging and will eventually be surrounded with
\#ifdef DEBUG so they won't be included in the compiled version.
Also, more ifdef preprocessor directives have been added so
that debug messages won't be printed to a user's output unless
they want them.
The next step is to implement SUBSCRIBE, and to compile the code
as mqtt.a - a linkable object file.