#!/bin/sh
#How does the user run this script: After SSH login, run the following command: chmod +x /root/AU915_Hopping_Script.sh #Add run permission
#Then type the command ：/root/AU915_Hopping_Script.sh
#Modify the script using the command: vim /root/AU915_Hopping_Script.sh
#The script loops the frequency specified below. If you need to change it, please modify it below.
# AU915
# 915.2 915.4 915.6 915.8 916.0 916.2 916.4 916.6
# 916.8 917.0 917.2 917.4 917.6 917.8 918.0 918.2
# 918.4 918.6 918.8 919.0 919.2 919.4 919.6 919.8
# 920.0 920.2 920.4 920.6 920.8 921.0 921.2 921.4
# 921.6 921.8 922.0 922.2 922.4 922.6 922.8 923.0
# 923.2 923.4 923.6 923.8 924.0 924.2 924.4 924.6
# 924.8 925.0 925.2 925.4 925.6 925.8 926.0 926.2
# 926.4 926.6 926.8 927.0 927.2 927.4 927.6 927.8
#Transmitting parameters can be changed
FRE_STD='915.75' #Transmitting frequency_STD
SF_STD='7' # SF_STD SF7 / SF8 / SF9 / SF10 / SF11  / SF12                    
SF='12'    # SF SF7 / SF8 / SF9 / SF10 / SF11  / SF12
BW='500'       # bw Set transmission bandwidth: 500/250/125/62.5kHz
BW_STD='250'   # Same as bw, for the bandwidth BW_STD
PWID='22'   # sx1250 Power index, 0... 22
Interval='5'    # Transmitting interval s. The time interval between each transmitting
FRE_COMMON='918.2' #Transmitting frequency_Common
SF_COMMON='12' #SF_COMMON  SF7 / SF8 / SF9 / SF10 / SF11  / SF12 
PA='1'        #PA modulation 1 / 0 is on/off respectively

AU915_FRE="915.2 915.4 915.6 915.8 916.0 916.2 916.4 916.6 916.8 917.0 917.2 917.4 917.6 917.8 918.0 918.2" #It is now frequency hopping in the AU915_2 band and AU915_1, which can be changed or added

while [ 1 ] 
do
	for FRE in `echo $AU915_FRE`
	do 
		sx1302_tx_test -d /dev/spidev1.0 -f $FRE -s $SF -b $BW -m LORA -r 1250 --pa $PA --pwid $PWID
		sleep $Interval
		echo "Trasmit at pa = $PA, pwid = $PWID , Bandwidth: $BW, Spreading Factor: $SF, $FRE"
	done
	
	sx1302_tx_test -d /dev/spidev1.0 -f $FRE_STD -s $SF_STD -b $BW_STD -m LORA -r 1250 --pa $PA --pwid $PWID	
	sleep $Interval	
	echo "Trasmit at pa = $PA, pwid = $PWID, Bandwidth: $BW_STD, Spreading Factor: $SF_STD, $FRE_STD"
	
	sx1302_tx_test -d /dev/spidev1.0 -f $FRE_COMMON -s $SF_COMMON -b $BW -m LORA -r 1250 --pa $PA --pwid $PWID	
	sleep $Interval	
	echo "Trasmit at pa = $PA, pwid = $PWID, Bandwidth: $BW, Spreading Factor: $SF_COMMON, $FRE_COMMON"
	
done