Setting up MultiTech LoRaWAN gateway on Ubuntu

As the convener for the Adelaide community of The Things Network, I am frequently setting up Multitech Conduit Gateways. Depending on your PC or notebook hardware you might have some problems with the Exar USB-UART driver on Linux.

Here are the steps to getting this unit setup from an Ubuntu (should work for any other Linux distro) machine.

lsusb

Should show something like this:

Bus 002 Device 006: ID 04e2:1410 Exar Corp. XR21V1410 USB-UART IC

Download the driver for the Exar site: https://www.exar.com/design-tools/software-drivers

unzip xr_usb_serial_common_lnx-3.6-and-newer-pak.zip
cd xr_usb_serial_common_lnx-3.6-and-newer-pak
make
sudo insmod ./xr_usb_serial_common.ko

Ensure driver is loaded at startup

sudo vim /etc/modules
#Add the following
xr_usb_serial_common

ls /dev/tty*

should now show another USB port ttyXRUSB0

For the rest you just need to follow the excellent instructions by Jac Kersing who maintains the Multitech TTN installer and documentation here:
https://www.thethingsnetwork.org/docs/gateways/multitech/mlinux.html

Get EUI of your gateway

mts-io-sysfs show lora/eui 2> /dev/null | sed 's/://g'

Finding Notebook Hardware for Ubuntu – 2015 Edition

Unfortunately it is still much harder than necessary to find notebook hardware to use with Ubuntu (or other Linux variants). This blog is full of past experiences (some of them quite time-consuming) on finding notebook hardware that will work without too much fiddling. This short note is to document my recent research on that front to help others who want to do the same (as there doesn’t seem to be a lot of good current info around).

There are some vendors that do ship with Ubuntu, however they are generally all based in the US and their pre-sales communications are pretty horrible (I am talking to you ZaReason – still waiting for reply email as well as tweet). Then there is Purism Librem, but unfortunately they have still not shipped their 15″ version and I need a tool now. The jury on this is still out and I don’t really have the time to be a guinea-pig. Maybe next time (as I like what they are doing) …

There was one option from one of the top-tier manufacturers (Dell XPS 13 – Developer Edition) which ships with Ubuntu. But as – per usual – NOT in Australia. However there was a lot of conflicting evidence I found that the Windows Version had some issues with current Ubuntu versions (Dell ship 14.04 LTS – which makes sense from their point).

I ended up buying the Lenovo X1 (3rd Generation) and after the install of Ubuntu I have to say this is the first notebook I just had to plug in the Ubuntu USB (Version 15.04 Vivid Vervet 64bit) and install and everything just worked. No fighting with UEFI firmware, no function keys not working and no issues with sound or other drivers. To be fair – there is one thing I noted (which is irrelevant to me) – the fingerprint reader does need some additional driver installed & configured.

It was also the first notebook I didn’t even bother booting up and create a repair disk first. There is no way I would ever restore something to Windows 8 – however if you are not sure that you will stick with Ubuntu – that’s probably not advisable.

Thank you Lenovo for developing a very decent piece of hardware that just works with Ubuntu ! However I would like to note that the recent Superfish debacle http://support.lenovo.com/us/en/product_security/superfish really left a sour taste and nearly made me take Lenovo off the evaluation list.

Some conversations that might be useful:

https://www.reddit.com/r/Ubuntu/comments/37ukqe/dell_xps_13_vs_lenovo_thinkpad_x1_carbon_3rd_gen/
https://www.reddit.com/r/Ubuntu/comments/37t4re/ubuntu_notebook_hardware_available_in_from/

Ubuntu 14.04 Amazon EC2 Cloud Desktop using LXQT

Using Amazon EC2’s free usage tier to host your own cloud desktop is a very economical way to to have a desktop at hand anytime you can not be near one. Since I quite often use Chromebooks these days when on the road this is a particular handy way should I need a full desktop for certain tasks.

Since Ubuntu 14.05 is my default desktop on my normal hardware I obviously want to have my cloud desktop running the same underlying OS. However I don’t think running Unity as the desktop interface would be appropriate via a low-bandwidth remote desktop connection. For this reason I chose LXQT. If you need total stability you probably should go for the more mature LXDE instead, but I have already tried LXQT on an old EEE PC and was very impressed by the speed and low resource usage.

NOTE (Edit: 2014-11-03): Please find an updated (and easier) version of this blog here. I was experiencing some issues with LXQT (which is understandable as it clearly states that it is not a release version)

Provision Ubuntu 14.04 LTS EC2 Instance

EC2 Choose Image

