packages feed

ble 0.4.1 → 0.4.2

raw patch · 4 files changed

+19/−9 lines, 4 files

Files

ble.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.17.0.+-- This file has been generated from package.yaml by hpack version 0.17.1. -- -- see: https://github.com/sol/hpack  name:           ble-version:        0.4.1+version:        0.4.2 synopsis:       Bluetooth Low Energy (BLE) peripherals description:    This package provides a Haskell API for writing Bluetooth Low Energy peripherals. stability:      alpha@@ -114,7 +114,7 @@   hs-source-dirs:       examples   default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators-  ghc-options: -Wall+  ghc-options: -Wall -threaded   build-depends:       base >= 4.8 && < 4.10     , bytestring >= 0.10 && < 0.11@@ -145,7 +145,7 @@   hs-source-dirs:       examples   default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators-  ghc-options: -Wall+  ghc-options: -Wall -threaded   build-depends:       base >= 4.8 && < 4.10     , bytestring >= 0.10 && < 0.11
examples/HeartRate.hs view
@@ -90,16 +90,22 @@ heartRateMeasurement :: AppState -> CharacteristicBS 'Local heartRateMeasurement appState   = "00002a37-0000-1000-8000-00805f9b34fb"-     & readValue ?~ fmap heartRateToBS (liftIO . readIORef $ currentHeartRate appState)+     & readValue ?~ fmap heartRateToBS (liftIO readV)      -- Even though we add a @writeValue@, this does not mean that the      -- characteristic is writable (for that, we would need to add the CPWrite      -- property to it). Instead, we can use the writeValue internally to      -- update the value and send notifications each time the value is changed.      & writeValue ?~ encodeWrite (liftIO <$> write)-     & properties .~ [CPNotify, CPRead]+     & properties .~ [ CPNotify, CPRead, CPWrite ]   where+    readV = do+      putStrLn "Reading value"+      readIORef $ currentHeartRate appState+     write v = do+      putStrLn "Received value"       writeIORef (currentHeartRate appState) v+      putStrLn "Wrote value"       return True  heartRateToBS :: Word8 -> BS.ByteString
package.yaml view
@@ -1,5 +1,5 @@ name:                ble-version:             0.4.1+version:             0.4.2 synopsis:            Bluetooth Low Energy (BLE) peripherals description:         >     This package provides a Haskell API for writing Bluetooth Low Energy@@ -123,6 +123,7 @@   hrs:     main:            HeartRate.hs     source-dirs:     examples+    ghc-options:     -threaded     dependencies:       - ble       - hslogger@@ -135,5 +136,6 @@   hrs-client:     main:            HeartRateClient.hs     source-dirs:     examples+    ghc-options:     -threaded     dependencies:       - ble
src/Bluetooth/Internal/HasInterface.hs view
@@ -204,10 +204,12 @@        writeVal = case char ^. value . writeValue of         Just w -> Method (repMethod $ go w)-                          "WriteValue" ("arg" :> Done) ("rep" :> Done)+                          "WriteValue" ("arg" :> "options" :> Done) ("rep" :> Done)         Nothing -> Method (repMethod notSup) "WriteValue" Done Done         where-          go writeTheVal newVal = do+          go :: (BS.ByteString -> Handler Bool)+             -> BS.ByteString -> CharacteristicOptions -> MethodHandlerT IO Bool+          go writeTheVal newVal _opts = do             res <- handlerToMethodHandler $ writeTheVal newVal             nots <- liftIO $ readMVar $               characteristicIsNotifying (char ^. value . uuid)