Add header license

This commit is contained in:
Tuan PM
2018-02-17 11:42:41 +07:00
parent 66b21752ba
commit 4fd75c1b4b
13 changed files with 74 additions and 7 deletions

View File

@ -1,3 +1,12 @@
[![](https://travis-ci.org/tuanpmt/espmqtt.png?branch=master)](https://travis-ci.org/tuanpmt/espmqtt)
[![](http://hits.dwyl.io/tuanpmt/espmqtt.svg)](http://hits.dwyl.io/tuanpmt/espmqtt)
![](https://img.shields.io/github/downloads/tuanpmt/espmqtt/total.svg)
[![Twitter Follow](https://img.shields.io/twitter/follow/tuanpmt.svg?style=social&label=Follow)](https://twitter.com/tuanpmt)
![GitHub contributors](https://img.shields.io/github/contributors/tuanpmt/espmqtt.svg)
[![Paypal donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/tuanpm)
# ESP32 MQTT Library
## Features
@ -15,6 +24,15 @@ Clone this component to [ESP-IDF](https://github.com/espressif/esp-idf) project
git submodule add https://github.com/tuanpmt/espmqtt.git components/espmqtt
```
Or run a sample (make sure you have `IDF_PATH` env):
```
git clonehttps://github.com/tuanpmt/espmqtt.git
cd espmqtt/examples/mqtt_tcp
make menuconfig
make flash monitor
```
## Documentation
### URI
@ -128,4 +146,5 @@ esp_mqtt_client_start(client);
## License
[@tuanpmt](https://twitter.com/tuanpmt)
Apache License

View File

@ -115,7 +115,7 @@ static void wifi_init(void)
static void mqtt_app_start(void)
{
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = "ws://iot.eclipse.org:80/mqtt",
.uri = "ws://iot.eclipse.org:80/ws",
.event_handle = mqtt_event_handler,
// .user_context = (void *)your_context
};

View File

@ -1,3 +1,9 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _MQTT_CLIENT_H_
#define _MQTT_CLIENT_H_
@ -7,10 +13,8 @@
#include "mqtt_config.h"
typedef struct esp_mqtt_client* esp_mqtt_client_handle_t;
typedef enum {
MQTT_EVENT_ERROR = 0,
MQTT_EVENT_CONNECTED,

View File

@ -1,3 +1,8 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _MQTT_CONFIG_H_
#define _MQTT_CONFIG_H_
#define MQTT_PROTOCOL_311 1

View File

@ -1,3 +1,8 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _MQTT_OUTOBX_H_
#define _MQTT_OUTOBX_H_
#include "platform.h"

View File

@ -1,3 +1,8 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _PLATFORM_H__
#define _PLATFORM_H__

View File

@ -1,4 +1,8 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _ESP_PLATFORM_H__
#define _ESP_PLATFORM_H__

View File

@ -1,3 +1,8 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _TRANSPORT_H_
#define _TRANSPORT_H_

View File

@ -1,4 +1,8 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _TRANSPORT_SSL_H_
#define _TRANSPORT_SSL_H_

View File

@ -1,3 +1,8 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _TRANSPORT_TCP_H_
#define _TRANSPORT_TCP_H_

View File

@ -1,3 +1,9 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _TRANSPORT_WS_H_
#define _TRANSPORT_WS_H_

View File

@ -191,7 +191,7 @@ static int ws_read(transport_handle_t t, char *buffer, int len, int timeout_ms)
buffer[i] = (data_ptr[i] ^ mask_key[i % 4]);
}
} else {
memcpy(buffer, data_ptr, payload_len);
memmove(buffer, data_ptr, payload_len);
}
return payload_len;
}

View File

@ -437,11 +437,16 @@ static void deliver_publish(esp_mqtt_client_handle_t client, uint8_t *message, i
mqtt_data_length = length;
mqtt_data = mqtt_get_publish_data(message, &mqtt_data_length);
if (total_mqtt_len == 0) {
if(total_mqtt_len == 0){
mqtt_topic_length = length;
mqtt_topic = mqtt_get_publish_topic(message, &mqtt_topic_length);
mqtt_data_length = length;
mqtt_data = mqtt_get_publish_data(message, &mqtt_data_length);
total_mqtt_len = client->mqtt_state.message_length - client->mqtt_state.message_length_read + mqtt_data_length;
mqtt_len = mqtt_data_length;
} else {
mqtt_len = len_read;
mqtt_data = (const char*)client->mqtt_state.in_buffer;
}
ESP_LOGD(TAG, "Get data len= %d, topic len=%d", mqtt_data_length, mqtt_topic_length);