Skip to content

Commit

Permalink
Merge pull request #108 from aimoehi/patch-1
Browse files Browse the repository at this point in the history
Fix 'ER-State error
  • Loading branch information
zivillian authored Aug 24, 2024
2 parents 51937ab + 5889823 commit 0d8360d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ism7mqtt/ISM7/Ism7Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,16 @@ private async Task OnPushResponseAsync(IResponse response, CancellationToken can
if (!String.IsNullOrEmpty(resp.Errormsg))
throw new InvalidDataException(resp.Errormsg);
if (resp.State != TelegrResponseState.OK)
throw new InvalidDataException($"unexpected state '{resp.State}");

var hasDatapoints = _config.ProcessData(resp.Telegrams.Where(x => x.State == TelegrResponseState.OK));
if (hasDatapoints)
{
await _messageHandler(_config, cancellationToken);
await Console.Error.WriteLineAsync($"unexpected state '{resp.State}");
}
else
{
var hasDatapoints = _config.ProcessData(resp.Telegrams.Where(x => x.State == TelegrResponseState.OK));
if (hasDatapoints)
{
await _messageHandler(_config, cancellationToken);
}
}
}

Expand Down Expand Up @@ -413,4 +417,4 @@ private XmlSerializer GetSerializer<T>()
return _serializers.GetOrAdd(typeof(T), x => new XmlSerializer(x));
}
}
}
}

0 comments on commit 0d8360d

Please sign in to comment.