From 4d7017402d025a20c84605800dded0199143e3c6 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 20 Sep 2017 08:26:42 -0700 Subject: [PATCH] basic OD client wrapper calls --- goRicochetMobile.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/goRicochetMobile.go b/goRicochetMobile.go index e9075e5..7266817 100644 --- a/goRicochetMobile.go +++ b/goRicochetMobile.go @@ -9,10 +9,15 @@ import ( "github.com/yawning/bulb/utils/pkcs1" "crypto/rsa" "github.com/dballard/goRicochetMobile/ODClient" + "strconv" ) var ( - odClient *ODClient.ODClient + // 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 ) func GeneratePrivateKey() (string, error) { @@ -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) {