Short answer

ZigZag, a Show HN project that reached the top of Hacker News on 13 November 2026, replaced a $300 embroidery machine's subscription app by reverse-engineering its Bluetooth LE protocol. For an iOS app that talks to a device like this, capture the official app's traffic with Apple's Bluetooth logging profile and PacketLogger, write down the GATT map, add NSBluetoothAlwaysUsageDescription first, drive Core Bluetooth through a state machine, pace your writes, and test the protocol against a fake device. Settle the trademark and permission questions before App Review asks.

A Show HN post climbed to the top of Hacker News on 13 November 2026 with a title most hardware owners can relate to: "My $300 embroidery machine needed a subscription, so I built my own app." By the evening of 13 November WIB it had more than 540 points and close to 190 comments. The app is ZigZag, a free, open-source embroidery editor for Mac and Windows written in Rust. It turns SVG artwork into stitches, exports common machine formats, and can send a design straight to a Brother Skitch (PP1) over Bluetooth.

The embroidery part is fun, but the part iOS developers should look at is the Bluetooth part. The README says plainly that the Skitch protocol was reverse-engineered, and its NOTICE file credits the Bluetooth protocol and sewing flow to an earlier Apache-licensed project called Respira. The README also documents how to capture the official app's Bluetooth conversation from an iPhone using Apple's own logging profile and PacketLogger. That is the same workflow you need when a client hands you a gadget and says "make our app talk to this," or when a founder used an AI tool to build a companion app and the Bluetooth code falls over the moment it meets a real device.

This post walks through that workflow for an iOS app: how to capture and read the traffic, how to write the Core Bluetooth side, how to handle permissions and background mode, and what App Review cares about before you ship an app that controls someone else's hardware.

What ZigZag actually does with Bluetooth

It helps to be precise about what the project contains, because the headline invites guesses. From the README and source tree on GitHub:

  • The Bluetooth code lives in src/machine/, described as the "Skitch Bluetooth protocol" with a btleplug client behind a ble build feature. btleplug is a cross-platform Rust Bluetooth LE library.
  • The Skitch is a Bluetooth LE device. The README notes it never shows up in macOS Bluetooth settings and pairs only when ZigZag connects.
  • The send flow has named steps: Connect, Home, Send, Trial, Sew, Done. The app reports progress, thread changes and machine errors such as thread breaks, and after a thread break it rolls the needle back a fixed number of stitches, the same way the official Artspira app does according to the README.
  • It ships a simulated machine you can connect to from the Skitch window, so the whole job can be tested without hardware.
  • It warns users to avoid firmware updates, because the protocol was worked out from the outside and a firmware change could break it.
  • For commands nobody has decoded yet, the README describes a diff method: read the settings block the machine reports, change one setting in the official app, read again, and compare the bytes that changed.

The project is licensed under Apache 2.0, and the README says the tests include a full Skitch flow against the simulated machine. It also has an MCP server so AI agents can edit designs, which is why it caught attention among AI tooling folks too. For this article, the Bluetooth design choices are what matter: a protocol layer separate from transport, a simulator, a capture tool, and clear warnings about what can break.

Step 1: Decide whether you are allowed to do this

Before you capture a single packet, settle the permission question, because App Review will ask it for you if you don't.

Guideline 5.2.1 says not to use protected third-party material such as trademarks, copyrighted works or patented ideas without permission, and not to include misleading or copycat names or metadata. Guideline 5.2.2 says that if your app uses or accesses a third-party service, you must be specifically permitted to do so under that service's terms, and "authorization must be provided upon request."

Those two rules shape the project in practice: Claude Code Won't Clone Games Anymore: What Still Gets Your Game Rejected by Apple covers the copycat side of the same guidelines.

  • If the device belongs to your client, get the protocol documentation or written permission from them and keep it somewhere you can attach to an App Review reply.
  • If you are building an unofficial app for someone else's hardware, don't put the manufacturer's brand in your app name, icon or screenshots. Describing compatibility in plain words in the description is a different thing from looking like the official app, but the line is App Review's to draw, so be conservative.
  • If the official device also talks to a cloud service, your app should talk only to the device over the air, not to the vendor's servers with borrowed keys.

None of this is legal advice. It is the set of questions a reviewer is likely to raise, and having answers ready saves a rejection cycle.

