Monday, 8 January 2024

What to do with an old iPad?

How old?

I have an iPad and an iPad mini which were in occasional use recently by aging relatives:

  • third generation iPad model MD328/A1416 (16GB, 9.7" screen)
  • first generation iPad mini MD528/A1432 (16GB, 7.9" screen)

Both models were first marketed by Apple in 2012, so they are really old in computer terms.
Both appear to be working well with acceptable battery life, however their software cannot be updated from iOS 9.3.5, iOS 9 was released in September 2015.  It was superceded by iOS 10 a year later and the current version is iOS 17.

Owing to their old software they have no real value, even on eBay, and worthy causes are not interested in them as a donation.   I am reluctant to dispose of them and I have been thinking how they could be useful.

Which apps can be installed?

The short answer is that existing apps should continue to work but practically nothing on the Apps Store can be installed on iOS9.
  
The apps store normally only allows recent versions of apps to be installed  and they are all post 2015.  The one exception is that, for apps which have been previously purchased / installed, an old version can be downloaded.  This provides a loophole which can be exploited: purchase or install a new app on your newer iPad then go back to the old one and install an older version, if it exists.

A third option is to jailbreak the iPad so that you can install apps from (possibly dodgy) non-Apple sources but I that is a slightly different subject so I wont investigate at this point.

It seems unnecessarily restrictive for Apple to prevent downloading old versions, but to be fair, this is ten year old software and hardware so it is unlikely that you need apps that you havent needed in the last ten years.

Which apps work?

Even if an app is installed on the iPad, it may not work properly.

Apps which are included with iOS9 appear to work well (Safari, camera, iBooks, photos for example).  If an app is purely local and doesn't require internet functionality it should work.  I had a few old games (The Room, Sudoku, Labyrinth and Candy Crush) which are ok.  

Apps using local networking (Heos, webSsh, Unix-Reflection, Pure Connect) may work and some  which use the internet are available.


To get an idea of which apps I can potentially use I went through the list of purchased apps on the App Store and tried to install them all on the old iPad.  I started them up and ran some quick tests.  A number of apps, including Chrome, failed at this stage, as they carried out internal checks and decided they needed (unavailable) upgrades to use.


At the end of this exercise my ipad has extra apps shown to the left.  The main apps which use media are likely to be the most useful: vlc (video), photos and LiveFrame (slideshows), safari (for browsing and my local web pages), Heos, iPad Music and Pure (for music control).

There is no file manager function available on iOS9 but it does include iCloud so you should be able to play music, videos, photos etc. and store them locally within applications.

In summary, although the choice of software available is very limited, we do have most of the functionality we may need.  If an extra function is required, I can search the web for suitable iOS9 compatible apps.

Potential Users

I already have a decent, newer iPad 5th generation MPGC2B which is a great tablet, although it has just stopped receiving upgrades (it is still on iOS16), so an older heavier iPad isn't going to be an acceptable substitute for me.  If I do use an old iPad it is likely to be dedicated to a single function, watching movies, controlling the music player or home automation.

Alternatively, the iPad could be useful to someone who currently doesn't have their own.  My elderly father-in-law Roy may like to use it as a family photo album, to help with his memory.  Grandson, Harry Junior might like his iPad to watch youtube videos or play childrens games.  Again they are likely to use for a single app rather than a general purpose device.

The iPad and iPad mini have great quality screens and good sound so they are very suitable for any audiovisual media: music, videos, photos, books.

By switching the iPad to never auto-lock, it retains the last application screen when you start to use it.  This minor configuation change makes quite a large difference; say when resuming a video, you can just turn it on and continue to watch, without all the faffing around of starting the app and finding the right place.
Similarly, for an audio controller it is almost as easy as a remote control, just turn on and your control screen is in front of you.

Potential Uses

1    Photograph slide show

Either the Apple photo app or LiveFrame can provide an ongoing slide show.
The show can be made continuous and the photo collection can be as large as you like.
Suitable for an elderly relative.

2    YouTube web

As a dedicated YouTube player, the iPad is very easy to use without adult assistance.
Suitable for a young child

3    ebook reader

I typically read a single book at any given time and there is a plentiful supply of ebooks and pdf documents to read.  The app provided by my local library for online reading also works.

4    Video player

The excellent quality screen is perfect for playing videos with VLC.
As usual, dedicating the device to this function makes it much easier to pick up and put down current viewing.

5    Music Controller

The iPad mini makes a very good smart remote control.  I have web pages to control my different sorts of music and if I leave the iPad mini lying around it is actually more convenient than a remote.  The only downside is to periodically plug it in when not in use.  My web pages also work on peoples phones but it is easier to pick up a small device than starting your browser and choosing an appropriate link.

6    Game Player

I dont often play games, but if an old iPad feels like an entertainment centre I may reach for it to play a game (or watch a film, read a book etc).

7    Home Automation Controller

This is a very good new / developing area for me.  Although the iOS9 doesn't support Home Assistant it may be possible to set up as a central control device.

8     Linux terminal

When working on a variety of linux tasks, it would be useful to have a dedicated virtual keyboard/screen for "headless" systems.

9    6502 Console

This is likely to be a rare but sexy usage to provide a screen and keyboard for my 6502 system.

10   Jailbreak

An old redundant iPad would be ideal to see how easy / useful it is to jailbreak a device and whether it makes a big difference to what you are able to do with it.


The trouble with bright ideas is that they may never be used.  Rather than choose one of the above functions I may play with a variety and see if any of them are properly useful.

Conclusion

I started off thinking it is a shame that good working technology hardware needs to be thrown away to be recycled.  After this exercise I am hopeful to extend the life of the iPad-3 and iPad mini-1 for a couple more years.

I will be very happy if I do find a proper use for these little gems.  There may be a future blog post describing any successes.

Saturday, 6 January 2024

Sonos : Web Page Control

Rationale

We have made excellent progress controlling Denon and Heos functions through python and web pages.  Playing albums using my web page only requires 3 clicks and is much easier than navigating through the NAS folder structure using Heos.  

I previously thought that Sonos was mainly limited to a closed eco-system of Amazon Music, Spotify etc but as I begin to look in detail I see that it can do a lot more, allowing you to play music from your own devices or a DLNA server.  The Sonos app, although it is slightly better than Heos, requires you to navigate through a menu structure to play albums.  Sonos actually provide an excellent in depth developers guide, if I want to develop from scratch.

My first objective was to see whether I could play RPI/mpd output on Sonos and I found that I could do so using TuneIn (Classic).  This was my fall back plan when my Sony amplifier was misbehaving, before I bought the Denon receiver.  It turned out I didn’t need to use Sonos for that purpose but the Sonos Beam is still available to me.  My temporary solution was somewhat limited as Sonos treats RPI/mpd input as a stream, whereas I really want to play an album using Sonos controls for viewing playlists, skipping tracks etc.

Investigation

Previously the usage of python for back-end programming and javascript / web sockets in the web page worked really well for the Denon  / Heos control page so I will use this approach again.
Sonos is more widely used than Heos and, searching on github,  SoCo is amongst the most popular Sonos projects.  It is a general purpose client written in python, currently maintained and includes excellent documentation so it seems perfectly suited for my needs.

 

Installation is trivial ("pip install soco").  Browsing the documentation I could see that the music_library submodule will be most useful to me. I was quickly able to check using just three statements in interactive python that I can use SoCo in conjunction with my Sonos Beam:

Music Storage

I have recently installed a rather excellent TP-link ax5400 router which has a USB port.  It has the capability to share music / video / data held on a USB flash drive.  I actually attach an unpowered 4-port USB hub which allows me to utilise multiple drives.  This gives me a free NAS capability and easily allows me to keep all music in one place.

Sonos likes good quality mp3 tags to scan so that it can scan music in an orderly manner.  In particular, my charts downloads often have the artists name both in the "album" tag and the "album artist" tag, which causes Sonos to think I have hundreds of albums each with one track.  In addition Sonos plays tracks in filename order if there are no track numbers.  I fixed these problems using the wonderful windows mp3tag utility by setting "album artists" to "various artists" for chart downloads and by adding a track number.  Sonos is now pretty good if I navigate through the music library by artist or album and play all tracks in an album.

Unfortunately Heos displays the "album artist" field to display tracks so lots of my tracks now appear as "Various Artists".  The only solution I can think of is to have separate charts folders for Heos and Sonos.  Ah well, it is not a perfect world.

 Soco python programs

SoCo is an excellent python module, which is enhanced by the comprehensive Sonos API and quality documentation.  It proved to be straightforward to set up my own functions to choose and play albums.

Although it is easy to choose an album by artist I prefer to use the folder structure to define my album playlists.  This allows me to navigate to an album and play it even if the mp3 tags for album, artist are imperfect.  

The following interactive python example shows how to navigate the router music flash drive folders to choose an album to play.  The  "root" level is a shared folder "//RouterShare/H" which is obtained using a command "get_music_library_information('share'). The music at each successive level in the folder structure is achieved by selecting an array element from root, level1, level2, level3 by browsing the folder object retrieved at the next level up.

Having chosen a level3 item, which is an album, it can be added to the Sonos music queue and played as shown below.


These commands can be integrated into our command line python program which can return a list of groups, artists or albums.  The list is typically passed to the web page which returns with a choice indicating the next level. Once the group/artist/album selection has been made their values are passed to the play option and python makes a Denon request to add the tracks to the queue and play the album.

Web page


Our web page simply has to display available groups, artists and albums and allow the user to choose what they want.
Initially the "Show Groups" button is used to make a python request to Sonos which returns the list of groups that are inserted into the page.  In due course this will be done automatically on loading the page.  In the HTML you see that the web socket command is still denon, as we are using the framework setup for Denon and Heos.  The "-l groups" parameter causes python to return a list of the groups.  For convenience all the commands include "-g" (group chosen) and "-a" (artist chosen) parameters as well.  

This web socket command  causes the python command "sonos.py -l groups -g 0 -a 0" to be executed and the list of groups "A-B", "C-F", ... is displayed.








Clicking on a group causes a Sonos request which fetches and displays an artist list.  Click again and a list of albums from that artist is displayed.  A third click puts the album on the Sonos play queue and starts the music.





The Chrome console log is very helpful when testing the web page.  In the example to the right you can see information returned to the web page after clicking the "show groups" button, then clicking "C-F" then "Coldplay".  At each stage the next level of information is returned and displayed on the web page.  The information from Sonos is returned in JSON format so that it can be easily interpreted in javascript.

My python script adds some extra fields at the end of JSON returned by Sonos.  In the example on the right the second JSON response has
 "Sonos" : "albums", "group":"1", "artist":"4"
added to show that the information is a list of albums relating to group1 (C-F) and artist4 (coldplay).

When a Sonos response is received by the web page web socket ws.onmessage function the javascript code looks at the "Sonos":"albums" field and can see that the list of albums should be placed in field #sonos7 which is below the group / artist fields.
makeSonosList formats the json as html fields and buttons so that it looks correct and reacts correctly.


If the level is groups or artists the html button causes a request for the next level of information.
If the level is album, the button submits a request to play the appropriate album.