{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RecordWildCards #-}
module SwiftNav.SBP.Ssr
( module SwiftNav.SBP.Ssr
) 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
import SwiftNav.SBP.Gnss
{-# ANN module ("HLint: ignore Use camelCase"::String) #-}
{-# ANN module ("HLint: ignore Redundant do"::String) #-}
{-# ANN module ("HLint: ignore Use newtype instead of data"::String) #-}
data CodeBiasesContent = CodeBiasesContent
{ _codeBiasesContent_code :: !Word8
, _codeBiasesContent_value :: !Int16
} deriving ( Show, Read, Eq )
instance Binary CodeBiasesContent where
get = do
_codeBiasesContent_code <- getWord8
_codeBiasesContent_value <- fromIntegral <$> getWord16le
pure CodeBiasesContent {..}
put CodeBiasesContent {..} = do
putWord8 _codeBiasesContent_code
(putWord16le . fromIntegral) _codeBiasesContent_value
$(makeJSON "_codeBiasesContent_" ''CodeBiasesContent)
$(makeLenses ''CodeBiasesContent)
data PhaseBiasesContent = PhaseBiasesContent
{ _phaseBiasesContent_code :: !Word8
, _phaseBiasesContent_integer_indicator :: !Word8
, _phaseBiasesContent_widelane_integer_indicator :: !Word8
, _phaseBiasesContent_discontinuity_counter :: !Word8
, _phaseBiasesContent_bias :: !Int32
} deriving ( Show, Read, Eq )
instance Binary PhaseBiasesContent where
get = do
_phaseBiasesContent_code <- getWord8
_phaseBiasesContent_integer_indicator <- getWord8
_phaseBiasesContent_widelane_integer_indicator <- getWord8
_phaseBiasesContent_discontinuity_counter <- getWord8
_phaseBiasesContent_bias <- fromIntegral <$> getWord32le
pure PhaseBiasesContent {..}
put PhaseBiasesContent {..} = do
putWord8 _phaseBiasesContent_code
putWord8 _phaseBiasesContent_integer_indicator
putWord8 _phaseBiasesContent_widelane_integer_indicator
putWord8 _phaseBiasesContent_discontinuity_counter
(putWord32le . fromIntegral) _phaseBiasesContent_bias
$(makeJSON "_phaseBiasesContent_" ''PhaseBiasesContent)
$(makeLenses ''PhaseBiasesContent)
data STECHeader = STECHeader
{ _sTECHeader_time :: !GpsTime
, _sTECHeader_num_msgs :: !Word8
, _sTECHeader_seq_num :: !Word8
, _sTECHeader_ssr_update_interval :: !Word16
, _sTECHeader_iod_ssr :: !Word8
} deriving ( Show, Read, Eq )
instance Binary STECHeader where
get = do
_sTECHeader_time <- get
_sTECHeader_num_msgs <- getWord8
_sTECHeader_seq_num <- getWord8
_sTECHeader_ssr_update_interval <- getWord16le
_sTECHeader_iod_ssr <- getWord8
pure STECHeader {..}
put STECHeader {..} = do
put _sTECHeader_time
putWord8 _sTECHeader_num_msgs
putWord8 _sTECHeader_seq_num
putWord16le _sTECHeader_ssr_update_interval
putWord8 _sTECHeader_iod_ssr
$(makeJSON "_sTECHeader_" ''STECHeader)
$(makeLenses ''STECHeader)
data GriddedCorrectionHeader = GriddedCorrectionHeader
{ _griddedCorrectionHeader_time :: !GpsTime
, _griddedCorrectionHeader_num_msgs :: !Word16
, _griddedCorrectionHeader_seq_num :: !Word16
, _griddedCorrectionHeader_ssr_update_interval :: !Word16
, _griddedCorrectionHeader_iod_ssr :: !Word8
, _griddedCorrectionHeader_tropo_quality :: !Word8
} deriving ( Show, Read, Eq )
instance Binary GriddedCorrectionHeader where
get = do
_griddedCorrectionHeader_time <- get
_griddedCorrectionHeader_num_msgs <- getWord16le
_griddedCorrectionHeader_seq_num <- getWord16le
_griddedCorrectionHeader_ssr_update_interval <- getWord16le
_griddedCorrectionHeader_iod_ssr <- getWord8
_griddedCorrectionHeader_tropo_quality <- getWord8
pure GriddedCorrectionHeader {..}
put GriddedCorrectionHeader {..} = do
put _griddedCorrectionHeader_time
putWord16le _griddedCorrectionHeader_num_msgs
putWord16le _griddedCorrectionHeader_seq_num
putWord16le _griddedCorrectionHeader_ssr_update_interval
putWord8 _griddedCorrectionHeader_iod_ssr
putWord8 _griddedCorrectionHeader_tropo_quality
$(makeJSON "_griddedCorrectionHeader_" ''GriddedCorrectionHeader)
$(makeLenses ''GriddedCorrectionHeader)
data STECSatElement = STECSatElement
{ _sTECSatElement_sv_id :: !SvId
, _sTECSatElement_stec_quality_indicator :: !Word8
, _sTECSatElement_stec_coeff :: ![Int16]
} deriving ( Show, Read, Eq )
instance Binary STECSatElement where
get = do
_sTECSatElement_sv_id <- get
_sTECSatElement_stec_quality_indicator <- getWord8
_sTECSatElement_stec_coeff <- replicateM 4 fromIntegral <$> getWord16le
pure STECSatElement {..}
put STECSatElement {..} = do
put _sTECSatElement_sv_id
putWord8 _sTECSatElement_stec_quality_indicator
mapM_ (putWord16le . fromIntegral) _sTECSatElement_stec_coeff
$(makeJSON "_sTECSatElement_" ''STECSatElement)
$(makeLenses ''STECSatElement)
data TroposphericDelayCorrection = TroposphericDelayCorrection
{ _troposphericDelayCorrection_hydro :: !Int16
, _troposphericDelayCorrection_wet :: !Int8
} deriving ( Show, Read, Eq )
instance Binary TroposphericDelayCorrection where
get = do
_troposphericDelayCorrection_hydro <- fromIntegral <$> getWord16le
_troposphericDelayCorrection_wet <- fromIntegral <$> getWord8
pure TroposphericDelayCorrection {..}
put TroposphericDelayCorrection {..} = do
(putWord16le . fromIntegral) _troposphericDelayCorrection_hydro
(putWord8 . fromIntegral) _troposphericDelayCorrection_wet
$(makeJSON "_troposphericDelayCorrection_" ''TroposphericDelayCorrection)
$(makeLenses ''TroposphericDelayCorrection)
data STECResidual = STECResidual
{ _sTECResidual_sv_id :: !SvId
, _sTECResidual_residual :: !Int16
} deriving ( Show, Read, Eq )
instance Binary STECResidual where
get = do
_sTECResidual_sv_id <- get
_sTECResidual_residual <- fromIntegral <$> getWord16le
pure STECResidual {..}
put STECResidual {..} = do
put _sTECResidual_sv_id
(putWord16le . fromIntegral) _sTECResidual_residual
$(makeJSON "_sTECResidual_" ''STECResidual)
$(makeLenses ''STECResidual)
data GridElement = GridElement
{ _gridElement_index :: !Word16
, _gridElement_tropo_delay_correction :: !TroposphericDelayCorrection
, _gridElement_STEC_residuals :: ![STECResidual]
} deriving ( Show, Read, Eq )
instance Binary GridElement where
get = do
_gridElement_index <- getWord16le
_gridElement_tropo_delay_correction <- get
_gridElement_STEC_residuals <- whileM (not <$> isEmpty) get
pure GridElement {..}
put GridElement {..} = do
putWord16le _gridElement_index
put _gridElement_tropo_delay_correction
mapM_ put _gridElement_STEC_residuals
$(makeJSON "_gridElement_" ''GridElement)
$(makeLenses ''GridElement)
data GridDefinitionHeader = GridDefinitionHeader
{ _gridDefinitionHeader_region_size_inverse :: !Word8
, _gridDefinitionHeader_area_width :: !Word16
, _gridDefinitionHeader_lat_nw_corner_enc :: !Word16
, _gridDefinitionHeader_lon_nw_corner_enc :: !Word16
, _gridDefinitionHeader_num_msgs :: !Word8
, _gridDefinitionHeader_seq_num :: !Word8
} deriving ( Show, Read, Eq )
instance Binary GridDefinitionHeader where
get = do
_gridDefinitionHeader_region_size_inverse <- getWord8
_gridDefinitionHeader_area_width <- getWord16le
_gridDefinitionHeader_lat_nw_corner_enc <- getWord16le
_gridDefinitionHeader_lon_nw_corner_enc <- getWord16le
_gridDefinitionHeader_num_msgs <- getWord8
_gridDefinitionHeader_seq_num <- getWord8
pure GridDefinitionHeader {..}
put GridDefinitionHeader {..} = do
putWord8 _gridDefinitionHeader_region_size_inverse
putWord16le _gridDefinitionHeader_area_width
putWord16le _gridDefinitionHeader_lat_nw_corner_enc
putWord16le _gridDefinitionHeader_lon_nw_corner_enc
putWord8 _gridDefinitionHeader_num_msgs
putWord8 _gridDefinitionHeader_seq_num
$(makeJSON "_gridDefinitionHeader_" ''GridDefinitionHeader)
$(makeLenses ''GridDefinitionHeader)
msgSsrOrbitClock :: Word16
msgSsrOrbitClock = 0x05DD
data MsgSsrOrbitClock = MsgSsrOrbitClock
{ _msgSsrOrbitClock_time :: !GpsTimeSec
, _msgSsrOrbitClock_sid :: !GnssSignal
, _msgSsrOrbitClock_update_interval :: !Word8
, _msgSsrOrbitClock_iod_ssr :: !Word8
, _msgSsrOrbitClock_iod :: !Word32
, _msgSsrOrbitClock_radial :: !Int32
, _msgSsrOrbitClock_along :: !Int32
, _msgSsrOrbitClock_cross :: !Int32
, _msgSsrOrbitClock_dot_radial :: !Int32
, _msgSsrOrbitClock_dot_along :: !Int32
, _msgSsrOrbitClock_dot_cross :: !Int32
, _msgSsrOrbitClock_c0 :: !Int32
, _msgSsrOrbitClock_c1 :: !Int32
, _msgSsrOrbitClock_c2 :: !Int32
} deriving ( Show, Read, Eq )
instance Binary MsgSsrOrbitClock where
get = do
_msgSsrOrbitClock_time <- get
_msgSsrOrbitClock_sid <- get
_msgSsrOrbitClock_update_interval <- getWord8
_msgSsrOrbitClock_iod_ssr <- getWord8
_msgSsrOrbitClock_iod <- getWord32le
_msgSsrOrbitClock_radial <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_along <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_cross <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_dot_radial <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_dot_along <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_dot_cross <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_c0 <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_c1 <- fromIntegral <$> getWord32le
_msgSsrOrbitClock_c2 <- fromIntegral <$> getWord32le
pure MsgSsrOrbitClock {..}
put MsgSsrOrbitClock {..} = do
put _msgSsrOrbitClock_time
put _msgSsrOrbitClock_sid
putWord8 _msgSsrOrbitClock_update_interval
putWord8 _msgSsrOrbitClock_iod_ssr
putWord32le _msgSsrOrbitClock_iod
(putWord32le . fromIntegral) _msgSsrOrbitClock_radial
(putWord32le . fromIntegral) _msgSsrOrbitClock_along
(putWord32le . fromIntegral) _msgSsrOrbitClock_cross
(putWord32le . fromIntegral) _msgSsrOrbitClock_dot_radial
(putWord32le . fromIntegral) _msgSsrOrbitClock_dot_along
(putWord32le . fromIntegral) _msgSsrOrbitClock_dot_cross
(putWord32le . fromIntegral) _msgSsrOrbitClock_c0
(putWord32le . fromIntegral) _msgSsrOrbitClock_c1
(putWord32le . fromIntegral) _msgSsrOrbitClock_c2
$(makeSBP 'msgSsrOrbitClock ''MsgSsrOrbitClock)
$(makeJSON "_msgSsrOrbitClock_" ''MsgSsrOrbitClock)
$(makeLenses ''MsgSsrOrbitClock)
msgSsrOrbitClockDepA :: Word16
msgSsrOrbitClockDepA = 0x05DC
data MsgSsrOrbitClockDepA = MsgSsrOrbitClockDepA
{ _msgSsrOrbitClockDepA_time :: !GpsTimeSec
, _msgSsrOrbitClockDepA_sid :: !GnssSignal
, _msgSsrOrbitClockDepA_update_interval :: !Word8
, _msgSsrOrbitClockDepA_iod_ssr :: !Word8
, _msgSsrOrbitClockDepA_iod :: !Word8
, _msgSsrOrbitClockDepA_radial :: !Int32
, _msgSsrOrbitClockDepA_along :: !Int32
, _msgSsrOrbitClockDepA_cross :: !Int32
, _msgSsrOrbitClockDepA_dot_radial :: !Int32
, _msgSsrOrbitClockDepA_dot_along :: !Int32
, _msgSsrOrbitClockDepA_dot_cross :: !Int32
, _msgSsrOrbitClockDepA_c0 :: !Int32
, _msgSsrOrbitClockDepA_c1 :: !Int32
, _msgSsrOrbitClockDepA_c2 :: !Int32
} deriving ( Show, Read, Eq )
instance Binary MsgSsrOrbitClockDepA where
get = do
_msgSsrOrbitClockDepA_time <- get
_msgSsrOrbitClockDepA_sid <- get
_msgSsrOrbitClockDepA_update_interval <- getWord8
_msgSsrOrbitClockDepA_iod_ssr <- getWord8
_msgSsrOrbitClockDepA_iod <- getWord8
_msgSsrOrbitClockDepA_radial <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_along <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_cross <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_dot_radial <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_dot_along <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_dot_cross <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_c0 <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_c1 <- fromIntegral <$> getWord32le
_msgSsrOrbitClockDepA_c2 <- fromIntegral <$> getWord32le
pure MsgSsrOrbitClockDepA {..}
put MsgSsrOrbitClockDepA {..} = do
put _msgSsrOrbitClockDepA_time
put _msgSsrOrbitClockDepA_sid
putWord8 _msgSsrOrbitClockDepA_update_interval
putWord8 _msgSsrOrbitClockDepA_iod_ssr
putWord8 _msgSsrOrbitClockDepA_iod
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_radial
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_along
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_cross
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_dot_radial
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_dot_along
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_dot_cross
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_c0
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_c1
(putWord32le . fromIntegral) _msgSsrOrbitClockDepA_c2
$(makeSBP 'msgSsrOrbitClockDepA ''MsgSsrOrbitClockDepA)
$(makeJSON "_msgSsrOrbitClockDepA_" ''MsgSsrOrbitClockDepA)
$(makeLenses ''MsgSsrOrbitClockDepA)
msgSsrCodeBiases :: Word16
msgSsrCodeBiases = 0x05E1
data MsgSsrCodeBiases = MsgSsrCodeBiases
{ _msgSsrCodeBiases_time :: !GpsTimeSec
, _msgSsrCodeBiases_sid :: !GnssSignal
, _msgSsrCodeBiases_update_interval :: !Word8
, _msgSsrCodeBiases_iod_ssr :: !Word8
, _msgSsrCodeBiases_biases :: ![CodeBiasesContent]
} deriving ( Show, Read, Eq )
instance Binary MsgSsrCodeBiases where
get = do
_msgSsrCodeBiases_time <- get
_msgSsrCodeBiases_sid <- get
_msgSsrCodeBiases_update_interval <- getWord8
_msgSsrCodeBiases_iod_ssr <- getWord8
_msgSsrCodeBiases_biases <- whileM (not <$> isEmpty) get
pure MsgSsrCodeBiases {..}
put MsgSsrCodeBiases {..} = do
put _msgSsrCodeBiases_time
put _msgSsrCodeBiases_sid
putWord8 _msgSsrCodeBiases_update_interval
putWord8 _msgSsrCodeBiases_iod_ssr
mapM_ put _msgSsrCodeBiases_biases
$(makeSBP 'msgSsrCodeBiases ''MsgSsrCodeBiases)
$(makeJSON "_msgSsrCodeBiases_" ''MsgSsrCodeBiases)
$(makeLenses ''MsgSsrCodeBiases)
msgSsrPhaseBiases :: Word16
msgSsrPhaseBiases = 0x05E6
data MsgSsrPhaseBiases = MsgSsrPhaseBiases
{ _msgSsrPhaseBiases_time :: !GpsTimeSec
, _msgSsrPhaseBiases_sid :: !GnssSignal
, _msgSsrPhaseBiases_update_interval :: !Word8
, _msgSsrPhaseBiases_iod_ssr :: !Word8
, _msgSsrPhaseBiases_dispersive_bias :: !Word8
, _msgSsrPhaseBiases_mw_consistency :: !Word8
, _msgSsrPhaseBiases_yaw :: !Word16
, _msgSsrPhaseBiases_yaw_rate :: !Int8
, _msgSsrPhaseBiases_biases :: ![PhaseBiasesContent]
} deriving ( Show, Read, Eq )
instance Binary MsgSsrPhaseBiases where
get = do
_msgSsrPhaseBiases_time <- get
_msgSsrPhaseBiases_sid <- get
_msgSsrPhaseBiases_update_interval <- getWord8
_msgSsrPhaseBiases_iod_ssr <- getWord8
_msgSsrPhaseBiases_dispersive_bias <- getWord8
_msgSsrPhaseBiases_mw_consistency <- getWord8
_msgSsrPhaseBiases_yaw <- getWord16le
_msgSsrPhaseBiases_yaw_rate <- fromIntegral <$> getWord8
_msgSsrPhaseBiases_biases <- whileM (not <$> isEmpty) get
pure MsgSsrPhaseBiases {..}
put MsgSsrPhaseBiases {..} = do
put _msgSsrPhaseBiases_time
put _msgSsrPhaseBiases_sid
putWord8 _msgSsrPhaseBiases_update_interval
putWord8 _msgSsrPhaseBiases_iod_ssr
putWord8 _msgSsrPhaseBiases_dispersive_bias
putWord8 _msgSsrPhaseBiases_mw_consistency
putWord16le _msgSsrPhaseBiases_yaw
(putWord8 . fromIntegral) _msgSsrPhaseBiases_yaw_rate
mapM_ put _msgSsrPhaseBiases_biases
$(makeSBP 'msgSsrPhaseBiases ''MsgSsrPhaseBiases)
$(makeJSON "_msgSsrPhaseBiases_" ''MsgSsrPhaseBiases)
$(makeLenses ''MsgSsrPhaseBiases)
msgSsrStecCorrection :: Word16
msgSsrStecCorrection = 0x05EB
data MsgSsrStecCorrection = MsgSsrStecCorrection
{ _msgSsrStecCorrection_header :: !STECHeader
, _msgSsrStecCorrection_stec_sat_list :: ![STECSatElement]
} deriving ( Show, Read, Eq )
instance Binary MsgSsrStecCorrection where
get = do
_msgSsrStecCorrection_header <- get
_msgSsrStecCorrection_stec_sat_list <- whileM (not <$> isEmpty) get
pure MsgSsrStecCorrection {..}
put MsgSsrStecCorrection {..} = do
put _msgSsrStecCorrection_header
mapM_ put _msgSsrStecCorrection_stec_sat_list
$(makeSBP 'msgSsrStecCorrection ''MsgSsrStecCorrection)
$(makeJSON "_msgSsrStecCorrection_" ''MsgSsrStecCorrection)
$(makeLenses ''MsgSsrStecCorrection)
msgSsrGriddedCorrection :: Word16
msgSsrGriddedCorrection = 0x05F0
data MsgSsrGriddedCorrection = MsgSsrGriddedCorrection
{ _msgSsrGriddedCorrection_header :: !GriddedCorrectionHeader
, _msgSsrGriddedCorrection_element :: !GridElement
} deriving ( Show, Read, Eq )
instance Binary MsgSsrGriddedCorrection where
get = do
_msgSsrGriddedCorrection_header <- get
_msgSsrGriddedCorrection_element <- get
pure MsgSsrGriddedCorrection {..}
put MsgSsrGriddedCorrection {..} = do
put _msgSsrGriddedCorrection_header
put _msgSsrGriddedCorrection_element
$(makeSBP 'msgSsrGriddedCorrection ''MsgSsrGriddedCorrection)
$(makeJSON "_msgSsrGriddedCorrection_" ''MsgSsrGriddedCorrection)
$(makeLenses ''MsgSsrGriddedCorrection)
msgSsrGridDefinition :: Word16
msgSsrGridDefinition = 0x05F5
data MsgSsrGridDefinition = MsgSsrGridDefinition
{ _msgSsrGridDefinition_header :: !GridDefinitionHeader
, _msgSsrGridDefinition_rle_list :: ![Word8]
} deriving ( Show, Read, Eq )
instance Binary MsgSsrGridDefinition where
get = do
_msgSsrGridDefinition_header <- get
_msgSsrGridDefinition_rle_list <- whileM (not <$> isEmpty) getWord8
pure MsgSsrGridDefinition {..}
put MsgSsrGridDefinition {..} = do
put _msgSsrGridDefinition_header
mapM_ putWord8 _msgSsrGridDefinition_rle_list
$(makeSBP 'msgSsrGridDefinition ''MsgSsrGridDefinition)
$(makeJSON "_msgSsrGridDefinition_" ''MsgSsrGridDefinition)
$(makeLenses ''MsgSsrGridDefinition)