destreza
2015-06-15, 07:37
I have made a script that fixed it for me and maybe others. For some reason crda needs to be woken up first before country is actually set (which is odd) even if it outputs an error.
this fixes error -22 for me and can possibly fix other issues people may be having.
I assume in the script your device is wlan0 and your target tx power is 30, as for the country it is US
So say you have your country set first and then start crda, it wont listen and outputs error as well as for setting tx power from iwconfig but I found out that starting it without a country set then after error setting country and then starting it again only with no error.
only then would it read from iw reg set
apt-get update
apt-get install python-m2crypto libgcrypt11 libgcrypt11-dev libnl-dev rfkill
echo " !!WARNING!!"
echo "MAKE SURE YOU HAVE COMPILED AND INSTALLED LATEST crda-x.xx.tar.xz AND wireless-regdb-xxxx.xx.xx.tar.xz"
echo "needs python-m2crypto, libgcrypt11, libgcrypt11-dev, libnl-dev and rfkill"
echo "This can be found here https://www.kernel.org/pub/software/network/"
echo "Be sure to use these instructions: http://pastebin.com/pY3i5f8h"
echo "Hit ^C to stop now if you wish. Also, it is prefered to do this on a fresh boot/reboot"
echo "-----------------------------------------------------------------------------------------------"
sleep 2
echo "To change this script to work for a specfic device and/or country do something like this: e.g."
sleep 1
echo "# sed -i ‘s/wlan0/wlan1/’ path/to/this/script"
echo "# sed -i ‘s/US/BO/’ path/to/this/script"
echo "Starting in 10 seconds"
sleep 11
echo "Stopping Possible Conflicting Services"
service NetworkManager stop &> /dev/null
service wicd stop &> /dev/null
service networking stop &> /dev/null
systemctl stop NetworkManager wicd networking &> /dev/null
sleep 2
rfkill unblock wlan &> /dev/null
echo "" > /etc/default/crda &> /dev/null
echo "Starting crda"
crda &> /dev/null
sleep 2
export COUNTRY=00
crda
iw reg set US
iw reg get
echo "Taking down wlan0"
ifconfig wlan0 down
sleep 3
echo "Setting Region to United States"
iw reg set US
sleep 3
echo "Setting TxPower to 30"
iwconfig wlan0 txpower 30
sleep 2
echo "Starting wlan0"
ifconfig wlan0 up
echo "Putting wlan0 interface up"
echo "------------------"
echo " Max tx Power Set "
echo "------------------"
sleep 3
echo "Turning Power Management off..."
ifconfig wlan0 down
sleep 1
iwconfig wlan0 power off
sleep 1
ifconfig wlan0 up
sleep 1
echo "-------------------"
echo " Power Managment "
echo " is now OFF "
echo "-------------------"
sleep 3
echo "==================================="
echo "Here are your all your new settings"
echo "==================================="
iw reg get
echo
echo "==================================="
iwconfig wlan0
echo "==================================="
echo "Restoring Stopped Services"
service NetworkManager start &> /dev/null
service wicd start &> /dev/null
service networking start &> /dev/null
systemctl start NetworkManager wicd networking &> /dev/null
sleep 2
echo "** If all is well, there should have been no errors outputed **"
sleep 2
this fixes error -22 for me and can possibly fix other issues people may be having.
I assume in the script your device is wlan0 and your target tx power is 30, as for the country it is US
So say you have your country set first and then start crda, it wont listen and outputs error as well as for setting tx power from iwconfig but I found out that starting it without a country set then after error setting country and then starting it again only with no error.
only then would it read from iw reg set
apt-get update
apt-get install python-m2crypto libgcrypt11 libgcrypt11-dev libnl-dev rfkill
echo " !!WARNING!!"
echo "MAKE SURE YOU HAVE COMPILED AND INSTALLED LATEST crda-x.xx.tar.xz AND wireless-regdb-xxxx.xx.xx.tar.xz"
echo "needs python-m2crypto, libgcrypt11, libgcrypt11-dev, libnl-dev and rfkill"
echo "This can be found here https://www.kernel.org/pub/software/network/"
echo "Be sure to use these instructions: http://pastebin.com/pY3i5f8h"
echo "Hit ^C to stop now if you wish. Also, it is prefered to do this on a fresh boot/reboot"
echo "-----------------------------------------------------------------------------------------------"
sleep 2
echo "To change this script to work for a specfic device and/or country do something like this: e.g."
sleep 1
echo "# sed -i ‘s/wlan0/wlan1/’ path/to/this/script"
echo "# sed -i ‘s/US/BO/’ path/to/this/script"
echo "Starting in 10 seconds"
sleep 11
echo "Stopping Possible Conflicting Services"
service NetworkManager stop &> /dev/null
service wicd stop &> /dev/null
service networking stop &> /dev/null
systemctl stop NetworkManager wicd networking &> /dev/null
sleep 2
rfkill unblock wlan &> /dev/null
echo "" > /etc/default/crda &> /dev/null
echo "Starting crda"
crda &> /dev/null
sleep 2
export COUNTRY=00
crda
iw reg set US
iw reg get
echo "Taking down wlan0"
ifconfig wlan0 down
sleep 3
echo "Setting Region to United States"
iw reg set US
sleep 3
echo "Setting TxPower to 30"
iwconfig wlan0 txpower 30
sleep 2
echo "Starting wlan0"
ifconfig wlan0 up
echo "Putting wlan0 interface up"
echo "------------------"
echo " Max tx Power Set "
echo "------------------"
sleep 3
echo "Turning Power Management off..."
ifconfig wlan0 down
sleep 1
iwconfig wlan0 power off
sleep 1
ifconfig wlan0 up
sleep 1
echo "-------------------"
echo " Power Managment "
echo " is now OFF "
echo "-------------------"
sleep 3
echo "==================================="
echo "Here are your all your new settings"
echo "==================================="
iw reg get
echo
echo "==================================="
iwconfig wlan0
echo "==================================="
echo "Restoring Stopped Services"
service NetworkManager start &> /dev/null
service wicd start &> /dev/null
service networking start &> /dev/null
systemctl start NetworkManager wicd networking &> /dev/null
sleep 2
echo "** If all is well, there should have been no errors outputed **"
sleep 2