Skip to content

Commit fc2c8ef

Browse files
authored
Merge pull request #82 from IOT-DSA/feature/Update-QOS-onChange
Resolve issue with QOS downgrades.
2 parents 0b0e2ba + a7298a5 commit fc2c8ef

4 files changed

Lines changed: 13 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ChangeLog
22

3+
* v1.0.5 - Ensure that QOS downgrades are propagated.
4+
* v1.0.4+1 - Map logger names to match DSA log levels.
5+
* v1.0.4 - Forward any errors generated by a `list` request to the requester.
6+
* v1.0.3 - Update packages to use hosted rather than repository sources.
37
* v1.0.2 - Properly forward QOS level changes to nodes when changing an existing subscription QOS level.
48
* v1.0.1 - Fix bug in list subscriptions for nodes which have been removed and recreated throughout subscription's life.
59
This may have prevented list subscriptions from updating full entries.

lib/src/requester/request/subscribe.dart

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,13 @@ class ReqSubscribeController {
265265
}
266266

267267
void listen(callback(ValueUpdate update), int qos) {
268-
if (qos < 0 || qos > 3) {
269-
qos = 0;
270-
}
271-
bool qosChanged = false;
268+
qos = qos.clamp(0, 3);
272269

273-
if (callbacks.containsKey(callback)) {
274-
callbacks[callback] = qos;
275-
qosChanged = updateQos();
276-
} else {
277-
callbacks[callback] = qos;
278-
if (qos > currentQos) {
279-
qosChanged = true;
280-
currentQos = qos;
281-
}
282-
if (_lastUpdate != null) {
283-
callback(_lastUpdate);
284-
}
270+
callbacks[callback] = qos;
271+
bool qosChanged = updateQos();
272+
273+
if (_lastUpdate != null) {
274+
callback(_lastUpdate);
285275
}
286276

287277
if (qosChanged) {

lib/src/responder/response/subscribe.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ class RespSubscribeController {
207207
ISubscriptionNodeStorage _storage;
208208

209209
void set qosLevel(int v) {
210-
if (v < 0 || v > 3) v = 0;
211-
if (_qosLevel == v)
212-
return;
210+
v = v.clamp(0, 3);
211+
if (_qosLevel == v) return;
213212

214213
_qosLevel = v;
215214
if (waitingValues == null && _qosLevel > 0) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: dslink
2-
version: 1.0.4+1
2+
version: 1.0.5
33
description: "DSA IoT Platform - DSLink SDK for Dart"
44
homepage: "http://iot-dsa.org"
55
documentation: "https://iot-dsa.github.io/docs/sdks/dart/"

0 commit comments

Comments
 (0)