#! /bin/bash
# hydra-reload-modules -- reload the hydra kernel modules

function print_help {
    cat <<EOF
Usage: $0 [OPTION]...
Reload all the kernel modules for the hydra driver stack.
  -a  auto driver mode
  -m  manual driver mode
  -s  semi-auto driver mode
  -h  display this help and exit
EOF
    exit 0
}

mode=0

while getopts "ahms" opt; do
    case $opt in
        a) mode=0
            ;;
        h) print_help
            ;;
        m) mode=2
            ;;
        s) mode=1
            ;;
        *) print_help
            ;;
    esac
done

#pkill hciattach
#sleep 2
#modprobe -r uart_hif
modprobe -r hydra_skeleton
modprobe -r hydra_sdio
modprobe -r hydra_core
modprobe -r csr_sdio_mmc
sleep 2
modprobe csr_sdio_mmc
modprobe hydra_core mode=$mode
modprobe hydra_sdio
modprobe hydra_skeleton
#modprobe uart_hif
