Auto refresh of QR code

This commit refines the UX of scanning a code by continuously
checking for a new code. In AP mode, a new code is generated when
the old code has expired. In device mode, a new code is generated
whenever the previous code has been consumed.