Matter smart home protocol implementation for OCaml
0
fork

Configure Feed

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

fix(lint): resolve E340 error helpers and E305 module naming

Extract err_* helpers in ocaml-hap/lib/hap.ml for pair setup/verify
error patterns. Extract err_unknown_type_code in ocaml-matter/lib/tlv.ml.
Rename OnOff -> On_off and AdministratorCommissioning ->
Administrator_commissioning in ocaml-matter for Snake_case convention.

+18 -14
+3 -3
lib/msg.ml
··· 445 445 encode_one invoke_request 446 446 447 447 (** On/Off cluster commands *) 448 - module OnOff = struct 448 + module On_off = struct 449 449 let cluster_id = 0x0006 450 450 let off_command = 0x00 451 451 let on_command = 0x01 ··· 464 464 ~command_data:[] 465 465 end 466 466 467 - (** AdministratorCommissioning cluster - for opening commissioning windows *) 468 - module AdministratorCommissioning = struct 467 + (** Administrator_commissioning cluster - for opening commissioning windows *) 468 + module Administrator_commissioning = struct 469 469 let cluster_id = 0x003C 470 470 let endpoint_id = 0 (* Root endpoint *) 471 471
+4 -4
lib/msg.mli
··· 205 205 206 206 (** {1:clusters Cluster helpers} *) 207 207 208 - module OnOff : sig 208 + module On_off : sig 209 209 val cluster_id : int 210 - (** OnOff cluster identifier (0x0006). *) 210 + (** On_off cluster identifier (0x0006). *) 211 211 212 212 val off_command : int 213 213 (** Off command identifier (0x00). *) ··· 228 228 (** [make_toggle ~endpoint_id] builds a Toggle command payload. *) 229 229 end 230 230 231 - module AdministratorCommissioning : sig 231 + module Administrator_commissioning : sig 232 232 val cluster_id : int 233 - (** AdministratorCommissioning cluster identifier (0x003C). *) 233 + (** Administrator_commissioning cluster identifier (0x003C). *) 234 234 235 235 val make_open_basic : timeout:int -> string 236 236 (** [make_open_basic ~timeout] builds an OpenBasicCommissioningWindow command
+6 -6
lib/session.ml
··· 285 285 (** {1 On/Off Commands} *) 286 286 287 287 let turn_on ~clock conn ~endpoint_id = 288 - invoke_command ~clock conn ~endpoint_id ~cluster_id:Msg.OnOff.cluster_id 289 - ~command_id:Msg.OnOff.on_command ~command_data:[] 288 + invoke_command ~clock conn ~endpoint_id ~cluster_id:Msg.On_off.cluster_id 289 + ~command_id:Msg.On_off.on_command ~command_data:[] 290 290 291 291 let turn_off ~clock conn ~endpoint_id = 292 - invoke_command ~clock conn ~endpoint_id ~cluster_id:Msg.OnOff.cluster_id 293 - ~command_id:Msg.OnOff.off_command ~command_data:[] 292 + invoke_command ~clock conn ~endpoint_id ~cluster_id:Msg.On_off.cluster_id 293 + ~command_id:Msg.On_off.off_command ~command_data:[] 294 294 295 295 let toggle ~clock conn ~endpoint_id = 296 - invoke_command ~clock conn ~endpoint_id ~cluster_id:Msg.OnOff.cluster_id 297 - ~command_id:Msg.OnOff.toggle_command ~command_data:[] 296 + invoke_command ~clock conn ~endpoint_id ~cluster_id:Msg.On_off.cluster_id 297 + ~command_id:Msg.On_off.toggle_command ~command_data:[] 298 298 299 299 (** {1 Pretty Printing} *) 300 300
+5 -1
lib/tlv.ml
··· 7 7 8 8 open Result.Syntax 9 9 10 + (** {1 Errors} *) 11 + 12 + let err_unknown_type_code code = Error (Fmt.str "Unknown type code: %d" code) 13 + 10 14 (** {1 TLV Types} *) 11 15 12 16 (** Tag forms (bits 5-6 of control byte) *) ··· 334 338 (* List *) 335 339 let* elems, off = decode_container data offset in 336 340 Ok (List elems, off) 337 - | _ -> Error (Fmt.str "Unknown type code: %d" type_code) 341 + | _ -> err_unknown_type_code type_code 338 342 339 343 and decode_container data offset = 340 344 let rec loop acc offset =