check iOS device is unlocked from macOS

I run a script from a mac, from macOS's terminal, to run a test on an iOS device connected to the mac via USB.

How can I programatically check that the device is unlocked? Also, how can I wake the iOS device from the mac?

The command "xcrun xctrace list devices" is very close to what I want, as it gives me the list of connected devices. However it does not tell me if the device is unlocked or not.

Thanks in advance.