Good Models for Designing Connection-Session library?

I have a small project that would be fun to try out having Swift talk serially to a microcontroller. Typically I've used Java (combined with Processing) to do what this project needs to do but I want to give a shot at a SwiftUI/Canvas based app.

I have sending and receiving hello worlds working (Thank you SwiftSerial!), but since this project also will pair with an Arduino board (which resets with every new serial port connection), I had to build a Serial Port manager class to keep the port open. Today is a refactoring day and I was thinking of tightening up the design based on URLSession, but I thought I'd gather the 2 cents of this community on what a loved communication-connection manager library is (of any protocol) to see if I could crib from that API, if URLSession is not it.

It's going to be really small, really lightweight, very modest, but I will share the code once it's a package.


Welp made some progress over the weekend:

  • Similar to SwiftSerial but different enough structure to make a new one. A SerialPort is a Class. Moved much of the C code into it's own C section of the Package. Shouldn't need Foundation anymore. has CLI for testing. Beginning of async.

  • SerialSession & SerialSessionUI Synchronous Read and Write examples. Async examples next on the todo list.

Will keep poking along at this but will only update thread when there is a 0.0.1 released :wink:. Feedback welcome.

UPDATE: GitHub - apple/swift-nio: Event-driven network application framework for high performance protocol servers & clients, non-blocking. is very helpful