Archives

All posts for the month March, 2015

I am working on a new build of D-Star hotspot which will be way better than the DVAP, or DHAP.  The new product will feature compact headless industrial design with super easy management and use.  Here are some highlights on the unit which is currently in development:

(but first, a teaser picture of the product – the finished prototype – click for larger images)

IMG_0078  IMG_0080  IMG_0081  Screenshot from 2015-04-13 16:36:18

  • Universal 9-35 VDC power input with internal regulation – power easily with Solar, DC, or portable source like Li-Po packs
  • UHF operation in the 70cm Ham Band
  • Easily shows operational status by panel mounted LEDs
  • Panel mounted NEUTRIK connectors for Ethernet & USB Tether connections for supreme field durability
  • Panel mounted coaxial DC input connection
  • fan-less design – no moving parts to wear out
  • Built in a compact die-cast aluminum enclosure that can stand the rigors of mobile field use
  • Easy web based configuration management via laptop on shortcable to ethernet port
  • Simple “Bat Shit Stupid” operation by 2 buttons, Reboot & Shutdown.
  • Seamlessly switch between USB tethered internet (iPhone & Android) and wired internet
  • You don’t need to be a Linux guru or programmer to operate this unit
  • Low power footprint (approx. 6 watts)
  • Panel mounted SMA antenna connector accepts any standard UHF SMA whip antenna, or for increased range, use an external antenna with an SMA adaptor
  • Approx. range is 1 mile line of sight but on average you can get .5 miles or more with just a whip antenna
  • Keeps you connected to the world-wide D-Star network while on the move or where D-Star repeaters are not available.
  • LED panel mount indicators for: ircddbgateway, dstarrepeater, internet reachability, & MicroSD card I/O for “at a glance” operational status.

Stay Tuned – more details and pictures to come soon!

I wrote this script to only start the d-star daemons on a DV hotspot when there is a viable internet connection.  The reason for this is to simplify “in-the-field” use and only allow the system to start when there is an available internet connection.  Without this script, it was often a problem to ensure that the daemons always started AFTER the internet became available.  This script makes it easy to use a portable DV hotspot on D-Star in a simple “plug & play” way. Copy and paste this script to any text editor of your choice.

PLEASE NOTE: This code was modeled on an ODROID C1 (same price as the raspberry pi) but should be adaptable for the raspberry pi as well.

 

Global Functions File: (copy to /scripts/functions & set executable)

 

#!/bin/bash
#################################################################
#                                                               #
# Global functions for DV Hotspot automated management          #
# release v1    3-13-2015       John Rogers     K1WIZ           #
#                                                               #
#                                                               #
#################################################################

################# Check for internet reachability               
netcheck() {
N1=`ping -c 1 8.8.8.8 | grep '1 received' | wc -l`
	echo $N1 > /tmp/.netflag
}

################# start the gateway IF it is not already running
gwstart() {
        if [ "$G1" -eq 0 ]; then
                if [ "$N1" -eq 1 ]; then
                        /usr/local/bin/dstarrepeaterd -confdir:/etc &
                        	sleep 10
                        /usr/local/bin/timeserverd -confdir:/etc &
                        	sleep 10
                        /usr/local/bin/ircddbgatewayd -confdir:/etc &
                else
                        echo "$(date) NOT STARTED - NO INTERNET CONNECTION" >> /tmp/hs-log.log
                fi
        else
                echo "GATEWAY IS UP - RETURN TO LOOP" > /dev/null 2>&1
        fi
}

################# Check status of daemons
daemon() {
G1=`ps -ef | grep [i]rcddbgate | wc -l`
	echo $G1 > /tmp/.gwflag
R1=`ps -ef | grep [d]star | wc -l`
	echo $R1 > /tmp/.rptrflag
}

################# Misc Checks
safeshut() {
pwroff=`/usr/local/bin/gpio read 27`
	echo $pwroff > /tmp/.shutflag
        if [ "$pwroff" -eq 0 ]; then
                /sbin/poweroff
        else
                return 1
        fi
}
reset() {
restart=`/usr/local/bin/gpio read 26`
	echo $restart > /tmp/.restartflag
        if [ "$restart" -eq 0 ]; then
                /sbin/reboot
        else
                return 1
        fi
}

################# Initialize GPIO Channels
gpioinit() {
	/usr/local/bin/gpio mode 21 out
		/usr/local/bin/gpio write 21 0
	/usr/local/bin/gpio mode 22 out
		/usr/local/bin/gpio write 22 0
	/usr/local/bin/gpio mode 23 out
		/usr/local/bin/gpio write 23 0
	/usr/local/bin/gpio mode 24 out
		/usr/local/bin/gpio write 24 0
}

################# Drive GPIO & LEDS
leddriver() {
	gwflag=`cat /tmp/.gwflag`
		/usr/local/bin/gpio write 21 $gwflag
	rptrflag=`cat /tmp/.rptrflag`
		/usr/local/bin/gpio write 22 $rptrflag
	net=`cat /tmp/.netflag`
		/usr/local/bin/gpio write 23 $net
	shut=`cat /tmp/.shutflag`
		/usr/local/bin/gpio write 24 $shut
}

 

