ARD Mediathek offline viewing on Ubuntu

Since I am a bit of a sucker for German “Krimis” as well as some their excellent documentaries I like to watch ARD Mediathek IPTV. However there are several problems with this when you live at the opposite side of the world. ARD has a block for any films that are 15+ years outside of 20.00h-6.00h GMT+1. Which makes it pretty much impossible to watch at a reasonable time in Australia. I also like to watch these things on the plane which requires download of the media files.

Install JSON Parser

sudo apt-get install jq

Download script

wget https://github.com/leogaggl/media/raw/master/download_mediathek.sh
chmod +x download_mediathek.sh

Usage

./download_mediathek.sh -f save_as_filename.mp4 -q 3 MEDIATHEK-URL

The -f and -q parameters are optional.
-f filename.mp4 (or full path + filename to save in different directory). Defaults to original filename
-q quality setting from 0 to 3 (where 0 is lowest and 3 highest quality). Defaults to highest quality

Please leave a comment if you find any issues or log an issue on GitHub.

NOTE (2014-07-06): If you are only interested in the Tatort series I suggest you look at this script by Felix Knecht (see comment below)

Upgrading Nokia X to CyanogenMod 11 (via Ubuntu)

The Nokia X seems to be a nice piece of hardware for just around $125 AUD. Nothing spectacular in terms of computing power, but much better build quality than your average cheap Chinese Android clone. I have always been a fan of Nokia hardware until they decided to commit suicide by firstly adding CEO Stephen Elop and ditching all of their software for Windows Mobile.

The problem with the device out of the box is that is has a horribly butchered version of Android. And by horribly I mean way worse than the usual bloat and crapware that poor Samsung, HTC or Sony users are normally subjected to. Hopefully this is only Nokia’s first step to a more open platform, but I wouldn’t hold my breath on that one.

Before committing to buy this device I made sure that I could flash it to CyanogenMod as soon as it arrives. Sidenote: I purchased from Mobicity AU – which turned out to be a big mistake. Do yourself a favour and go somewhere else unless you have weeks to wait.

Nokia X - CyanogenMod 11

Boot Mode – Nokia X

Nokia Recovery Mode:

1. Turn off your device
2. Press Volume + and Power Button 15 seconds

Dependencies

If you haven’t got the Android SDK or tools yet you need to install

sudo apt-get install android-tools-adb android-tools-fastboot

USB Configuration

sudo vim /etc/udev/rules.d/51-android.rules
#add the following line
SUBSYSTEMS=="usb", ATTR{idVendor}=="0421", MODE="0666", OWNER="plugdev"
sudo service udev restart

vim ~/.android/adb_usb.ini
#add at the end of the file
0x2207

sudo adb kill-server
sudo adb devices

Rooting the device

Download ClockWorkMod Recovery (or TWRP if you prefer).

http://forum.xda-developers.com/showthread.php?t=2703708

Check USB debugging in “Settings –> Developer Options” (it seems that the NokiaX has debugging enabled out of the box)

Boot into Recovery (see above)

sudo adb reboot bootloader
sudo fastboot -i 0×0421 flash recovery cwm-6048-normandy.img
sudo fastboot reboot

Installing CyanogenMod 11

Please note that currently this is not an official CM release but an unofficial port, however CM has already committed to taking this device onboard as an officially supported one in the near future.

EDIT 2014-06-17: WIFI is currently not working which should be a showstopper for day-to-day use.

Boot into Recovery (see above) – this should now be CWM Recovery rather than the previous Android Recovery.

Download files:
CM 11 ROM for Nokia X (Android 4.4.2)
Google Apps for CM 11

In CWM recovery, select “Data Wipeout / Factory reset” option and wipe the data.
Select “Wipe Dalvik cache” from the Advanced Option
Select “Install ZIP –> Install ZIP from sideload”

sudo adb sideload cm-11-20140426-UNOFFICIAL-normandy.zip

Select “Reboot system now”

Note: the reboot can take about 1 minute to get started due to a bug in the current CWM Recovery.

Enjoy !

Apache Cordova development environment install on Ubuntu

Apache Cordova has very nice documentation, however as so many projects it is focused on the Windows/MacOS duopolies only. Fortunately it’s not too hard to work out the differences.

Apache Cordova Logo

Installing dependencies

Thanks to: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

sudo apt-get install python-software-properties python g++ make ant

Installing Android SDK

Please note: one of the problems I found was that I had some Android tools from the Ubuntu repos that were conflicting with the SDK install. It’s probably a good idea to remove them first. That might save you from a lot of headaches down the line (and time to troubleshoot).

sudo apt-get remove android-tools-adb android-tools-fastboot

Download as per http://developer.android.com/sdk/index.html

wget http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz

Note: check for updated link version obviously

vim ~/.bashrc

Add the PATH variables to the top of the file

#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

Reload bash variables without reboot / logout

source ~/.bashrc

Testing SDK

android

This command should now bring up the SDK manager.

Installing Eclipse IDE

This is obviously an optional step depending on the IDE you want to use. I have previously covered a manual Eclipse install (as opposed to the Ubuntu repositories).

Install Eclipse ADT Plugin

As per: http://developer.android.com/sdk/installing/installing-adt.html

Node.js Install

The main difficulty on Ubuntu (as with so many development tools – see Eclipse above) is that the included node.js version in the Ubuntu repositories is outdated (remove the Ubuntu version with ‘sudo apt-get remove node’).

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs

Install Cordova

sudo npm install -g cordova

Check Cordova Requirements

This will check for Android SDK installation, Ant and other dependencies – saving you going through error messages later.

~/.cordova/lib/android/cordova/3.4.0/bin/check_reqs

Create Cordova Project

mkdir ~/projects/PROJECTNAME
cd ~/projects/PROJECTNAME
cordova create ~/projects/PROJECTNAME com.COMPANYNAME.PROJECTNAME PROJECTNAME
cordova -d platform add android
cordova build

Create Eclipse Project

Open Eclipse
Create New Android project from existing sources
Import ~/projects/PROJECTNAME/platforms/android
Test in emulator by right clicking the project and selecting “Run As –> Android App”

Ubuntu Touch install on Nexus 4

This is the last of a series of alternative mobile OS installs and the easiest install by a country mile !

Ubuntu Touch Logo

Install

Everything is quite well documented here: https://wiki.ubuntu.com/Touch/Install.

sudo add-apt-repository ppa:phablet-team/tools
sudo apt-get update
sudo apt-get install phablet-tools android-tools-adb android-tools-fastboot
phablet-flash ubuntu-system --channel devel --bootstrap

That is it really ! This is how a OS change on a mobile should work !

Issues

Ubuntu touch can not yet handle the radio firmware past Android 4.3 devices. So if your N4 was upgraded to Android 4.4 (KitKat) you need to flash the radio to the Android 4.3 (up to Version 2.0.1700.84) else WIFI will not work.

Download 4.3 Stock Image from: https://developers.google.com/android/nexus/images#occamjwr66y

fastboot flash radio fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1700.84.img
fastboot reboot

Wifi setup

(Optional – this can be done via phone UI as well). Connect the phone via USB

adb shell
nmcli -pretty dev wifi connect NETWORK-NAME password PASSWORD

Install FirefoxOS on Nexus S (GT-9023)

I just had one of my old hand-me-down phones returned by my offspring in a great condition (junior is very careful with his equipment – well done young man !). This doesn’t happen all too often shows that the Nexus S is a decently built phone. This is also a good example of breaking the built-in obsolescence of modern phones. This particular unit has served me well for nearly 2 years (my average is one year) and served 2 kids after that.

These instructions have been compiled on Ubuntu 13.10 64bit to allow me to re-do this process in future. It should work on any Linux based distro (see pre-requisites) – if you are using another Operating System it might be time to switch. Hopefully it might be useful for other people as well.

Installing pre-requisites

As per https://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions/Linux_Prerequisites

wget https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py
python bootstrap.py

Ubuntu 13.10 additions

As per https://developer.mozilla.org/en-US/Firefox_OS/Firefox_OS_build_prerequisites#Ubuntu_13.10.

sudo apt-get install --no-install-recommends autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git lib32ncurses5-dev lib32z1-dev zlib1g:amd64 zlib1g-dev:amd64 zlib1g:i386 zlib1g-dev:i386 libgl1-mesa-dev libx11-dev make zip libxml2-utils
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 1
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 2
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 2
sudo update-alternatives --set gcc "/usr/bin/gcc-4.6"
sudo update-alternatives --set g++ "/usr/bin/g++-4.6"

Check out & build Firefox OS

git clone git://github.com/mozilla-b2g/B2G.git
cd B2G
echo "export HIDPI=1" > .userconfig
./config.sh nexus-s
./build.sh -j3

The config script will take quite some time depending on your internet connection as it has to download a lot of data. The build time will depend on your machine. In my case it took xx hours for the config and yy hours for build.

