HomeKit Accessory Protocol (HAP) for OCaml
0
fork

Configure Feed

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

ocaml-crow, ocaml-hap: drop let _ = / let _x discards in README examples

Per the mdx skill: in docs, unused values are a smell — the example
shouldn't be going through the motions without showing the API at
work.

- ocaml-crow: replace [let _ = Crow.build_targets ...] with a [match]
that surfaces build errors, and use [Campaign.instances campaign]
so the [campaign] return value is read.
- ocaml-hap: drop the [let _ =] around [turn_on_outlet] (handle the
Result), drop the unused [pair_verify] call (the example only needs
pair_setup for the saved pairing + turn_on_outlet by IP).

+9 -19
+9 -19
README.md
··· 37 37 | [] -> () 38 38 | (a : Hap.accessory_info) :: _ -> 39 39 (* Pair with an accessory (one-time setup). *) 40 - let pairing = 41 - match 42 - Hap.pair_setup ~net ~sw ~clock ~ip:a.ip ~port:a.port 43 - ~pin:"031-45-154" 44 - with 45 - | Ok p -> p 46 - | Error (`Msg m) -> failwith m 47 - in 48 - (* Verify and establish an encrypted session. *) 49 - let _session = 50 - match 51 - Hap.pair_verify ~net ~sw ~clock ~ip:a.ip ~port:a.port ~pairing 52 - with 53 - | Ok s -> s 54 - | Error (`Msg m) -> failwith m 55 - in 56 - (* Control an outlet. *) 57 - let _ = Hap.turn_on_outlet ~net ~sw ~clock ~fs a.device_id in 58 - () 40 + (match 41 + Hap.pair_setup ~net ~sw ~clock ~ip:a.ip ~port:a.port ~pin:"031-45-154" 42 + with 43 + | Ok _pairing -> () 44 + | Error (`Msg m) -> failwith m); 45 + (* Control an outlet (uses the saved pairing). *) 46 + match Hap.turn_on_outlet ~net ~sw ~clock ~fs a.ip with 47 + | Ok () -> () 48 + | Error (`Msg m) -> failwith m 59 49 ``` 60 50 61 51 ## API