Are you unlocking on a user event or the ICD state_sig signal (when last arg = 2) which is sent when it connects to wifi? ICD would be best because it verifies and removes the devlock as soon as a connection is made.