Instance details

  1. Connect to AWS Console and go to EC2 Service
  2. Choose OS Image: “Ubuntu Server 14.04 LTS” (see screenshot)
  3. Choose a “Micro Instance” if you want to use Amazon’s Free Usage Tier
  4. Choose Instance details – the defaults will generally be fine
  5. Add Storage (I generally add a separate Volume for /home but default should do)
  6. Tag instance (just give it a name to that makes sense to you in the console if you have more than one)
  7. Configure Security Group – I only set SSH which is the default (see Firewall config below). Add any other ports needed
  8. Review & Launch the instance. You need to choose your RSA Access Keys in this step. If you haven’t got any and download. DO NOT LOOSE the private keys or you will not be able to connect.

Setup Desktop & VNC

Connect via SSH to the EC2 Instance you just created (using the IP in the control panel and your RSA Key)

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:lubuntu-dev/lubuntu-daily
sudo add-apt-repository ppa:gilir/q-project
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lxqt-metapackage lxqt-panel vnc4server

Start VNC server under the desired user account. This will create the desired configuration files. Kill after the startup process is finished.

vncserver
#after successful start
vncserver -kill :1

Edit xstartup files

vim ~/.vnc/xstartup
Paste the following:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
exec openbox-session &
startlxqt &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &

Create startup script

sudo vim /etc/init.d/vncserver
Paste the following:
#!/bin/bash
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: VNC Server Startup Script
# Description: Author: Leo Gaggl (www.gaggl.com)
### END INIT INFO
unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
DISP="${display%%:*}"
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
fi
done
}
stop() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Shutting down VNCServer: "
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
export USER="${display##*:}"
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
fi
done
echo -e "\n"
echo "VNCServer Stopped"
}
case "$1" in
start)
start $@
;;
stop)
stop $@
;;
restart|reload)
stop $@
sleep 3
start $@
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop $@
sleep 3
start $@
fi
;;
status)
status Xvnc
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

Mark the startup script as executable and create the config file for the startup script.
sudo chmod +x /etc/init.d/vncserver
sudo mkdir /etc/vncserver
sudo vim /etc/vncserver/vncservers.conf

Paste the following:
VNCSERVERS="1:USERNAME"
VNCSERVERARGS[1]="-geometry 1024x768"

update-rc.d vncserver defaults 99

Start the VNC Server

sudo /etc/init.d/vncserver start

Firewall configuration

By default VNC will use port 9501 (and subsequent ports for each session). Since VNC password authentication is generally very weak I personally do not expose this port through the firewall. I use SSH port forwarding to tunnel the VNC port through SSH (encrypted) which means only the SSH port is open and can be properly secured.

ssh -L 5901:localhost:5901 -i /path/to/your/aws/keyfile.pem YOUR.EC2.IP.ADDRESS

You should then be able to access VNC via localhost:

VNC Viewer

Hopefully you should see the LXQT Desktop:

Ubuntu LXQT

 

If you want to access this from a Chromebook this blog might help.

LXQt – extending the life of my trusty old EEE PC (even further)

My old Asus EEE PC 900 is the oldest piece of hardware I own. With an old Intel Atom processor and 1GB of RAM it’s never was the fastest kid on the block (in fact I never considered the Windows XP version of the same unit usable as it was very sluggish). However after owning it for nearly 7 years I am very surprised I can still use it. Granted I only use it occasionally when I am at home, but thanks to LXDE it was still usable. I recently learned that LXDE is merging with the Razor-Qt project (great idea!) to create the combined LXQT – an ultra-low resource window manager.

Warning: LXQt is still considered a work in progress. So probably not a good idea on your prime work machine.

I started with a clean re-install of LUBUNTU LTS 14.04 – to add LXQt you need to add the lubuntu-daily PPA.

sudo add-apt-repository ppa:lubuntu-dev/lubuntu-daily
sudo add-apt-repository ppa:gilir/q-project
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lxqt-metapackage

Log out and log in back to LXQt desktop environment. Voilà !

LXQT Screenshot
LXQT Screenshot

After using it a little while it really is a joy to use and extremely responsive even on such a resource constrained old unit.

Great work !

Getting Foscam IP Cameras to work from Linux (Ubuntu)

As with most hardware manufacturers of hardware Foscam utility software is Windows or Mac only. The actual unit tested with the below is a FI9805E Outdoor POE camera.

Foscam Outdoor Cam

Installation

The installation is relatively painless as the unit is set up to get the IP assignment via DHCP (check your routers DHCP assignment list).

https://IP.ADDRESS.OF.CAM

should get you to the web-admin interface. The default user is ‘admin’ with no (empty) password.

Taking snapshots

http://IP.ADDRESS.OF.CAM:PORT/cgi-bin/CGIProxy.fcgi?cmd=snapPicture&usr=username&pwd=password