Step 2: Capture the official app's Bluetooth traffic on an iPhone

Apple provides a Bluetooth logging profile for iOS and iPadOS that turns on detailed Bluetooth logging on the device. You pair it with PacketLogger on a Mac to watch the traffic live.

  1. On the iPhone, open Apple's Profiles and Logs page, search for "bluetooth" and pick the entry named Bluetooth for iOS/iPadOS. In March 2026 an Apple DTS engineer confirmed on the developer forums that this is where the profile lives, after a developer reported it missing from an older page.
  2. Sign in with your Apple Developer account, download the profile, then install it from Settings. Follow the instructions PDF linked from the same entry, including any restart it asks for.
  3. On the Mac, get PacketLogger. It ships in the Hardware folder of the Additional Tools for Xcode download from Apple's developer downloads page.
  4. Connect the iPhone to the Mac with a cable, open PacketLogger and choose File > New iOS Trace.
  5. Use the official app on the phone to do one action at a time: connect, then one command, then disconnect. Save the trace as a .pklg file between actions so each file holds one thing.

ZigZag's README describes exactly this capture path, and its zigzag capture command reads both iPhone PacketLogger traces and Android HCI snoop logs to list the Skitch conversation by command name. You don't need ZigZag to do your own capture, but its approach is worth copying: record small, single-purpose traces and label them with what you did.

Step 3: Read the trace and write down the GATT map

A Bluetooth LE device exposes services, each with characteristics. The official app reads characteristics, writes to them, and subscribes to notifications. In PacketLogger you will see this as ATT operations. What you want out of the trace is a small table, kept in your repo next to the code:

What you recordWhy it matters
Advertised name and service UUIDsLets you scan for this device only, instead of scanning for everything
Service and characteristic UUIDsEvery read, write and subscription targets one of these
Write type per characteristic (with or without response)Decides whether you get a success callback and how fast you can send
Byte layout of each command and replyThe actual protocol: opcodes, lengths, checksums, sequence numbers
Order of operations on connectMany devices refuse commands until a handshake or status read happens first
Errors and their codesSo your app can tell the user "bobbin empty" instead of "something went wrong"

The diff trick from ZigZag's README works for any device. Capture once, change exactly one setting in the official app, capture again, and compare. The bytes that moved are the ones that encode that setting. Do this for each setting you need and you build the protocol one field at a time, with evidence for each field.

One caution. If the device uses encrypted pairing, the trace shows encrypted payloads only after pairing in some cases, and some devices also sign or encrypt at the application layer. If the payloads look random from the first byte, stop and talk to the manufacturer. Breaking application-level protection is a different project with different legal risk, and it is outside what this post covers.

Step 4: Add the Bluetooth permission string before you write any code

Apple's Core Bluetooth documentation is blunt about this: "Your app will crash if its Info.plist doesn't include usage description keys for the types of data it needs to access." For apps linked on or after iOS 13, the key is NSBluetoothAlwaysUsageDescription. The older NSBluetoothPeripheralUsageDescription only applies to iOS 12 and earlier.

A common way this goes wrong in AI-built apps: the generated code creates a CBCentralManager, the plist key is missing, and the app crashes the moment that screen opens. It often passes in the simulator during quick checks because nobody reached that screen, then fails on a reviewer's device. Guideline 2.1 Rejection: Why Your AI-Built App Crashed in App Review shows how that crash looks to a reviewer.

Write the string as a real sentence about what the user gets. Guideline 5.1.1(ii) says to "ensure your purpose strings clearly and completely describe your use of the data." Something like this works:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>Bluetooth lets this app send your designs to your embroidery machine and show its progress while it sews.</string>

"This app uses Bluetooth" is the kind of string that draws a 5.1.1 rejection, because it says nothing about why.

Step 5: Write the central manager around a state machine

The Core Bluetooth flow for a single device always runs the same way: wait for the manager to be powered on, scan for the device's service, connect, discover services, discover characteristics, subscribe to notifications, then start sending commands. Apple's CBCentralManager documentation says to make sure the manager's state is powered on before calling its methods.

Here is a trimmed Swift sketch. The UUIDs are placeholders you replace with the ones from your GATT map. It was later compiled for iOS 17, as described after Step 7, but not run against a real device, so treat it as a starting shape.

@preconcurrency import CoreBluetooth

final class DeviceLink: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate {
    enum State { case idle, scanning, connecting, discovering, ready, failed(String) }

    static let serviceID = CBUUID(string: "00000000-0000-0000-0000-000000000000")
    static let commandID = CBUUID(string: "00000000-0000-0000-0000-000000000001")
    static let statusID  = CBUUID(string: "00000000-0000-0000-0000-000000000002")

    private var central: CBCentralManager!
    private var peripheral: CBPeripheral?
    private var command: CBCharacteristic?
    private(set) var state: State = .idle

    override init() {
        super.init()
        central = CBCentralManager(delegate: self, queue: nil)
    }

    func centralManagerDidUpdateState(_ central: CBCentralManager) {
        guard central.state == .poweredOn else {
            state = .failed("Bluetooth is off or not allowed")
            return
        }
        state = .scanning
        central.scanForPeripherals(withServices: [Self.serviceID], options: nil)
    }

    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral,
                        advertisementData: [String: Any], rssi RSSI: NSNumber) {
        central.stopScan()
        self.peripheral = peripheral
        peripheral.delegate = self
        state = .connecting
        central.connect(peripheral, options: nil)
    }

    func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
        state = .discovering
        peripheral.discoverServices([Self.serviceID])
    }

    func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
        guard let service = peripheral.services?.first(where: { $0.uuid == Self.serviceID }) else { return }
        peripheral.discoverCharacteristics([Self.commandID, Self.statusID], for: service)
    }

    func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
        for c in service.characteristics ?? [] {
            if c.uuid == Self.commandID { command = c }
            if c.uuid == Self.statusID { peripheral.setNotifyValue(true, for: c) }
        }
        state = .ready
    }

    func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
        guard let data = characteristic.value else { return }
        // Decode with your protocol layer, not here.
        _ = data
    }
}

Three things in that sketch matter more than they look. Scanning with the service UUID instead of nil keeps the scan narrow and is what works in the background. Stopping the scan once you find the device saves battery. And the decode comment is there on purpose: keep byte parsing out of the delegate.

Save the peripheral's identifier after the first connection. Next launch, call retrievePeripherals(withIdentifiers:) and connect directly instead of scanning again, which is faster and kinder to the battery.

Step 6: Send data at the rate the device can take

Large transfers like an embroidery design, firmware chunks or an image are where AI-generated Bluetooth code usually breaks. The pattern that fails is a tight loop calling writeValue on every chunk as fast as possible.

Apple's documentation for writeValue(_:for:type:) explains the difference between the two write types. With .withResponse, your delegate gets peripheral(_:didWriteValueFor:error:) and learns whether the write worked. With .withoutResponse, Core Bluetooth "attempts to write the value but doesn't guarantee success," and you are not told if it fails. Check the characteristic's properties to see which writes it supports.

A safer transfer loop looks like this:

  1. Ask the peripheral for maximumWriteValueLength(for:) with the write type you will use, and cut your payload into chunks no larger than that.
  2. For writes without response, send only while canSendWriteWithoutResponse is true. When it turns false, stop and wait for peripheralIsReady(toSendWriteWithoutResponse:) before sending the next chunk.
  3. For writes with response, send one chunk, wait for the callback, then send the next.
  4. If the device's own protocol has acknowledgements or sequence numbers, which you will see in the trace, respect those too. The radio accepting a write doesn't mean the device processed it.
func pump() {
    guard let p = peripheral, let c = command else { return }
    let max = p.maximumWriteValueLength(for: .withoutResponse)
    while p.canSendWriteWithoutResponse, offset < payload.count {
        let end = min(offset + max, payload.count)
        p.writeValue(payload.subdata(in: offset..<end), for: c, type: .withoutResponse)
        offset = end
    }
}

func peripheralIsReady(toSendWriteWithoutResponse peripheral: CBPeripheral) {
    pump()
}

Step 7: Split the protocol from the radio and build a fake device

ZigZag keeps the protocol in its own files (protocol.rs, session.rs, skitch.rs per its NOTICE) and has a simulated machine. That split is the single most useful idea to copy into an iOS project.

In Swift, define the transport as a protocol:

import Foundation

protocol DeviceTransport {
    func send(_ bytes: Data) async throws
    var incoming: AsyncStream<Data> { get }
}

