Change the default QoS of will message to QOS_1

This commit is contained in:
Feng Lee 2017-03-06 18:17:07 +08:00
parent c3919a64e6
commit 35e08df735
1 changed files with 19 additions and 17 deletions

View File

@ -80,6 +80,7 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Control Packet Types %% MQTT Control Packet Types
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-define(RESERVED, 0). %% Reserved -define(RESERVED, 0). %% Reserved
-define(CONNECT, 1). %% Client request to connect to Server -define(CONNECT, 1). %% Client request to connect to Server
-define(CONNACK, 2). %% Server to Client: Connect acknowledgment -define(CONNACK, 2). %% Server to Client: Connect acknowledgment
@ -94,7 +95,7 @@
-define(UNSUBACK, 11). %% Unsubscribe acknowledgment -define(UNSUBACK, 11). %% Unsubscribe acknowledgment
-define(PINGREQ, 12). %% PING request -define(PINGREQ, 12). %% PING request
-define(PINGRESP, 13). %% PING response -define(PINGRESP, 13). %% PING response
-define(DISCONNECT, 14). %% Client is disconnecting -define(DISCONNECT, 14). %% Client or Server is disconnecting
-define(AUTH, 15). %% Authentication exchange -define(AUTH, 15). %% Authentication exchange
-define(TYPE_NAMES, [ -define(TYPE_NAMES, [
@ -146,11 +147,12 @@
%% MQTT Packet Fixed Header %% MQTT Packet Fixed Header
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-record(mqtt_packet_header, { -record(mqtt_packet_header,
type = ?RESERVED :: mqtt_packet_type(), { type = ?RESERVED :: mqtt_packet_type(),
dup = false :: boolean(), dup = false :: boolean(),
qos = ?QOS_0 :: mqtt_qos(), qos = ?QOS_0 :: mqtt_qos(),
retain = false :: boolean()}). retain = false :: boolean()
}).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Packets %% MQTT Packets
@ -165,7 +167,7 @@
proto_ver = ?MQTT_PROTO_V4 :: mqtt_vsn(), proto_ver = ?MQTT_PROTO_V4 :: mqtt_vsn(),
proto_name = <<"MQTT">> :: binary(), proto_name = <<"MQTT">> :: binary(),
will_retain = false :: boolean(), will_retain = false :: boolean(),
will_qos = ?QOS_0 :: mqtt_qos(), will_qos = ?QOS_1 :: mqtt_qos(),
will_flag = false :: boolean(), will_flag = false :: boolean(),
clean_sess = false :: boolean(), clean_sess = false :: boolean(),
keep_alive = 60 :: non_neg_integer(), keep_alive = 60 :: non_neg_integer(),
@ -199,25 +201,25 @@
}). }).
-record(mqtt_packet_suback, -record(mqtt_packet_suback,
{ packet_id :: mqtt_packet_id(), { packet_id :: mqtt_packet_id(),
qos_table :: list(mqtt_qos() | 128) qos_table :: list(mqtt_qos() | 128)
}). }).
-record(mqtt_packet_unsuback, -record(mqtt_packet_unsuback,
{ packet_id :: mqtt_packet_id() }). { packet_id :: mqtt_packet_id() }).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Control Packet %% MQTT Control Packet
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-record(mqtt_packet, -record(mqtt_packet,
{ header :: #mqtt_packet_header{}, { header :: #mqtt_packet_header{},
variable :: #mqtt_packet_connect{} | #mqtt_packet_connack{} variable :: #mqtt_packet_connect{} | #mqtt_packet_connack{}
| #mqtt_packet_publish{} | #mqtt_packet_puback{} | #mqtt_packet_publish{} | #mqtt_packet_puback{}
| #mqtt_packet_subscribe{} | #mqtt_packet_suback{} | #mqtt_packet_subscribe{} | #mqtt_packet_suback{}
| #mqtt_packet_unsubscribe{} | #mqtt_packet_unsuback{} | #mqtt_packet_unsubscribe{} | #mqtt_packet_unsuback{}
| mqtt_packet_id() | undefined, | mqtt_packet_id() | undefined,
payload :: binary() | undefined payload :: binary() | undefined
}). }).
-type(mqtt_packet() :: #mqtt_packet{}). -type(mqtt_packet() :: #mqtt_packet{}).