You need to do heartbeat every x seconds. Hikvision default is 30s for their devices web interface.
If you get anything other than 200 , something is wrong.
So lets say you run 2 services together, 1 for checking device status. other for fetching data.
Once device status is offline, make a...