#include #include #include #include static int cmd_valve_set_max_open_time(const struct shell *sh, size_t argc, char **argv) { if (argc != 2) { shell_print(sh, "Usage: valve set_max_open_time "); return -EINVAL; } uint16_t seconds = (uint16_t)atoi(argv[1]); valve_set_max_open_time(seconds); shell_print(sh, "Max open time set to %u seconds.", seconds); return 0; } static int cmd_valve_get_max_open_time(const struct shell *sh, size_t argc, char **argv) { uint16_t seconds = valve_get_max_open_time(); shell_print(sh, "Max open time: %u seconds.", seconds); return 0; } static int cmd_valve_set_max_close_time(const struct shell *sh, size_t argc, char **argv) { if (argc != 2) { shell_print(sh, "Usage: valve set_max_close_time "); return -EINVAL; } uint16_t seconds = (uint16_t)atoi(argv[1]); valve_set_max_close_time(seconds); shell_print(sh, "Max close time set to %u seconds.", seconds); return 0; } static int cmd_valve_get_max_close_time(const struct shell *sh, size_t argc, char **argv) { uint16_t seconds = valve_get_max_close_time(); shell_print(sh, "Max close time: %u seconds.", seconds); return 0; } static int cmd_valve_set_end_current_threshold_open( const struct shell *sh, size_t argc, char **argv) { if (argc != 2) { shell_print(sh, "Usage: valve set_end_current_threshold_open "); return -EINVAL; } uint16_t current_ma = (uint16_t)atoi(argv[1]); valve_set_end_current_threshold_open(current_ma); shell_print(sh, "End current threshold (open) set to %u mA.", current_ma); return 0; } static int cmd_valve_get_end_current_threshold_open( const struct shell *sh, size_t argc, char **argv) { uint16_t current_ma = valve_get_end_current_threshold_open(); shell_print(sh, "End current threshold (open): %u mA.", current_ma); return 0; } static int cmd_valve_set_end_current_threshold_close( const struct shell *sh, size_t argc, char **argv) { if (argc != 2) { shell_print(sh, "Usage: valve set_end_current_threshold_close "); return -EINVAL; } uint16_t current_ma = (uint16_t)atoi(argv[1]); valve_set_end_current_threshold_close(current_ma); shell_print(sh, "End current threshold (close) set to %u mA.", current_ma); return 0; } static int cmd_valve_get_end_current_threshold_close( const struct shell *sh, size_t argc, char **argv) { uint16_t current_ma = valve_get_end_current_threshold_close(); shell_print(sh, "End current threshold (close): %u mA.", current_ma); return 0; } SHELL_STATIC_SUBCMD_SET_CREATE(sub_valve_settings, SHELL_CMD(set_max_open_time, NULL, "Set max open time (seconds)", cmd_valve_set_max_open_time), SHELL_CMD(get_max_open_time, NULL, "Get max open time (seconds)", cmd_valve_get_max_open_time), SHELL_CMD( set_max_close_time, NULL, "Set max close time (seconds)", cmd_valve_set_max_close_time), SHELL_CMD( get_max_close_time, NULL, "Get max close time (seconds)", cmd_valve_get_max_close_time), SHELL_CMD(set_end_current_threshold_open, NULL, "Set end current threshold for opening (mA)", cmd_valve_set_end_current_threshold_open), SHELL_CMD(get_end_current_threshold_open, NULL, "Get end current threshold for opening (mA)", cmd_valve_get_end_current_threshold_open), SHELL_CMD(set_end_current_threshold_close, NULL, "Set end current threshold for closing (mA)", cmd_valve_set_end_current_threshold_close), SHELL_CMD(get_end_current_threshold_close, NULL, "Get end current threshold for closing (mA)", cmd_valve_get_end_current_threshold_close), SHELL_SUBCMD_SET_END); SHELL_CMD_REGISTER(valve, &sub_valve_settings, "Valve commands", NULL);