Kitt.encode
You're seeing just the function
encode
, go back to Kitt module for more information.
Encodes a message struct wrapped in a message frame, tagged with the message type identifying integer as the second byte of the message.
Defaults the format of the encoded message to a hexadecimal string. Optionally
specify the desired output format with the option format: :hex | :binary
.
Returns the encoded message as {:ok, encoded_message}
or {:error, reason}
Example
iex> Kitt.encode(%Kitt.Message.BSM{
...> coreData: %Kitt.Message.BSM.CoreData{
...> accelSet: %{lat: 2001, long: 2001, vert: -127, yaw: 0},
...> accuracy: %{orientation: 65535, semiMajor: 255, semiMinor: 255},
...> angle: 127,
...> brakes: %{
...> abs: :unavailable,
...> auxBrakes: :unavailable,
...> brakeBoost: :unavailable,
...> scs: :unavailable,
...> traction: :unavailable,
...> wheelBrakes: [:unavailable]
...> },
...> elev: 1260,
...> heading: 4800,
...> id: <<0, 0, 2, 89>>,
...> lat: 374_230_638,
...> long: -1_221_420_467,
...> msgCnt: 1,
...> secMark: 43476,
...> size: %{length: 1200, width: 300},
...> speed: 486,
...> transmission: :unavailable
...> },
...> partII: nil,
...> regional: nil
...> })
{:ok,
"00142500400000966A7525F99BB7113E36260A767FFFFFFFF0F312C0FDFA1FA1007FFF8000962580"}