Your real DeviceLink implements it with Core Bluetooth. A FakeDevice implements it in memory and replies the way your traces say the real device replies, including the error cases. Your protocol code, which builds commands and decodes replies, only ever sees DeviceTransport.

This gives you three things you can't easily get any other way. You can write unit tests that run in the simulator, where Core Bluetooth has no real radio to talk to. You can feed the decoder the exact bytes from your saved traces as test fixtures. And you can show App Review a working flow even when the reviewer has no hardware, which matters more than most founders expect.

Compiling the sketch, and a fake device that runs

The Swift above was type-checked with Xcode 26.2 against the iOS 17 Simulator SDK, with the pump() fragment placed inside DeviceLink and the two transfer properties it uses, payload and offset, added. In the Swift 5 language mode it compiled cleanly. Two changes were needed for the rest:

  • In Swift 6 mode the three static let UUIDs failed with "static property 'serviceID' is not concurrency-safe because non-'Sendable' type 'CBUUID' may have shared mutable state", and the compiler suggested @preconcurrency on the import. The sketch above now imports Core Bluetooth that way, and it compiles in both modes.
  • The DeviceTransport protocol, saved in a file of its own, failed with "cannot find type 'Data' in scope", because every Swift file needs its own imports. It now imports Foundation.

Reading the sketch closely for the test also showed what "trimmed" left out. There is no centralManager(_:didFailToConnect:error:) and no centralManager(_:didDisconnectPeripheral:error:), so a failed connection leaves the state at .connecting and a dropped one leaves it at .ready. And .ready is set even if the command characteristic was never found. Add both callbacks and that check before the sketch goes anywhere near users.

Step 7's fake device is the part that can run without hardware, so it was built. This is a minimal version, with a protocol layer that sends a design in chunks and waits for a reply after each one. The byte values are made up for the example; yours come from your traces:

import Foundation

/// An in-memory stand-in for the machine. The byte values are made up
/// for this example: 0x10 sends stitches, 0x90 is an ack, 0xE1 a thread break.
final class FakeDevice: DeviceTransport {
    let incoming: AsyncStream<Data>
    private let reply: AsyncStream<Data>.Continuation
    private let breakAfter: Int?
    private var stitches = 0

    init(threadBreakAfter: Int? = nil) {
        (incoming, reply) = AsyncStream.makeStream(of: Data.self)
        breakAfter = threadBreakAfter
    }

    func send(_ bytes: Data) async throws {
        stitches += bytes.count - 1
        if let limit = breakAfter, stitches > limit {
            reply.yield(Data([0xE1]))
        } else {
            reply.yield(Data([0x90]))
        }
    }
}

enum SendResult: Equatable { case done, threadBreak(afterChunk: Int) }
struct LinkClosed: Error {}

/// The protocol layer: knows the bytes, not the radio.
func sendDesign(_ stitches: [UInt8], chunk: Int, over link: DeviceTransport) async throws -> SendResult {
    var replies = link.incoming.makeAsyncIterator()
    var index = 0
    for start in stride(from: 0, to: stitches.count, by: chunk) {
        index += 1
        let part = stitches[start..<min(start + chunk, stitches.count)]
        try await link.send(Data([0x10]) + Data(part))
        guard let answer = await replies.next() else { throw LinkClosed() }
        if answer == Data([0xE1]) { return .threadBreak(afterChunk: index) }
    }
    return .done
}

Run as a Mac command-line tool in both language modes, a 1,000-stitch design in chunks of 180 finished with .done. With the fake set to break the thread after 500 stitches, it returned .threadBreak(afterChunk: 3), which is right, since the third chunk takes the count to 540. An empty design returned .done without sending anything, which may or may not be what your real device expects. That last case is exactly the kind of question a fake device lets you settle in a unit test, long before you have the hardware on your desk.

Step 8: Background mode, only if you really need it

If the app must keep talking to the device while the user is in another app, for example to report progress during a long job, add the Background Modes capability in Xcode and tick Uses Bluetooth LE accessories. Xcode writes bluetooth-central into UIBackgroundModes. Apple describes it as for an app that "communicates with a Bluetooth accessory while in the background."

