basic OD client wrapper calls

This commit is contained in:
Dan Ballard 2017-09-20 08:26:42 -07:00
parent 7265e7b7de
commit 4d7017402d
1 changed files with 26 additions and 1 deletions

View File

@ -9,9 +9,14 @@ import (
"github.com/yawning/bulb/utils/pkcs1"
"crypto/rsa"
"github.com/dballard/goRicochetMobile/ODClient"
"strconv"
)
var (
// Downsampling array from https://git.mascherari.press/oniondildonics/client/src/master/main.go
// moddified
levelArr = []int{1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6}
odClient *ODClient.ODClient
)
@ -46,6 +51,26 @@ func GetDeviceName() string {
return name
}
func GetBatteryLevel() string {
odClient.SendMessage("/battery")
batteryLevel := odClient.GetMessage()
return batteryLevel
}
func GetVibeLevel() int {
odClient.SendMessage("/level")
level, err := strconv.Atoi(odClient.GetMessage())
if err != nil {
// TODO: don't swallow errors
return 0
}
return levelArr[level] // not bounds checking...
}
func SetVibeLevel(newVibeLevel int) {
odClient.SendMessage("/level " + strconv.Itoa(newVibeLevel))
}
/******** Testing by standing up an echobot ******/
func TestNet() (ok bool, ex error) {