module SwiftNav.SBP.Navigation where
import BasicPrelude
import Control.Monad
import Control.Monad.Loops
import Data.Aeson.TH (deriveJSON, defaultOptions, fieldLabelModifier)
import Data.Binary
import Data.Binary.Get
import Data.Binary.IEEE754
import Data.Binary.Put
import Data.ByteString
import Data.ByteString.Lazy hiding ( ByteString )
import Data.Int
import Data.Word
import SwiftNav.SBP.Encoding
msgGpsTime :: Word16
msgGpsTime = 0x0100
data MsgGpsTime = MsgGpsTime
{ msgGpsTime_wn :: Word16
, msgGpsTime_tow :: Word32
, msgGpsTime_ns :: Int32
, msgGpsTime_flags :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgGpsTime where
get = do
msgGpsTime_wn <- getWord16le
msgGpsTime_tow <- getWord32le
msgGpsTime_ns <- liftM fromIntegral getWord32le
msgGpsTime_flags <- getWord8
return MsgGpsTime {..}
put MsgGpsTime {..} = do
putWord16le msgGpsTime_wn
putWord32le msgGpsTime_tow
putWord32le $ fromIntegral msgGpsTime_ns
putWord8 msgGpsTime_flags
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgGpsTime_" . stripPrefix "msgGpsTime_"}
''MsgGpsTime)
msgDops :: Word16
msgDops = 0x0206
data MsgDops = MsgDops
{ msgDops_tow :: Word32
, msgDops_gdop :: Word16
, msgDops_pdop :: Word16
, msgDops_tdop :: Word16
, msgDops_hdop :: Word16
, msgDops_vdop :: Word16
} deriving ( Show, Read, Eq )
instance Binary MsgDops where
get = do
msgDops_tow <- getWord32le
msgDops_gdop <- getWord16le
msgDops_pdop <- getWord16le
msgDops_tdop <- getWord16le
msgDops_hdop <- getWord16le
msgDops_vdop <- getWord16le
return MsgDops {..}
put MsgDops {..} = do
putWord32le msgDops_tow
putWord16le msgDops_gdop
putWord16le msgDops_pdop
putWord16le msgDops_tdop
putWord16le msgDops_hdop
putWord16le msgDops_vdop
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgDops_" . stripPrefix "msgDops_"}
''MsgDops)
msgPosEcef :: Word16
msgPosEcef = 0x0200
data MsgPosEcef = MsgPosEcef
{ msgPosEcef_tow :: Word32
, msgPosEcef_x :: Double
, msgPosEcef_y :: Double
, msgPosEcef_z :: Double
, msgPosEcef_accuracy :: Word16
, msgPosEcef_n_sats :: Word8
, msgPosEcef_flags :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgPosEcef where
get = do
msgPosEcef_tow <- getWord32le
msgPosEcef_x <- getFloat64le
msgPosEcef_y <- getFloat64le
msgPosEcef_z <- getFloat64le
msgPosEcef_accuracy <- getWord16le
msgPosEcef_n_sats <- getWord8
msgPosEcef_flags <- getWord8
return MsgPosEcef {..}
put MsgPosEcef {..} = do
putWord32le msgPosEcef_tow
putFloat64le msgPosEcef_x
putFloat64le msgPosEcef_y
putFloat64le msgPosEcef_z
putWord16le msgPosEcef_accuracy
putWord8 msgPosEcef_n_sats
putWord8 msgPosEcef_flags
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgPosEcef_" . stripPrefix "msgPosEcef_"}
''MsgPosEcef)
msgPosLlh :: Word16
msgPosLlh = 0x0201
data MsgPosLlh = MsgPosLlh
{ msgPosLlh_tow :: Word32
, msgPosLlh_lat :: Double
, msgPosLlh_lon :: Double
, msgPosLlh_height :: Double
, msgPosLlh_h_accuracy :: Word16
, msgPosLlh_v_accuracy :: Word16
, msgPosLlh_n_sats :: Word8
, msgPosLlh_flags :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgPosLlh where
get = do
msgPosLlh_tow <- getWord32le
msgPosLlh_lat <- getFloat64le
msgPosLlh_lon <- getFloat64le
msgPosLlh_height <- getFloat64le
msgPosLlh_h_accuracy <- getWord16le
msgPosLlh_v_accuracy <- getWord16le
msgPosLlh_n_sats <- getWord8
msgPosLlh_flags <- getWord8
return MsgPosLlh {..}
put MsgPosLlh {..} = do
putWord32le msgPosLlh_tow
putFloat64le msgPosLlh_lat
putFloat64le msgPosLlh_lon
putFloat64le msgPosLlh_height
putWord16le msgPosLlh_h_accuracy
putWord16le msgPosLlh_v_accuracy
putWord8 msgPosLlh_n_sats
putWord8 msgPosLlh_flags
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgPosLlh_" . stripPrefix "msgPosLlh_"}
''MsgPosLlh)
msgBaselineEcef :: Word16
msgBaselineEcef = 0x0202
data MsgBaselineEcef = MsgBaselineEcef
{ msgBaselineEcef_tow :: Word32
, msgBaselineEcef_x :: Int32
, msgBaselineEcef_y :: Int32
, msgBaselineEcef_z :: Int32
, msgBaselineEcef_accuracy :: Word16
, msgBaselineEcef_n_sats :: Word8
, msgBaselineEcef_flags :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgBaselineEcef where
get = do
msgBaselineEcef_tow <- getWord32le
msgBaselineEcef_x <- liftM fromIntegral getWord32le
msgBaselineEcef_y <- liftM fromIntegral getWord32le
msgBaselineEcef_z <- liftM fromIntegral getWord32le
msgBaselineEcef_accuracy <- getWord16le
msgBaselineEcef_n_sats <- getWord8
msgBaselineEcef_flags <- getWord8
return MsgBaselineEcef {..}
put MsgBaselineEcef {..} = do
putWord32le msgBaselineEcef_tow
putWord32le $ fromIntegral msgBaselineEcef_x
putWord32le $ fromIntegral msgBaselineEcef_y
putWord32le $ fromIntegral msgBaselineEcef_z
putWord16le msgBaselineEcef_accuracy
putWord8 msgBaselineEcef_n_sats
putWord8 msgBaselineEcef_flags
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgBaselineEcef_" . stripPrefix "msgBaselineEcef_"}
''MsgBaselineEcef)
msgBaselineNed :: Word16
msgBaselineNed = 0x0203
data MsgBaselineNed = MsgBaselineNed
{ msgBaselineNed_tow :: Word32
, msgBaselineNed_n :: Int32
, msgBaselineNed_e :: Int32
, msgBaselineNed_d :: Int32
, msgBaselineNed_h_accuracy :: Word16
, msgBaselineNed_v_accuracy :: Word16
, msgBaselineNed_n_sats :: Word8
, msgBaselineNed_flags :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgBaselineNed where
get = do
msgBaselineNed_tow <- getWord32le
msgBaselineNed_n <- liftM fromIntegral getWord32le
msgBaselineNed_e <- liftM fromIntegral getWord32le
msgBaselineNed_d <- liftM fromIntegral getWord32le
msgBaselineNed_h_accuracy <- getWord16le
msgBaselineNed_v_accuracy <- getWord16le
msgBaselineNed_n_sats <- getWord8
msgBaselineNed_flags <- getWord8
return MsgBaselineNed {..}
put MsgBaselineNed {..} = do
putWord32le msgBaselineNed_tow
putWord32le $ fromIntegral msgBaselineNed_n
putWord32le $ fromIntegral msgBaselineNed_e
putWord32le $ fromIntegral msgBaselineNed_d
putWord16le msgBaselineNed_h_accuracy
putWord16le msgBaselineNed_v_accuracy
putWord8 msgBaselineNed_n_sats
putWord8 msgBaselineNed_flags
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgBaselineNed_" . stripPrefix "msgBaselineNed_"}
''MsgBaselineNed)
msgVelEcef :: Word16
msgVelEcef = 0x0204
data MsgVelEcef = MsgVelEcef
{ msgVelEcef_tow :: Word32
, msgVelEcef_x :: Int32
, msgVelEcef_y :: Int32
, msgVelEcef_z :: Int32
, msgVelEcef_accuracy :: Word16
, msgVelEcef_n_sats :: Word8
, msgVelEcef_flags :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgVelEcef where
get = do
msgVelEcef_tow <- getWord32le
msgVelEcef_x <- liftM fromIntegral getWord32le
msgVelEcef_y <- liftM fromIntegral getWord32le
msgVelEcef_z <- liftM fromIntegral getWord32le
msgVelEcef_accuracy <- getWord16le
msgVelEcef_n_sats <- getWord8
msgVelEcef_flags <- getWord8
return MsgVelEcef {..}
put MsgVelEcef {..} = do
putWord32le msgVelEcef_tow
putWord32le $ fromIntegral msgVelEcef_x
putWord32le $ fromIntegral msgVelEcef_y
putWord32le $ fromIntegral msgVelEcef_z
putWord16le msgVelEcef_accuracy
putWord8 msgVelEcef_n_sats
putWord8 msgVelEcef_flags
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgVelEcef_" . stripPrefix "msgVelEcef_"}
''MsgVelEcef)
msgVelNed :: Word16
msgVelNed = 0x0205
data MsgVelNed = MsgVelNed
{ msgVelNed_tow :: Word32
, msgVelNed_n :: Int32
, msgVelNed_e :: Int32
, msgVelNed_d :: Int32
, msgVelNed_h_accuracy :: Word16
, msgVelNed_v_accuracy :: Word16
, msgVelNed_n_sats :: Word8
, msgVelNed_flags :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgVelNed where
get = do
msgVelNed_tow <- getWord32le
msgVelNed_n <- liftM fromIntegral getWord32le
msgVelNed_e <- liftM fromIntegral getWord32le
msgVelNed_d <- liftM fromIntegral getWord32le
msgVelNed_h_accuracy <- getWord16le
msgVelNed_v_accuracy <- getWord16le
msgVelNed_n_sats <- getWord8
msgVelNed_flags <- getWord8
return MsgVelNed {..}
put MsgVelNed {..} = do
putWord32le msgVelNed_tow
putWord32le $ fromIntegral msgVelNed_n
putWord32le $ fromIntegral msgVelNed_e
putWord32le $ fromIntegral msgVelNed_d
putWord16le msgVelNed_h_accuracy
putWord16le msgVelNed_v_accuracy
putWord8 msgVelNed_n_sats
putWord8 msgVelNed_flags
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgVelNed_" . stripPrefix "msgVelNed_"}
''MsgVelNed)