@@ -35,14 +35,29 @@ MqttRawReceiverFbImpl::~MqttRawReceiverFbImpl()
3535FunctionBlockTypePtr MqttRawReceiverFbImpl::CreateType ()
3636{
3737 auto defaultConfig = PropertyObject ();
38- auto builder = StringPropertyBuilder (PROPERTY_NAME_TOPIC, " " )
39- .setDescription (" An MQTT topic to subscribe to for receiving raw binary data." );
40- defaultConfig.addProperty (builder.build ());
41- const auto fbType = FunctionBlockType (RAW_FB_NAME,
42- RAW_FB_NAME,
43- " The raw MQTT function block allows subscribing to an MQTT topic and converting MQTT payloads into "
44- " openDAQ signal binary data samples." ,
45- defaultConfig);
38+ {
39+ auto builder =
40+ IntPropertyBuilder (PROPERTY_NAME_SUB_QOS, DEFAULT_SUB_QOS)
41+ .setMinValue (0 )
42+ .setMaxValue (2 )
43+ .setSuggestedValues (List<IInteger>(0 , 1 , 2 ))
44+ .setDescription (
45+ fmt::format (" MQTT Quality of Service level for subscribing. It can be 0 (at most once), 1 (at least once), or 2 "
46+ " (exactly once). By default it is set to {}." ,
47+ DEFAULT_SUB_QOS));
48+ defaultConfig.addProperty (builder.build ());
49+ }
50+ {
51+ auto builder =
52+ StringPropertyBuilder (PROPERTY_NAME_TOPIC, " " ).setDescription (" An MQTT topic to subscribe to for receiving raw binary data." );
53+ defaultConfig.addProperty (builder.build ());
54+ }
55+ const auto fbType =
56+ FunctionBlockType (RAW_FB_NAME,
57+ RAW_FB_NAME,
58+ " The raw MQTT function block allows subscribing to an MQTT topic and converting MQTT payloads into "
59+ " openDAQ signal binary data samples." ,
60+ defaultConfig);
4661 return fbType;
4762}
4863
@@ -77,6 +92,17 @@ void MqttRawReceiverFbImpl::readProperties()
7792 }
7893 }
7994 }
95+
96+ if (objPtr.hasProperty (PROPERTY_NAME_SUB_QOS))
97+ {
98+ auto qosProp = objPtr.getPropertyValue (PROPERTY_NAME_SUB_QOS).asPtrOrNull <IInteger>();
99+ if (qosProp.assigned ())
100+ {
101+ const auto qos = qosProp.getValue (DEFAULT_SUB_QOS);
102+ this ->qos = (qos < 0 || qos > 2 ) ? DEFAULT_SUB_QOS : qos;
103+ }
104+ }
105+
80106 if (!isPresent)
81107 {
82108 LOG_W (" \' {}\' property is missing!" , PROPERTY_NAME_TOPIC);
0 commit comments