1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
 
   3 # SPDX-License-Identifier: MIT
 
   5 from unittest import TestCase
 
   6 from testing import await_true
 
  11 class TestGPSInteractive(TestCase):
 
  12     def test_read_value(self):
 
  13         import adafruit_blinka
 
  15         adafruit_blinka.patch_system()  # needed before adafruit_gps imports time
 
  17         import microcontroller.pin
 
  27         # configure the last available UART (first uart often for REPL)
 
  28         uartId, uartTx, uartRx = microcontroller.pin.uartPorts[0]
 
  29         uart = busio.UART(uartTx, uartRx, baudrate=9600, timeout=3000)
 
  31         gps = adafruit_gps.GPS(uart)
 
  33         gps.send_command("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
 
  34         gps.send_command("PMTK220,1000")
 
  40         await_true("GPS fix", try_fix)
 
  42         self.assertTrue(gps.satellites is not None)
 
  43         self.assertTrue(-90 <= gps.latitude < 90)
 
  44         self.assertTrue(-180 <= gps.longitude < 180)