Commit graph

42 commits

Author SHA1 Message Date
fdac75a728 Merge branch 'revert-dc724a2c' into 'master'
Revert "Merged updates from dev branch into master"

See merge request mraureliusr/mqtt-esp8266!2
2019-04-07 14:14:27 +00:00
0aac8d5b66 Revert "Merged updates from dev branch into master"
This reverts commit dc724a2c96
2019-04-07 14:14:27 +00:00
dc724a2c96
Merged updates from dev branch into master
Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-04-06 09:52:45 -04:00
7c5dfae57b
Updated formatting with astyle -A14 -S
Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-03-04 12:58:17 -05:00
3de8cc9ed7
merged master back into priv 2019-02-27 02:42:14 -05:00
d0b019edff
Updated to v0.3.2 2019-02-27 02:40:10 -05:00
70973a0b14
Added DHT prototypes.
Added the beginning of the DHT code which will likely be used
in part 4 of the tutorial series.

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-02-27 02:31:42 -05:00
8acff6e880
Updated to v0.3.1
Renamed mqtt_send to mqttSend to better follow my usual naming
convention. Made a few other small changes, including disabling
the debug macro by default. Just uncomment to add it again.

This is the version that will be used with the first release
of Part 3 of the SDK tutorials on hackaday.io.

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-02-27 02:28:00 -05:00
045e438b6e
Mergine master back into priv to continue work/debugging
Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-23 02:53:59 -05:00
049573ad4b
Added documentation, removed library from Makefile
Making the mqtt as a .a library is a project for a later date.
The recipe was broken and so was removed to avoid confusion.

Added the Mozilla License header to the new files. Also a few
small corrections and additions to the Doxygen documentation.

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-22 12:16:39 -05:00
d339bd525f
Merge remote-tracking branch 'refs/remotes/origin/master' 2019-01-21 20:35:55 -05:00
930d00a9a0
Added logo and updated Doxyfile
Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-21 20:35:28 -05:00
86b180e5f2 Update .gitlab-ci.yml to add graphviz 2019-01-22 01:33:02 +00:00
09a3195cbb
Merge branch 'master' of gitlab.com:mraureliusr/mqtt-esp8266 2019-01-21 20:27:33 -05:00
31eb087a7a
Updated README and created Doxygen automation
Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-21 20:26:58 -05:00
b253769f9f Add .gitlab-ci.yml 2019-01-22 01:23:51 +00:00
627df20e53
Squashed commit of the following:
commit a4632bb7ad
Author: A.M. Rowsell <amrowsell@frozenelectronics.ca>
Date:   Mon Jan 21 20:13:12 2019 -0500

    Sanitizing key and wifi

    Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>

commit 5e3be0f561
Author: A.M. Rowsell <amrowsell@frozenelectronics.ca>
Date:   Mon Jan 21 19:53:42 2019 -0500

    It's alive! New code all working.

    The OneWire library works. It's a bit hacked together, as neither
    the software timer or hardware timer APIs would have worked well,
    because they are implemented terribly by Espressif. The easiest
    way to get around this was to just use system_get_time() and work
    off of that for timing in one-wire comms.

    Split the publish function into two separate functions: one to
    publish floating point numbers, and one to publish integers. In
    a language like Lua or C++ you could have these as one function,
    but in C it's easier to just split them.

    The main.c has a new function called dataLog that deals with
    getting the DS18B20 data and then handing that off to pubfloat().

    I updated the timer names to be more descriptive.

    I grabbed some code to convert integers and floats to strings, as
    I can't be bothered to write that code myself for the millionth
    time.

    If something goes wrong and we are disconnected from our TCP
    connection, all timers are halted so we don't blindly keep
    trying to send packets over a non-existent link.

    Unfortunately the onewire library is hardcoded to use pin 5.
    That will be the next update.

    Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>

commit 48702bf328
Author: A.M. Rowsell <amrowsell@frozenelectronics.ca>
Date:   Sun Jan 20 21:13:04 2019 -0500

    First version that compiles with new file layout.

    Had to make many changes to get it to compile across many files,
    including removing the LOCAL specifier from almost all functions.
    Edited the Makefile to compile all three files and link them.
    Haven't tested on hardware yet, that's the next step.

    Lots of small changes to avoid warnings, now that I have turned
    -Wall on. This makes the code a bit "better".

    Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>

commit 1cd8191682
Author: A.M. Rowsell <amrowsell@frozenelectronics.ca>
Date:   Sat Jan 19 15:25:44 2019 -0500

    New branch for my new AIO key.

    Will have to remember to sanitize before committing to master.

    Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-21 20:14:09 -05:00
a4632bb7ad
Sanitizing key and wifi
Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-21 20:13:12 -05:00
5e3be0f561
It's alive! New code all working.
The OneWire library works. It's a bit hacked together, as neither
the software timer or hardware timer APIs would have worked well,
because they are implemented terribly by Espressif. The easiest
way to get around this was to just use system_get_time() and work
off of that for timing in one-wire comms.

Split the publish function into two separate functions: one to
publish floating point numbers, and one to publish integers. In
a language like Lua or C++ you could have these as one function,
but in C it's easier to just split them.

The main.c has a new function called dataLog that deals with
getting the DS18B20 data and then handing that off to pubfloat().

I updated the timer names to be more descriptive.

I grabbed some code to convert integers and floats to strings, as
I can't be bothered to write that code myself for the millionth
time.

If something goes wrong and we are disconnected from our TCP
connection, all timers are halted so we don't blindly keep
trying to send packets over a non-existent link.

Unfortunately the onewire library is hardcoded to use pin 5.
That will be the next update.

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-21 19:53:42 -05:00
48702bf328
First version that compiles with new file layout.
Had to make many changes to get it to compile across many files,
including removing the LOCAL specifier from almost all functions.
Edited the Makefile to compile all three files and link them.
Haven't tested on hardware yet, that's the next step.

Lots of small changes to avoid warnings, now that I have turned
-Wall on. This makes the code a bit "better".

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-20 21:13:04 -05:00
1cd8191682
New branch for my new AIO key.
Will have to remember to sanitize before committing to master.

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-19 15:25:44 -05:00
70cf55efdf
Splitting library into own file. Adding onewire.
The mqtt.c file was getting pretty big, so the example code
is now in main.c. Also, we need a onewire library, so I've
started to write on in onewire.c. We will need to make some
changes to the Makefile as well, but I will need to consult
a couple of resources for that.

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-18 23:38:31 -05:00
c8bff5cace
Removed a few lines before release of the tutorial publicly.
Not a huge deal, and they are still in the git history, but
I wanted to make it clear that the SSID and passkey need to
be replaced with the user's own SSID and passkey for their
WIFI. They'd probably be unable to connect to mine!

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
2019-01-02 18:55:21 -05:00
0692b1776c
Updated doxyfile. Small changes to mqtt.c 2018-12-20 13:37:05 -05:00
13790637fe
Fixed small merge conflict in README 2018-08-29 02:46:06 -04:00
cfb041a679
Added Doxyfile. See full log.
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.
2018-08-29 02:36:11 -04:00
b551f832dd Updated license in README. Forgot to do that earlier. 2018-08-19 06:57:00 +00:00
33cdfa54a9 Freaking markdown is so broken on GitLab... 2018-08-19 06:52:11 +00:00
dd332ba337 Fixed README so it actually has meaningful information 2018-08-19 06:50:55 +00:00
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