@@ -518,6 +518,7 @@ void scan_cellular_execute(uint8_t cell_count, struct lte_lc_cells_info *cell_da
518518{
519519 int err ;
520520 uint8_t ncellmeas3_cell_count ;
521+ int rrc_mode ;
521522
522523 nrfcloud_cell_data = cell_data ;
523524 if (cell_data == NULL ) {
@@ -563,25 +564,28 @@ void scan_cellular_execute(uint8_t cell_count, struct lte_lc_cells_info *cell_da
563564 goto end ;
564565 }
565566
566- /* TODO: RRC idle not monitored */
567567 /* GCI searches are not done when in RRC connected mode. We are waiting for
568568 * device to enter RRC idle mode unless it's there already.
569+ * We'll poll for the RRC connection release every second for 10 seconds.
570+ * We could order CSCON notifications but this would require handling of
571+ * SM subscription of CSCON and host subscription so that
572+ * we send the notifications correctly to the host.
569573 */
570- LOG_DBG ("%s" , k_sem_count_get (& entered_rrc_idle ) == 0 ?
571- "Waiting for the RRC connection release..." :
572- "RRC already in idle mode" );
573-
574- if (k_sem_take (& entered_rrc_idle , K_SECONDS (SCAN_CELLULAR_RRC_IDLE_WAIT_TIME )) != 0 ) {
575- /* If semaphore is reset while waiting, the position request was canceled */
576- if (!nrfcloud_sending_loc_req ) {
577- goto end ;
574+ for (int i = 0 ; i < 10 ; i ++ ) {
575+ err = sm_util_at_scanf ("AT+CSCON?" , "+CSCON: %*d,%d" , & rrc_mode );
576+ if (err == 1 ) {
577+ if (rrc_mode == 0 ) {
578+ break ;
579+ }
580+ LOG_DBG ("Waiting for RRC connection release" );
581+ k_sleep (K_SECONDS (1 ));
582+ } else {
583+ /* If AT+CSCON fails, we just go ahead and perform the GCI searches */
584+ LOG_ERR ("+CSCON failed %d" , err );
585+ break ;
578586 }
579- /* The wait for RRC idle timed out */
580- LOG_WRN ("RRC connection was not released in %d seconds." ,
581- SCAN_CELLULAR_RRC_IDLE_WAIT_TIME );
582- goto end ;
583587 }
584- k_sem_give ( & entered_rrc_idle );
588+
585589
586590 /*****
587591 * 2nd: GCI history search to get GCI cells we can quickly search and measure.
0 commit comments