```

    /*
        gnss.ino - GNSS example application
        Copyright 2018 Sony Semiconductor Solutions Corporation
    
        This library is free software; you can redistribute it and/or
        modify it under the terms of the GNU Lesser General Public
        License as published by the Free Software Foundation; either
        version 2.1 of the License, or (at your option) any later version.
    
        This library is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        Lesser General Public License for more details.
    
        You should have received a copy of the GNU Lesser General Public
        License along with this library; if not, write to the Free Software
        Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    */
    
    /**
       @file gnss.ino
       @author Sony Semiconductor Solutions Corporation
       @brief GNSS example application
       @details Spresense has an built in GNSS receiver which supports GPS and other
                GNSS satellites. This skecth provides an example the GNSS operation.
                Simply upload the sketch, reset the board and check the USB serial
                output. After 3 seconds status information should start to appear.\n\n
    
                This example code is in the public domain.
    */
    
    /* include the GNSS library */
    #include <GNSS.h>
    #include <SDHCI.h>
    #include <Audio.h>
    #define STRING_BUFFER_SIZE  128       /**< %Buffer size */
    #define PLAYBACK_FILE_NAME "Sound.wav"
    #define RESTART_CYCLE       (60 * 5)  /**< positioning test term */
    
    static SpGnss Gnss;                   /**< SpGnss object */
    SDClass theSD;
    AudioClass *theAudio;
    File myFile;
    
    WavContainerFormatParser theParser;
    
    const int32_t sc_buffer_size = 6144;
    uint8_t s_buffer[sc_buffer_size];
    
    uint32_t s_remain_size = 0;
    bool ErrEnd = false;
    /**
       @enum ParamSat
       @brief Satellite system
    */
    enum ParamSat {
      eSatGps,            /**< GPS                     World wide coverage  */
      eSatGlonass,        /**< GLONASS                 World wide coverage  */
      eSatGpsSbas,        /**< GPS+SBAS                North America        */
      eSatGpsGlonass,     /**< GPS+Glonass             World wide coverage  */
      eSatGpsBeidou,      /**< GPS+BeiDou              World wide coverage  */
      eSatGpsGalileo,     /**< GPS+Galileo             World wide coverage  */
      eSatGpsQz1c,        /**< GPS+QZSS_L1CA           East Asia & Oceania  */
      eSatGpsGlonassQz1c, /**< GPS+Glonass+QZSS_L1CA   East Asia & Oceania  */
      eSatGpsBeidouQz1c,  /**< GPS+BeiDou+QZSS_L1CA    East Asia & Oceania  */
      eSatGpsGalileoQz1c, /**< GPS+Galileo+QZSS_L1CA   East Asia & Oceania  */
      eSatGpsQz1cQz1S,    /**< GPS+QZSS_L1CA+QZSS_L1S  Japan                */
    };
    
    /* Set this parameter depending on your current region.
      現在の地域に応じてこのパラメーターを設定します*/
    static enum ParamSat satType =  eSatGps;
    
    
    static void audio_attention_cb(const ErrorAttentionParam *atprm)
    {
      puts("Attention!");
    
      if (atprm->error_code >= AS_ATTENTION_CODE_WARNING)
      {
        ErrEnd = true;
      }
    }
    
    class Score
    {
      public:
    
        typedef struct {
          int fs;
          int time;
        } Note;
    
        void init() {
          pos = 0;
        }
    
        Note get() {
          return data[pos++];
        }
    
      private:
    
        int pos;
    
        Note data[17] =
        {
          {262, 500},
          {294, 500},
          {330, 500},
          {349, 500},
          {392, 500},
          {440, 500},
          {494, 500},
          {523, 1000},
    
          {523, 500},
          {494, 500},
          {440, 500},
          {392, 500},
          {349, 500},
          {330, 500},
          {294, 500},
          {262, 1000},
    
          {0, 0}
        };
    
        /*  Note data[17] =
          {
            {440,1000},
            {440,1000},
            {494,2000},
    
            {440,1000},
            {440,1000},
            {494,2000},
    
            {440,1000},
            {494,1000},
            {523,1000},
            {494,1000},
    
            {440,1000},
            {494,500},
            {440,500},
            {349,2000},
    
            {0,0}
          };*/
    
    };
    
    Score theScore;
    
    /**
       @brief Activate GNSS device and start positioning.
       GNSS デバイスをアクティブにして測位を開始します。
    */
    
    static const uint32_t sc_prestore_frames = 10;
    
    void setup() {
      /* put your setup code here, to run once: */
    
      theScore.init();
    
      int error_flag = 0;
    
      /* Initialize SD */
      while (!theSD.begin())
      {
        /* wait until SD card is mounted. */
        Serial.println("Insert SD card.");
      }
    
      // Get wav file info
    
      fmt_chunk_t fmt;
    
      handel_wav_parser_t *handle
        = (handel_wav_parser_t *)theParser.parseChunk("/mnt/sd0/" PLAYBACK_FILE_NAME, &fmt);
      if (handle == NULL)
      {
        printf("Wav parser error.\n");
        exit(1);
      }
    
      // Get data chunk info from wav format
      uint32_t data_offset = handle->data_offset;
      s_remain_size = handle->data_size;
    
      theParser.resetParser((handel_wav_parser *)handle);
    
      // start audio system
      theAudio = AudioClass::getInstance();
    
      theAudio->begin(audio_attention_cb);
    
      puts("initialization Audio Library");
    
      /* Set clock mode to normal */
    
      theAudio->setRenderingClockMode((fmt.rate <= 48000) ? AS_CLKMODE_NORMAL : AS_CLKMODE_HIRES);
    
      /* Set output device to speaker with first argument.
         If you want to change the output device to I2S,
         specify "AS_SETPLAYER_OUTPUTDEVICE_I2SOUTPUT" as an argument.
         Set speaker driver mode to LineOut with second argument.
         If you want to change the speaker driver mode to other,
         specify "AS_SP_DRV_MODE_1DRIVER" or "AS_SP_DRV_MODE_2DRIVER" or "AS_SP_DRV_MODE_4DRIVER"
         as an argument.
      */
      theAudio->setPlayerMode(AS_SETPLAYER_OUTPUTDEVICE_SPHP, AS_SP_DRV_MODE_LINEOUT);
    
      /*
         Set main player to decode wav. Initialize parameters are taken from wav header.
         Search for WAV decoder in "/mnt/sd0/BIN" directory
      */
      err_t err = theAudio->initPlayer(AudioClass::Player0, AS_CODECTYPE_WAV, "/mnt/sd0/BIN", fmt.rate, fmt.bit, fmt.channel);
    
      /* Verify player initialize */
      if (err != AUDIOLIB_ECODE_OK)
      {
        printf("Player0 initialize error\n");
        exit(1);
      }
    
      /* Open file placed on SD card */
      myFile = theSD.open(PLAYBACK_FILE_NAME);
    
      /* Verify file open */
      if (!myFile)
      {
        printf("File open error\n");
        exit(1);
      }
      printf("Open! %s\n", myFile.name());
    
      /* Set file position to beginning of data */
      myFile.seek(data_offset);
    
      for (uint32_t i = 0; i < sc_prestore_frames; i++)
      {
        size_t supply_size = myFile.read(s_buffer, sizeof(s_buffer));
        s_remain_size -= supply_size;
    
        err = theAudio->writeFrames(AudioClass::Player0, s_buffer, supply_size);
        if (err != AUDIOLIB_ECODE_OK)
        {
          break;
        }
    
        if (s_remain_size == 0)
        {
          break;
        }
      }
    
      /* Main volume set to -16.0 dB */
    
      theAudio->setVolume(-160);
    
      theAudio->startPlayer(AudioClass::Player0);
      puts("Play!");
    
    
    
    
      /* Set serial baudrate.シリアルボーレートを設定する */
      Serial.begin(115200);
    
      /* Wait HW initialization done. */
      sleep(3);
    
      /* Turn on all LED:Setup start. */
      ledOn(PIN_LED0);
      ledOn(PIN_LED1);
      ledOn(PIN_LED2);
      ledOn(PIN_LED3);
    
      /* Set Debug mode to Info */
      Gnss.setDebugMode(PrintInfo);
    
      int result;
    
      /* Activate GNSS device */
      result = Gnss.begin();
    
      if (result != 0)
      {
        Serial.println("Gnss begin error!!");
        error_flag = 1;
      }
      else
      {
        /* Setup GNSS
            It is possible to setup up to two GNSS satellites systems.
            Depending on your location you can improve your accuracy by selecting different GNSS system than the GPS system.
            See: https://developer.sony.com/develop/spresense/developer-tools/get-started-using-nuttx/nuttx-developer-guide#_gnss
            for detailed information.
            最大 2 つの GNSS 衛星システムをセットアップできます。
            場所によっては、GPS システムとは異なる GNSS システムを選択することで精度を向上させることができます。
        */
        switch (satType)
        {
          case eSatGps:
            Gnss.select(GPS);
            break;
    
          case eSatGpsSbas:
            Gnss.select(GPS);
            Gnss.select(SBAS);
            break;
    
          case eSatGlonass:
            Gnss.select(GLONASS);
            break;
    
          case eSatGpsGlonass:
            Gnss.select(GPS);
            Gnss.select(GLONASS);
            break;
    
          case eSatGpsBeidou:
            Gnss.select(GPS);
            Gnss.select(BEIDOU);
            break;
    
          case eSatGpsGalileo:
            Gnss.select(GPS);
            Gnss.select(GALILEO);
            break;
    
          case eSatGpsQz1c:
            Gnss.select(GPS);
            Gnss.select(QZ_L1CA);
            break;
    
          case eSatGpsQz1cQz1S:
            Gnss.select(GPS);
            Gnss.select(QZ_L1CA);
            Gnss.select(QZ_L1S);
            break;
    
          case eSatGpsBeidouQz1c:
            Gnss.select(GPS);
            Gnss.select(BEIDOU);
            Gnss.select(QZ_L1CA);
            break;
    
          case eSatGpsGalileoQz1c:
            Gnss.select(GPS);
            Gnss.select(GALILEO);
            Gnss.select(QZ_L1CA);
            break;
    
          case eSatGpsGlonassQz1c:
          default:
            Gnss.select(GPS);
            Gnss.select(GLONASS);
            Gnss.select(QZ_L1CA);
            break;
        }
    
        /* Start positioning */
        result = Gnss.start(COLD_START);
        if (result != 0)
        {
          Serial.println("Gnss start error!!");
          error_flag = 1;
        }
        else
        {
          Serial.println("Gnss setup OK");
        }
      }
    
      /* Start 1PSS output to PIN_D02 */
      //Gnss.start1PPS();
    
      /* Turn off all LED:Setup done. */
      ledOff(PIN_LED0);
      ledOff(PIN_LED1);
      ledOff(PIN_LED2);
      ledOff(PIN_LED3);
    }
    
    /**
       @brief %Print position information.
    */
    static void print_pos(SpNavData *pNavData)
    {
      static double latitude;
      static double longitude;
    
      char StringBuffer[STRING_BUFFER_SIZE];
    
      /* print time */
      snprintf(StringBuffer, STRING_BUFFER_SIZE, "%04d/%02d/%02d ", pNavData->time.year, pNavData->time.month, pNavData->time.day);
      Serial.print(StringBuffer);
    
      snprintf(StringBuffer, STRING_BUFFER_SIZE, "%02d:%02d:%02d.%06ld, ", pNavData->time.hour, pNavData->time.minute, pNavData->time.sec, pNavData->time.usec);
      Serial.print(StringBuffer);
    
      /* print satellites count */
      snprintf(StringBuffer, STRING_BUFFER_SIZE, "numSat:%2d, ", pNavData->numSatellites);
      Serial.print(StringBuffer);
    
      /* print position data */
      if (pNavData->posFixMode == FixInvalid)
      {
        Serial.print("No-Fix, ");
      }
      else
      {
        Serial.print("Fix, ");
      }
      if (pNavData->posDataExist == 0)
      {
        Serial.print("No Position");
      }
      else
      {
        Serial.print("Lat=");
        Serial.print(pNavData->latitude, 6);
        Serial.print(", Lon=");
        Serial.print(pNavData->longitude, 6);
      }
    
    
    
    
      if ((pNavData->latitude <= 43.20) && (pNavData->longitude <= 142.20)) {
        Serial.println(" 道南 ");
    
        if (((pNavData->latitude >= 42.68) && (pNavData->longitude >= 141.54)) &&
            ((pNavData->latitude >= 42.71) && (pNavData->longitude >= 141.69)) &&
            ((pNavData->latitude >= 42.68) && (pNavData->longitude >= 141.72)) &&
            ((pNavData->latitude >= 42.73) && (pNavData->longitude >= 141.77)) &&
            ((pNavData->latitude >= 42.67) && (pNavData->longitude >= 141.76)) &&
            ((pNavData->latitude >= 42.62) && (pNavData->longitude >= 141.83)) &&
            ((pNavData->latitude >= 42.52) && (pNavData->longitude >= 142.02)) &&
            ((pNavData->latitude >= 42.61) && (pNavData->longitude >= 142.14)) &&
            ((pNavData->latitude >= 42.08) && (pNavData->longitude >= 140.58)) &&
            ((pNavData->latitude >= 42.95) && (pNavData->longitude >= 140.64)) &&
            ((pNavData->latitude >= 42.11) && (pNavData->longitude >= 140.75)) &&
            ((pNavData->latitude >= 42.61) && (pNavData->longitude >= 140.33)) &&
            ((pNavData->latitude >= 42.71) && (pNavData->longitude >= 140.96)) &&
            ((pNavData->latitude >= 42.76) && (pNavData->longitude >= 140.07)) &&
            ((pNavData->latitude >= 42.82) && (pNavData->longitude >= 141.12))) {
    
          Serial.println(" 鹿出没注意 ");
          digitalWrite(LED1, HIGH);
        }
      }
    
    
    
      if ((pNavData->latitude <= 43.20) && (pNavData->longitude >= 142.20)); {
        Serial.println(" 道東 ");
    
        if (((pNavData->latitude >= 42.99) && (pNavData->longitude >= 144.50)) &&
            ((pNavData->latitude >= 42.97) && (pNavData->longitude >= 144.53)) &&
            ((pNavData->latitude >= 42.98) && (pNavData->longitude >= 144.55)) &&
            ((pNavData->latitude >= 42.98) && (pNavData->longitude >= 144.63)) &&
            ((pNavData->latitude >= 43.00) && (pNavData->longitude >= 144.59)) &&
            ((pNavData->latitude >= 43.01) && (pNavData->longitude >= 144.66)) &&
            ((pNavData->latitude >= 43.01) && (pNavData->longitude >= 144.72)) &&
            ((pNavData->latitude >= 43.05) && (pNavData->longitude >= 144.74)) &&
            ((pNavData->latitude >= 43.06) && (pNavData->longitude >= 144.82))) {
    
          Serial.println(" 鹿出没注意 ");
          digitalWrite(LED2, HIGH);
        }
      }
    
      if (pNavData->latitude >= 44.20); {
        Serial.println(" 道北 ");
    
        if (((pNavData->latitude >= 45.52) && (pNavData->longitude >= 141.93)) &&
            ((pNavData->latitude >= 44.91) && (pNavData->longitude >= 142.58)) &&
            ((pNavData->latitude >= 45.22) && (pNavData->longitude >= 141.71)) &&
            ((pNavData->latitude >= 45.03) && (pNavData->longitude >= 141.74)) &&
            ((pNavData->latitude >= 45.03) && (pNavData->longitude >= 141.82)) &&
            ((pNavData->latitude >= 45.42) && (pNavData->longitude >= 141.63)) &&
            ((pNavData->latitude >= 45.44) && (pNavData->longitude >= 142.64)) &&
            ((pNavData->latitude >= 45.01) && (pNavData->longitude >= 142.29)) &&
            ((pNavData->latitude >= 45.11) && (pNavData->longitude >= 141.66)) &&
            ((pNavData->latitude >= 45.39) && (pNavData->longitude >= 141.79))) {
    
          Serial.println(" 鹿出没注意 ");
          digitalWrite(LED3, HIGH);
        }
      }
    }
    
    
    /**
       @brief %Print satellite condition.
    */
    static void print_condition(SpNavData * pNavData)
    {
      char StringBuffer[STRING_BUFFER_SIZE];
      unsigned long cnt;
    
      /* Print satellite count. */
      snprintf(StringBuffer, STRING_BUFFER_SIZE, "numSatellites:%2d\n", pNavData->numSatellites);
      Serial.print(StringBuffer);
    
      for (cnt = 0; cnt < pNavData->numSatellites; cnt++)
      {
        const char *pType = "---";
        SpSatelliteType sattype = pNavData->getSatelliteType(cnt);
    
        /* Get satellite type. */
        /* Keep it to three letters. */
        switch (sattype)
        {
          case GPS:
            pType = "GPS";
            break;
    
          case GLONASS:
            pType = "GLN";
            break;
    
          case QZ_L1CA:
            pType = "QCA";
            break;
    
          case SBAS:
            pType = "SBA";
            break;
    
          case QZ_L1S:
            pType = "Q1S";
            break;
    
          case BEIDOU:
            pType = "BDS";
            break;
    
          case GALILEO:
            pType = "GAL";
            break;
    
          default:
            pType = "UKN";
            break;
        }
    
        /* Get print conditions. */
        unsigned long Id  = pNavData->getSatelliteId(cnt);
        unsigned long Elv = pNavData->getSatelliteElevation(cnt);
        unsigned long Azm = pNavData->getSatelliteAzimuth(cnt);
        float sigLevel = pNavData->getSatelliteSignalLevel(cnt);
    
        /* Print satellite condition. */
        snprintf(StringBuffer, STRING_BUFFER_SIZE, "[%2ld] Type:%s, Id:%2ld, Elv:%2ld, Azm:%3ld, CN0:", cnt, pType, Id, Elv, Azm );
        Serial.print(StringBuffer);
        Serial.println(sigLevel, 6);
      }
    }
    
    
    /**
       @brief %Print position information and satellite condition.
    
       @details When the loop count reaches the RESTART_CYCLE value, GNSS device is
                restarted.
    */
    
    static const uint32_t sc_store_frames = 10;
    
    void loop()
    {
      /* put your main code here, to run repeatedly: */
      static int LoopCount = 0;
      static int LastPrintMin = 0;
      static bool is_carry_over = false;
      static size_t supply_size = 0;
    
      /* Check update. */
      if (Gnss.waitUpdate(-1))
      {
        /* Get NaviData. */
        SpNavData NavData;
        Gnss.getNavData(&NavData);
    
        /* Set posfix LED. */
        bool LedSet = (NavData.posDataExist && (NavData.posFixMode != FixInvalid));
    
        /* Print satellite information every minute. */
        if (NavData.time.minute != LastPrintMin)
        {
          print_condition(&NavData);
          LastPrintMin = NavData.time.minute;
        }
    
        /* Print position information. */
        print_pos(&NavData);              /* ここにWAVを挿入する？. */
    
    
    
    
        
        for (uint32_t i = 0; i < sc_store_frames; i++)
        {
          if (!is_carry_over)
          {
            supply_size = myFile.read(s_buffer, (s_remain_size < sizeof(s_buffer)) ? s_remain_size : sizeof(s_buffer));
            s_remain_size -= supply_size;
          }
          is_carry_over = false;
    
          int err = theAudio->writeFrames(AudioClass::Player0, s_buffer, supply_size);
    
          if (err == AUDIOLIB_ECODE_SIMPLEFIFO_ERROR)
          {
            is_carry_over = true;
            break;
          }
    
          if (s_remain_size == 0)
          {
            goto stop_player;
          }
        }
    
        if (ErrEnd)
        {
          printf("Error End\n");
          goto stop_player;
        }
    
        /* This sleep is adjusted by the time to read the audio stream file.
           Please adjust in according with the processing contents
           being processed at the same time by Application.
    
           The usleep() function suspends execution of the calling thread for usec
           microseconds. But the timer resolution depends on the OS system tick time
           which is 10 milliseconds (10,000 microseconds) by default. Therefore,
           it will sleep for a longer time than the time requested here.
        */
    
        usleep(1000);
    
        /* Don't go further and continue play */
    
        return;
    
    stop_player:
        theAudio->stopPlayer(AudioClass::Player0);
        myFile.close();
        theAudio->setReadyMode();
        theAudio->end();
        printf("Exit player\n");
        exit(1);
    
    
    
    
        
      }
      else
      {
        /* Not update. */
        Serial.println("data not update");
      }
    
      /* Check loop count. */
      LoopCount++;
      if (LoopCount >= RESTART_CYCLE)
      {
        int error_flag = 0;
    
        /* Turn off LED0 */
        ledOff(PIN_LED0);
    
        /* Restart GNSS. */
        if (Gnss.stop() != 0)
        {
          Serial.println("Gnss stop error!!");
          error_flag = 1;
        }
        else if (Gnss.end() != 0)
        {
          Serial.println("Gnss end error!!");
          error_flag = 1;
        }
        else
        {
          Serial.println("Gnss stop OK.");
        }
    
        if (Gnss.begin() != 0)
        {
          Serial.println("Gnss begin error!!");
          error_flag = 1;
        }
        else if (Gnss.start(HOT_START) != 0)
        {
          Serial.println("Gnss start error!!");
          error_flag = 1;
        }
        else
        {
          Serial.println("Gnss restart OK.");
        }
    
        LoopCount = 0;
      }
    }
    
```
CC BY-SA 4.0
2022-12-12T05:06:23.067
92718
2022-12-14T01:38:41.083
2022-12-12T05:37:09.357
3060
55910
question
spresense
ArduinoでAudioとgnssを組み合わせ特定の座標時に音声を流すプログラムを作成したいのですが、エラーが出てしまいます
エラーの内容がわからないので的を外しているかも知れませんが、GPS時刻を使った時報を作ったことがあります。詳しくは次のURLに記載していますが、作成したコードも貼っておきます。

