Commit graph

13 commits

Author SHA1 Message Date
dee07e5fe7
Subscribe feature now works. See huge commit log!
Quite a few updates. Subscription feature is now working,
which is great. This has been tested with mosquitto broker
as well as Adafruit IO, and it works perfectly with both.

I tried to compile this project as a library (see the changes
to Makefile) but when I used that .a file in another project
the linking process failed. More research needed, I've never
tried to do that before.

I compressed some of the case statements in mqtt_send as they
are so similar, it's a waste of code space to duplicate them.
Disconnect and ping are identical except for one byte, and
unsubscribe and subscribe differ in only a few lines.

The data receive callback now prints information on what kind
of packet/data was received; again, mostly useful during
debugging, but the framework is there to expand it to do
useful things like triggering other tasks/timers, etc.

There is now a keepalive ping timer which keeps both the MQTT
and thus the TCP connection alive. It currently pings every 5
seconds, though I might change that closer to the timeout
maximum (50 seconds).

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2018-08-19 02:19:25 -04:00
29306a5699
Implemented basic receive functionality. See full log.
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.
2018-08-18 14:58:03 -04:00
16355bc42f
Merge branch 'publish' into master 2018-08-18 06:05:42 -04:00
247b772e3e
Completed PUBLISH, PINGREQ and DISCONNECT. See full log.
Publish still has a small bug, but it's unclear if the bug is in
my implementation, or the way Wireshark decodes the MQTT packets.
It seems to miscalculate the length of the data itself; it's not
subtracting the length of the topic name to get the length of the
message, or something along those lines. Further testing will be
needed.

PINGREQ and DISCONNECT are almost identical -- the packets simply
contain the command byte and a 0 for the remaining length. Both
of these have been tested and work perfectly.

Next steps:
Implement subscribe and unsubscribe
Implement events/tasks on receive
Remove testing code, or put in separate branch
Change makefile to create .a (library version that can be linked)
2018-08-18 06:01:11 -04:00
b10ef4c8c1 Changed license to Mozilla Public License v2.0
All previous commits are licensed under the MIT License.
Commits from this point on are licensed under the Mozille Public License v2.0 as included.
2018-08-18 06:11:39 +00:00
68755929e6
Started to write PUBLISH. Merging with Master next. 2018-08-18 01:53:12 -04:00
bcbcde455a
Rewritten code works! See full log.
After much consternation, finally got the code generalized. For
some reason the ESP8266 absolutely cannot pass pointers between
functions. I'm not sure if this is because it's a timer function?
Either way, we have to memcpy the values, which makes things a
bit messier, but not too bad.

Now to start work on Publish...
2018-08-16 19:11:47 -04:00
8d77605654 Added LICENSE 2018-08-16 19:01:56 +00:00
f0d14dc2cb Fixed the markdown in README 2018-08-16 19:01:14 +00:00
cbc182fed4
Started the rewrite of the library on this new branch. See full log.
Created a README, as yet incomplete. Added more files to the gitignore
to get rid of emacs temporary files. Currently making the mqtt_send command
independent of connecting, which is all it can do currently.
2018-08-16 14:26:31 -04:00
65d0810b5e
Managed to get our first MQTT connection started!
The code is now pretty messy, as I've just been hacking it
together so far. It's basically hardcoded, so the next steps
will be to parameterise everything. I also need to rethink
the data structures, and function names/structures.

I need to make this feel more like an API to be called by
a user. This will naturally help organize the functions.
2018-08-15 00:07:42 -04:00
ff0c7fac97
added gitignore 2018-08-13 23:35:00 -04:00
557188bb38 Initial commit 2018-08-13 23:34:17 -04:00