Kitt.decode

You're seeing just the function decode, go back to Kitt module for more information.
Link to this function

decode(binary, opts \\ [])

View Source

Decodes a message wrapped in a message frame, tagged with the message type identifying integer as the second byte of the message, to a Kitt Elixir struct representing the messaage content.

Defaults the expected input format of the message to a hexadecimal string. Optionally specify the input format with the option format: :hex | :binary.

Returns the decoded message as {:ok, %Struct{}} or {:error, reason}

Example

iex> Kitt.decode(<<0, 29, 45, 115, 204, 33, 222, 6, 2, 3, 148, 0, 0, 15, 172, 20, 128, 128, 60,
...> 243, 8, 136, 219, 128, 250, 12, 0, 0, 0, 18, 200, 72, 25, 169, 126, 102, 237,
...> 196, 79, 141, 137, 130, 157, 132, 176, 56, 121, 128>>, format: :binary)
{:ok,
 %Kitt.Message.SRM{
   regional: nil,
   requestor: %{
     id: {:entityID, 601},
     position: %{
       heading: 4800,
       position: %{elevation: 1260, lat: 374230638, long: -1221420467},
       speed: %{speed: 486, transmisson: :unavailable}
     },
     type: %{hpmsType: :bus, role: :transit}
   },
   requests: [
     %{
       duration: 2000,
       minute: 497732,
       request: %{
         id: %{id: 1003, region: 0},
         inBoundLane: {:lane, 8},
         outBoundLane: {:lane, 30},
         requestID: 5,
         requestType: :priorityRequest
       },
       second: 18140
     }
   ],
   second: 48140,
   sequenceNumber: 2,
   timeStamp: 497731
 }}