{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RecordWildCards #-}
module SwiftNav.SBP.System
( module SwiftNav.SBP.System
) where
import BasicPrelude
import Control.Lens
import Control.Monad.Loops
import Data.Binary
import Data.Binary.Get
import Data.Binary.IEEE754
import Data.Binary.Put
import Data.ByteString.Lazy hiding (ByteString)
import Data.Int
import Data.Word
import SwiftNav.SBP.TH
import SwiftNav.SBP.Types
{-# ANN module ("HLint: ignore Use camelCase"::String) #-}
{-# ANN module ("HLint: ignore Redundant do"::String) #-}
{-# ANN module ("HLint: ignore Use newtype instead of data"::String) #-}
msgStartup :: Word16
msgStartup = 0xFF00
data MsgStartup = MsgStartup
{ _msgStartup_cause :: !Word8
, _msgStartup_startup_type :: !Word8
, _msgStartup_reserved :: !Word16
} deriving ( Show, Read, Eq )
instance Binary MsgStartup where
get = do
_msgStartup_cause <- getWord8
_msgStartup_startup_type <- getWord8
_msgStartup_reserved <- getWord16le
pure MsgStartup {..}
put MsgStartup {..} = do
putWord8 _msgStartup_cause
putWord8 _msgStartup_startup_type
putWord16le _msgStartup_reserved
$(makeSBP 'msgStartup ''MsgStartup)
$(makeJSON "_msgStartup_" ''MsgStartup)
$(makeLenses ''MsgStartup)
msgDgnssStatus :: Word16
msgDgnssStatus = 0xFF02
data MsgDgnssStatus = MsgDgnssStatus
{ _msgDgnssStatus_flags :: !Word8
, _msgDgnssStatus_latency :: !Word16
, _msgDgnssStatus_num_signals :: !Word8
, _msgDgnssStatus_source :: !Text
} deriving ( Show, Read, Eq )
instance Binary MsgDgnssStatus where
get = do
_msgDgnssStatus_flags <- getWord8
_msgDgnssStatus_latency <- getWord16le
_msgDgnssStatus_num_signals <- getWord8
_msgDgnssStatus_source <- decodeUtf8 . toStrict <$> getRemainingLazyByteString
pure MsgDgnssStatus {..}
put MsgDgnssStatus {..} = do
putWord8 _msgDgnssStatus_flags
putWord16le _msgDgnssStatus_latency
putWord8 _msgDgnssStatus_num_signals
putByteString $ encodeUtf8 _msgDgnssStatus_source
$(makeSBP 'msgDgnssStatus ''MsgDgnssStatus)
$(makeJSON "_msgDgnssStatus_" ''MsgDgnssStatus)
$(makeLenses ''MsgDgnssStatus)
msgHeartbeat :: Word16
msgHeartbeat = 0xFFFF
data MsgHeartbeat = MsgHeartbeat
{ _msgHeartbeat_flags :: !Word32
} deriving ( Show, Read, Eq )
instance Binary MsgHeartbeat where
get = do
_msgHeartbeat_flags <- getWord32le
pure MsgHeartbeat {..}
put MsgHeartbeat {..} = do
putWord32le _msgHeartbeat_flags
$(makeSBP 'msgHeartbeat ''MsgHeartbeat)
$(makeJSON "_msgHeartbeat_" ''MsgHeartbeat)
$(makeLenses ''MsgHeartbeat)
msgInsStatus :: Word16
msgInsStatus = 0xFF03
data MsgInsStatus = MsgInsStatus
{ _msgInsStatus_flags :: !Word32
} deriving ( Show, Read, Eq )
instance Binary MsgInsStatus where
get = do
_msgInsStatus_flags <- getWord32le
pure MsgInsStatus {..}
put MsgInsStatus {..} = do
putWord32le _msgInsStatus_flags
$(makeSBP 'msgInsStatus ''MsgInsStatus)
$(makeJSON "_msgInsStatus_" ''MsgInsStatus)
$(makeLenses ''MsgInsStatus)
msgCsacTelemetry :: Word16
msgCsacTelemetry = 0xFF04
data MsgCsacTelemetry = MsgCsacTelemetry
{ _msgCsacTelemetry_id :: !Word8
, _msgCsacTelemetry_telemetry :: !Text
} deriving ( Show, Read, Eq )
instance Binary MsgCsacTelemetry where
get = do
_msgCsacTelemetry_id <- getWord8
_msgCsacTelemetry_telemetry <- decodeUtf8 . toStrict <$> getRemainingLazyByteString
pure MsgCsacTelemetry {..}
put MsgCsacTelemetry {..} = do
putWord8 _msgCsacTelemetry_id
putByteString $ encodeUtf8 _msgCsacTelemetry_telemetry
$(makeSBP 'msgCsacTelemetry ''MsgCsacTelemetry)
$(makeJSON "_msgCsacTelemetry_" ''MsgCsacTelemetry)
$(makeLenses ''MsgCsacTelemetry)
msgCsacTelemetryLabels :: Word16
msgCsacTelemetryLabels = 0xFF05
data MsgCsacTelemetryLabels = MsgCsacTelemetryLabels
{ _msgCsacTelemetryLabels_id :: !Word8
, _msgCsacTelemetryLabels_telemetry_labels :: !Text
} deriving ( Show, Read, Eq )
instance Binary MsgCsacTelemetryLabels where
get = do
_msgCsacTelemetryLabels_id <- getWord8
_msgCsacTelemetryLabels_telemetry_labels <- decodeUtf8 . toStrict <$> getRemainingLazyByteString
pure MsgCsacTelemetryLabels {..}
put MsgCsacTelemetryLabels {..} = do
putWord8 _msgCsacTelemetryLabels_id
putByteString $ encodeUtf8 _msgCsacTelemetryLabels_telemetry_labels
$(makeSBP 'msgCsacTelemetryLabels ''MsgCsacTelemetryLabels)
$(makeJSON "_msgCsacTelemetryLabels_" ''MsgCsacTelemetryLabels)
$(makeLenses ''MsgCsacTelemetryLabels)