Bouke / HAP

Swift implementation of the Homekit Accessory Protocol
https://boukehaarsma.nl/HAP/
MIT License
364 stars 50 forks source link

Rewrite network stack to Swift NIO (armv7 support!) #68

Closed Bouke closed 5 years ago

Bouke commented 5 years ago

The current network stack uses BlueSocket, which operates very directly on sockets, which means we have to build our own eventing mechanisms. Swift has seen the release of Swift NIO, an event-driven network application framework. Incorporating NIO means that we outsource a lot of the socket handling and eventing.

This PR incorporates a small portion of Vapor's HTTP handler, to parse the raw HTTP fields received from NIO.

The great thing about this rewrite, is that I'm finally able to run HAP on my Raspberry Pi3 (Stretch) on the community build of Swift 4.1.3.

This PR is not finished, there might be some cases that are not yet handled. I'm currently running this in my home to identify gaps, but so far seems to work like a charm. I plan on doing additional refactors to clean up, but maybe I'll leave that for a future PR.

Todo before merging:

gbrooker commented 5 years ago

Why did HAP not run on the Pi before ? Is BlueSocket incompatible ?

Bouke commented 5 years ago

Swift has various 32 bit incompatibilities, and as a result it would segfault a lot; either during compilation or at runtime. There’s a community build version for 4.1.3 that’s much better. Maybe it would even run master branch, I haven’t checked.

Op 18 dec. 2018 om 06:56 heeft Guy Brooker notifications@github.com het volgende geschreven:

Why did HAP not run on the Pi before ? Is BlueSocket incompatible ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.