<https://makers-with-myson.blog.ss-blog.jp/2019-11-24>

ご参考になれば。

```

    #include <GNSS.h>
    #include <RTC.h>
    #include <SDHCI.h>
    #include <Audio.h>
    #include <pthread.h>
    
    static SDClass theSD;
    static SpGnss Gnss; 
    AudioClass *theAudio = AudioClass::getInstance();
    
    #define JST_IN_SECONDS  (9 * 60 * 60);
    
    static File myFile;
    static bool bTimeFixed = false;
    
    static void time_signal_thread(void *arg) {
    
      while(true) {
        usleep(100000);
        if (bTimeFixed == false) continue;
      
        RtcTime now = RTC.getTime();
        if (now.second() != 56) continue;
    
        myFile = theSD.open("jihou.mp3");
        if (!myFile) {
          Serial.println("File open error");
          while(1);
        }
    
        theAudio->writeFrames(AudioClass::Player0, myFile);
        theAudio->setVolume(-60);
        theAudio->startPlayer(AudioClass::Player0);
        while (true) {
          sleep(1);  //  To ensure not re-entering the audio routine. 
          int err = theAudio->writeFrames(AudioClass::Player0, myFile);
          if (err == AUDIOLIB_ECODE_FILEEND) {
            theAudio->stopPlayer(AudioClass::Player0);
            myFile.close();
            break;
          }
        }
      }
    
      return 0;
    }
    
    void setup() {
      int result;
    
      Serial.begin(115200);
      theSD.begin();
      sleep(3);  /* Wait HW initialization done. */
      
      theAudio->begin();
      theAudio->setRenderingClockMode(AS_CLKMODE_NORMAL);
      theAudio->setPlayerMode(AS_SETPLAYER_OUTPUTDEVICE_SPHP, AS_SP_DRV_MODE_LINEOUT);
      theAudio->initPlayer(AudioClass::Player0, AS_CODECTYPE_MP3, "/mnt/sd0/BIN"
                         , AS_SAMPLINGRATE_AUTO, AS_CHANNEL_MONO);
      Serial.println("Audio initialized");
      
      Gnss.begin();
      Gnss.select(GPS);
      Gnss.start(COLD_START);
      Serial.println("Gnss start...");
    
      int policy;
      struct sched_param param;
      pthread_t m_pid = pthread_self();
      pthread_getschedparam(m_pid, &policy, &param);
      Serial.println("Main Priority is : " + String(param.sched_priority));
    
      pthread_t t_pid;
      pthread_create(&t_pid, NULL, time_signal_thread, NULL);
      param.sched_priority = 130;
      pthread_setschedparam(t_pid, policy, &param);
      Serial.println("time_signal_thread start: " + String(param.sched_priority));
    }
    
    
    void loop() {
     
      if (!Gnss.waitUpdate(-1)) return;
    
      SpNavData NavData;
      Gnss.getNavData(&NavData);
      
      Serial.println("numSat: " + String(NavData.numSatellites));
    
      if (NavData.time.year == 1980) return;
      bTimeFixed = true;
      
      /* Create RTC time */
      RtcTime gtime(NavData.time.year, NavData.time.month, NavData.time.day
              , NavData.time.hour, NavData.time.minute, NavData.time.sec
              , NavData.time.usec * 1000 /* RtcTime requires nsec */);
    
      gtime += JST_IN_SECONDS; /* convert UTC to JST */
    
      printf("%04d/%02d/%02d %02d:%02d:%02d\n"
              , gtime.year(), gtime.month(), gtime.day()
              , gtime.hour(), gtime.minute(), gtime.second());
      
      /* When time is different more than 1 sec, update RTC time */
      if (abs(RTC.getTime() - gtime) >= 1) {
        RTC.setTime(gtime);
        Serial.println(" * Updated RTC time * ");
      }
    }
    
```
CC BY-SA 4.0
2022-12-14T01:38:41.083
92764
2022-12-14T01:38:41.083
27334
92718
answer