Sunday 16 July 2023

TP-Link Tapo Camera Configuration

We use an IP camera as a video monitor for Benjamin, and our old D-Link one is starting to show signs of becoming unreliable so I am thinking of a replacement.

The issue is that since I got our latest camera, the cheap, readily available IP cameras have become 'smart' and talk to remote servers so you can view your video stream from outside of the house etc.

This is way more than I want - I'd rather not connect it to the internet and just manually configure an IP address and username/password for an RTSP stream - then it is done, I don't need any more.

It looked like the 'consumer' level D-Link cameras no longer support RTSP (or you have to be very careful which one you get to make sure it has it), but I found that TP-Link do say on their web site that you can enable RTSP to use the camera with third party devices - so I decided to try a TP-Link One - I got their base model (C100), which is  wifi-only device for less than £20 from amazon.

The official instructions say you have to install a Tapo app on your phone to configure it, but I thought I'd try and do it manually by dong the following.

Attempt at Manual Configuration

  • Switch On Camera
  •  It appeared as wifi SSID Tapo_Cam_11CB - connect (no password required)
  •  The camera provied my laptop with an ip address 192.168.191.100
  •  Ran nmap -sP 192.168.191.10/24, which found a host at 192.168.191.1 (in addition to my laptop)
  •  nmap 192.168.191.1 showed that ports 443 (https), 554 (rtsp), 2020 and 8800 were open.
  •  Pointing browser at https://192.168.191.1 gave a 'No such file or directory' response
  •  Pointing mplayer at rtsp://192.168.191.1/stream1 gave an unauthorised error (probably because we have not enabled RTSP yet).
  • Pointing browser at https://192.168.191.1/index.html returned a json string which included a key - is this some sort of oauth response?
At this point I gave up for now and decided to see what the Tapo app does.   I think it should be possible to reverse engineer the configuration and authentication if I am feeling very keen, but there might be some pre-shared key involved which could mean it is not possible.

Configuration using Tapo App

  •   Used Tapo app to configure camera to connect to my router.  It did not work at first for some reason - it said it did not receive an IP address -
    • This may be because it connected to a new access point that I installed a few days ago and haven't tested thoroughly, so I moved the camera and switched off the access point and it worked.
  • Used Tapo app to enable RTSP stream with username and password - we can now use mplayer to connect to the stream using mplayer rtsp://<uname>:<passwd>@192.168.191.1/stream1
  • I can also use the Tapo app to view the stream from outside of the house, which is not something I want to be able to do.
  • Deleted my Tapo account and have confirmed that the camera still works with RTSP.
  • I do not know whether it is still connecting to the TP-Link servers, even though I deleted my account though.
  • The only way I have thought of doing it is to run my own DHCP server and a simple router app on a Raspberry Pi which will block internet access for the camera - Maybe there is a better way.
Or am I just being too paranoid about trusting remote servers with my live video stream?   I guess the vast majority of customers will just follow the TP-Link instructions without worrying about it.......



Monday 8 May 2023

Temporary Swap File on Ubuntu

 I am training a Machine Learning (Neural Network, "AI") model for epileptic seizure detection.   An issue I have is that I have a lot more false alarm data than I do genuine seizure data, so I am using 'Data Augmentation' to make more seizure-like data.

Unfortunately when doing this using Python, it seems to eat huge amounts of memory.   The 16GB on my computer is not enough, so I added more swap space using the following:

fallocate -l 16G /swapfile2

chmod 600 /swapfile2

mkswap /swapfile2

swapon /swapfile2


Check it is working with 

swapon --show

or

free -h




Tuesday 11 April 2023

Arduino Nano Clone (CH340)

 I have a few cheap Arduino Nano clones, which use the CH340 USB chip.

I had a few problems getting them to work with Ubuntu 22.04 LTS - first the ttyUSBx devices was not appearing, and then there were errors trying to upload firmware.


