An apparatus comprising: a flow generator (210, 212) configured to generate an outlet flow at an outlet port for delivery to a patient; at least one sensor (230, 232) configured to measure properties of the flow of gas exiting the flow generator (210, 212) through the outlet port or being delivered to the patient; and a controller operatively connected to the flow generator (210, 212) and connected to the at least one sensor (230, 232), the controller being configured to switch between a pressure control mode of operation and a flow control mode of operation, wherein: in the pressure control mode (104, 106, 108), the controller controls the flow generator (210, 212) to output a substantially steady pressure so that the average pressure over a period of multiple breaths remains substantially constant or within a limited predetermined range; in the flow control mode (104, 118, 124, 120, 128), the controller controls the flow generator to output a substantially steady flow so that the average flow over a period of multiple breaths remains substantially constant or within a limited predetermined range; the controller is configured to maintain a value being a probability assessed by the controller and representing the controller's belief that the patient is awake or asleep by assessing recent breathing patterns of the user, assessing recent history of apneaic events and/or assessing recent history of obstructed breathing of the user; the controller is configured to determine if the patient is awake or asleep based on said value; and wherein according to a therapy mode of the controller: the controller is configured to operate in the flow control mode when the result of the determination is that the patient is awake and operate in the pressure control mode (104,106, 108) when the result of the determination is that the patient is asleep, and the controller is additionally configured to switch from the flow control mode (104, 118, 124, 120, 128) to the pressure control mode (104, 106, 108) when the flow rate is below a predetermined limit, the predetermined limit being the substantially constant flow or a lower threshold of the predetermined flow range, and the pressure is above a pressure threshold. a flow generator (210, 212) configured to generate an outlet flow at an outlet port for delivery to a patient; at least one sensor (230, 232) configured to measure properties of the flow of gas exiting the flow generator (210, 212) through the outlet port or being delivered to the patient; and a controller operatively connected to the flow generator (210, 212) and connected to the at least one sensor (230, 232), the controller being configured to switch between a pressure control mode of operation and a flow control mode of operation, wherein: in the pressure control mode (104, 106, 108), the controller controls the flow generator (210, 212) to output a substantially steady pressure so that the average pressure over a period of multiple breaths remains substantially constant or within a limited predetermined range; in the flow control mode (104, 118, 124, 120, 128), the controller controls the flow generator to output a substantially steady flow so that the average flow over a period of multiple breaths remains substantially constant or within a limited predetermined range; in the pressure control mode (104, 106, 108), the controller controls the flow generator (210, 212) to output a substantially steady pressure so that the average pressure over a period of multiple breaths remains substantially constant or within a limited predetermined range; in the flow control mode (104, 118, 124, 120, 128), the controller controls the flow generator to output a substantially steady flow so that the average flow over a period of multiple breaths remains substantially constant or within a limited predetermined range; the controller is configured to maintain a value being a probability assessed by the controller and representing the controller's belief that the patient is awake or asleep by assessing recent breathing patterns of the user, assessing recent history of apneaic events and/or assessing recent history of obstructed breathing of the user; the controller is configured to determine if the patient is awake or asleep based on said value; and wherein according to a therapy mode of the controller: the controller is configured to operate in the flow control mode when the result of the determination is that the patient is awake and operate in the pressure control mode (104,106, 108) when the result of the determination is that the patient is asleep, and operate in the flow control mode when the result of the determination is that the patient is awake and operate in the pressure control mode (104,106, 108) when the result of the determination is that the patient is asleep, and the controller is additionally configured to switch from the flow control mode (104, 118, 124, 120, 128) to the pressure control mode (104, 106, 108) when the flow rate is below a predetermined limit, the predetermined limit being the substantially constant flow or a lower threshold of the predetermined flow range, and the pressure is above a pressure threshold.