I had some issues with the color of the images in daylight (which for an outdoor camera is not really a good thing. A Firmware update (V2.14.1.5) improved this (you can disable the IR LEDs during daylight hours). Thanks for FOSCAM UK support via Twitter I found the download URL as the main site seems to have been down for a while.

Firmware URL: http://foscamuk.co.uk/downloads/

Streaming in H.264 video

The easiest way to get the stream appears to be the RTSP connection (using VLC or any network video player). MXPlayer on Android works very well too.

rtsp://username:password@IP.ADDRESS.OF.CAM:PORT/videoMain
rtsp://username:password@IP.ADDRESS.OF.CAM:PORT/videoSub
rtsp://username:password@IP.ADDRESS.OF.CAM:PORT/audio

Streaming in MPEG mode

The be able to use the MPEG streaming the stream format needs to be set first.

http://IP.ADDRESS.OF.CAM:PORT/cgi-bin/CGIProxy.fcgi?&usr=username&pwd=password&cmd=setSubStreamFormat&format=1
http://IP.ADDRESS.OF.CAM:PORT/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=username&pwd=password

Resetting back to H264:

http://IP.ADDRESS.OF.CAM:PORT/cgi-bin/CGIProxy.fcgi?&usr=username&pwd=password&cmd=setSubStreamFormat&format=0

Next steps will be to make this work from a headless device with an Amazon S3 storage backend. This Github project https://github.com/phil-lavin/Foscam-FI8908W-Recorder is looking promising.

Watch this space.

Making VIM the default text editor on Ubuntu

In my never ending quest to find the ideal text editor here is another installment. Since I have been using VIM as my default command line editor for years I thought I give it a try for basic GUI editing as well.

VIM Logo

Install and set desktop app & icon

sudo apt-get install vim vim-gnome
sudo wget --output-document=/usr/share/applications/gvim.desktop https://raw.github.com/leogaggl/misc-scripts/master/gvim.desktop
sudo wget --output-document=/usr/share/icons/hicolor/scalable/apps/gvim.svg http://gfxmonk.net/images/vim-logo/vim-logo.svg
sudo update-desktop-database

Set MIME defaults

vim ~/.local/share/applications/mimeapps.list
#add or edit the following mime type and add others as needed
text/plain=gvim.desktop;

Ideal OS for EEE PC – REVISITED

As a follow-up on a very old post I thought it’s worth providing an update. Despite it’s age (& only costing $350 at the time) my little Asus EEE PC 900 it is still a useful device. It has turned out as one of the better IT investments in my lifetime. However it’s not (and was never) the fastest kid on the block and recent OS upgrades have become increasingly resource hungry.

With the recent Ubuntu 12.04 LTS upgrade I was in the process of upgrading a few other notebooks and noticed that the release schedule for some of the Ubuntu variants (Kubuntu, Xubuntu & Lubuntu) has been brought in line with the main OS branch. So while waiting for the installs on the other machines to finish I thought about updating the EEEPC as well. I tried Xubuntu at first, but did not like the interface (and the default apps pre-installed) and there were hardly any performance gains.

But installing Lubuntu was a different story. I am very impressed by the LXDE desktop environment and the UI performance. The responsiveness of the UI is remarkably better than other desktop managers on a small netbook. And you still get the underlying strengths of the Ubuntu (Debian) based package management in it’s latest revision. That means most applications come packaged and there’s PPA’s for the rest.

Looks Lubuntu’s the new favourite. Hat tip to the Lubuntu maintainers and LXDE developers – excellent work in producing a no-frills but very functional, decent looking & usable desktop environment for devices that are getting a bit older … !

 

Darktable – Photo Management under Ubuntu

Whilst I am by no means a photographer I do end up taking quite a few photos (these days pretty much exclusively on my phone) and the management of these photos can be a pain. So far I have never found an program worth the pain over plain old file management.

But having stumbled across Darktable (http://darktable.org/) I think I might have found a worthwile package.

Screenshot

Install on Ubuntu:

sudo add-apt-repository ppa:pmjdebruijn/darktable-release
sudo apt-get update
sudo apt-get install darktable

Getting a handle on Ubuntu mobile power management

To get an idea on the current power usage and some suggestions on how to improve power-management ‘powertop‘ is a must-have.

sudo apt-get install powertop

Powertop Screenshot

For some more detailed suggestions this is a good start: https://help.ubuntu.com/community/PowerManagement/ReducedPower

Installing Ubuntu: Extending the HP Touchpad

As one of those who grabbed a HP Touchpad at the recent firesale (after announcing the killing of the product line) I did it as in full knowledge that this device in it’s current form is of limited use and (highly) unlikely to have lots of additional applications created for it.

After casually using it for a few nights of use I am personally not surprised that HP decided to ditch this product. Compared to the current Tablet leaders the Touchpad is miles behind both Android and iOS and HP would have had to spend  serious money to even get close to the current functionality of the competition. And you can take a bet that both of these will not remain static. I was actually hoping that WebOS can be a serious competitor to the current duopoly, but after using this thing I have to say that it is not even close.

However I still think the AUD149 I spent for the 32GB model are actually well spent. Since WebOS has always been a very open platform built on a Linux base I knew it would not be a major effort to run other Open Source OS’s on this device. There is already a whole bunch of people working on a full Android port (see TouchDroid and XDA Devs).

But since I already have an Android Tab (Samsung Galaxy Tab 7”) I am more interested in other alternatives at this stage. As a current Ubuntu user I started looking around and after comparing some of the existing efforts found that the guys at Preware (WebOS Internals) have already done an excellent job in getting Ubuntu to run on top of WebOS, rather than replacing WebOS entirely. Which at the current stage of this seems to most reasonable choice.

ubuntu on touchpad

The installation was a very smooth process from an existing Ubuntu machine (Windows users might find it a little more challenging).

I have documented the process in case it’s useful for others. This assumes a WIFI only 32 GB Touchpad as sold in Australia. Detailed instructions for all devices (such as other WebOS phones) are avaialble on the WebOS Internals Wiki. Hat-tip to these guys for the excellent work.

Install Preware

  1. Set Device into Developer Mode: just type “webos20090606” into the ‘Just Type’ box on the home screen (once you have installed Preware you can install a patch to permanently un-hide the Developer Mode icon).
  2. Check that you have Java JRE installed
  3. Download latest version of Preware WebOS Quickinstall
  4. Connect the Touchpad to your computer with the USB cable, and select “Just Charge” (do not select USB Drive)
  5. Run WebOS Quick Install JAR. WebOS Quick Install will download and install the Novacom Driver for you if not yet installed.
  6. Click the globe icon (third button on the right)
  7. Search for Preware (in the Applications tab) and install

Apart from Preware itself I also installed OpenSSH and a few other useful packages from the WebOS Internals Homebrew Apps

Install MetaDoctor

Again the instructions here are for the Wifi Touchpad 32GB – check http://www.webos-internals.org/wiki/Application:MetaDoctor for details on other variants. The current version of MetaDoctor can be found here.

Pre-requisites: check if git is installed (apt-get install git)

git clone git://git.webos-internals.org/tools/meta-doctor.git
cd meta-doctor
mkdir downloads
cd downloads
wget http://palm.cdnetworks.net/rom/touchpad/p302r0d08012011/wifip302rod/webosdoctorp302hstnhwifi.jar
mv webosdoctorp302hstnhwifi.jar webosdoctorp302hstnhwifi-3.0.2.jar
cd ..
vim MAKEFILE
---------------------------------------
Uncomment:
ENABLE_DEVELOPER_MODE = 1
AUTO_INSTALL_PREWARE  = 1
ENABLE_TESTING_FEEDS  = 1
VAR_PARTITION_SIZE    = 8GB
SWAP_PARTITION_SIZE   = 512MB
EXT3FS_PARTITION_SIZE = 8GB

Changes:
DEVICE = touchpad
CARRIER = wifi
---------------------------------------
make all

The compile process takes a few minutes – COFFEETIME !!!

Edit: If you have a 16GB Touchpad make sure you reduce “VAR_PARTITION_SIZE” and “EXT3FS_PARTITION_SIZE” to fit with the smaller Flash Memory size (thanks to @Dan & @bob for comments)

cd build/touchpad-p302hstnh-wifi-3.0.2/
java -jar webosdoctorp302hstnhwifi-3.0.2.jar

For those who just want to run the MetaDoctor install without compiling it as described below I have made the JAR file available for download. As always with these things – use at your own risk. EDIT: Removed JAR due to licensing issue. You will HAVE to compile yourself.

Create Ubuntu partition

After the reboot when finishing the MetaDoctor install just run novaterm with the USB cable connected and mount the ext3fs partition

mount -o remount,rw /
mkdir -p /media/ext3fs
echo "/dev/mapper/store-ext3fs /media/ext3fs ext3   noatime,data=writeback   0   0" >> /etc/fstab
mount -a

Install Ubuntu

On the Touchpad run the Preware App and install the following

  • Xecutah
  • XServer
  • Ubuntu 11.04 Chroot

Start Xecutah and run (in the order listed)

  1. XServer
  2. Xterm
  3. Ubuntu Chroot

You will have a Ubuntu commandline prompt and can use apt-get from here on to install any ubuntu app (provided there is an ARM port for it).

apt-get install lxde
startlxde

TIPS: if your keyboard covers some of the X Window keep the keyboard icon on the soft-keys pressed and choose the XS size.

Enjoy !