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.
This commit is contained in:
parent
65d0810b5e
commit
cbc182fed4
3 changed files with 33 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,3 +4,6 @@
|
||||||
*.pdf
|
*.pdf
|
||||||
*.map
|
*.map
|
||||||
mqtt
|
mqtt
|
||||||
|
trace*
|
||||||
|
\#*\#
|
||||||
|
.\#*
|
||||||
|
|
29
README.md
Normal file
29
README.md
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#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
|
||||||
|
```typedef struct {
|
||||||
|
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.
|
2
mqtt.c
2
mqtt.c
|
@ -83,7 +83,7 @@ LOCAL uint8_t ICACHE_FLASH_ATTR tcpConnect(void *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCAL uint8_t ICACHE_FLASH_ATTR mqtt_connect(mqtt_session_t *session) {
|
LOCAL uint8_t ICACHE_FLASH_ATTR mqtt_connect(mqtt_session_t *session, uint8_t *username, uint8_t *password) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue