mqtt/README.md
A.M. Rowsell 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

1.7 KiB

#MQTT Library for ESP8266 SDK written by Alexander Rowsell (MrAureliusR) Released under the terms of the MIT License -- see LICENSE for more detail.

##Summary While working on a series of tutorials for Hackaday, I realized MQTT would be the perfect solution for one of the projects I was presenting. However, I didn't want to use a pre-existing MQTT library - that would be boring, and I wouldn't be able to teach the readers as much. Instead, I started to write one from scratch.

At this point, it's a bit messy. It still needs a lot of work. This documentation will help me keep everything organized and easy-to-use.

##API Structures

  uint8_t ip[4];
  uint32_t port;
  uint32_t localPort;
  uint8_t *client_id;
  uint8_t *topic_name;
  uint8_t qos_level;
  uint8_t *username;
  uint8_t *password;
  char valid_connection;
  struct espconn *activeConnection;
} mqtt_session_t;```

This is the main structure that contains all the information about the connection to the server. The IP address, port, client\_id, topic\_name, username, and password are all specified here by the end user. localPort is set by the API, and qos\_level should be set to 0. *activeConnection will point to the espconn struct that represents the TCP connection to the server. The end-user shouldn't need to touch anything in this struct.

##API Functions

###mqtt\_connect(mqtt\_session\_t *session, uint8\_t *username, uint8\_t *password)
This function establishes a TCP connection with the server specified in session->ip, on session->port. Most MQTT brokers listen on port 1883 for unencrypted packets, and on 8883 for TLS connections. This API currently only supports unencrypted packets on 1883. However, the port still needs to be specified, in case you use a non standard port.