module SwiftNav.SBP.Logging 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
msgLog :: Word16
msgLog = 0x0401
data MsgLog = MsgLog
{ msgLog_level :: Word8
, msgLog_text :: ByteString
} deriving ( Show, Read, Eq )
instance Binary MsgLog where
get = do
msgLog_level <- getWord8
msgLog_text <- liftM toStrict getRemainingLazyByteString
return MsgLog {..}
put MsgLog {..} = do
putWord8 msgLog_level
putByteString msgLog_text
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgLog_" . stripPrefix "msgLog_"}
''MsgLog)
msgTweet :: Word16
msgTweet = 0x0012
data MsgTweet = MsgTweet
{ msgTweet_tweet :: ByteString
} deriving ( Show, Read, Eq )
instance Binary MsgTweet where
get = do
msgTweet_tweet <- getByteString 140
return MsgTweet {..}
put MsgTweet {..} = do
putByteString msgTweet_tweet
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgTweet_" . stripPrefix "msgTweet_"}
''MsgTweet)
msgPrintDep :: Word16
msgPrintDep = 0x0010
data MsgPrintDep = MsgPrintDep
{ msgPrintDep_text :: ByteString
} deriving ( Show, Read, Eq )
instance Binary MsgPrintDep where
get = do
msgPrintDep_text <- liftM toStrict getRemainingLazyByteString
return MsgPrintDep {..}
put MsgPrintDep {..} = do
putByteString msgPrintDep_text
$(deriveJSON defaultOptions {fieldLabelModifier = fromMaybe "msgPrintDep_" . stripPrefix "msgPrintDep_"}
''MsgPrintDep)