Motivation:
channelActive must always precede channelInactive. Unfortunately, this
isn't guaranteed right now: if we happen to get channelInactive as a
result of our writing the preamble we'll fire them in the wrong order.
Many systems can tolerate this, but we should avoid doing this anyway.
Modifications:
- Added a state enum to keep track of the state we're in
- Use that state enum to ensure we deliver active/inactive in the right
order
- Additionally police other unexpected active/inactive behaviours
Result:
We'll appropriately police the state.