basic OD client wrapper calls
This commit is contained in:
parent
7265e7b7de
commit
4d7017402d
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue