[wfb] autdetect wifi card

pull/600/head
cronyx 2023-01-15 23:41:13 +03:00
parent 34503baca8
commit 50e9bbff31
4 changed files with 53 additions and 29 deletions

View File

@ -8,25 +8,62 @@
keydir="/etc" keydir="/etc"
chip=$(ipcinfo -c) chip=$(ipcinfo -c)
load_rtl() { driver=""
modprobe cfg80211
modprobe 88XXau rtw_tx_pwr_idx_override=${driver_txpower_override} detect_wifi_card() {
sleep 3 echo "Detecting wifi card vendor..."
devices=$(lsusb | cut -d ' ' -f6 | sort | uniq)
for card in ${devices}
do
case "${card}" in
"0bda:8812" | "0bda:881a")
driver="realtek"
modprobe 88XXau rtw_tx_pwr_idx_override=${driver_txpower_override}
;;
"0cf3:9271")
driver="atheros"
modprobe mac80211
modprobe ath9k_htc
;;
"148f:3070")
driver="ralink"
modprobe rt2800usb
modprobe rt2x00usb
;;
esac
done
if [ -z "${driver}" ]; then
echo "No usb wifi card detected. Check wifi stick connection, usb power or possible bad soldering."
exit
else
echo "Detected:" ${driver}
fi
echo "Awaiting interface ${wlan} in system..."
local n=0
while ! $(ifconfig -a | grep -q ${wlan})
do
if [ ${n} -ge 5 ]; then
echo "No interface ${wlan}. Check wifi stick connection, usb power or possible bad soldering."
exit
fi
sleep 0.5
n=$(expr ${n} + 1)
done
} }
load_ath() { load_modules() {
modprobe cfg80211 modprobe cfg80211
modprobe mac80211 detect_wifi_card
modprobe ath9k_htc
sleep 3
} }
load_interface() { load_interface() {
if [ ${driver} = "realtek" ]; then
if [ ${driver} = "rtl" ]; then
ifconfig ${wlan} up ifconfig ${wlan} up
iwconfig ${wlan} mode monitor iwconfig ${wlan} mode monitor
elif [ ${driver} = "ath" ]; then elif [ ${driver} = "atheros" ] | [ ${driver} = "ralink" ]; then
iwconfig ${wlan} mode monitor iwconfig ${wlan} mode monitor
ifconfig ${wlan} up ifconfig ${wlan} up
fi fi
@ -49,31 +86,19 @@ case "$1" in
if [ ${daemon} -eq 1 ]; then if [ ${daemon} -eq 1 ]; then
echo "Loading modules for selected driver..." echo "Loading modules and wifi card driver..."
if [ ${driver} = "rtl" ]; then load_modules
if ! lsmod | grep "88XXau"; then
load_rtl
fi
elif [ ${driver} = "ath" ]; then
if ! lsmod | grep "ath9k_htc"; then
load_ath
fi
fi
echo "Done."
echo "Preparing interface wlan..." echo "Preparing interface wlan..."
load_interface load_interface
echo "Done."
if ! cat ${keydir}/drone.key > /dev/null 2>&1; then if ! cat ${keydir}/drone.key > /dev/null 2>&1; then
echo "Generating drone & ground station keys..." echo "Generating drone & ground station keys..."
cd ${keydir} ; wfb_keygen cd ${keydir} ; wfb_keygen
echo "Done."
else else
echo "Drone key exist... Done." echo "Drone key exist..."
fi fi
echo "Starting Wifibroadcast service..." echo "Starting Wifibroadcast service..."

View File

@ -1,6 +1,6 @@
serial=/dev/ttyAMA0 serial=/dev/ttyAMA0
baud=115200
wlan=wlan0 wlan=wlan0
baud=115200
bandwidth=20 bandwidth=20
stbc=1 stbc=1
ldpc=1 ldpc=1

View File

@ -37,7 +37,7 @@ all_other() {
${cli} -s .video0.bitrate 5120 ${cli} -s .video0.bitrate 5120
${cli} -s .video0.codec h264 ${cli} -s .video0.codec h264
${cli} -s .video0.rcMode cbr ${cli} -s .video0.rcMode cbr
${cli} -s .video0.gopSize 0 ${cli} -s .video0.gopSize 0.2
${cli} -s .hls.enabled false ${cli} -s .hls.enabled false
${cli} -s .netip.enabled false ${cli} -s .netip.enabled false
${cli} -s .jpeg.enabled false ${cli} -s .jpeg.enabled false

View File

@ -1,5 +1,4 @@
daemon=1 daemon=1
driver=rtl
wlan=wlan0 wlan=wlan0
region=BO region=BO
channel=14 channel=14