none
how to get signal strength in dbm/mw

    Question

  • HI EXPERTS


    Please help me to find the signal strength in the dbm/mw, as i am making an application for windows mobile by using c#. and i am testing it on HTC.
    please help me how can i get signal strength in dbm/wm(milliwatt), if its possible then provide me code also....

    Thanks in advance


    Mobile_Developer
    Tuesday, December 23, 2008 6:28 AM

Answers


  •  Many devices (OEM dependent) reports signal quality when calling the RIL api RIL_GetSignalQuality.
    Excerpts from my native code (C++). Bellow is some needed C# code - DllImports.


    HTH
    Rene Stein
    http://blog.renestein.net

    void CALLBACK RilImplementor::ResultCallback(DWORD dwCode,   
                                                     HRESULT hrCmdID,         
                                                     const void *lpData,   
                                                     DWORD cbData,   
                                                     DWORD dwParam)  
     
    {  
    if (hrCmdID == GetSignalQualityResult)  
            {  
                //MessageBox(NULL, L"Before Cell", L"NEW RIL", 0);  
                LPRILSIGNALQUALITY signal = (LPRILSIGNALQUALITY) lpData;  
                HandleSignal(signal);  
                GetSignalQualityResult=0;  
            }  
     
    }  
     
     
    void RilImplementor::GetSignalQuality()  
        {  
            if (!InitRil())  
            {  
                return;  
            }  
              
              
     
            GetSignalQualityResult = RIL_GetSignalQuality(RilHandle);  
          
        }  
     
        bool RilImplementor::InitRil()  
        {  
            DWORD dwParam = 0;  
            DWORD dwNotifications = RIL_NOTIFY_RADIOEQUIPMENTSTATECHANGED | RIL_NOTIFY_SIGNALQUALITY |  
                                    RIL_NOTIFY_STATUSMESSAGE | RIL_NCLASS_DEVSPECIFIC;  
     
            if (!IsRilNotificationRunning )  
            {  
                IsRilNotificationRunning = true;          
                HRESULT  result = RIL_Initialize(1,   
                                             ResultCallback,   
                                             NotifyCallback,   
                                             dwNotifications,   
                                             dwParam,   
                                             &RilHandle);  
              
                if (FAILED(result))  
                {  
                  wstring error = L"Nepodařilo se inicializovat knihovnu RIL";  
                  SendErrorToSubscribers(error);  
                  IsRilNotificationRunning = false;  
                  return false;  
                }  
            }  
     
            TryRILEnableDisableNotification(true);  
     
            return true;  
              
        }  
     



     

     [DllImport("ril.dll")]  
            private static extern IntPtr RIL_Initialize(uint dwIndex,  
                                                        RILRESULTCALLBACK pfnResult,  
                                                        RILNOTIFYCALLBACK pfnNotify,  
                                                        uint dwNotificationClasses,  
                                                        uint dwParam,  
                                                        out IntPtr lphRil);   
            [DllImport("ril.dll")]  
            private static extern IntPtr RIL_GetCellTowerInfo(IntPtr hRil);  
     
            [DllImport("ril.dll")]  
            private static extern IntPtr RIL_GetSignalQuality(IntPtr hRil);  
     
            [DllImport("ril.dll")]  
            private static extern IntPtr RIL_Deinitialize(IntPtr hRil  
     
    • Marked as answer by cool_gurl Tuesday, January 06, 2009 2:34 PM
    Tuesday, January 06, 2009 2:23 PM

All replies

  • Hi cool_gurl,

    Microsoft.WindowsMobile.Status.SystemState.PhoneSignalStrength will give you the signal strength.

    For  more information:
     http://msdn2.microsoft.com/en-us/library/microsoft.windowsmobile.status.systemstate.phonesignalstrength.aspx


    Best regards,
    Guang-Ming Bian - MSFT


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Thursday, December 25, 2008 7:31 AM
    Moderator
  • Thanks for your Reply

    By using this i can get the signal strength in the percentage,
    but  i want the signal strength in Milliwatt or DBM.
    please help to get the signal strength in dbm or mw.

    Thanks in advance.

    Mobile_Developer
    Friday, December 26, 2008 8:52 AM
  • If you have (rather expensive) measurement equipment and a lab setup then you can calibrate your phone to see what 100% really means.

    If not – try using one of these formulas (see which one makes more sense):

    dBm = 0.62 * S – 113

    dBm = -51 - 10 log (100 / S)

    It probably will be seriously off but phone is not a measurement device anyways and would be off a lot anyways.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, December 26, 2008 10:53 PM
    Moderator

  • hi Thanks for your reply

    As you have given me the formula for that i want to know that which one is better

    dBm = 0.62 * S – 113

    or

    dBm = -51 - 10 log (100 / S)


    and i also want that above formulas are given by any standard. or how much accurate they gives the values if we compare with the engineering mode.please let me know and reply soon.



    Thanks in advance

    Regards



    Mobile_Developer
    Saturday, December 27, 2008 6:50 AM
  • The values you see in engineering mode are very imprecise as phone is not calibrated, probably within +/-10 dBm.

    As to these formulas, I’ve made an assumption what percentage is calculated from the value produced by AT+CSQ command - which are probably same values you see in engineering mode.

    I’ve assumed calculation of percentage is done either by using linear scale for results  - in which case it is indeed percentage of power and 100 is twice as much power as 50, that is second formula.

    Or, it is done by using logarithmic scale - in which case it’s a percentage of dBm and 100 is twice as much dBm (and 10x as much power) as 50 – first formula.

    If my assumptions are correct then formulas themselves would be very precise as they just reverse the calculation.

    If you have access to engineering mode values then you can easily verify my assumptions or come up with your own formula by matching these two sources of measurements.

     


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Saturday, December 27, 2008 7:45 AM
    Moderator
  • hi Thanks 4 your reply

    as i am implementing your formula(dBm = 0.62 * S – 113,    dBm = -51 - 10 log (100 / S) i am getting the signals strength of GSM in the dbm but this value is differ from the value signal strength in the engineering mode of the HTC.....
    please help me how can i get the exact value of the signals which matched with the values of the engineering mode of the device.
     is there any process to capture the values of engineering mode in our application directly.

    please reply if you get somthing.

    Thanks in Advance




    Mobile_Developer
    Tuesday, December 30, 2008 3:59 PM
  • You need to adjust constantans in the formulas so it would match based on actual measurement you've taken so it would match.

    You should call phone manufacturer about accessing engineering mode data on particular phone.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, December 30, 2008 4:56 PM
    Moderator
  • Since there is no answer I suspect that there is no universal way tog get this info on all devices. There might be OEM-specific ways but you have to contact OEM for them.
    AFAIU Ilya's idea was to find out formula to convert signal strength to dBm. He might be wrong in his calculation or the formula might be different on different devices. We can try to find formula for you HTC device if you provide us some list with pairs (dBm, Signal Strength %) for a wide range of values. If we find some reasonable formula you'll have to test it on some other device to check if formula is the same on all devices or device-specific.
    Tuesday, December 30, 2008 4:57 PM

  •  Many devices (OEM dependent) reports signal quality when calling the RIL api RIL_GetSignalQuality.
    Excerpts from my native code (C++). Bellow is some needed C# code - DllImports.


    HTH
    Rene Stein
    http://blog.renestein.net

    void CALLBACK RilImplementor::ResultCallback(DWORD dwCode,   
                                                     HRESULT hrCmdID,         
                                                     const void *lpData,   
                                                     DWORD cbData,   
                                                     DWORD dwParam)  
     
    {  
    if (hrCmdID == GetSignalQualityResult)  
            {  
                //MessageBox(NULL, L"Before Cell", L"NEW RIL", 0);  
                LPRILSIGNALQUALITY signal = (LPRILSIGNALQUALITY) lpData;  
                HandleSignal(signal);  
                GetSignalQualityResult=0;  
            }  
     
    }  
     
     
    void RilImplementor::GetSignalQuality()  
        {  
            if (!InitRil())  
            {  
                return;  
            }  
              
              
     
            GetSignalQualityResult = RIL_GetSignalQuality(RilHandle);  
          
        }  
     
        bool RilImplementor::InitRil()  
        {  
            DWORD dwParam = 0;  
            DWORD dwNotifications = RIL_NOTIFY_RADIOEQUIPMENTSTATECHANGED | RIL_NOTIFY_SIGNALQUALITY |  
                                    RIL_NOTIFY_STATUSMESSAGE | RIL_NCLASS_DEVSPECIFIC;  
     
            if (!IsRilNotificationRunning )  
            {  
                IsRilNotificationRunning = true;          
                HRESULT  result = RIL_Initialize(1,   
                                             ResultCallback,   
                                             NotifyCallback,   
                                             dwNotifications,   
                                             dwParam,   
                                             &RilHandle);  
              
                if (FAILED(result))  
                {  
                  wstring error = L"Nepodařilo se inicializovat knihovnu RIL";  
                  SendErrorToSubscribers(error);  
                  IsRilNotificationRunning = false;  
                  return false;  
                }  
            }  
     
            TryRILEnableDisableNotification(true);  
     
            return true;  
              
        }  
     



     

     [DllImport("ril.dll")]  
            private static extern IntPtr RIL_Initialize(uint dwIndex,  
                                                        RILRESULTCALLBACK pfnResult,  
                                                        RILNOTIFYCALLBACK pfnNotify,  
                                                        uint dwNotificationClasses,  
                                                        uint dwParam,  
                                                        out IntPtr lphRil);   
            [DllImport("ril.dll")]  
            private static extern IntPtr RIL_GetCellTowerInfo(IntPtr hRil);  
     
            [DllImport("ril.dll")]  
            private static extern IntPtr RIL_GetSignalQuality(IntPtr hRil);  
     
            [DllImport("ril.dll")]  
            private static extern IntPtr RIL_Deinitialize(IntPtr hRil  
     
    • Marked as answer by cool_gurl Tuesday, January 06, 2009 2:34 PM
    Tuesday, January 06, 2009 2:23 PM
  • how did you add the C# code to the C++ project  (or C++ to C# project) as above ?

    Thanks

    Monday, April 19, 2010 4:30 PM