refactor(db): add constante for max QOS
This commit is contained in:
@@ -14,6 +14,8 @@ import (
|
|||||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const maxQoS = 2
|
||||||
|
|
||||||
// A MqttParams is the abstracted MQTT gateway.
|
// A MqttParams is the abstracted MQTT gateway.
|
||||||
// It provides the MQTT parameters to initialize the connection and the method to add data.
|
// It provides the MQTT parameters to initialize the connection and the method to add data.
|
||||||
type MqttParams struct {
|
type MqttParams struct {
|
||||||
@@ -69,7 +71,7 @@ func NewMqttGateway(p MqttParams) (*MqttGateway, error) {
|
|||||||
return nil, errors.New("[MQTT Gateway] Invalid client id")
|
return nil, errors.New("[MQTT Gateway] Invalid client id")
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Qos > 2 {
|
if p.Qos > maxQoS {
|
||||||
return nil, errors.New("[MQTT Gateway] Invalid QoS level")
|
return nil, errors.New("[MQTT Gateway] Invalid QoS level")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user