This parameter is optional, so compatibility shouldn't be affected. Each SLMessage can set its own sender ID which is present on the returned message. This allows callers to fire multiple requests at once, even of the same type, while being able to identify which response went with which request. If not specified, the default value is 0.
Also went ahead and documented some of the helper functions present on SLMessage (so, available on all message instances).
Finally, since I was in and messing with each message anyway, I simplified and removed some repeated code from each derived message and had it call into the super to take advantage of shared decoding functionality.
The lambdas ("arrow functions") in test functions were removed per advice from Mocha's documentation where the implicit `this` rebinding can apparently cause problems. This should probably have been its own commit, but, again, I was already in there messing with stuff, so...oh well.
Closes#43
* initial code to interpret valveDataArray
* Some additional comments on the valveDataArray decoding message
* Adds decodeSensorData, decodeValveData, decodeDelayData, decodeMiscData
* reverts unintended change to index.js
* Refactor / rename variables
- renamed variables to better describe their use
- created a helper function 'isValvePresent' to simplify code
- changed while loop to for loop
* - Fixes bug in decodeValveData where only last valve's data was returned
- renames some variables based on testing to more descriptive names
- add CIRCUIT_NAME_VALUE_MAP for fixed values that the system uses (determined by testing on my system)
* refactored decodeMiscData to simplify code
* - Changed CIRCUIT_NAME_VALUE_MAP to array of objects
- Refactored getCircuitByDeviceId
- Added getCircuitsMap as helper to getCircuitByDeviceId and as a utility function to help in UI development
This avoids unnecessary allocations/reallocations while decoding a message by pre-sizing the buffer to the amount we know it will require. I feel like there's probably a better way to handle this, but this works for now.
I should probably turn the semi-colon linter off since I really dislike the semi-colons everywhere, but it's probably too late for that at this point in the project.
Added verification of broadcast response message size
Added clearer handling of message types
I'm sure there's a better way to do debug logging, but I don't really feel like adding a dependency on another module just for that.