nerves-networking / vintage_net_mobile

Mobile networking for VintageNet
Apache License 2.0
27 stars 11 forks source link

Refactor AT command runner to support notifications #48

Closed fhunleth closed 4 years ago

fhunleth commented 4 years ago

This refactors that AT command runner in the following ways:

  1. Add notification support so that AT commands can be used where the modem periodically posts its status.
  2. Separate the main logic out of the GenServer so that it's easier to test.
  3. Check for error returns as well as "OK". This makes it possible to return failure without waiting for a timeout.
  4. Various timeout handling improvements to avoid GenServer timeouts happening before modem timeouts
  5. Don't query for signal strength when not connected. Some modems don't like this.
fhunleth commented 4 years ago

I would like to make a few more improvements to this, but the change is already getting kind of big.

I'm not happy with the notification mechanism from ExChat to SignalMonitor, so I'll make a pass on that. I also think that there are some more simplifications to the code and possibly some test improvements to bump coverage.

However, this does increase some robustness for monitoring signals and it prevents the whole modem unhappiness thing when polling while not connected (it just sets the RSSI to 99 to indicate not connected). I feel that it's worth using if you're following master.

fhunleth commented 4 years ago

Thanks - I forgot to check the hex docs. I'm going to @moduledoc false them for now. I've been debating about renaming ExChat too. For some reason, it makes me smile, so I've kept it. I'm hoping that I figure out another name after I get the next pass at the signal checking work in. I do think that it should eventually be public since anyone adding a custom modem implementation will likely need to add it to their supervision tree at a minimum.