BACnet
BACnet copied to clipboard
Receiving events (OnEventNotify) is not working
With BacnetClient I have used OnEventNotify event, but it seems that it is never called. However, OnUnconfirmedServiceRequest does work. I have used "AnotherStorageImplementation" example which is sending those events.
I think the problem lies in Serialize\Services.cs DecodeEventNotifyData method.
How to reproduce
Create new C# console, install BACnet.Core via NuGet. Write code, such as:
class Program
{
static void Main(string[] args)
{
BacnetClient client = new BacnetClient();
client.OnIam += Client_OnIam;
client.OnEventNotify += Client_OnEventNotify;
client.OnUnconfirmedServiceRequest += Client_OnUnconfirmedServiceRequest;
client.Start();
Console.ReadLine();
}
private static void Client_OnUnconfirmedServiceRequest(BacnetClient sender, BacnetAddress adr, BacnetPduTypes type, BacnetUnconfirmedServices service, byte[] buffer, int offset, int length)
{
Console.WriteLine("Client_OnUnconfirmedServiceRequest");
}
private static void Client_OnEventNotify(BacnetClient sender, BacnetAddress adr, byte invokeId, BacnetEventNotificationData eventData, bool needConfirm)
{
Console.WriteLine("Client_OnEventNotify");
}
private static void Client_OnIam(BacnetClient sender, BacnetAddress adr, uint deviceId, uint maxAPDU, BacnetSegmentations segmentation, ushort vendorId)
{
Console.WriteLine("Got I am.");
}
}
And now test it with "AnotherStorageImplementation" example. Client_OnEventNotify is never called.
Edit: It seems like there is a problem in the part where it is "tag 12 - event values". ASN1.decode_is_closing_tag_number is false, and then it returns -1.
hi @DoctorSloww, which version of the nuget are you using? Please try with latest beta. If that still exists, can you checkout the v2 branch and try again?
@gralin, the nuget I am using is: NuGet Package Manager 4.6.0. And I installed BACnet.Core, version 1.0.30. I think I have no option for beta.
I tried with v2 branch and it is the same. Is it possible that AnotherStorageImplementation example is not working properly? How would you test this?