Skip to content

Commit

Permalink
Improvements and fixes for warnings due to XML source comments. (ecli…
Browse files Browse the repository at this point in the history
…pse-paho#108)

* Fix for EventArgs lib
* Correct SSL protocol support for nF
  • Loading branch information
networkfusion authored Mar 29, 2021
1 parent cdf496e commit 42b23a4
Show file tree
Hide file tree
Showing 30 changed files with 361 additions and 91 deletions.
4 changes: 3 additions & 1 deletion M2Mqtt/Internal/MsgInternalEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public MqttMsgBase Message

#endregion

// related message
/// <summary>
/// Related message
/// </summary>
protected MqttMsgBase msg;

/// <summary>
Expand Down
40 changes: 31 additions & 9 deletions M2Mqtt/Messages/MqttMsgBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,23 @@ public abstract class MqttMsgBase
internal const byte MQTT_MSG_DISCONNECT_FLAG_BITS = 0x00;

// QOS levels
/// <summary>
/// QOS At Most Once
/// </summary>
public const byte QOS_LEVEL_AT_MOST_ONCE = 0x00;
/// <summary>
/// QOS At Least Once
/// </summary>
public const byte QOS_LEVEL_AT_LEAST_ONCE = 0x01;
/// <summary>
/// QOS Exactly Once
/// </summary>
public const byte QOS_LEVEL_EXACTLY_ONCE = 0x02;

// SUBSCRIBE QoS level granted failure [v3.1.1]
/// <summary>
/// QOS Granted Failure
/// </summary>
public const byte QOS_LEVEL_GRANTED_FAILURE = 0x80;

internal const ushort MAX_TOPIC_LENGTH = 65535;
Expand Down Expand Up @@ -138,16 +150,26 @@ public ushort MessageId

#endregion

// message type
/// <summary>
/// The Message type
/// </summary>
protected byte type;
// duplicate delivery
protected bool dupFlag;
// quality of service level
protected byte qosLevel;
// retain flag
protected bool retain;
// message identifier
protected ushort messageId;
/// <summary>
/// Duplicate delivery flag
/// </summary>
internal protected bool dupFlag;
/// <summary>
/// Quality of Service level
/// </summary>
internal protected byte qosLevel;
/// <summary>
/// The retain flag
/// </summary>
internal protected bool retain;
/// <summary>
/// The message identifier
/// </summary>
internal protected ushort messageId;

/// <summary>
/// Returns message bytes rapresentation
Expand Down
27 changes: 27 additions & 0 deletions M2Mqtt/Messages/MqttMsgConnack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,29 @@ public class MqttMsgConnack : MqttMsgBase
#region Constants...

// return codes for CONNACK message
/// <summary>
/// Connection Accepted
/// </summary>
public const byte CONN_ACCEPTED = 0x00;
/// <summary>
/// Connection refused due to protocol version
/// </summary>
public const byte CONN_REFUSED_PROT_VERS = 0x01;
/// <summary>
/// Connection refused due to identity
/// </summary>
public const byte CONN_REFUSED_IDENT_REJECTED = 0x02;
/// <summary>
/// Connection refused due to server being unavailable
/// </summary>
public const byte CONN_REFUSED_SERVER_UNAVAILABLE = 0x03;
/// <summary>
/// Connection refused due to username or password being incorrect
/// </summary>
public const byte CONN_REFUSED_USERNAME_PASSWORD = 0x04;
/// <summary>
/// Connection refused due to authentication failure
/// </summary>
public const byte CONN_REFUSED_NOT_AUTHORIZED = 0x05;

private const byte TOPIC_NAME_COMP_RESP_BYTE_OFFSET = 0;
Expand Down Expand Up @@ -121,6 +139,11 @@ public static MqttMsgConnack Parse(byte fixedHeaderFirstByte, byte protocolVersi
return msg;
}

/// <summary>
/// Returns the bytes that represents the current object.
/// </summary>
/// <param name="ProtocolVersion">MQTT protocol version</param>
/// <returns>An array of bytes that represents the current object.</returns>
public override byte[] GetBytes(byte ProtocolVersion)
{
int fixedHeaderSize = 0;
Expand Down Expand Up @@ -176,6 +199,10 @@ public override byte[] GetBytes(byte ProtocolVersion)
return buffer;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
21 changes: 17 additions & 4 deletions M2Mqtt/Messages/MqttMsgConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,13 @@ public ushort KeepAlivePeriod
private byte protocolVersion;
// client identifier
private string clientId;
// will retain flag
/// <summary>
/// will retain flag
/// </summary>
protected bool willRetain;
// will quality of service level
/// <summary>
/// will quality of service level
/// </summary>
protected byte willQosLevel;
// will flag
private bool willFlag;
Expand Down Expand Up @@ -240,7 +244,7 @@ public MqttMsgConnect(string clientId) :
/// <param name="willMessage">Will message</param>
/// <param name="cleanSession">Clean sessione flag</param>
/// <param name="keepAlivePeriod">Keep alive period</param>
/// <param name="protocolVersion">Protocol version</param>
/// <param name="protocolVersion">MQTT Protocol version</param>
public MqttMsgConnect(string clientId,
string username,
string password,
Expand Down Expand Up @@ -275,7 +279,7 @@ byte protocolVersion
/// Parse bytes for a CONNECT message
/// </summary>
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
/// <param name="protocolVersion">Protocol Version</param>
/// <param name="protocolVersion">MQTT Protocol Version</param>
/// <param name="channel">Channel connected to the broker</param>
/// <returns>CONNECT message instance</returns>
public static MqttMsgConnect Parse(byte fixedHeaderFirstByte, byte protocolVersion, IMqttNetworkChannel channel)
Expand Down Expand Up @@ -393,6 +397,11 @@ public static MqttMsgConnect Parse(byte fixedHeaderFirstByte, byte protocolVersi
return msg;
}

/// <summary>
///
/// </summary>
/// <param name="protocolVersion">MQTT protocol version</param>
/// <returns></returns>
public override byte[] GetBytes(byte protocolVersion)
{
int fixedHeaderSize = 0;
Expand Down Expand Up @@ -567,6 +576,10 @@ public override byte[] GetBytes(byte protocolVersion)
return buffer;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
10 changes: 4 additions & 6 deletions M2Mqtt/Messages/MqttMsgConnectEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ and the Eclipse Distribution License is available at
Paolo Patierno - initial API and implementation and/or initial documentation
*/

#if (NANOFRAMEWORK_1_0)
using System;
#elif (!MF_FRAMEWORK_VERSION_V4_2 && !MF_FRAMEWORK_VERSION_V4_3)
using System;
#else
#if (MF_FRAMEWORK_VERSION_V4_2 || MF_FRAMEWORK_VERSION_V4_3 || MF_FRAMEWORK_VERSION_V4_4)
using Microsoft.SPOT;
#else
using System;
#endif

namespace uPLibrary.Networking.M2Mqtt.Messages
Expand All @@ -37,7 +35,7 @@ public class MqttMsgConnectEventArgs : EventArgs
/// <summary>
/// Constructor
/// </summary>
/// <param name="msg">CONNECT message received from client</param>
/// <param name="connect">CONNECT message received from client</param>
public MqttMsgConnectEventArgs(MqttMsgConnect connect)
{
this.Message = connect;
Expand Down
11 changes: 10 additions & 1 deletion M2Mqtt/Messages/MqttMsgDisconnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MqttMsgDisconnect()
/// Parse bytes for a DISCONNECT message
/// </summary>
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
/// <param name="protocolVersion">Protocol Version</param>
/// <param name="protocolVersion">MQTT Protocol Version</param>
/// <param name="channel">Channel connected to the broker</param>
/// <returns>DISCONNECT message instance</returns>
public static MqttMsgDisconnect Parse(byte fixedHeaderFirstByte, byte protocolVersion, IMqttNetworkChannel channel)
Expand All @@ -56,6 +56,11 @@ public static MqttMsgDisconnect Parse(byte fixedHeaderFirstByte, byte protocolVe
return msg;
}

/// <summary>
/// Returns the bytes that represents the current object.
/// </summary>
/// <param name="ProtocolVersion">MQTT protocol version</param>
/// <returns>An array of bytes that represents the current object.</returns>
public override byte[] GetBytes(byte protocolVersion)
{
byte[] buffer = new byte[2];
Expand All @@ -71,6 +76,10 @@ public override byte[] GetBytes(byte protocolVersion)
return buffer;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
11 changes: 10 additions & 1 deletion M2Mqtt/Messages/MqttMsgPingReq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public MqttMsgPingReq()
this.type = MQTT_MSG_PINGREQ_TYPE;
}

/// <summary>
/// Returns the bytes that represents the current object.
/// </summary>
/// <param name="ProtocolVersion">MQTT protocol version</param>
/// <returns>An array of bytes that represents the current object.</returns>
public override byte[] GetBytes(byte protocolVersion)
{
byte[] buffer = new byte[2];
Expand All @@ -50,7 +55,7 @@ public override byte[] GetBytes(byte protocolVersion)
/// Parse bytes for a PINGREQ message
/// </summary>
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
/// <param name="protocolVersion">Protocol Version</param>
/// <param name="protocolVersion">MQTT Protocol Version</param>
/// <param name="channel">Channel connected to the broker</param>
/// <returns>PINGREQ message instance</returns>
public static MqttMsgPingReq Parse(byte fixedHeaderFirstByte, byte protocolVersion, IMqttNetworkChannel channel)
Expand All @@ -71,6 +76,10 @@ public static MqttMsgPingReq Parse(byte fixedHeaderFirstByte, byte protocolVersi
return msg;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
11 changes: 10 additions & 1 deletion M2Mqtt/Messages/MqttMsgPingResp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public MqttMsgPingResp()
/// Parse bytes for a PINGRESP message
/// </summary>
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
/// <param name="protocolVersion">Protocol Version</param>
/// <param name="protocolVersion">MQTT Protocol Version</param>
/// <param name="channel">Channel connected to the broker</param>
/// <returns>PINGRESP message instance</returns>
public static MqttMsgPingResp Parse(byte fixedHeaderFirstByte, byte protocolVersion, IMqttNetworkChannel channel)
Expand All @@ -57,6 +57,11 @@ public static MqttMsgPingResp Parse(byte fixedHeaderFirstByte, byte protocolVers
return msg;
}

/// <summary>
/// Returns the bytes that represents the current object.
/// </summary>
/// <param name="ProtocolVersion">MQTT protocol version</param>
/// <returns>An array of bytes that represents the current object.</returns>
public override byte[] GetBytes(byte protocolVersion)
{
byte[] buffer = new byte[2];
Expand All @@ -72,6 +77,10 @@ public override byte[] GetBytes(byte protocolVersion)
return buffer;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
11 changes: 10 additions & 1 deletion M2Mqtt/Messages/MqttMsgPuback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public MqttMsgPuback()
this.type = MQTT_MSG_PUBACK_TYPE;
}

/// <summary>
/// Returns the bytes that represents the current object.
/// </summary>
/// <param name="ProtocolVersion">MQTT protocol version</param>
/// <returns>An array of bytes that represents the current object.</returns>
public override byte[] GetBytes(byte protocolVersion)
{
int fixedHeaderSize = 0;
Expand Down Expand Up @@ -80,7 +85,7 @@ public override byte[] GetBytes(byte protocolVersion)
/// Parse bytes for a PUBACK message
/// </summary>
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
/// <param name="protocolVersion">Protocol Version</param>
/// <param name="protocolVersion">MQTT Protocol Version</param>
/// <param name="channel">Channel connected to the broker</param>
/// <returns>PUBACK message instance</returns>
public static MqttMsgPuback Parse(byte fixedHeaderFirstByte, byte protocolVersion, IMqttNetworkChannel channel)
Expand Down Expand Up @@ -110,6 +115,10 @@ public static MqttMsgPuback Parse(byte fixedHeaderFirstByte, byte protocolVersio
return msg;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
11 changes: 10 additions & 1 deletion M2Mqtt/Messages/MqttMsgPubcomp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public MqttMsgPubcomp()
this.type = MQTT_MSG_PUBCOMP_TYPE;
}

/// <summary>
/// Returns the bytes that represents the current object.
/// </summary>
/// <param name="ProtocolVersion">MQTT protocol version</param>
/// <returns>An array of bytes that represents the current object.</returns>
public override byte[] GetBytes(byte protocolVersion)
{
int fixedHeaderSize = 0;
Expand Down Expand Up @@ -80,7 +85,7 @@ public override byte[] GetBytes(byte protocolVersion)
/// Parse bytes for a PUBCOMP message
/// </summary>
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
/// <param name="protocolVersion">Protocol Version</param>
/// <param name="protocolVersion">MQTT Protocol Version</param>
/// <param name="channel">Channel connected to the broker</param>
/// <returns>PUBCOMP message instance</returns>
public static MqttMsgPubcomp Parse(byte fixedHeaderFirstByte, byte protocolVersion, IMqttNetworkChannel channel)
Expand Down Expand Up @@ -110,6 +115,10 @@ public static MqttMsgPubcomp Parse(byte fixedHeaderFirstByte, byte protocolVersi
return msg;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
11 changes: 10 additions & 1 deletion M2Mqtt/Messages/MqttMsgPublish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public MqttMsgPublish(string topic,
this.messageId = 0;
}

/// <summary>
/// Returns the bytes that represents the current object.
/// </summary>
/// <param name="ProtocolVersion">MQTT protocol version</param>
/// <returns>An array of bytes that represents the current object.</returns>
public override byte[] GetBytes(byte protocolVersion)
{
int fixedHeaderSize = 0;
Expand Down Expand Up @@ -191,7 +196,7 @@ public override byte[] GetBytes(byte protocolVersion)
/// Parse bytes for a PUBLISH message
/// </summary>
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
/// <param name="protocolVersion">Protocol Version</param>
/// <param name="protocolVersion">MQTT Protocol Version</param>
/// <param name="channel">Channel connected to the broker</param>
/// <returns>PUBLISH message instance</returns>
public static MqttMsgPublish Parse(byte fixedHeaderFirstByte, byte protocolVersion, IMqttNetworkChannel channel)
Expand Down Expand Up @@ -262,6 +267,10 @@ public static MqttMsgPublish Parse(byte fixedHeaderFirstByte, byte protocolVersi
return msg;
}

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
#if TRACE
Expand Down
Loading

0 comments on commit 42b23a4

Please sign in to comment.