forked from Elara6331/itd
		
	Fix bug where itctl could not be killed
This commit is contained in:
		| @@ -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,9 +26,10 @@ func watchHeart(c *cli.Context) error { | ||||
| 			} else { | ||||
| 				fmt.Println(heartRate, "BPM") | ||||
| 			} | ||||
| 	} | ||||
|  | ||||
| 		case <-c.Done(): | ||||
| 			return nil | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func watchBattLevel(c *cli.Context) error { | ||||
| @@ -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,9 +50,10 @@ func watchBattLevel(c *cli.Context) error { | ||||
| 			} else { | ||||
| 				fmt.Printf("%d%%\n", battLevel) | ||||
| 			} | ||||
| 	} | ||||
|  | ||||
| 		case <-c.Done(): | ||||
| 			return nil | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func watchStepCount(c *cli.Context) error { | ||||
| @@ -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,9 +74,10 @@ func watchStepCount(c *cli.Context) error { | ||||
| 			} else { | ||||
| 				fmt.Println(stepCount, "Steps") | ||||
| 			} | ||||
| 	} | ||||
|  | ||||
| 		case <-c.Done(): | ||||
| 			return nil | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func watchMotion(c *cli.Context) error { | ||||
| @@ -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 | ||||
		Reference in New Issue
	
	Block a user