Device for diagnosing railway bogies by applying an energy-autonomous measuring and transmitting bolt, and corresponding control method