I'm using one of the Raspberry Pi as an access control system.

It reads an rfid tag (using an RFID read) and then it sends the information to an iPad, trough an USB Wifi dongle (I'm using a TP-LINK TL-WN727N).

The system must be up and running 12 hours per day, so the connection shall be always available. The operating system is Wheezy.

raspbian_os

During the first day of work I experienced a disconnection from the Wifi, without any real problem on the network.

Running dmesg on the raspberry I could see the following interesting lines:


 

[  404.401597] wlan0: authenticate with 8c:77:12:8b:60:70 (try 1)

[  404.407902] wlan0: authenticated

[  404.511104] wlan0: associate with 8c:77:12:8b:60:70 (try 1)

[  404.513951] wlan0: RX AssocResp from 8c:77:12:8b:60:70 (capab=0x431 status=0 aid=1)

[  404.514124] wlan0: associated

[  521.357247] smsc95xx 1-1.1:1.0: eth0: link down

[ 2995.280139] usb 1-1.2: USB disconnect, device number 4

[ 2995.322857] wlan0: deauthenticating from 8c:77:12:8b:60:70 by local choice (reason=3)

[ 2995.343127] cfg80211: Calling CRDA for country: US


After unplugging and the plugging back the wifi dongle the connection was up again….

 

[ 2997.307626] usb 1-1.2: new high-speed USB device number 6 using dwc_otg

[ 2997.425575] usb 1-1.2: New USB device found, idVendor=148f, idProduct=5370

[ 2997.425605] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 2997.425621] usb 1-1.2: Product: 802.11 n WLAN

[ 2997.425635] usb 1-1.2: Manufacturer: TPlink

[ 2997.425659] usb 1-1.2: SerialNumber: 1.0

[ 2997.517792] usb 1-1.2: reset high-speed USB device number 6 using dwc_otg

[ 2997.653985] ieee80211 phy1: Selected rate control algorithm 'minstrel_ht'

[ 2997.662838] Registered led device: rt2800usb-phy1::radio

[ 2997.662990] Registered led device: rt2800usb-phy1::assoc

[ 2997.663143] Registered led device: rt2800usb-phy1::quality

[ 3000.806715] wlan0: authenticate with 8c:77:12:8b:60:70 (try 1)

[ 3000.998312] wlan0: authenticate with 8c:77:12:8b:60:70 (try 2)

[ 3001.198385] wlan0: authenticate with 8c:77:12:8b:60:70 (try 3)

[ 3001.199974] wlan0: authenticated

[ 3001.294750] wlan0: associate with 8c:77:12:8b:60:70 (try 1)

[ 3001.297146] wlan0: RX ReassocResp from 8c:77:12:8b:60:70 (capab=0x431 status=0 aid=1)

[ 3001.297170] wlan0: associated


So the problem could be present on the wifi dongle. After some investigation I came to the solution of my problem. The power-saving policies of the wifi adapter is just a little "aggressive".
So I disabled the power-saving engine issuing the following command:

$ sudo iwconfig wlan0 power off

Since this command I did not have any other deauthenticating troubles. (Several days of connection up and running).

Gg1