diff --git a/util/sponsor/hemspro.go b/util/sponsor/hemspro.go index 7e1bdabef..d6525bcb4 100644 --- a/util/sponsor/hemspro.go +++ b/util/sponsor/hemspro.go @@ -2,34 +2,7 @@ package sponsor -import ( - i2c "github.com/d2r2/go-i2c" -) - -const hemspro = "hemspro" - // checkHemsPro checks if the hardware is a supported HEMS Pro device and returns sponsor subject func checkHemsPro() string { - const ( - ADDR = 0b1101000 // 0x68 DS1307 - REG_TIMEDATE = 0x00 - ) - - // Create new connection to I2C bus 1 - i2c, err := i2c.NewI2C(ADDR, 1) - if err != nil { - return "" - } - defer i2c.Close() - - if _, err := i2c.WriteBytes([]byte{REG_TIMEDATE}); err != nil { - return "" - } - - buf := make([]byte, 7) - if n, err := i2c.ReadBytes(buf); err != nil || n != 7 { - return "" - } - - return hemspro + return "" } diff --git a/util/sponsor/hemspro_linux.go b/util/sponsor/hemspro_linux.go index cfbdf8eed..d7527728d 100644 --- a/util/sponsor/hemspro_linux.go +++ b/util/sponsor/hemspro_linux.go @@ -2,15 +2,34 @@ package sponsor +import ( + i2c "github.com/d2r2/go-i2c" +) + const hemspro = "hemspro" // checkHemsPro checks if the hardware is a supported HEMS Pro device and returns sponsor subject func checkHemsPro() string { - // TODO i2c validation + const ( + ADDR = 0b1101000 // 0x68 DS1307 + REG_TIMEDATE = 0x00 + ) - if false { - return hemspro + // Create new connection to I2C bus 1 + i2c, err := i2c.NewI2C(ADDR, 1) + if err != nil { + return "" + } + defer i2c.Close() + + if _, err := i2c.WriteBytes([]byte{REG_TIMEDATE}); err != nil { + return "" } - return "" + buf := make([]byte, 7) + if n, err := i2c.ReadBytes(buf); err != nil || n != 7 { + return "" + } + + return hemspro }