Skip to content

Instantly share code, notes, and snippets.

View heidefinnischen's full-sized avatar

Jan heidefinnischen

  • Europe
View GitHub Profile
@conath
conath / Data+Hex.swift
Last active May 11, 2026 19:01
A close to complete CoreData Bluetooth peripheral implementation of the Bluetooth HID Keyboard standard. As of iOS 14, the services are blocked by the system so it's impossible to make an iOS device act as a bluetooth keyboard, for example.
import Foundation
extension Data {
init?(hexString: String) {
let len = hexString.count / 2
var data = Data(capacity: len)
for i in 0..<len {
let j = hexString.index(hexString.startIndex, offsetBy: i*2)
let k = hexString.index(j, offsetBy: 2)
let bytes = hexString[j..<k]