Check whether network is available before uploading measurements

This PR should reduce the number of measurements lost to network errors, but issue #102 still needs additional work.