Ticket #1024: brc_qtopia_quickfix.patch

File brc_qtopia_quickfix.patch, 2.3 KB (added by mwester@…, 10 years ago)

Additional code to actually issue the AT%SLEEP=2 command to GSM

  • src/libraries/qtopiaphonemodem/qmodemnetworkregistration.cpp

    old new public: 
    5757 
    5858        nTotalLosses = 0; 
    5959 
     60        nRecentBounces = 0; 
    6061        nTotalBounces = 0; 
    6162        tShortestBounceTime = 0; 
    6263        tLongestBounceTime = 0; 
    public: 
    7980    QTimer *cregTimer; 
    8081    QTime lastTime; 
    8182 
     83    int nRecentBounces; 
    8284    int nTotalLosses; 
    8385    int nTotalBounces; 
    8486    int tShortestBounceTime; 
    void QModemNetworkRegistration::cregNoti 
    242244            qLog(Modem) << "LoR -> Timer cancelled. (ms=" << t << ")"; 
    243245 
    244246            d->nTotalBounces++; 
     247            d->nRecentBounces++; 
    245248            d->tTotalBounceTime = d->tTotalBounceTime + t; 
    246249            if (t > d->tLongestBounceTime) 
    247250                d->tLongestBounceTime = t; 
    void QModemNetworkRegistration::cregNoti 
    297300            "ms=(" << d->tShortestBounceTime << "/" << 
    298301            (d->nTotalBounces ? (d->tTotalBounceTime / d->nTotalBounces) : 0) << 
    299302            "/" << d->tLongestBounceTime << ")"; 
     303 
     304        // See if we have begun bouncing; three bounces and we'll disable deep sleep. 
     305        if (d->nRecentBounces > 2) { 
     306            d->nRecentBounces = 0; 
     307            qLog(Modem) << "LoR -> Bouncing detected; limiting sleep."; 
     308            // Disable deep sleep mode. 
     309            // TODO: We really should find a good place in the code to attempt 
     310            // to re-enable deep sleep mode, but since we don't know the root 
     311            // cause at this time it is difficult to know when to attempt this. 
     312            d->service->chat("AT%SLEEP=2"); 
     313        } 
    300314    } 
    301315} 
    302316 
    void QModemNetworkRegistration::cregTime 
    308322    qLog(Modem) << "LoR -> Timer expired (registration lost)."; 
    309323    d->nTotalLosses++; 
    310324    updateRegistrationState( (QTelephony::RegistrationState)0 ); 
     325    // If we de-registered for real, we may be in weak signal area, this is a 
     326    // good reason to restart whatever progress has happened to disabling deep 
     327    // sleep mode. 
     328    // TODO: There should be other "disablers" too, but we don't yet 
     329    // know what the best heuristics for this might actually be... 
     330    d->nRecentBounces = 0; 
    311331} 
    312332 
    313333void QModemNetworkRegistration::cregQuery( bool, const QAtResult& result )