# functions to check HW state

USB_MODEM="1bc7:1003"

. /usr/local/etc/telem/hw/usb_interfaces

. /usr/local/bin/telem/motd/usb_ethernet
. /usr/local/bin/telem/motd/gps_status
. /usr/local/bin/telem/motd/rtc_clock
. /usr/local/bin/telem/motd/io_board
. /usr/local/bin/telem/motd/eth0

SerialPortsOk(){
    lsusb | grep 0403:6011 > /dev/null
    if [ $? = 0 ]; then
        echo "OK"
    else
        echo "Not detected"
    fi
}

ModemOk(){
    # update USB_MODEM variable
    [ -f /var/local/telem/usb-modem-vidpid ] && source /var/local/telem/usb-modem-vidpid
    lsusb | grep -q "$USB_MODEM" || { echo "Not detected"; return 1; }
    # [ -f /var/local/telem/modem_tty ] && [ -d "$(cat /var/local/telem/modem_tty)" ] || { echo "Modem tty not ready"; return 1; } 
    # [ -f /var/local/telem/modem_tty_cmd ] && [ -d "$(cat /var/local/telem/modem_tty_cmd)" ] || { echo "Modem tty cmd not ready"; return 1; } 
    echo "OK"
    return 0
}