To get the ttyUSBx working, I had to 

  • uninstall brltty as that seemed to be grabbing the device - not a problem for me because I don't use braile, but if I did, it would have needed more faffing.
  • add myself to the dialout group in /etc/group
  • make /dev/ttyUSBx group read/write
  • I still had errors doing upload using either the default nano board or the old bootloader version in the arduino IDE.
  • Installed a patched driver for the CH340 chips from https://github.com/juliagoda/CH341SER
  • After that, I can upload firmware using the 'old bootloader' version of the Arduino Nano board in the Arduino IDE.

Note, Have just re-checked and I think I am using the original CH341 driver, not the new one, so it must have been the bootloader change that got it working?

Wednesday 13 April 2022

Preventing Doze Mode on Samsung Galaxy Tab 8

We have a relatively old Samsung Galaxy Tab 8 android device that we use as a monitor for OpenSeizureDetector.

The problem is that when it is not plugged in, we start to get fault 'pips' until we wake up the device.     There are no obvious 'Battery Optimisation' settings in the OpenSeizureDetector page of the device Settings->Apps menu.

It turns out that the battery optimisation settings are well hidden.  To disable battery optimisation do:

  • Settings -> Apps
  • Three dots at top of screen to open extra menu.
  • "Special Access"
  • "Optimise Battery Usage"
  • Select "All Apps"
  • Locate OpenSeizureDetector and set the switch to off (not optimised).
This should prevent OpenSeizureDetector being forced into 'Dose Mode' so it will continue to run normally in the background when the device is asleep.

Sunday 6 March 2022

Transferring a MySQL Database to another Server

 This should be easy...

On server do:

mysqldump -u osd -p osd > osd_dump_06mar21.sql

But on my very small virtual server I hit an error about conection to mysql being lost.     I had to increase some timeouts in the mysqld configuration file....but I have forgotten which ones - will update this when I remember.


Transfer the dump file to the other server (I use scp).

On the other server, set up the user login details then do:

mysql -u osd -p osd < osd_dump_06mar21.sql

BUT this gave an error:

Unknown collation: 'utf8mb4_0900_ai_ci'

I found (on stack exchange!) that the solution is to replace all occurrences of this string with 'utf8mb4_unicode_ci'

The simplest way to do that is with sed:

sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' osd_dump_06mar21.sql 

After doing that the import:

mysql -u osd -p osd < osd_dump_06mar21.sql

worked fine. 

 

Friday 4 February 2022

Using a Brother Networked Printer/Scanner with Linux

 Notes for future reference:

Printing just worked using the 'Printing' GUI.

Scanning Didn't.....the SimpleScan programme did not detect the scanner.

The trick is to install a driver that pretends that the networked scanner is connected locally using the SANE interface, brsaneconfig4

Doing:

brsaneconfig4 -q lists the scanners that are available.

brsaneconfig4 -a name=SCANNER model=MFC-L3750CDW ip=192.168.0.19

adds the scanner, and it now works nicely with simplescan.

Sunday 2 January 2022

Parkrun Finish Token Generator

We had an issue with 'losing' some of our nice new finish tokens from Hartlepool Parkrun. We ended up replacing them with spares from our old set of tokens, but these were worn and difficult to scan, and had been repaired using barcode stickers which wear off easily.

The main parkrun web site gives the ability to print out a finish toke bar code, but they are not the same size as the real tokens so do not stack nicely with the original tokens.

To get around this I wrote a Python script that will generate SVG images of a requested set of finish tokens.  These can be printed out, laminated and cut to the same size as the original tokens.   The python scripts are here: https://github.com/jones139/parkrun_tokens

I know that some people that might find this useful will struggle with using a python script from the command line, so I made a simple web app that presents the script as a web page to allow the user to specify the parkrun name to be printed on the tokens along with the list of tokens to generate.   The token generator web app is running here: https://barcodes.ddns.net.



A typical A4 sized SVG output image is shown below:

Once the page is printed, laminated and cut to size, the completed set of tokens looks like this:
We have not had any issues with scanning these tokens - they seem to work as well as the originals (at least for the first few weeks that we have been using them - they may well deteriorate after a few very rainy Saturdays!).