Notes

I had the following error with the config script: https://bugzilla.mozilla.org/show_bug.cgi?id=956098 (workaround contained in comments).

Install on the phone

NOTE: Before doing this you obviously want to backup your phone & data if you have anything useful on there (in my case not necessary).
NOTE: Before doing this step you need to ensure that the Nexus S bootloader is unlocked

  1. Reboot the Nexus S into bootloader mode by pressing volume up + power buttons simultaneously until you see the bootloader screen
  2. Connect the device to the PC via the USB cable
  3. Check the line “LOCK STATE – LOCKED”

If the unit is locked you can unlock it by issuing the following command
fastboot oem unlock
And use the VOLUME key to select + the POWER key to confirm/

Flash the phone

./flash.sh

VOILA !

FirefoxOS Home Screen

Or you can do it manually by using fastboot to copy the images

fastboot erase boot
fastboot erase system
fastboot erase userdata
fastboot flash userdata userdata.img
fastboot flash system system.img
fastboot flash boot boot.img
fastboot reboot

For the people that don’t want or can not (time to upgrade your OS!) build I have uploaded the resulting images (Build Date: 2014-01-20) to GoogleDrive. As usual this comes with a warning – proceed at your own risk !

If you want to return back to the factory Android ROM you can find the Google images here: https://developers.google.com/android/nexus/images

Now this unit will serve as a secondary phone (being compared against Ubuntu Touch on a Nexus N4) while Overseas where I generally need 2 phones.

Thank you Mozilla foundation for all the work and making it available fully in Open Source ! If you haven’t done so it’s time to join here: https://sendto.mozilla.org/

FirefoxOS Browser

Thank you to Google for NOT making it harder than necessary to extend the usefulness of their NEXUS range of phones and tablets. And in the same breath curse you SAMSUNG, APPLE, … ! The reason for me moving phones actually was the fact that the Galaxy S4 is such a P.I.T.A. to get upgraded and get rid of the Samsung bloatware. Back on the Nexus range – in hindsight I should have never left.

SMS Gateway using Sierra Wireless USB Modem on Debian Wheezy

I have been planning to set up a SMS Gateway for sending and receiving SMS messages via a headless utility unit (Raspberry Pi) for a while. Since I had a leftover Sierra Wireless AirCard 880U from Telstra in Australia I wanted to re-purpose this unit with a spare SIM card. Unfortunately it was very hard to find any good setup manual for this particular combination and took some time to fiddle & debug. This is the working setup for future reference and hopefully it helps somebody.

Install dependencies

Note: install usb-modeswitch BEFORE connecting USB Modem
sudo apt-get install usb-modeswitch gsm-utils smstools gammu

Connect the USB Modem

Check if modem is recognised

lsub

Bus 003 Device 002: ID 1199:6855 Sierra Wireless, Inc.

Edit smstools config file

vim /etc/smsd.conf

Change the GSM1 entry
[GSM1]
init = ATE0;+CPMS="SM","SM"
device = /dev/ttyUSB2
incoming = yes
mode = new
baudrate = 115200
smsc = 61418706700
pin = ignore
#rtscts = yes
#cs_convert = yes
report = yes
sending_disabled = no
memory_start = 1
pre_init = yes
primary_memory = SM
secondary_memory = SM
secondary_memory_max = 40

Troubleshooting the modem

I installed gammu purely to have an easier way to test if the modem actually worked. You can use gammu-config to do a GUI config or create a config file manually

vim /etc/gammurc

[gammu]
port = /dev/ttyUSB2
connection = at115200

Testing

gammu-detect

; Configuration file generated by gammu-detect.
; Please check The Gammu Manual for more information.

[gammu]
device = /dev/ttyUSB0
name = Phone on USB serial port Sierra_Wireless__Incorporated AirCard
connection = at

[gammu1]
device = /dev/ttyUSB1
name = Phone on USB serial port Sierra_Wireless__Incorporated AirCard
connection = at

[gammu2]
device = /dev/ttyUSB2
name = Phone on USB serial port Sierra_Wireless__Incorporated AirCard
connection = at

#send sms
sudo echo "sms test" | /usr/bin/gammu --sendsms TEXT +61XXXXXXXX
#check received sms
gammu getallsms

Add your own user account to dialout group if you want to send from your own account for testing (gammu)

sudo adduser $UNPRIVILEGEDUSER$ dialout

Next I will have some fun setting up PlaySMS to allow me to send SMS commands and create some inbound SMS workflows for family.

