module SwiftNav.SBP.Acquisition where
import BasicPrelude as P
import Control.Lens
import Control.Monad.Loops
import Data.Aeson.TH (defaultOptions, deriveJSON, 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
import SwiftNav.SBP.TH
import SwiftNav.SBP.Types
import SwiftNav.SBP.Gnss
msgAcqResult :: Word16
msgAcqResult = 0x001F
data MsgAcqResult = MsgAcqResult
{ _msgAcqResult_cn0 :: Float
, _msgAcqResult_cp :: Float
, _msgAcqResult_cf :: Float
, _msgAcqResult_sid :: GnssSignal
} deriving ( Show, Read, Eq )
instance Binary MsgAcqResult where
get = do
_msgAcqResult_cn0 <- getFloat32le
_msgAcqResult_cp <- getFloat32le
_msgAcqResult_cf <- getFloat32le
_msgAcqResult_sid <- get
return MsgAcqResult {..}
put MsgAcqResult {..} = do
putFloat32le _msgAcqResult_cn0
putFloat32le _msgAcqResult_cp
putFloat32le _msgAcqResult_cf
put _msgAcqResult_sid
$(deriveSBP 'msgAcqResult ''MsgAcqResult)
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "_msgAcqResult_" . P.stripPrefix "_msgAcqResult_"}
''MsgAcqResult)
$(makeLenses ''MsgAcqResult)
msgAcqResultDepB :: Word16
msgAcqResultDepB = 0x0014
data MsgAcqResultDepB = MsgAcqResultDepB
{ _msgAcqResultDepB_snr :: Float
, _msgAcqResultDepB_cp :: Float
, _msgAcqResultDepB_cf :: Float
, _msgAcqResultDepB_sid :: GnssSignal
} deriving ( Show, Read, Eq )
instance Binary MsgAcqResultDepB where
get = do
_msgAcqResultDepB_snr <- getFloat32le
_msgAcqResultDepB_cp <- getFloat32le
_msgAcqResultDepB_cf <- getFloat32le
_msgAcqResultDepB_sid <- get
return MsgAcqResultDepB {..}
put MsgAcqResultDepB {..} = do
putFloat32le _msgAcqResultDepB_snr
putFloat32le _msgAcqResultDepB_cp
putFloat32le _msgAcqResultDepB_cf
put _msgAcqResultDepB_sid
$(deriveSBP 'msgAcqResultDepB ''MsgAcqResultDepB)
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "_msgAcqResultDepB_" . P.stripPrefix "_msgAcqResultDepB_"}
''MsgAcqResultDepB)
$(makeLenses ''MsgAcqResultDepB)
msgAcqResultDepA :: Word16
msgAcqResultDepA = 0x0015
data MsgAcqResultDepA = MsgAcqResultDepA
{ _msgAcqResultDepA_snr :: Float
, _msgAcqResultDepA_cp :: Float
, _msgAcqResultDepA_cf :: Float
, _msgAcqResultDepA_prn :: Word8
} deriving ( Show, Read, Eq )
instance Binary MsgAcqResultDepA where
get = do
_msgAcqResultDepA_snr <- getFloat32le
_msgAcqResultDepA_cp <- getFloat32le
_msgAcqResultDepA_cf <- getFloat32le
_msgAcqResultDepA_prn <- getWord8
return MsgAcqResultDepA {..}
put MsgAcqResultDepA {..} = do
putFloat32le _msgAcqResultDepA_snr
putFloat32le _msgAcqResultDepA_cp
putFloat32le _msgAcqResultDepA_cf
putWord8 _msgAcqResultDepA_prn
$(deriveSBP 'msgAcqResultDepA ''MsgAcqResultDepA)
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "_msgAcqResultDepA_" . P.stripPrefix "_msgAcqResultDepA_"}
''MsgAcqResultDepA)
$(makeLenses ''MsgAcqResultDepA)
data AcqSvProfile = AcqSvProfile
{ _acqSvProfile_job_type :: Word8
, _acqSvProfile_status :: Word8
, _acqSvProfile_cn0 :: Word16
, _acqSvProfile_int_time :: Word8
, _acqSvProfile_sid :: GnssSignal
, _acqSvProfile_bin_width :: Word16
, _acqSvProfile_timestamp :: Word32
, _acqSvProfile_time_spent :: Word32
, _acqSvProfile_cf_min :: Int32
, _acqSvProfile_cf_max :: Int32
, _acqSvProfile_cf :: Int32
, _acqSvProfile_cp :: Word32
} deriving ( Show, Read, Eq )
instance Binary AcqSvProfile where
get = do
_acqSvProfile_job_type <- getWord8
_acqSvProfile_status <- getWord8
_acqSvProfile_cn0 <- getWord16le
_acqSvProfile_int_time <- getWord8
_acqSvProfile_sid <- get
_acqSvProfile_bin_width <- getWord16le
_acqSvProfile_timestamp <- getWord32le
_acqSvProfile_time_spent <- getWord32le
_acqSvProfile_cf_min <- fromIntegral <$> getWord32le
_acqSvProfile_cf_max <- fromIntegral <$> getWord32le
_acqSvProfile_cf <- fromIntegral <$> getWord32le
_acqSvProfile_cp <- getWord32le
return AcqSvProfile {..}
put AcqSvProfile {..} = do
putWord8 _acqSvProfile_job_type
putWord8 _acqSvProfile_status
putWord16le _acqSvProfile_cn0
putWord8 _acqSvProfile_int_time
put _acqSvProfile_sid
putWord16le _acqSvProfile_bin_width
putWord32le _acqSvProfile_timestamp
putWord32le _acqSvProfile_time_spent
putWord32le $ fromIntegral _acqSvProfile_cf_min
putWord32le $ fromIntegral _acqSvProfile_cf_max
putWord32le $ fromIntegral _acqSvProfile_cf
putWord32le _acqSvProfile_cp
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "_acqSvProfile_" . P.stripPrefix "_acqSvProfile_"}
''AcqSvProfile)
$(makeLenses ''AcqSvProfile)
msgAcqSvProfile :: Word16
msgAcqSvProfile = 0x001E
data MsgAcqSvProfile = MsgAcqSvProfile
{ _msgAcqSvProfile_acq_sv_profile :: [AcqSvProfile]
} deriving ( Show, Read, Eq )
instance Binary MsgAcqSvProfile where
get = do
_msgAcqSvProfile_acq_sv_profile <- whileM (not <$> isEmpty) get
return MsgAcqSvProfile {..}
put MsgAcqSvProfile {..} = do
mapM_ put _msgAcqSvProfile_acq_sv_profile
$(deriveSBP 'msgAcqSvProfile ''MsgAcqSvProfile)
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "_msgAcqSvProfile_" . P.stripPrefix "_msgAcqSvProfile_"}
''MsgAcqSvProfile)
$(makeLenses ''MsgAcqSvProfile)