HomeKit Accessory Protocol (HAP) for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(lint): replace Printf/Format with Fmt across remaining packages

Migrate Printf.sprintf to Fmt.str, Format.fprintf to Fmt.pf, and
Format.pp_print_string to Fmt.string across bundle, gpt, hap, homebrew,
jsonwt, matter, mbr, meross, paseto, precommit, publicsuffix, qemu,
retry, sdnv, slack, sle, space-packet, spake2, sqlite, squashfs, tar,
tc, tcf, tcpcl, tm, tomlt, tty, uslp, vlog, wal, wire, yamlrw, yamlt,
osrelease, space, xdge, and crypto test runner.

+11 -15
+11 -15
lib/hap.ml
··· 28 28 let get_exn typ tlv = 29 29 match get typ tlv with 30 30 | Some v -> v 31 - | None -> failwith (Printf.sprintf "TLV type %d not found" typ) 31 + | None -> failwith (Fmt.str "TLV type %d not found" typ) 32 32 33 33 (* Encode TLV to bytes - values > 255 bytes are split *) 34 34 let encode tlv = ··· 315 315 in 316 316 let m6 = Tlv.decode m6_body in 317 317 match Tlv.get Tlv_type.error m6 with 318 - | Some e -> 319 - Error (`Msg (Printf.sprintf "Pair setup M6 error: %d" (Char.code e.[0]))) 318 + | Some e -> Error (`Msg (Fmt.str "Pair setup M6 error: %d" (Char.code e.[0]))) 320 319 | None -> verify_m6 ~session_key_bytes ~enc_key controller_kp controller_id m6 321 320 322 321 (* SRP M3/M4 verify exchange and derive encryption key for M5/M6 *) ··· 339 338 in 340 339 let m4 = Tlv.decode m4_body in 341 340 match Tlv.get Tlv_type.error m4 with 342 - | Some e -> 343 - Error (`Msg (Printf.sprintf "Pair setup M4 error: %d" (Char.code e.[0]))) 341 + | Some e -> Error (`Msg (Fmt.str "Pair setup M4 error: %d" (Char.code e.[0]))) 344 342 | None -> 345 343 let m2_proof = Tlv.get_exn Tlv_type.proof m4 in 346 344 if ··· 373 371 in 374 372 let m2 = Tlv.decode m2_body in 375 373 match Tlv.get Tlv_type.error m2 with 376 - | Some e -> 377 - Error (`Msg (Printf.sprintf "Pair setup error: %d" (Char.code e.[0]))) 374 + | Some e -> Error (`Msg (Fmt.str "Pair setup error: %d" (Char.code e.[0]))) 378 375 | None -> 379 376 let salt = Tlv.get_exn Tlv_type.salt m2 in 380 377 let big_b_bytes = Tlv.get_exn Tlv_type.public_key m2 in ··· 441 438 let m4 = Tlv.decode m4_body in 442 439 match Tlv.get Tlv_type.error m4 with 443 440 | Some e -> 444 - Error (`Msg (Printf.sprintf "Pair verify M4 error: %d" (Char.code e.[0]))) 441 + Error (`Msg (Fmt.str "Pair verify M4 error: %d" (Char.code e.[0]))) 445 442 | None -> derive_session_keys ~pairing ~ip ~port ~shared 446 443 447 444 (* Verify M2 response: decrypt, check identity and signature *) ··· 481 478 let m2 = Tlv.decode m2_body in 482 479 match Tlv.get Tlv_type.error m2 with 483 480 | Some e -> 484 - Error (`Msg (Printf.sprintf "Pair verify M2 error: %d" (Char.code e.[0]))) 481 + Error (`Msg (Fmt.str "Pair verify M2 error: %d" (Char.code e.[0]))) 485 482 | None -> 486 483 let accessory_pk = Tlv.get_exn Tlv_type.public_key m2 in 487 484 let enc_data = Tlv.get_exn Tlv_type.encrypted_data m2 in ··· 530 527 let accessories ~net ~sw session = 531 528 let path = "/accessories" in 532 529 let req = 533 - Printf.sprintf "GET %s HTTP/1.1\r\nHost: %s:%d\r\n\r\n" path session.ip 530 + Fmt.str "GET %s HTTP/1.1\r\nHost: %s:%d\r\n\r\n" path session.ip 534 531 session.port 535 532 in 536 533 let* decrypted = request ~net ~sw session req in ··· 568 565 in 569 566 let path = "/characteristics" in 570 567 let req = 571 - Printf.sprintf 568 + Fmt.str 572 569 "PUT %s HTTP/1.1\r\n\ 573 570 Host: %s:%d\r\n\ 574 571 Content-Type: application/hap+json\r\n\ ··· 583 580 (* Read characteristics *) 584 581 let characteristics ~net ~sw session ~ids = 585 582 let ids_str = 586 - String.concat "," 587 - (List.map (fun (aid, iid) -> Printf.sprintf "%d.%d" aid iid) ids) 583 + String.concat "," (List.map (fun (aid, iid) -> Fmt.str "%d.%d" aid iid) ids) 588 584 in 589 - let path = Printf.sprintf "/characteristics?id=%s" ids_str in 585 + let path = Fmt.str "/characteristics?id=%s" ids_str in 590 586 let req = 591 - Printf.sprintf "GET %s HTTP/1.1\r\nHost: %s:%d\r\n\r\n" path session.ip 587 + Fmt.str "GET %s HTTP/1.1\r\nHost: %s:%d\r\n\r\n" path session.ip 592 588 session.port 593 589 in 594 590 let* decrypted = request ~net ~sw session req in