forked from Elara6331/itd
Fix bug where itctl could not be killed
This commit is contained in:
parent
78b5ca1de8
commit
1e0f1c5b76
@ -14,7 +14,9 @@ func watchHeart(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for heartRate := range heartCh {
|
||||
for {
|
||||
select {
|
||||
case heartRate := <-heartCh:
|
||||
if c.Bool("json") {
|
||||
json.NewEncoder(os.Stdout).Encode(
|
||||
map[string]uint8{"heartRate": heartRate},
|
||||
@ -24,10 +26,11 @@ func watchHeart(c *cli.Context) error {
|
||||
} else {
|
||||
fmt.Println(heartRate, "BPM")
|
||||
}
|
||||
}
|
||||
|
||||
case <-c.Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func watchBattLevel(c *cli.Context) error {
|
||||
battLevelCh, err := client.WatchBatteryLevel(c.Context)
|
||||
@ -35,7 +38,9 @@ func watchBattLevel(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for battLevel := range battLevelCh {
|
||||
for {
|
||||
select {
|
||||
case battLevel := <-battLevelCh:
|
||||
if c.Bool("json") {
|
||||
json.NewEncoder(os.Stdout).Encode(
|
||||
map[string]uint8{"battLevel": battLevel},
|
||||
@ -45,10 +50,11 @@ func watchBattLevel(c *cli.Context) error {
|
||||
} else {
|
||||
fmt.Printf("%d%%\n", battLevel)
|
||||
}
|
||||
}
|
||||
|
||||
case <-c.Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func watchStepCount(c *cli.Context) error {
|
||||
stepCountCh, err := client.WatchStepCount(c.Context)
|
||||
@ -56,7 +62,9 @@ func watchStepCount(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for stepCount := range stepCountCh {
|
||||
for {
|
||||
select {
|
||||
case stepCount := <-stepCountCh:
|
||||
if c.Bool("json") {
|
||||
json.NewEncoder(os.Stdout).Encode(
|
||||
map[string]uint32{"stepCount": stepCount},
|
||||
@ -66,10 +74,11 @@ func watchStepCount(c *cli.Context) error {
|
||||
} else {
|
||||
fmt.Println(stepCount, "Steps")
|
||||
}
|
||||
}
|
||||
|
||||
case <-c.Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func watchMotion(c *cli.Context) error {
|
||||
motionCh, err := client.WatchMotion(c.Context)
|
||||
@ -77,7 +86,9 @@ func watchMotion(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for motionVals := range motionCh {
|
||||
for {
|
||||
select {
|
||||
case motionVals := <-motionCh:
|
||||
if c.Bool("json") {
|
||||
json.NewEncoder(os.Stdout).Encode(motionVals)
|
||||
} else if c.Bool("shell") {
|
||||
@ -90,7 +101,8 @@ func watchMotion(c *cli.Context) error {
|
||||
} else {
|
||||
fmt.Println(motionVals)
|
||||
}
|
||||
}
|
||||
|
||||
case <-c.Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
unknown
|
||||
r150.78b5ca1
|
Loading…
Reference in New Issue
Block a user