예제 #1
0
void gps_wait_for_lock()
{
	struct gps_info gpsinfo;
	while (1)
	{
		if (gps_update_info(&gpsinfo))   // We got a new GPS reading
		{
			if (gpsinfo.status == ACTIVE)
				return; // OK, we got a lock
		}	
	}	
}
예제 #2
0
int gps_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    char *pTimeout=NULL;
    int chosen;
    bool exit = false;
    struct gps_desc *gps = (struct gps_desc *)priv;
    struct itemview *iv;
	pTimeout = ftm_get_prop("GPS.TIMEOUT");
	if(pTimeout != NULL )
	{
		timeout=atoi(pTimeout);
		LOGD(TAG "timeout value is %d\n", timeout);	
	}
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&gps->title, param->name, COLOR_YELLOW);
    init_text(&gps->text, &gps->info[0], COLOR_YELLOW);
    
    gps_update_info(gps, gps->info);
   
    gps->exit_thd = false;

    if (!gps->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        gps->iv = iv;
    }
    
    iv = gps->iv;
    iv->set_title(iv, &gps->title);
    iv->set_items(iv, gps_items, 0);
    iv->set_text(iv, &gps->text);
    
	iv->start_menu(iv,0);
    pthread_create(&gps->update_thd, NULL, gps_update_iv_thread, priv);
    int wait_time = 10;
    int init_try_time = 0;
    while(!init_flag && wait_time)
    {
    	LOGD(TAG" init_flag = %d, try time = %d\n", init_flag, ++init_try_time);
    	sleep(1);
    	--wait_time;	
    }
    init_flag = 0;
    wait_time = 10;
    init_try_time = 0;
    LOGD(TAG" init_flag = %d\n", init_flag);
	iv->redraw(iv);
    do{
        //Auto test: only CTTFF
        cttff = 1;
        do{
            usleep(1000000); //check status per sec
            LOGD(TAG"after %d sec from test starting, we still can not see any SV\n", ttff);
        }while(ttff <= timeout && !ttff_check_res);

        if(ttff_check_res == 1){
            LOGD(TAG"Test pass"); 
            gps->mod->test_result = FTM_TEST_PASS;
	      }else{
            LOGD(TAG"Test fail");
            gps->mod->test_result = FTM_TEST_FAIL;		
        }
		if(unlink("/data/misc/mtkgps.dat")!=0 )
			LOGD(TAG "unlink mtkgps.dat error, error is %s\n", strerror(errno));
		    ttff_check_res = 0;

     }while(0);
     
    gps->exit_thd = true;
    LOGD(TAG "%s, gps->exit_thd = true\n", __FUNCTION__);    
#if 0
    do {
        chosen = iv->run(iv, &exit);
        LOGD(TAG "%s, chosen = %d\n", __FUNCTION__, chosen);
        switch (chosen) {
        case ITEM_HTTFF:
            httff = 1;
            break;
        case ITEM_CTTFF:
            cttff = 1;
            break;
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                gps->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                gps->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;
            break;
        }
        
        if (exit) {
            gps->exit_thd = true;
            LOGD(TAG "%s, gps->exit_thd = true\n", __FUNCTION__);
            break;
        }        
    } while (1);
#endif
    pthread_join(gps->update_thd, NULL);

    return 0;
}
예제 #3
0
static void *gps_update_iv_thread(void *priv)
{
    struct gps_desc *gps = (struct gps_desc *)priv;
    struct itemview *iv = gps->iv;
    short count = 1, chkcnt = 10;
    int init_status;

    LOGD(TAG "%s: Start\n", __FUNCTION__);
    //init GPS driver
    memset(gps->info, '\n', INFO_SIZE);
    sprintf(gps->info, "%s\n", uistr_info_gps_init);
    iv->redraw(iv);
    sleep(1);
    init_status = GPS_Open();
    if(init_status != 0)    // GPS init fail
    {
        memset(gps->info, '\n', INFO_SIZE);
        sprintf(gps->info, "%s (%d)\n", uistr_info_gps_error, init_status);
        iv->redraw(iv);
    }
    else
    {
        //init GPS driver done
        ttff = 0;
        fixed = 0;
        memset(gps->info, '\n', INFO_SIZE);
        iv->redraw(iv);
        
        while (1) {
            usleep(100000); // wake up every 0.1sec
            chkcnt--;

            if (gps->exit_thd)
            {
                LOGD(TAG "%s, gps->exit_thd = true\n", __FUNCTION__);
                break;
            }

            if(httff == 1)
            {
                httff = 0;
                write(sockfd, "$PMTK101*32\r\n", sizeof("$PMTK101*32\r\n"));
                ttff = 0;
                fixed = 0;
                memset(gps->info, '\n', INFO_SIZE);
                gps->info[INFO_SIZE-1] = 0x0;
                iv->redraw(iv);
            }

            if(cttff == 1)
            {
                cttff = 0;
                write(sockfd, "$PMTK103*30\r\n", sizeof("$PMTK103*30\r\n") );
                ttff = 0;
                fixed = 0;
                memset(gps->info, '\n', INFO_SIZE);
                gps->info[INFO_SIZE-1] = 0x0;
                iv->redraw(iv);
            }

            if (chkcnt > 0)
                continue;

            chkcnt = 10;

            gps_update_info(gps, gps->info);
            iv->redraw(iv);
        }
    }
    //close GPS driver
    GPS_Close();
    //close GPS driver done
    LOGD(TAG "%s: Exit\n", __FUNCTION__);
    pthread_exit(NULL);

	return NULL;
}