mirror of
https://github.com/cmur2/miflorad.git
synced 2025-06-26 12:30:23 +02:00
munin-miflora: enrich underlying library errors with current operation using wrapping
This commit is contained in:
@ -1,11 +1,10 @@
|
||||
package ble
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"miflorad/common"
|
||||
|
||||
"github.com/go-ble/ble"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func FindServiceByUUID(services []*ble.Service, u ble.UUID) *ble.Service {
|
||||
@ -39,7 +38,7 @@ func RequestVersionBattery(client ble.Client, profile *ble.Profile) (common.Vers
|
||||
|
||||
bytes, err := client.ReadCharacteristic(mifloraVersionBatteryChar)
|
||||
if err != nil {
|
||||
return common.VersionBatteryResponse{}, err
|
||||
return common.VersionBatteryResponse{}, errors.Wrap(err, "can't read version battery")
|
||||
}
|
||||
|
||||
return common.ParseVersionBattery(bytes), nil
|
||||
@ -58,7 +57,7 @@ func RequestModeChange(client ble.Client, profile *ble.Profile) error {
|
||||
|
||||
err := client.WriteCharacteristic(mifloraModeChangeChar, common.MifloraGetModeChangeData(), false)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "can't change mode")
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -77,7 +76,7 @@ func RequestSensorData(client ble.Client, profile *ble.Profile) (common.SensorDa
|
||||
|
||||
bytes, err := client.ReadCharacteristic(mifloraSensorDataChar)
|
||||
if err != nil {
|
||||
return common.SensorDataResponse{}, err
|
||||
return common.SensorDataResponse{}, errors.Wrap(err, "can't read sensor data")
|
||||
}
|
||||
|
||||
return common.ParseSensorData(bytes), nil
|
||||
|
@ -1,11 +1,10 @@
|
||||
package gatt
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"miflorad/common"
|
||||
|
||||
"github.com/currantlabs/gatt"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var MifloraCharVersionBatteryUUID = gatt.MustParseUUID("00001a02-0000-1000-8000-00805f9b34fb")
|
||||
@ -41,7 +40,7 @@ func MifloraRequestVersionBattery(p gatt.Peripheral) (common.VersionBatteryRespo
|
||||
|
||||
bytes, err := p.ReadCharacteristic(mifloraVersionBatteryChar)
|
||||
if err != nil {
|
||||
return common.VersionBatteryResponse{}, err
|
||||
return common.VersionBatteryResponse{}, errors.Wrap(err, "can't read version battery")
|
||||
}
|
||||
|
||||
return common.ParseVersionBattery(bytes), nil
|
||||
@ -60,7 +59,7 @@ func MifloraRequestModeChange(p gatt.Peripheral) error {
|
||||
|
||||
err := p.WriteCharacteristic(mifloraModeChangeChar, common.MifloraGetModeChangeData(), false)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "can't change mode")
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -79,7 +78,7 @@ func MifloraRequstSensorData(p gatt.Peripheral) (common.SensorDataResponse, erro
|
||||
|
||||
bytes, err := p.ReadCharacteristic(mifloraSensorDataChar)
|
||||
if err != nil {
|
||||
return common.SensorDataResponse{}, err
|
||||
return common.SensorDataResponse{}, errors.Wrap(err, "can't read sensor data")
|
||||
}
|
||||
|
||||
return common.ParseSensorData(bytes), nil
|
||||
|
Reference in New Issue
Block a user