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 | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for heartRate := range heartCh { | 	for { | ||||||
|  | 		select { | ||||||
|  | 		case heartRate := <-heartCh: | ||||||
| 			if c.Bool("json") { | 			if c.Bool("json") { | ||||||
| 				json.NewEncoder(os.Stdout).Encode( | 				json.NewEncoder(os.Stdout).Encode( | ||||||
| 					map[string]uint8{"heartRate": heartRate}, | 					map[string]uint8{"heartRate": heartRate}, | ||||||
| @@ -24,10 +26,11 @@ func watchHeart(c *cli.Context) error { | |||||||
| 			} else { | 			} else { | ||||||
| 				fmt.Println(heartRate, "BPM") | 				fmt.Println(heartRate, "BPM") | ||||||
| 			} | 			} | ||||||
| 	} | 		case <-c.Done(): | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| func watchBattLevel(c *cli.Context) error { | func watchBattLevel(c *cli.Context) error { | ||||||
| 	battLevelCh, err := client.WatchBatteryLevel(c.Context) | 	battLevelCh, err := client.WatchBatteryLevel(c.Context) | ||||||
| @@ -35,7 +38,9 @@ func watchBattLevel(c *cli.Context) error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for battLevel := range battLevelCh { | 	for { | ||||||
|  | 		select { | ||||||
|  | 		case battLevel := <-battLevelCh: | ||||||
| 			if c.Bool("json") { | 			if c.Bool("json") { | ||||||
| 				json.NewEncoder(os.Stdout).Encode( | 				json.NewEncoder(os.Stdout).Encode( | ||||||
| 					map[string]uint8{"battLevel": battLevel}, | 					map[string]uint8{"battLevel": battLevel}, | ||||||
| @@ -45,10 +50,11 @@ func watchBattLevel(c *cli.Context) error { | |||||||
| 			} else { | 			} else { | ||||||
| 				fmt.Printf("%d%%\n", battLevel) | 				fmt.Printf("%d%%\n", battLevel) | ||||||
| 			} | 			} | ||||||
| 	} | 		case <-c.Done(): | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| func watchStepCount(c *cli.Context) error { | func watchStepCount(c *cli.Context) error { | ||||||
| 	stepCountCh, err := client.WatchStepCount(c.Context) | 	stepCountCh, err := client.WatchStepCount(c.Context) | ||||||
| @@ -56,7 +62,9 @@ func watchStepCount(c *cli.Context) error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for stepCount := range stepCountCh { | 	for { | ||||||
|  | 		select { | ||||||
|  | 		case stepCount := <-stepCountCh: | ||||||
| 			if c.Bool("json") { | 			if c.Bool("json") { | ||||||
| 				json.NewEncoder(os.Stdout).Encode( | 				json.NewEncoder(os.Stdout).Encode( | ||||||
| 					map[string]uint32{"stepCount": stepCount}, | 					map[string]uint32{"stepCount": stepCount}, | ||||||
| @@ -66,10 +74,11 @@ func watchStepCount(c *cli.Context) error { | |||||||
| 			} else { | 			} else { | ||||||
| 				fmt.Println(stepCount, "Steps") | 				fmt.Println(stepCount, "Steps") | ||||||
| 			} | 			} | ||||||
| 	} | 		case <-c.Done(): | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| func watchMotion(c *cli.Context) error { | func watchMotion(c *cli.Context) error { | ||||||
| 	motionCh, err := client.WatchMotion(c.Context) | 	motionCh, err := client.WatchMotion(c.Context) | ||||||
| @@ -77,7 +86,9 @@ func watchMotion(c *cli.Context) error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for motionVals := range motionCh { | 	for { | ||||||
|  | 		select { | ||||||
|  | 		case motionVals := <-motionCh: | ||||||
| 			if c.Bool("json") { | 			if c.Bool("json") { | ||||||
| 				json.NewEncoder(os.Stdout).Encode(motionVals) | 				json.NewEncoder(os.Stdout).Encode(motionVals) | ||||||
| 			} else if c.Bool("shell") { | 			} else if c.Bool("shell") { | ||||||
| @@ -90,7 +101,8 @@ func watchMotion(c *cli.Context) error { | |||||||
| 			} else { | 			} else { | ||||||
| 				fmt.Println(motionVals) | 				fmt.Println(motionVals) | ||||||
| 			} | 			} | ||||||
| 	} | 		case <-c.Done(): | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|   | |||||||
| @@ -1 +1 @@ | |||||||
| unknown | r150.78b5ca1 | ||||||
		Reference in New Issue
	
	Block a user