References
PlaySMS: http://playsms.org/
Gammu: http://wammu.eu/phones/sierra/2551/
smstools: http://smstools3.kekekasvi.com/index.php?p=configure

Connection Android 4.x MTP mass storage to Ubuntu 12.x

The ability to connect Android 4.+ devices to Ubuntu using the USB Mass Storage interface has always been a pain. With Ubuntu 13.04 a new MTP back-end (gvfs-mtp) is going to be introduced, but I have had some issues with the 13.04 Beta so I found this backport PPA to Ubuntu 12.04 and 12.10

sudo add-apt-repository ppa:langdalepl/gvfs-mtp
sudo apt-get update
sudo apt-get install gvfs
sudo apt-get upgrade

Kudos to Phillip Langdale for the work and maintaining the PPA !

Running Android 4.0 (ICS) on Virtualbox

Debugging things on the Android Emulator (incluced in the SDK) can be a very slow and cumbersome process. Thanks to the Android-x86 Project it’s quite easy to run Android in VirtualBox. This is highly useful when you need to test mobile apps and websites from the Android Browser (as well as Chrome Mobile).

  1. Download an Ethernet enabled ISO from Tablets x86

    wget http://dl.dropbox.com/u/75945873/android-x86-4.0-eth0-generic_x86-20120426.iso.torrent
    transmission android-x86-4.0-eth0-generic_x86-20120426.iso.torrent

  2. Create new ViratualBox VM
    VM Settings 1
    VM Settings 2
    VM Settings 3
    Important Settings (see screenshots)

    • OS: Linux, Version: Linux 2.6
    • Enable VTx/AMD-V
    • Use Bridged Network Adapter (if you want to allow direct Internet Access)
  3. Mount the ISO file downloaded previosly and start the VM
    Install dialog
  4. Create the Root Filesystem (ext3) on the VBox .vdi created with the new VM, mark as bootable
  5. Write the Filesystem changes to disk (VDI) and format the disk
  6. Install GRUB Boatloader
  7. Copy files from ISO to VDI
  8. Unmount the ISO image and reboot
  9. Note: You need to disable the mouse pointer integration (if you have installed VirtualBox Client Add-ons) in the menu of Virtualbox (‘Machine’ –> ‘Disable Mouse Integration’) when you start the VM (see screenshot). I have not found a way to disable this by default on Virtualbox on Ubuntu (If anybody has managed this I would love to know how !)

    Disable Mouse Integration

  10. Start the Android Setup Wizard to set locale and you should be up and running (network should already function to test external sites from Android browser) !

Intel Ultrabook tweaks on Ubuntu 12.04

After upgrading my Toshiba Z830 Ultrabook to 12.04 (Precise Pangolin) I noticed that the ability to control the screen back-light was not working using the Toshiba Fn F6/F7 keys.

Thanks to http://www.linlap.com/wiki/acer+aspire+s3 the solution was found quite quickly.

sudo vim /etc/default/grub

This will open the grub configuration file. (Grub is the initial boot selection software)
To be able to dim the screen brightness, You’ve got to modify the line:

GRUB_CMDLINE_LINUX=""

to these two lines:

pcie_aspm=force
GRUB_CMDLINE_LINUX="quiet splash pcie_aspm=force i915.i915_enable_rc6=1 i915.lvds_downclock=1 acpi_osi=Linux acpi_backlight=vendor elevator=noop"

Another neat tip: intel-gpu-tools can be used to control brightness from the commandline.

# will set brightness at 50%
intel_backlight 50


EDIT [2012-08-24]: to avoid issues on resume you need to add a script to the

sudo vim /etc/pm/sleep.d/20_wakeup

Add the following:

#!/bin/bash
case "$1" in
suspend|hibernate)
#do nothing
;;
resume|thaw)
echo 7 > /sys/class/backlight/toshiba/brightness
;;
*)
exit 1
;;
esac
exit 0

Mark the file as executable
sudo chmod +x /etc/pm/sleep.d/20_wakeup

Android 4.0 screenshot functionality on Galaxy Nexus

One of the features I missed since the good old Android 1.5 days was the ability to take screen-shots on the device. Prior to Android 4 (ICS) the only workable way to create screen-shots was to connect via USB cable and use the Android SDK to make remote screen-shots.

On Android 4.0 all you have to do is press Volume Down Key + Power Key down at the same time and hold.  You should hear the camera click (if audio is on) and Android will show a notification that the screenshot was saved on your device and you can now upload or transfer to your favourite service.