×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605

    Reading battery Strength, Network Strength etc ..

    Hi I am looking for the API's for the following functions .....

    1. Reading the Battery Meter
    2. Reading the network Strength
    3. GPRS status ( on or not)
    4. Missed Calls
    5. Message Indicator
    6. Blutooth Status ( on or not)

    Can anyone provide me the the API and also if someone has some example code for the same , it will be really helpful to me .

  2. #2
    Registered User
    Join Date
    May 2003
    Location
    London (United Kingdom)
    Posts
    15
    Hi I have got somthing which hopefully useful for you. It uses RSystemAgent to get the state of network indicators. you need to pass Network Indicator bars UID to RSystemAgent::GetStates() methods I wonder if some can help me I need UID for battery indicator panel.

    const TInt KUidNetworkIndicatorValue = 0x100052D3;
    const TUid KUidNetworkIndicator ={KUidNetworindicatorValue};

    RSystemAgent agent;
    agent.Connect();
    TInt batteryStrength = agent.GetState(KUidNetworkBars);
    agent.Close();

    TInt batteryStrengthInPercent = (TInt)(batteryStrength * 100/7);

    Does any body have list UIDs for UI Components? thanks in advance

  3. #3
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    Hi tan_aslam@yahoo.co.uk

    Have u tested the Code for Battery Level in percentage ?Can u give me the header file for

    const TInt KUidNetworkIndicatorValue = 0x100052D3;
    const TUid KUidNetworkIndicator ={KUidNetworindicatorValue};


    What do u mean by UID for battery indicator panel ?
    If u r talking about the UIDs for the State Variables which are available thru RSystemAgent Class then it is simple .

    Just go to SACLS.h and u will find all the constants defined here.

  4. #4
    Registered User
    Join Date
    May 2003
    Location
    London (United Kingdom)
    Posts
    15
    Hi Amit,

    My method is based on UI indicator (bars) of battery and network status and percentile status is multiple of 7. If there is one bar on battey status indicator panel, percentage bettery strength will 14% if indicator/panel has 2 bars the percentage strength will be 28% 7 bars indicates 100% battery strength. I belive these UID are missing from SACLS.h header. I was just experimenting with the code I posed you earlier and realize that 0x100052D3 is UID value for battery strength panel. Just replace this value in above code and you will get the percentage result in multiple of 7

    UID defined for battery strength in SACLS.H doesnt work. any idea why ?

  5. #5
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    They do work , I have got the following values .

    ESABatteryAlmostEmpty
    ESABatteryLow
    ESABatteryFull

    Thye r working on P900 .MAN what is puzzling me is how to get the other state variables like Network Strength as System AGent does not gives it

  6. #6
    Registered User
    Join Date
    May 2003
    Location
    London (United Kingdom)
    Posts
    15
    Use my method it definitly works. testing is little bit difficult you have find a place where network has low signals again its based on UI network panel so It will give you network signal strength in percentage of multiple of 7

  7. #7
    Registered User
    Join Date
    May 2003
    Location
    London (United Kingdom)
    Posts
    15
    Or use "mobinfo" api extension just released by Symbian. you can find further information in Mobinfo\Mobinfo Usage.htm

    void CMobileContext::GetSignalStrengthLevel(TMobileSignalStrength& aLevel, TRequestStatus& aStatus)

  8. #8
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    Thnx friend. I will try your method.
    But have u tested it on any UIQ device also or only on Series 60 .
    Also when i write ur statement agent.GetState(tUID) , it does not recognise it .

    Also there is one more thing, isnt there a way where in whenever network signal changes , my app shud be notified rather than i checking every time.

    If u wish to share more info and knowledge on Symbian , go to my profile and add me in your IM.
    Last edited by amitaggarwal; 2004-11-24 at 11:08.

  9. #9
    Registered User
    Join Date
    May 2003
    Location
    London (United Kingdom)
    Posts
    15
    Sorry ....forgot to mention that my method only works with S60 phones for UIQ you have to use "MobInfo" API.

    for make an observer you need to create listenere application in most case an exe. which get booted at boot time and listen for network status. use CTimer or CHeartbeat classes those already AOs and used for time base services.

    Symbian Recogniser (.MDL) provides you hook point to execute your application at boot time.

    http://www.newlc.com/article.php3?id...che=Recognizer

  10. #10
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    Do i need to do something like

    const TInt KUidNetworkIndicatorValue = 0x100052D3;
    const TUid KUidNetworkIndicator ={KUidNetworindicatorValue};

    in my SACLS.h.

    and then DO something like

    RSystemAgent agent;
    agent.Connect();
    TInt batteryStrength = agent.GetState(KUidNetworkIndicator);
    agent.Close();

    TInt batteryStrengthInPercent = (TInt)(batteryStrength * 100/7);
    in the function where i m fetching the % .
    Last edited by amitaggarwal; 2004-11-24 at 11:27.

  11. #11
    Registered User
    Join Date
    May 2003
    Location
    London (United Kingdom)
    Posts
    15
    No........Just declare the consts at top of you helper method and return batteryStrength at the end of method.

    TBool GetBatteryStrengthPercent(TInt *apDest)
    {
    TBool r = EFalse;

    //#ifdef _BUILDS60_
    const TInt KUidPowerBarsValue = 0x100052D3; //Network bars UID (0x100052D4);
    const TUid KUidPowerBars ={KUidPowerBarsValue};

    RSystemAgent sysAgent;
    sysAgent.Connect();
    TInt batteryStrength = sysAgent.GetState(KUidPowerBars);
    sysAgent.Close();

    *apDest = (TInt)(batteryStrength * 100/7); /* 0 = 0%, 7 = 100%, rest in steps */
    r - ETrue;
    //#endif

    return r;

    }

    when called, method will return % strength in apDest e.g.

    TInt aArg;
    if(GetBatteryStrengthPercent(&aArg))
    {
    //DO YOUR STUFF
    }
    else
    {
    //Handle Error
    }

  12. #12
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    Hi Friend
    I m getting a value -271 on this operation .
    ------------------------------------------------------------------------------
    This is what i m doing (On a UIQ Phone)
    void CBatteryReader::GetBatteryState()
    {
    /* I was just experimenting with the code I posed you
    earlier and realize that 0x100052D3 is UID value
    for battery strength panel. Just replace this value
    in above code and you will get the percentage result in multiple of 7*/

    const TInt KUidPowerBarsValue = 0x100052D3; //Network bars UID (0x100052D4);
    const TUid KUidPowerBars ={KUidPowerBarsValue};
    iBatteryObserver->OnBatteryChange(iSystemAgent.GetState(KUidPowerBars));
    }
    ------------------------------------------------------------------------------

    and here is the method On BatteryChange
    ------------------------------------------------------------------------------
    void CSkreenPlayAppUi::OnBatteryChange(TInt aBatteryStatus)
    {
    if(aBatteryStatus)
    {
    aBatteryStatus = (TInt)(aBatteryStatus * 100/7); /* 0 = 0%, 7 = 100%, rest in steps */
    TBuf<20> aBatStrength;
    aBatStrength.Num(aBatteryStatus);
    iEikonEnv->AlertWin(aBatStrength);
    }
    if(aBatteryStatus==KErrNotFound)
    {
    _LIT(KBatteryNotFound,"\nBattery Variable Not found");
    iEikonEnv->AlertWin(KBatteryNotFound);
    }
    }
    ------------------------------------------------------------------------------

    Can u tell me why it is happening ?

  13. #13
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    on what phone did u test it ?

  14. #14
    Regular Contributor
    Join Date
    Oct 2003
    Location
    Spain
    Posts
    329
    Hi there,

    I don't need retrieve battery level, just if the phone is charging.
    Anyway to do that?

    Bye

  15. #15
    Registered User
    Join Date
    May 2003
    Location
    London (United Kingdom)
    Posts
    15
    This is how you get the charging status

    include: "saclient.h"
    link against: " sysagt.lib"

    RSystemAgent systemAgent;
    User::LeaveIfError(systemAgent.Connect());
    TInt strength = systemAgent.GetState(KUidChargerStatus);
    if (strength == TSAChargerStatus::ESAChargerConnected )
    {
    // DO SOMTHING
    }

    using the enum you can get the status bit

    enum TSAChargerStatus
    {
    ESAChargerConnected,
    ESAChargerDisconnected,
    ESAChargerNotCharging
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×