Definitive check for "am I connected to AP/STA"

I have been using iwinfo wlan0 info (rpcd-mod-iwinfo over uBus) to display to users whether they are connected to an AP or not. Also useful in an AP use case where only 1 station is expected at any time.
I was checking if ESSID or Signal are returned to decide if we are connected.

I notice that this isn't always consistent and usually either SSID or RSSI/signal linger around in the output of iwinfo long after we are disconnected.

I have recently discovered through LuCi code that 'encryption' is always returned as '-' when disconnected, and another string when connected, so this might be a better way of determining. I'm not yet sure if LuCi uses iwinfo or something else to get this data.

Has anyone solved this before? Can anyone think of any better definitive way to check if we are connected/associated?