Management Loop Script calling functions above: (copy to /scripts/dvstart.sh & make executable)

(call this script from /etc/rc.local and background it with a “&”)

#!/bin/bash

# THIS SCRIPT WAITS FOR VIABLE INTERNET CONNECTION BEFORE STARTING HOTSPOT
# Written by: John Rogers, K1WIZ
# Permission is granted for free use as long as this notice is intact.

. /scripts/functions


for (( ; ; ))
        do
                safeshut
                reset
                netcheck
                daemon
                leddriver
                gwstart
                sleep 10
        done

So I recently decided to try a Banana Pro ARM microcomputer to evaluate for my next project.  I was disappointed that the unit output had overscan on my TV.  Fortunately there is a simple fix for this annoying problem which the folks at LeMaker do not mention in their forums.

 

1) Press Source on your remote
2) Move down to your HDMI source and press Tools
3) Select Edit name
4) Scroll down to PC and select that one
Your screen goes blank for a second – and mission accomplished.

banana-pro-interfaces

I wrote a short python script to read a GPIO pin and watch for a state change (from a momentary contact switch) in order to execute a safe, clean, & orderly shutdown of the raspberry pi computer, since no on-board provision exists out of the box. It is necessary to ensure a clean shutdown in order to avoid the chance that you might corrupt your SD card:


import os
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4,GPIO.IN)

prev_input = 0
while True:
input = GPIO.input(4)
if ((not prev_input) and input):
os.system("/sbin/poweroff")
prev_input = input
#slight pause to debounce
time.sleep(0.05)

This script is used as an LED driver to show the operational status of the ircddbgateway & dstarrepeater daemons. If the daemons are up and running, an LED will be lit from the assigned GPIO to show simple operational status. Permission is granted to freely use and distribute for all purposes.


#!/bin/bash

gateway() {
G1=`ps -ef | grep [i]rcddbgate | wc -l`
echo $G1 > /sys/class/gpio/gpio17/value
}

repeater() {
R1=`ps -ef | grep [d]star | wc -l`
echo $R1 > /sys/class/gpio/gpio25/value
}

for (( ; ; ))
do
gateway && repeater
sleep 10
done

For added fun, you might also want to light an LED to indicate viable connectivity to the internet so that you know if you can connect to a reflector or not:


#!/bin/bash

netcheck() {
N1=`ping -c 1 8.8.8.8 | grep '1 received' | wc -l`
echo $N1 > /sys/class/gpio/gpio27/value
}

for (( ; ; ))
do
netcheck
sleep 20
done

If you’ve built a D-Star hotspot and sometimes find the DV modem (GMSK modem) occasionally loses connection on the USB bus, I wrote a helpful script to check the presence of the modem and if not found on the expected device node, instructs the hotspot host to reboot and bring the system back on the air.  This is published free and clear and anyone may use it and distribute it without permission so long as the preamble remains intact:

 


#!/bin/bash
#########################################################################
# UPDATED: 10-24-2014 #
# #
# This script checks the status of the DV modem and if found #
# to be missing, will reboot your hotspot and log the event. #
# #
# This is useful for applications where the DV modem loses #
# connection and functionality is halted in an unattended setting. #
# #
# OPERATION: #
# This assumes your DV modem is normally detected as /dev/ttyACM0 #
# When a DV modem disappears, the running dstarrepeater software locks #
# /dev/ttyACM0 and when the DV modem tries to reconnect, Linux #
# enumerates the device as the next available device node, #
# /dev/ttyACM1. Therefore, this script looks for the next enumerated #
# ttyACM device and if detected, reboots your Hotspot or repeater. #
# #
# This script was written by John Rogers, K1WIZ and permission #
# is granted for use and distribution so long as this notice #
# is unaltered and not removed. #
# #
# TO USE: #
# Simply place this script in /root/ #
# Rename the script file extension from .txt to .sh and make it #
# executable as follows: #
# #
# mv hotspot-dv-modem-check-script.txt hotspot-dv-modem-check-script.sh #
# chmod +x hotspot-dv-modem-check-script.sh #
# #
# call it every 5 minutes by setting a line in your /etc/crontab file #
# as follows: #
# #
# */5 * * * * /root/hotspot-dv-modem-check-script.sh #
# #
# Save the file and restart cron service (refer to your Linux #
# distro for instructions on restarting cron or simply reboot #
# your hotspot. #
#########################################################################

check=`ls /dev/ttyACM1 | wc -l`

timestamp() {
date
}

present() {
P1=`timestamp`
P2=`echo ". . . DV MODEM IS PRESENT"`
echo $P1 $P2 > /dev/null 2>&1
}

notpresent() {
P1=`timestamp`
P2=`echo ". . . DV MODEM IS NOT PRESENT, REBOOTING HOTSPOT"`
echo $P1 $P2;
/sbin/reboot;
}

if [ "$check" = 1 ]; then
notpresent >> /var/log/dvstat.log
exit 0
else
present
exit 0
fi
return 0