Skip to main content

waitForGpioSignalChange v6.0

Wait for a GPIO signal to change.

The request returns as soon as the signal's generation differs from generation. If generation is omitted, or already differs, the request returns immediately. A client can follow every change of a signal by passing the generation from the previous reply in the next request. Unlike waitForGpioSignal, which waits for a given state, this also notices a signal that changes and changes back between two requests.

Parameter​

KeyTypeDescription
namestringSignal name.
generationnumberOptional. The last seen generation. The request waits until the generation differs from it.
timeoutnumberOptional. Maximum time to wait, in seconds. If omitted, the request waits indefinitely.

Return value​

KeyTypeDescription
activebooleanWhether the signal is active.
generationnumberA number that changes whenever the signal changes.

The generation never repeats, not even across restarts or when a signal is removed and created again, so it is only useful for comparing with an earlier generation.

If the timeout expires, the current state is returned with an unchanged generation. Compare the returned generation with the one passed in to tell whether the signal changed.

The request fails if there is no signal with the given name, including if the signal is removed while waiting.

Example​

waitForGpioSignalChange {"name": "MySignal"}

Returns at once with the current state:

OK {"active":false,"generation":1830266141927}

Then wait for the next change, for at most 10 seconds:

waitForGpioSignalChange {"name": "MySignal", "generation": 1830266141927, "timeout": 10}