⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form_wifi.cpp

📁 MTK 手机软件开发 META 源代码,开发环境: C++ Builder
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        sprintf( str, " address     data                                      " );
        memMACResult->Lines->Add(str);
        sprintf( str, "=======================================================" );
        memMACResult->Lines->Add(str);
    }
    else
    {
        AnsiString as_macinfo;
        unsigned int   mac_addr;

        if( rbMAC16bits->Checked )
        {
            unsigned int   mac16_value;
            vector<WiFi_MACReg16_S>:: iterator iter;
            WiFi_MACReg16_S mcr16_first = *m_pvMCR16Disp->begin();
           // for( int i=0; i<m_sMCR16.count; i++ )
            for( iter = m_pvMCR16Disp->begin(); iter != m_pvMCR16Disp->end(); iter++ )
            {
                mac_addr    = iter->index;
                mac16_value = iter->mcr_data16;

                if( (mac_addr-mcr16_first.index) % 0x10 == 0 )
                {
                    sprintf(str, "%04lx:        ", mac_addr);
                    as_macinfo = str;
                }
                sprintf(str, "%04lx ", mac16_value);
                as_macinfo += str;

                if( (mac_addr-mcr16_first.index) % 0x10 == 0x0E  )
                {
                    strcpy( str, as_macinfo.c_str() );
                    memMACResult->Lines->Add(str);
                }
            }

            if( (mac_addr-mcr16_first.index) % 0x10 != 0x0E  )
            {
                strcpy( str, as_macinfo.c_str() );
                memMACResult->Lines->Add(str);
            }
        }
        else // MAC32
        {
            unsigned int   mac32_value;
            vector<WiFi_MACReg32_S>:: iterator iter;
            WiFi_MACReg32_S mcr32_first = *m_pvMCRDisp->begin();
            //for( int i=0; i<m_sMCR.count; i++ )
            for( iter = m_pvMCRDisp->begin(); iter != m_pvMCRDisp->end(); iter++ )
            {
                mac_addr    = iter->index;
                mac32_value = iter->mcr_data32;

                if( (mac_addr-mcr32_first.index) % 0x10 == 0 )
                {
                    sprintf(str, "%04lx:        ", mac_addr);
                    as_macinfo = str;
                }
                sprintf(str, "%08lx ", mac32_value);
                as_macinfo += str;

                if( (mac_addr-mcr32_first.index) % 0x10 == 0x0C  )
                {
                    strcpy( str, as_macinfo.c_str() );
                    memMACResult->Lines->Add(str);
                }
            }

            if( (mac_addr-mcr32_first.index) % 0x10 != 0x0C  )
            {
                strcpy( str, as_macinfo.c_str() );
                memMACResult->Lines->Add(str);
            }
        }
    }
}

