diff --git a/recipes-connectivity/gnss-config/files/gnss-config.sh b/recipes-connectivity/gnss-config/files/gnss-config.sh index 78376d0..383541a 100755 --- a/recipes-connectivity/gnss-config/files/gnss-config.sh +++ b/recipes-connectivity/gnss-config/files/gnss-config.sh @@ -13,6 +13,7 @@ # 4 saving to flash failed # 5 baud rate specified in $CONFIG_FILE not supported by $DEVICE_NAME # 6 set tty baud rate was not successful +# 7 failed to restart gpsd # static variables DEVICE_NAME="NEO-M8L" @@ -164,6 +165,15 @@ write_config_out(){ echo "Supported Augmentation Services: $augment_service" >> $CONFIG_OUT_FILE } +restart_gpsd(){ + if [ "$RESTART_GPSD" -eq "1" ]; then + systemctl start gpsd + if [ "$?" -ne "0" ]; then + exit 7 # failed to restart gpsd + fi + fi +} + # start of main # check if script was launched by systemd @@ -239,9 +249,7 @@ if br_receiver="$(poll_baud_rate_receiver "$DESIRED_BAUD_RATE")";then exit 6 fi write_config_out - if [ "$RESTART_GPSD" -eq "1" ]; then - systemctl start gpsd - fi + restart_gpsd # script can exit exit 0 # baud rate of receiver is already matching $DESIRED_BAUD_RATE else @@ -330,10 +338,6 @@ else fi write_config_out - -# TODO: verify or error handling -if [ "$RESTART_GPSD" -eq "1" ]; then - systemctl start gpsd -fi +restart_gpsd exit 0 # successfully changed baud rate to $DESIRED_BAUD_RATE specified in $CONFIG_FILE