Powersave mode

I’m wondering how to correctly use powersave mode.

I have a code like this:

`local output = OutputPort(“Send test”, “string”);

imp.configure(“Send test”, [], [output]);
imp.setpowersave(true);

function send_test(){
imp.wakeup(600.0, send_test);
output.set(“Test”);
}

send_test();`

Is this correct?

Because i have really strange log:

Monday, November 19, 2012 06:12:54: Device configured to be "Send test"
Monday, November 19, 2012 06:31:04: Power state: online=>offline
Monday, November 19, 2012 06:31:21: Power state: offline=>online
Monday, November 19, 2012 06:40:31: Power state: online=>offline
Monday, November 19, 2012 06:40:53: Power state: offline=>online
Monday, November 19, 2012 06:50:03: Power state: online=>offline
Monday, November 19, 2012 06:50:17: Power state: offline=>online
Monday, November 19, 2012 06:59:27: Power state: online=>offline
Monday, November 19, 2012 06:59:43: Power state: offline=>online
Monday, November 19, 2012 07:08:53: Power state: online=>offline
Monday, November 19, 2012 07:25:12: Power state: offline=>online
Monday, November 19, 2012 07:34:22: Power state: online=>offline
Monday, November 19, 2012 07:35:02: Power state: offline=>online
Monday, November 19, 2012 08:02:15: Power state: online=>offline
Monday, November 19, 2012 08:13:10: Power state: offline=>online
Monday, November 19, 2012 08:22:20: Power state: online=>offline
Monday, November 19, 2012 08:23:02: Power state: offline=>online
Monday, November 19, 2012 08:32:12: Power state: online=>offline
Monday, November 19, 2012 08:43:25: Power state: offline=>online
Monday, November 19, 2012 08:52:35: Power state: online=>offline
Monday, November 19, 2012 09:25:00: Power state: offline=>online

And the output HTTP request to my server does not always have a gap in the 10 minutes.

Hmm, that’s strange. If you comment the powersave line, does it behave as expected?

The device being marked offline at ~9 minutes could well be a server ping that isn’t being answered; that would mean that the imp didn’t get the packet via the wifi base station, which in theory means the wifi base station is not respecting the powersave mode command (where it should queue packets for the node in powersave, and tell us about them in the beacon).

Which wifi AP?

Do I understand correctly that the server periodically pings imp?
The point is that my imp is behind NAT, so I have to do port forwarding.
Please tell me what port number should I forward to the imp?

I’m using d-link dir-825 with OpenWRT firmware.
If the power saving mode and uapsd (Unscheduled Automatic Power Save Delivery) is the same things than the default is off.

It’s not a real ICMP ping, it’s more like a keepalive sent over the existing (initiated by imp) TLS TCP connection. You don’t need to forward any ports.

Peter

No this isn’t uapsd, it’s just standard 802.11 powersave (polling).

I’ve no idea what level of configuration openwrt provides (and 5 minutes of googling tells me nothing apart from “it’s really complex and depends on the chipset and linux drivers you have”, but all other routers I’ve come across support it by default.

I removed the imp.setpowersave(true) line and it seems nothing has changed.
Imp with 750mah LiPo battery lives approximately 3 days in both cases.
It seems that the powersave mode does not work in my case. I’ll try to use a server.sleepfor instead of a imp.setpowersave.

By the way, the first days everything is fine, but at the last start those strange log.

Monday, November 19, 2012 08:32:12: Power state: online=>offline Monday, November 19, 2012 08:43:25: Power state: offline=>online Monday, November 19, 2012 08:52:35: Power state: online=>offline Monday, November 19, 2012 09:25:00: Power state: offline=>online
Could this be due to that the battery starts to die?

Is there any other network traffic that might be causing the wifi to stay awake? (eg: any other network scanners, etc?).

If you’re getting 3 days without powersave from 750mAh, that’s strange. That’s more like a powersave current draw (~10mA, 72 hours = 720mAh).

server.sleepfor will last much, much, much longer for a sampling application.