//----------------------------------------------------------------------------
void  TfrmWiFi::FillEEResult( bool  is_title )
{
    char  str[256];

    if( is_title )
    {
        memEEResult->Lines->Clear();
        sprintf( str, " EEProm                                   EEPRom                                       " );
        memEEResult->Lines->Add(str);
        sprintf( str, " address                                  data                                         " );
        memEEResult->Lines->Add(str);
        if( rbEEWord->Checked )
            sprintf( str, "=======================================================================================" );
        else
            sprintf( str, "=====================================================================================================" );

        memEEResult->Lines->Add(str);
    }
    else
    {
        AnsiString as_eeinfo;
        unsigned int     ee_addr;
        unsigned short   ee_value;
        vector<WiFi_EEPROM_S>:: iterator iter;
        WiFi_EEPROM_S eeprom_first = *m_pvEEDisp->begin();
        if( rbEEByte->Checked )
        {
            for( iter = m_pvEEDisp->begin(); iter != m_pvEEDisp->end(); iter++ )
            //for( int i=0; i<m_sEE.count; i++ )
            {
                //WiFi_EEPROM_S eeprom;
                //eeprom = *iter;
                ee_addr  = iter->index;
                ee_value = iter->eeprom_data16;
                if( (ee_addr-eeprom_first.index) % 0x10 == 0 )
                {
                    sprintf(str, "%04lx: ", ee_addr);
                    as_eeinfo = str;
                }
                sprintf(str, "%02lx ", ee_value & 0x00FF );
                as_eeinfo += str;
                sprintf(str, "%02lx ", (ee_value & 0xFF00)>>8 );
                as_eeinfo += str;

                if( (ee_addr-eeprom_first.index) % 0x10 == 0x0F  )
                {
                    strcpy( str, as_eeinfo.c_str() );
                    memEEResult->Lines->Add(str);
                }
            }

            if( (ee_addr-eeprom_first.index) % 0x10 != 0x0F  )
            {
                strcpy( str, as_eeinfo.c_str() );
                memEEResult->Lines->Add(str);
            }
        }
        else
        {
            //for( int i=0; i<m_sEEDisp.count; i++ )
            for( iter = m_pvEEDisp->begin(); iter != m_pvEEDisp->end(); iter++ )
            {
               // WiFi_EEPROM_S eeprom;
               // eeprom = *iter;
                ee_addr  = iter->index;
                ee_value = iter->eeprom_data16;
                if( (ee_addr-eeprom_first.index) % 0x10 == 0 )
                {
                    sprintf(str, "%04lx: ", ee_addr);
                    as_eeinfo = str;
                }
                sprintf(str, "%04lx ", ee_value);
                as_eeinfo += str;

                if( (ee_addr-eeprom_first.index) % 0x10 == 0x0F  )
                {
                    strcpy( str, as_eeinfo.c_str() );
                    memEEResult->Lines->Add(str);
                }
            }

            if( (ee_addr-eeprom_first.index) % 0x10 != 0x0F  )
            {
                strcpy( str, as_eeinfo.c_str() );
                memEEResult->Lines->Add(str);
            }
        } // word
    }

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool  TfrmWiFi::CheckFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
{
    switch(pctlToolSel->ActivePageIndex)
    {
        case PAGEIDX_TXALL:
        {

        }
        break;

        case PAGEIDX_CPRX:

        break;

        case PAGEIDX_PS:
        break;


        case PAGEIDX_BB:
             if( ! CheckBBFields( access_type, op_type ) )  return false;
        break;


        case PAGEIDX_MAC:
             if( ! CheckMACFields( access_type, op_type ) )  return false;
        break;

        case PAGEIDX_EE:
             if( ! CheckEEFields( access_type, op_type ) )  return false;
        break;

        case PAGEIDX_SC:
        break;
    }

    return true;
}

//---------------------------------------------------------------------------
bool  TfrmWiFi::CheckBBFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
{
    unsigned int uidata;
    AnsiString text;

    if( ACCESS_SINGLE == access_type )
    {
        text = edtBBCRIndex->Text;        if( !IsValidDecWiFiBBRegAddr( text, uidata ) )           {  edtBBCRIndexCheck(edtBBCRIndex);            return false;   }
        m_uiBBIdx = uidata;

        if( op_type == OP_WRITE )
        {
            unsigned char ucdata;
            text = edtBBCRData->Text;
            if( btnBBCRData->Tag==0 )  // Dec
            {
                if( !IsValidDecWiFiBBRegValue( text, ucdata ) )
                {
                    edtBBCRDataCheck( edtBBCRData );
                    return false;
                }
            }
            else  // Hex
            {
                if( !IsValidHexWiFiBBRegValue( text, ucdata ) )
                {
                    edtBBCRDataCheck( edtBBCRData );
                    return false;
                }
            }
            m_ucBBValue = ucdata;
        }
    }
    else // dump
    {
        text = edtBBBeginCRIndex->Text;        if( !IsValidDecWiFiBBRegAddr( text, uidata ) )           {  edtBBBeginCRIndexCheck(edtBBBeginCRIndex);            return false;   }
        m_uiBBBeginIdx = uidata;

        text = edtBBEndCRIndex->Text;        if( !IsValidDecWiFiBBRegAddr( text, uidata ) )           {  edtBBEndCRIndexCheck(edtBBEndCRIndex);            return false;   }
        m_uiBBEndIdx = uidata;


    }

    return true;
}

//---------------------------------------------------------------------------
bool  TfrmWiFi::CheckMACFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
{
    unsigned int uidata;
    AnsiString text;

    if( ACCESS_SINGLE == access_type )
    {
        text = edtMACMCRAddress->Text;        if( !IsValidHexWiFiMacRegAddr( text, uidata ) )           {  edtMACMCRAddressCheck(edtMACMCRAddress);            return false;   }
        m_uiMacAddr = uidata;

        text = edtMACMCRData->Text;

        if( rbMAC16bits->Checked )
        {
            unsigned short usdata;
            if( btnMACMCRData->Tag==0 )  // Dec
            {
                if( !IsValidDecWiFiMacReg16Value( text, usdata ) )
                {
                    edtMACMCRDataCheck( edtMACMCRData );
                    return false;
                }
            }
            else  // Hex
            {
                if( !IsValidHexWiFiMacReg16Value( text, usdata ) )
                {
                    edtMACMCRDataCheck( edtMACMCRData );
                    return false;
                }
            }
            m_usMac16Data = usdata;
        }
        else
        {
            if( btnMACMCRData->Tag==0 )  // Dec
            {
                if( !IsValidDecWiFiMacRegValue( text, uidata ) )
                {
                    edtMACMCRDataCheck( edtMACMCRData );
                    return false;
                }
            }
            else  // Hex
            {
                if( !IsValidHexWiFiMacRegValue( text, uidata ) )
                {
                    edtMACMCRDataCheck( edtMACMCRData );
                    return false;
                }
            }
            m_uiMacData = uidata;
        }
    }
    else // dump
    {
        if( rbMAC16bits->Checked )
        {
            text = edtMACBeginMCRAddr->Text;        if( !IsValidHexWiFiMacRegAddr( text, uidata ) )           {  edtMACBeginMCRAddrCheck(edtMACBeginMCRAddr);            return false;   }
            m_uiMacBeginAddr = uidata;

            text = edtMACEndMCRAddr->Text;          if( !IsValidHexWiFiMacRegAddr( text, uidata ) )           {  edtMACBeginMCRAddrCheck(edtMACEndMCRAddr);            return false;   }
            m_uiMacEndAddr = uidata;
        }
    }

    return true;
}

//---------------------------------------------------------------------------
bool  TfrmWiFi::CheckEEFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
{
    unsigned int uidata;
    unsigned short usdata;

    AnsiString text;

    if( ACCESS_SINGLE == access_type )
    {
        text = edtEEIndex->Text;        if( !IsValidHexWiFiEERegAddr( text, uidata ) )           {  edtMACMCRAddressCheck(edtMACMCRAddress);            return false;   }
        m_uiEEPROMIdx = uidata;

        text = edtEEData->Text;
        if( 0 == btnEEData->Tag )  // Dec
        {
            if( !IsValidDecWiFiEERegValue( text, usdata ) )
            {
                edtEEDataCheck( edtEEData );
                return false;
            }
        }
        else  // Hex
        {
            if( !IsValidHexWiFiEERegValue( text, usdata ) )
            {
                edtEEDataCheck( edtEEData );
                return false;
            }
        }
        m_usEEPROMData = usdata;
    }
    else
    {
        text = edtEEBeginIndex->Text;        if( !IsValidHexWiFiEERegAddr( text, uidata ) )           {  edtBeginEEIndexCheck(edtEEBeginIndex);            return false;   }
        m_uiEEPROMBeginIdx = uidata;

        text = edtEEEndIndex->Text;        if( !IsValidHexWiFiEERegAddr( text, uidata ) )           {  edtEndEEIndexCheck(edtEEEndIndex);            return false;   }
        m_uiEEPROMEndIdx = uidata;
    }

    return true;
}

//---------------------------------------------------------------------------
bool  TfrmWiFi::CheckTXOPFields( void )
{
    return true;
}

//---------------------------------------------------------------------------
void  TfrmWiFi::EnableCPTUIComponent( void )
{
    // ALC
    m_edtTXTargetAlc->Enabled = true;
    m_cbTXTargetGain->Enabled = true;
    m_cbTXAlcTracking->Enabled = true;
    m_cbTargetAlc->Enabled = true;

    // MAC header
    edtTXFramCtrl1->Enabled = true;
    edtTXFramCtrl0->Enabled = true;

    edtTXDuration1->Enabled = true;
    edtTXDuration0->Enabled = true;

    edtTXAddress15->Enabled = true;
    edtTXAddress14->Enabled = true;
    edtTXAddress13->Enabled = true;
    edtTXAddress12->Enabled = true;
    edtTXAddress11->Enabled = true;
    edtTXAddress10->Enabled = true;

    edtTXAddress25->Enabled = true;
    edtTXAddress24->Enabled = true;
    edtTXAddress23->Enabled = true;
    edtTXAddress22->Enabled = true;
    edtTXAddress21->Enabled = true;
    edtTXAddress20->Enabled = true;

    edtTXAddress35->Enabled = true;
    edtTXAddress34->Enabled = true;
    edtTXAddress33->Enabled = true;
    edtTXAddress32->Enabled = true;
    edtTXAddress31->Enabled = true;
    edtTXAddress30->Enabled = true;

    edtTXSeqCtrl1->Enabled = true;
    edtTXSeqCtrl0->Enabled = true;

    edtTXPacketLength->Enabled = true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -