master
Bryan 2021-01-02 00:33:35 -06:00
parent ea82fd9605
commit 242d13928c
2 changed files with 11 additions and 59 deletions

View File

@ -1,41 +1,14 @@
# blonk.cfg -- version: "28-Feb-2020" # blonk.cfg
# Configuration for /usr/local/bin/blonk.sh which is normally # Configuration for /usr/local/bin/blonk.sh which is normally
# installed as a service started at bootup. # installed as a service started at bootup.
# See https://github.com/ondsinet/blonk # See https://github.com/ondsinet/blonk
BLINK_ENABLED=1 # Blink CHIP's status LED.
BLINK_GPIO=XIO_P7 # Blink a GPIO.
BLINK_FREQUENCY=1 # Period of the blinking in second
SENSOR_READ_FREQUENCY=5 # Period for polling sensors in seconds SENSOR_READ_FREQUENCY=5 # Period for polling sensors in seconds
IP_READ_FREQUENCY=60 # Period for polling sensors in seconds
RESET_ENABLED=1 # Monitor reset button for short press.
#RESET_GPIO=XIO_P4 # Shutdown when this GPIO is triggered.
#RESET_GPIO_VALUE=0 # The value read from MON_GPIO that initiates shutdown.
#BATTERY_SHUT_VALUE=7 # When battery percentage is below this, shut down. #BATTERY_SHUT_VALUE=7 # When battery percentage is below this, shut down.
BATTERY_WARN_VALUE=20 # When battery percentage is below this, assert warning. BATTERY_WARN_VALUE=20 # When battery percentage is below this, assert warning.
#BATTERY_WARN_GPIO=XIO_P5 # When battery warning, activate this GPIO.
#BATTERY_WARN_GPIO_VALUE=0 # Warning value to write to WARN_BATTERY_GPIO.
#TEMPERATURE_SHUT_VALUE=800 # Shutdown temperature in tenths of a degree C. #TEMPERATURE_SHUT_VALUE=800 # Shutdown temperature in tenths of a degree C.
TEMPERATURE_WARN_VALUE=650 # Warning temperature in tenths of a degree C. TEMPERATURE_WARN_VALUE=650 # Warning temperature in tenths of a degree C.
#TEMPERATURE_WARN_GPIO=XIO_P6 # When temperature warning, activate this GPIO. #TEMPERATURE_WARN_GPIO=XIO_P6 # When temperature warning, activate this GPIO.
#TEMPERATURE_WARN_GPIO_VALUE=0 # Warning value to write to WARN_TEMPERATURE_GPIO. #TEMPERATURE_WARN_GPIO_VALUE=0 # Warning value to write to WARN_TEMPERATURE_GPIO.
#IP_CHANGE_CHECK=1 # Monitor the external ip of the chip. Might be slow on some connections
#IP_CHANGE_WARN= # Warn if ip changes.
#IP_COMPARE_DOMAIN=domain.net # Use a domain directing to your ip. Will use machine's recorded last ip if commented.
#IP_UPDATE_DDNS=1 # Wether to run the routine below or not. Use it to update the ip of your dns or run another program.
update_ddns(){
https://dynamicdns/update?host=[host]&domain=[domain_name]&password=[ddns_password]&ip=[your_ip]
echo "updated ddns"
}

View File

@ -12,6 +12,11 @@
# https://github.com/ondsinet/chip/tree/master/Programs/blonk # https://github.com/ondsinet/chip/tree/master/Programs/blonk
# #
if [ "$1" == "-d"]; then
DAEMON="1"
else
DAEMON="0"
fi
BATTERY_VALUE= #% BATTERY_VALUE= #%
BATTERY_STATE= #connected/CHARGING/DISCHARGING/charged BATTERY_STATE= #connected/CHARGING/DISCHARGING/charged
@ -29,14 +34,8 @@ CHG_CURR=
TEMPERATURE_VALUE= TEMPERATURE_VALUE=
TEMPERATURE_PRINT= TEMPERATURE_PRINT=
UPTIME_VALUE= UPTIME_VALUE=
BLINK_GPIO_STATE=0
BLINK_FREQUENCY=1 # Period of the blinking in second
BLINK_FREQUENCY_HALF=
SENSOR_READ_FREQUENCY=5 SENSOR_READ_FREQUENCY=5
FREQ_DIV=2 FREQ_DIV=2
@ -60,8 +59,7 @@ read_config(){
if [ -f /usr/local/etc/blonk.cfg ]; then : if [ -f /usr/local/etc/blonk.cfg ]; then :
source /usr/local/etc/blonk.cfg source /usr/local/etc/blonk.cfg
else : else :
MON_RESET=1 blonk_error "can't find /usr/local/etc/blonk.cfg"
BLINK_STATUS=1
fi fi
} }
@ -70,7 +68,7 @@ read_config(){
check_i2c_installed(){ check_i2c_installed(){
# Need to communicate with AXP209 via I2C commands # Need to communicate with AXP209 via I2C commands
if [ ! -x /usr/sbin/i2cget -o ! -x /usr/sbin/i2cset ]; then : if [ ! -x /usr/sbin/i2cget -o ! -x /usr/sbin/i2cset ]; then :
blonk_error "need i2c-tools for MON_RESET" "Use: sudo apt-get install i2c-tools" blonk_error "need i2c-tools" "Use: sudo apt-get install i2c-tools"
fi fi
} }
@ -309,12 +307,8 @@ compile_warnings(){
# echo $TEMPERATURE_VALUE # echo $TEMPERATURE_VALUE
# echo $WARN_TEMP # echo $WARN_TEMP
#no internet
} }
handle_warnings(){ handle_warnings(){
echo echo
} }
@ -329,9 +323,6 @@ echo
compile_report compile_report
compile_warnings compile_warnings
BLINK_FREQUENCY_HALF=$((${BLINK_FREQUENCY}00/2))
BLINK_FREQUENCY_HALF=$(echo "${BLINK_FREQUENCY_HALF:0:-2}.${BLINK_FREQUENCY_HALF: -2}")
######################################### #########################################
#if [ $PRINT ]; then #if [ $PRINT ]; then
@ -346,25 +337,13 @@ echo
LAST_TIME_SENSORS=`date +%s` LAST_TIME_SENSORS=`date +%s`
#LAST_TIME_IP=`date +%s` #LAST_TIME_IP=`date +%s`
# if [ $SERVICE ]; then if [ $DAEMON == "1" ]; then
while true; do : while true; do :
TIME=`date +%s`
#echo $TIME
#echo $LAST_TIME_SENSORS
if (( $TIME > $LAST_TIME_SENSORS )); then #read and handle sensors
#echo "reading sensors"
read_AXP read_AXP
read_stats read_stats
#read_gpio
compile_warnings compile_warnings
#handle_warnings #handle_warnings
LAST_TIME_SENSORS=$((TIME+SENSOR_READ_FREQUENCY)) sleep "$SENSOR_READ_FREQUENCY"
#echo $LAST_TIME_SENSORS
sleep 0.1
fi fi
done done
# fi fi