band_utils.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:12k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * band_utils.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Band utility source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include "meta.h"
- #ifndef _RF_COMMON_H_
- #include "rf_common.h"
- #endif
- #ifndef age1960_INCLUDE
- #include "age1960.h"
- #endif
- //---------------------------------------------------------------------------
- FrequencyBand BandIdx_To_FreqBand(E_BANDSEL band_idx)
- {
- FrequencyBand freq_band;
- switch(band_idx)
- {
- case BANDSEL_GSM900:
- freq_band = FrequencyBand900;
- break;
- case BANDSEL_DCS1800:
- freq_band = FrequencyBand1800;
- break;
- case BANDSEL_PCS1900:
- freq_band = FrequencyBand1900;
- break;
- case BANDSEL_GSM850:
- freq_band = FrequencyBand850;
- break;
- default:
- freq_band = FrequencyBand900;
- break;
- }
- return freq_band;
- }
- //---------------------------------------------------------------------------
- E_BANDSEL FreqBand_To_BandIdx( FrequencyBand freq_band )
- {
- E_BANDSEL band_idx;
- switch( freq_band )
- {
- case FrequencyBand900:
- band_idx = BANDSEL_GSM900;
- break;
- case FrequencyBand1800:
- band_idx = BANDSEL_DCS1800;
- break;
- case FrequencyBand1900:
- band_idx = BANDSEL_PCS1900;
- break;
- case FrequencyBand850:
- band_idx = BANDSEL_GSM850;
- break;
- default:
- band_idx = BANDSEL_GSM900;
- break;
- }
- return band_idx;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- int FreqBand_To_AgeBand( FrequencyBand freq_band )
- {
- int age_band;
- switch( freq_band )
- {
- case FrequencyBand900:
- age_band = age1960_EGSM_BAND;
- break;
- case FrequencyBand1800:
- age_band = age1960_DCS1800_BAND;
- break;
- case FrequencyBand1900:
- age_band = age1960_PCS1900_BAND;
- break;
- case FrequencyBand850:
- age_band = age1960_GSM850_BAND;
- break;
- default:
- age_band = age1960_EGSM_BAND;
- break;
- }
- return age_band;
- }
- //--------------------------------------------------------------------------
- FrequencyBand AgeBand_To_FreqBand( int age_band )
- {
- FrequencyBand freq_band;
- switch( age_band )
- {
- case age1960_PGSM_BAND:
- case age1960_EGSM_BAND:
- freq_band = FrequencyBand900;
- break;
- case age1960_DCS1800_BAND:
- freq_band = FrequencyBand1800;
- break;
- case age1960_PCS1900_BAND:
- freq_band = FrequencyBand1900;
- break;
- case age1960_GSM850_BAND:
- freq_band = FrequencyBand850;
- break;
- default:
- freq_band = FrequencyBand900;
- break;
- }
- return freq_band;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- int Get_AgeBand( AnsiString as_band )
- {
- if( as_band.AnsiCompareIC("GSM") == 0 )
- {
- return age1960_EGSM_BAND;
- }
- else if( as_band.AnsiCompareIC("DCS") == 0 )
- {
- return age1960_DCS1800_BAND;
- }
- else if( as_band.AnsiCompareIC("PCS") == 0 )
- {
- return age1960_PCS1900_BAND;
- }
- else if( as_band.AnsiCompareIC("GSM850") == 0 )
- {
- return age1960_GSM850_BAND;
- }
- return age1960_EGSM_BAND; // default to EGSM
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- int BandIdx_To_AgeBand(E_BANDSEL band_idx)
- {
- if( band_idx == BANDSEL_GSM900 )
- {
- return age1960_EGSM_BAND;
- }
- else if( band_idx == BANDSEL_DCS1800 )
- {
- return age1960_DCS1800_BAND;
- }
- else if( band_idx == BANDSEL_PCS1900 )
- {
- return age1960_PCS1900_BAND;
- }
- else if( band_idx == BANDSEL_GSM850 )
- {
- return age1960_GSM850_BAND;
- }
- return age1960_EGSM_BAND; // default to EGSM
- }
- //-------------------------------------------------------------------------
- E_BANDSEL AgeBand_To_BandIdx(int age_band)
- {
- E_BANDSEL band_idx;
- switch (age_band)
- {
- case (int)age1960_EGSM_BAND:
- case (int)age1960_PGSM_BAND:
- {
- band_idx = BANDSEL_GSM900;
- }
- break;
- case (int)age1960_DCS1800_BAND:
- {
- band_idx = BANDSEL_DCS1800;
- }
- break;
- case (int)age1960_PCS1900_BAND:
- {
- band_idx = BANDSEL_PCS1900;
- }
- break;
- case (int)age1960_GSM850_BAND:
- {
- band_idx = BANDSEL_GSM850;
- }
- break;
- }
- return band_idx;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- AnsiString BandIdx_To_String( E_BANDSEL band_idx )
- {
- AnsiString as_band="";
- switch( band_idx )
- {
- case BANDSEL_GSM850:
- as_band = "GSM850";
- break;
- case BANDSEL_GSM900:
- as_band = "GSM";
- break;
- case BANDSEL_DCS1800:
- as_band = "DCS";
- break;
- case BANDSEL_PCS1900:
- as_band = "PCS";
- break;
- }
- return as_band;
- }
- //---------------------------------------------------------------------------
- E_BANDSEL String_To_BandIdx( AnsiString as_str )
- {
- E_BANDSEL band_sel;
- if( as_str.AnsiCompareIC("GSM850") == 0 )
- {
- band_sel = BANDSEL_GSM850;
- }
- else if( as_str.AnsiCompareIC("GSM") == 0 )
- {
- band_sel = BANDSEL_GSM900;
- }
- else if( as_str.AnsiCompareIC("DCS") == 0 )
- {
- band_sel = BANDSEL_DCS1800;
- }
- else if( as_str.AnsiCompareIC("PCS") == 0 )
- {
- band_sel = BANDSEL_PCS1900;
- }
- return band_sel;
- }
- //---------------------------------------------------------------------------
- AnsiString BandIdx_To_FreqBandString(int band_idx)
- {
- AnsiString as_band = "";
- switch (band_idx)
- {
- case BANDSEL_GSM850:
- {
- as_band = "0x02";
- }
- break;
- case BANDSEL_GSM900:
- {
- as_band = "0x04";
- }
- break;
- case BANDSEL_DCS1800:
- {
- as_band = "0x08";
- }
- break;
- case BANDSEL_PCS1900:
- {
- as_band = " 0x10";
- }
- break;
- }
- return as_band;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- AnsiString viBand_To_String( int vi_band )
- {
- AnsiString as_band="";
- switch( vi_band )
- {
- case age1960_GSM850_BAND:
- as_band = "GSM850";
- break;
- case age1960_PGSM_BAND:
- case age1960_EGSM_BAND:
- as_band = "GSM";
- break;
- case age1960_DCS1800_BAND:
- as_band = "DCS";
- break;
- case age1960_PCS1900_BAND:
- as_band = "PCS";
- break;
- }
- return as_band;
- }
- //--------------------------------------------------------------------------
- int String_To_viBand( AnsiString as_band )
- {
- int vi_band = 0;
- if( as_band.AnsiCompareIC( "GSM850" ) == 0 )
- {
- vi_band = age1960_GSM850_BAND;
- }
- else if( as_band.AnsiCompareIC( "GSM" ) == 0 )
- {
- vi_band = age1960_EGSM_BAND;
- }
- else if( as_band.AnsiCompareIC( "DCS" ) == 0 )
- {
- vi_band = age1960_DCS1800_BAND;
- }
- else if( as_band.AnsiCompareIC( "PCS" ) == 0 )
- {
- vi_band = age1960_PCS1900_BAND;
- }
- return vi_band;
- }
- //------------------------------------------------------------------------------
- AnsiString FreqBand_To_Str( FrequencyBand freq_band )
- {
- AnsiString as="";
- switch( freq_band )
- {
- case FrequencyBand850:
- as="GSM850";
- break;
- case FrequencyBand900:
- as="GSM";
- break;
- case FrequencyBand1800:
- as="DCS";
- break;
- case FrequencyBand1900:
- as="PCS";
- break;
- default:
- as="GSM";
- break;
- }
- return as;
- }
- //------------------------------------------------------------------------------
- AnsiString ViBand_To_Str( int viBand)
- {
- AnsiString as="";
- switch( viBand )
- {
- case age1960_CURRENT_BAND:
- as="Current band";
- break;
- case age1960_PGSM_BAND:
- case age1960_EGSM_BAND:
- as="EGSM";
- break;
- case age1960_DCS1800_BAND:
- as="DCS";
- break;
- case age1960_PCS1900_BAND:
- as="PCS";
- break;
- case age1960_GSM850_BAND:
- as="GSM850";
- break;
- default:
- as="GSM";
- break;
- }
- return as;
- }
- //------------------------------------------------------------------------------
- FrequencyBand Get_FreqBandFromStr( AnsiString asBand )
- {
- FrequencyBand freqband;
- if( asBand.AnsiCompareIC("GSM850") == 0 )
- {
- freqband = FrequencyBand850;
- }
- else if( asBand.AnsiCompareIC("GSM") == 0 )
- {
- freqband = FrequencyBand900;
- }
- else if( asBand.AnsiCompareIC("DCS") == 0 )
- {
- freqband = FrequencyBand1800;
- }
- else if( asBand.AnsiCompareIC("PCS") == 0 )
- {
- freqband = FrequencyBand1900;
- }
- else
- {
- freqband = FrequencyBand900;
- }
- return freqband;
- }
-