Guideline 2.5.4 says background services may only be used for their intended purposes. If you tick the box and the reviewer can't see why the app needs it, expect questions. Mention the background use in the App Review notes with a sentence like "the app keeps receiving progress updates from the connected machine during a sewing job."

Apple's Core Bluetooth overview adds one newer option: in iOS 26 and later, if your app has a CBManager and starts a Live Activity before going to the background, it keeps its foreground Bluetooth privileges while the Live Activity runs. For a job with a clear start and end, a Live Activity showing progress can be a better fit than permanent background mode.

Step 9: Consider AccessorySetupKit for new apps on iOS 18 and later

AccessorySetupKit, available from iOS 18, lets an app discover and set up a specific Bluetooth or Wi-Fi accessory through a system picker. Apple's sample is titled "Setting up and authorizing a Bluetooth accessory" and describes doing that "without requesting permission to use Bluetooth." The user picks the accessory in a system sheet and the app gets access to that accessory only.

It uses its own Info.plist keys, listed on the framework page: NSAccessorySetupKitSupports, NSAccessorySetupBluetoothServices, NSAccessorySetupBluetoothNames and NSAccessorySetupBluetoothCompanyIdentifiers. If your minimum target is iOS 18 and you only need one kind of device, it can remove the scary system permission prompt and narrow what your app can see, which also helps with 5.1.1(iii) on data minimization. If you support older iOS versions you will still need the Core Bluetooth path from Step 4.

App Review checklist for an app that controls hardware

Run through this before you press Submit:

  • NSBluetoothAlwaysUsageDescription is present and says what the user gets.
  • The app does something useful before Bluetooth permission is granted, or explains clearly why it needs the device. Guideline 5.1.1(iv) asks for alternatives where possible when a user declines.
  • App name, icon and screenshots don't use the device maker's trademarks unless you have permission (5.2.1).
  • You can show authorization for any third-party service the app uses (5.2.2).
  • Background mode is ticked only if the app truly works in the background, and the review notes explain it (2.5.4).
  • The review notes say the app needs a specific device and include a demo video of it working. If you built a fake device mode for testing, say whether reviewers can turn it on.
  • The app only uses public APIs (2.5.1). Core Bluetooth and AccessorySetupKit are public; private frameworks for Bluetooth are not.
  • Error states read like the device's real errors from your traces, not raw byte dumps.

What to take from ZigZag even if you never touch embroidery

The project shows a complete, honest version of a job many iOS developers get asked to do: make a phone or laptop talk to a device whose maker didn't publish a protocol. It records traffic with Apple's own tools, keeps the decoded protocol in one place, tests against a simulated device, warns users about firmware updates, and credits the earlier work it ported. If an AI coding tool wrote your app's Bluetooth layer, comparing it with that structure is a quick way to find what's missing. Check for the simulator, the write pacing and the plist key first.

FAQ

Do I need MFi certification to talk to a Bluetooth LE device?

Core Bluetooth is the public framework for Bluetooth LE devices, and the examples above use only it. MFi applies to other accessory programs; check Apple's MFi program page if your device uses the External Accessory framework instead of Bluetooth LE.

Can I test Core Bluetooth in the iOS Simulator?

Apple's AccessorySetupKit sample says it can't run in Simulator because it relies on Bluetooth and needs a device. Plan for physical devices for radio tests and use a fake transport, as in Step 7, for everything else.

Why does my app crash when the Bluetooth screen opens?

The most common cause is a missing NSBluetoothAlwaysUsageDescription key. Apple's Core Bluetooth documentation says the app will crash without the usage description.

Is the Bluetooth logging profile still available?

Yes. In March 2026 an Apple DTS engineer pointed developers to the Bug Reporting Profiles and Logs page, searching for "bluetooth" and picking Bluetooth for iOS/iPadOS.

Will a firmware update break my reverse-engineered protocol?

It can. ZigZag's README tells users to avoid firmware updates for that reason. Detect the firmware version on connect if the device reports one, and show a clear message when it doesn't match what you tested.

If you build iOS apps with Claude Code, my Claude Code + Xcode: The Production iOS Workflow Kit is a set of Claude Code commands, agents and rules for SwiftUI and UIKit projects, with a runnable Xcode sample app. It includes rules for privacy and release safety and a release-readiness agent, which help with the plist and review-notes checks above. It doesn't include Bluetooth code, so use the steps in this post for that part.

Sources