How to check iOS device is online/offline

I wanted to check whether the device is online or offline before starting specific scenarios.
Is there any way to do using appium-java