mirror of https://github.com/OpenIPC/firmware.git
				
				
				
			
		
			
				
	
	
		
			94 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			94 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
| #!/bin/sh
 | |
| #
 | |
| # Start wifibroadcast
 | |
| #
 | |
| 
 | |
| . /etc/wfb.conf
 | |
| 
 | |
| keydir="/etc"
 | |
| 
 | |
| load_rtl() {
 | |
|   modprobe cfg80211
 | |
|   modprobe 88XXau rtw_tx_pwr_idx_override=${driver_txpower_override}
 | |
| }
 | |
| 
 | |
| load_ath() {
 | |
|   modprobe cfg80211
 | |
|   modprobe mac80211
 | |
|   modprobe ath9k_htc
 | |
|   sleep 3 # need to load firmware
 | |
| }
 | |
| 
 | |
| load_interface() {
 | |
| 
 | |
|   if [ ${driver} = "rtl" ]; then
 | |
| 	  ifconfig ${wlan} up
 | |
| 	  iwconfig ${wlan} mode monitor
 | |
|   elif [ ${driver} = "ath" ]; then
 | |
| 	  iwconfig ${wlan} mode monitor
 | |
| 	  ifconfig ${wlan} up
 | |
|   fi
 | |
| 
 | |
|   iw reg set ${region}
 | |
|   iwconfig ${wlan} channel ${channel}
 | |
|   iw dev ${wlan} set txpower fixed $((${txpower} * 100))
 | |
| }
 | |
| 
 | |
| start_wfb() {
 | |
|   wfb_tx -p ${radio_port} -u ${udp_port} -K ${keydir}/drone.key -B ${bandwidth} -M ${mcs_index} -S ${stbc} -L ${ldpc} -G ${guard_interval} -k ${fec_k} -n ${fec_n} -T ${fec_timeout} ${wlan} &
 | |
| }
 | |
| 
 | |
| case "$1" in
 | |
|   start)
 | |
|     if [ ${daemon} -eq 1 ]; then
 | |
| 
 | |
| 	  echo "Loading modules for selected driver..."
 | |
| 
 | |
| 	  if [ ${driver} = "rtl"  ]; then
 | |
| 		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..."
 | |
| 	  
 | |
| 	  load_interface
 | |
| 	  
 | |
| 	  echo "Done."
 | |
| 
 | |
| 	  if ! cat ${keydir}/drone.key > /dev/null 2>&1; then
 | |
| 		echo "Generating drone & ground station keys..."
 | |
| 		cd ${keydir} ; wfb_keygen
 | |
| 		echo "Done."
 | |
| 	  else
 | |
| 		echo "Drone key exist... Done."
 | |
| 	  fi
 | |
| 
 | |
| 	  echo "Starting Wifibroadcast service..."
 | |
| 	  
 | |
| 	  start_wfb
 | |
| 
 | |
| 	  echo "Done."
 | |
| 
 | |
| 	  if [ ${telemetry} = "true" ]; then
 | |
| 		  sh /usr/bin/telemetry start
 | |
| 	  fi
 | |
| 
 | |
| 	else
 | |
|       echo "Wifibroadcast service disabled in wfb.conf..."
 | |
| 	fi
 | |
|     ;;
 | |
|   stop)
 | |
|     echo "Stopping wifibroadcast service..."
 | |
|     kill -9 $(pidof wfb_tx)
 | |
|     ;;
 | |
|     *)
 | |
|     echo "Usage: $0 {start|stop}"
 | |
|     exit 1
 | |
| esac
 |