kopia lustrzana https://github.com/martin-ger/esp_mqtt
add protocol name selection(3.11 or 3.1), defaut is v3.1, resolve #36
rodzic
f3cd69d5bb
commit
774f5a99d4
|
@ -25,4 +25,6 @@
|
||||||
#define DEFAULT_SECURITY 0
|
#define DEFAULT_SECURITY 0
|
||||||
#define QUEUE_BUFFER_SIZE 2048
|
#define QUEUE_BUFFER_SIZE 2048
|
||||||
|
|
||||||
|
#define PROTOCOL_NAMEv31 /*MQTT version 3.1 compatible with Mosquitto v0.15*/
|
||||||
|
//PROTOCOL_NAMEv311 /*MQTT version 3.11 compatible with https://eclipse.org/paho/clients/testing/*/
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "mqtt_msg.h"
|
#include "mqtt_msg.h"
|
||||||
|
#include "user_config.h"
|
||||||
#define MQTT_MAX_FIXED_HEADER_SIZE 3
|
#define MQTT_MAX_FIXED_HEADER_SIZE 3
|
||||||
|
|
||||||
enum mqtt_connect_flag
|
enum mqtt_connect_flag
|
||||||
|
@ -47,7 +47,13 @@ struct __attribute((__packed__)) mqtt_connect_variable_header
|
||||||
{
|
{
|
||||||
uint8_t lengthMsb;
|
uint8_t lengthMsb;
|
||||||
uint8_t lengthLsb;
|
uint8_t lengthLsb;
|
||||||
|
#if defined(PROTOCOL_NAMEv31)
|
||||||
|
uint8_t magic[6];
|
||||||
|
#elif defined(PROTOCOL_NAMEv311)
|
||||||
uint8_t magic[4];
|
uint8_t magic[4];
|
||||||
|
#else
|
||||||
|
#error "Please define protocol name"
|
||||||
|
#endif
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint8_t keepaliveMsb;
|
uint8_t keepaliveMsb;
|
||||||
|
@ -293,9 +299,18 @@ mqtt_message_t* ICACHE_FLASH_ATTR mqtt_msg_connect(mqtt_connection_t* connection
|
||||||
connection->message.length += sizeof(*variable_header);
|
connection->message.length += sizeof(*variable_header);
|
||||||
|
|
||||||
variable_header->lengthMsb = 0;
|
variable_header->lengthMsb = 0;
|
||||||
|
#if defined(PROTOCOL_NAMEv31)
|
||||||
|
variable_header->lengthLsb = 6;
|
||||||
|
memcpy(variable_header->magic, "MQIsdp", 6);
|
||||||
|
variable_header->version = 3;
|
||||||
|
#elif defined(PROTOCOL_NAMEv311)
|
||||||
variable_header->lengthLsb = 4;
|
variable_header->lengthLsb = 4;
|
||||||
memcpy(variable_header->magic, "MQTT", 4);
|
memcpy(variable_header->magic, "MQTT", 4);
|
||||||
variable_header->version = 4;
|
variable_header->version = 4;
|
||||||
|
#else
|
||||||
|
#error "Please define protocol name"
|
||||||
|
#endif
|
||||||
|
|
||||||
variable_header->flags = 0;
|
variable_header->flags = 0;
|
||||||
variable_header->keepaliveMsb = info->keepalive >> 8;
|
variable_header->keepaliveMsb = info->keepalive >> 8;
|
||||||
variable_header->keepaliveLsb = info->keepalive & 0xff;
|
variable_header->keepaliveLsb = info->keepalive & 0xff;
|
||||||
|
|
Ładowanie…
Reference in New Issue