Mystic Pants have just released our AT commands library.
Why do we need this? When working with AT commands to an external device you must send and receive data as text. Complications arise well beyond the basic “send ping, receive pong”:
- The partner’s response time may vary
- The partner may stop responding (you need timeouts)
- Multiple responses may need to be matched, either in a specific order or not
- The partner may interject with extra, unsolicited messages at any time
- Multiple commands may need to be chained together
- The commands that are sent, and what data they contain, may depend on the results of previous commands (e.g. for retries or branching logic)
The AT class simplifies checking incoming responses and sequencing together asynchronous commands with all the flexibility you need to implement complex text-based communications flows.
It might even be useful for other sync or async text-based communications between your Imp code and some other conversation partner. There is nothing about the library that limits it to AT commands only. You could even run one instance on the device and one on the agent and have them talk to each other.
The library’s been used for AT commands against multiple external chips (connected to an Imp by UART), and unit tests are included. Head on over to the README to check out the API.