Localization of mobile devices based on a magnetic field generated by a rotating magnetic dipole