roblans / ZWave4Net

ZWave4Net is a .NET library that interfaces with the Aeotec / Aeon Labs Z-Stick.
MIT License
41 stars 34 forks source link

Implement RequestNodeNeighborUpdate #18

Closed richardthombs closed 6 years ago

richardthombs commented 6 years ago

Hi Rob,

This is my first attempt at getting RequestNodeNeighborUpdate to work. In order to get the Send method to be able to return the appropriate payload, I added an IMessageWithPayload interface which both ControllerFunctionCompleted and UnknownMessage implement (it just returns the payload byte array).

I know it's not very elegant to just return UnknownMessage and I'm happy to do something else instead. Also, I know the way of recognising the return message isn't very pretty either, and again I'm happy to do something else.

Cheers,

R.

roblans commented 6 years ago

Hi Richard,

I've done some refactoring on this one, and I think I've got a good and generic solution: I seems that the RequestNodeNeighborUpdate function sends multiple eventmessages during execution (Started, Done and Failed). So I added a new messagetype ControllerFunctionEvent which represents this message (no more UnknownMessage on this one).

I've implemented this mechanism om RequestNeighborUpdate:

var report = await node.RequestNeighborUpdate();

or if you want progress:

var result = await node.RequestNeighborUpdate((progress) => LogMessage($"RequestNeighborUpdate: {progress} "));

https://github.com/roblans/ZWave4Net/commit/ea1026bb06e9a9c24898d7413e14481c1afe86c8

richardthombs commented 6 years ago

Thanks Rob!