losing wifi when screen turned off

Discussion in 'iOS Programming' started by dok24, Jul 6, 2011.

  1. dok24 macrumors newbie

    Joined:
    Jun 30, 2011
    #1
    Hey all,

    I have a quick question regarding my iphone application I'm building. It is sending and receiving data over the wifi, which is working great. When I have it plugged into the computer, and have it running through Xcode, it never loses wifi. When I have the phone on it's own, and I turn off the screen, within about 20 seconds it loses wifi connection. It gets connection back when I go through the lock screen, but ideally I would rather have it maintain a constant connection to avoid complications server side.

    Is there any way to prevent this behavior?? I have searched through the apple documentation and have come up empty handed.

    Thanks!
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    And I think u will remain empty handed.. Something the OS Does for you, you can mostly (wel, allmost never) change.
    It's to secure battery life if i'm not mistaking. So I think u need to rebuild parts of your app ;o
    Unless someone has a better idea.
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    You should build your app so that it handles the possibility of no network connection. Apple may reject it, if it doesn't. I know first-hand. We had an app rejected because it didn't gracefully handle when there was no internet connection.

    Maybe tell us more about why you think it needs a constant connection (i.e. what is your app doing over this connection) and we might be able to suggest some alternatives.
     
  4. dok24 thread starter macrumors newbie

    Joined:
    Jun 30, 2011
    #4
    I am not going to upload it to the store - this is purely for research purposes.

    What we are doing with the iphone is using it for both localization(through pinpointing the WiFi signal strength), and back and fourth communications with the server that have to happen in real time.

    I guess I could just turn off autolock and keep the screen on, but that seems to drastically decrease battery life. Does anybody know if blacking the screen out manually will lessen the impact?
     
  5. Big-TDI-Guy macrumors 68030

    Big-TDI-Guy

    Joined:
    Jan 11, 2007
    #5
    I've had some large downloads to my IP4 - I sleep the phone, and after the download is complete (10-15 minutes later) the battery life fell by 10% or so. (and the phone was warm - even though the display had not been running at all)

    I'm sure the packet handling, data processing also bit a lot more - but even so, I was surprised how much it consumed, especially with excellent signal strength on the radio...
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Have you considered your options in regards to iOS 4's background services?
     
  7. dok24 thread starter macrumors newbie

    Joined:
    Jun 30, 2011
    #7
    As far as I know you would need 3g to take advantage of those services? Unfortunately, 3g is not available to us.
     
  8. chown33, Jul 7, 2011
    Last edited: Jul 7, 2011

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #8
    Autolock (and the switch on top of the phone) do more than just turn off the screen. They put the thing to sleep, which suspends all processing, pretty much the same as if you put your Mac to sleep. The switch on the top of the iPhone is even called Sleep/Wake in the User Manual.

    The reason it doesn't sleep when it's connected to USB is because it doesn't need to. It's charging, which doesn't deplete the battery.

    If you mean simply drawing all black pixels to the screen, then I doubt that will improve the battery life. The screen-related battery killer is the backlight, not the LCD itself. So figure out a way to dim the backlight all the way down, and that might improve battery life.

    The wireless chip is a pretty big power hog, too, so I frankly wouldn't expect much of a gain even if you manage to dim the backlight to nothing.
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    Hmm, what options for devices are available to you?
     
  10. dok24 thread starter macrumors newbie

    Joined:
    Jun 30, 2011
    #10
    At the moment the iphones and computers in charge of running the servers.
     
  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    I meant want models of iPhones are available to you (original iPhone, iPhone 3G, iPhone 3GS, etc.) Unless of course you meant 3G, the telecommunication service, as opposed to say, EDGE.
     
  12. dok24 thread starter macrumors newbie

    Joined:
    Jun 30, 2011
    #12
    Oh! My mistake. It is a 3Gs.
     

Share This Page