Blog Archive

Sunday 24 October 2021

 https://blakadder.com/tuya-covers/#determining-functions

Tuya blind

Friday 29 January 2016

Broken Windows 10 App Store

My daughter brought her shiny new laptop to me this week, very sheepishly telling me the App Store was not working. She thought she'd done something wrong, but obviously it was Microsoft's doing.
The icon had changed to be "@{Microsoft.Windows...." and would not open. Time to learn lots more than I ever wanted to about Windows 10...

The Store app is stored alongside all the apps downloaded from the Store (and pre-installed) in C:\Program Files\WindowsApps, which is a hidden directory. There seemed to be two versions of the app store in there, 2015.25.22.0 and 2015.25.24.0. Neither worked. After a lot of Googling (and Binging?) I found this link which pointed me in the right direction and was basically the only helpful thing I could find about the issue, although seemingly not the issue I was having.
So I removed version 24:


remove-AppxPackage Microsoft.WindowsStore_2015.25.24.0_x64__8wekyb3d8bbwe -confirm

Fine. Nothing bad happened.

So I tried to reinstall it as suggested in my Google find. Except it complained about version 22 still being installed. I didn't save the error message unfortunately. So, OK, I thought, just remove version 22. So I tried:

remove-AppxPackage Microsoft.WindowsStore_2015.25.22.0_x64__8wekyb3d8bbwe -confirm

And got this (relevant bit picked out of a screenful of messages). Not what I wanted:

error 0x80070002: Reading manifest from location:
C:\ProgramData\Microsoft\Windows\AppRepository\Microsoft.WindowsStore_2015.25.22.0_neutral_split.scale-100_8wekyb3d8bbwe.xml failed with error:
The system cannot find the file specified.

It was right though. That file wasn't there. So I then simply(!) installed Windows 10 as a VM in VirtualBox on my trusty MacBook and found that file. Actually it was the version 24 xml file, but I renamed it and edited it so it looked like version 22, put it into the place suggested by the error and tried the remove command again, and: hoorah! It "removed" the xml file and its corresponding directory in c:\Program Files\WindowsApps. (Did I mention that was hidden and owned by TrustedInstaller?). I did :

Takeown.exe /F c:\Program Files\WindowsApps 

to get round that.

Anyway, time to try reinstalling the version 24 of the Store (as that was the only version I now had, as my VM decided to install updates all by itself. Bloody Microsoft).

I copied the directory (I will not call them folders) into c:\Program Files\WindowsApps\Microsoft.WindowsStore_2015.25.24.0_x64__8wekyb3d8bbwe 
and put the xml file into c:\ProgramData\Microsoft\Windows\AppRepository. The I ran:

Add-AppxPackage -Register c:\Program Files\WindowsApps\Microsoft.WindowsStore_2015.25.24.0_x64__8wekyb3d8bbwe\AppxManifest.xml -DisableDevelopmentMode

The PowerShell command (I mentioned I was in PowerShell right? No? Well I was. As Administrator) ran without error. Progress, I thought. Then nothing happened.
I pressed the Win key to show the start menu and the App Store icon still showed the gobbledygook it showed before. Obviously, then, being the logical, level-headed animal I am, I furiously hammered the Win key for a few seconds until, lo and behold, the Store "tile" looked right again. Eureka!
And it worked. I clicked on it and it opened. F**king-A! I download the first sh*tty app I could see, and it downloaded and ran. Job done. Let adulation from 14 year old daughter commence. 

Yeah, right.

Thursday 10 December 2015

CLI Android ADB rsync on a MAC (or Linux)


$ export PATH=~/Downloads/android-sdk-macosx/platform-tools:$PATH

$ mv rsync.rsync4android rsync.bin

$ adb push rsync.bin /data/local/tmp/rsync
3922 KB/s (793148 bytes in 0.197s)

$ adb shell chmod 755 /data/local/tmp/rsync

$ adb shell cp /data/local/tmp/rsync /sdcard/rsync.bin

$ adb shell /data/local/tmp/rsync --version
rsync  version 3.1.1  protocol version 31
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
    no socketpairs, hardlinks, symlinks, no IPv6, batchfiles, inplace,
    append, no ACLs, no xattrs, no iconv, no symtimes, no prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

$ adb shell 'exec >/sdcard/rsyncd.conf && echo address = 127.0.0.1 && echo port = 1873 && echo "[root]" && echo path = / && echo use chroot = false && echo read only = false'

$ adb shell /data/local/tmp/rsync --daemon --no-detach --config=/sdcard/rsyncd.conf --log-file=/proc/self/fd/2
2015/10/28 20:59:16 [11983] rsyncd version 3.1.1 starting, listening on port 1873


In a new terminal window:

$ export PATH=~/Downloads/android-sdk-macosx/platform-tools:$PATH

$ cd Downloads/nexus5/sdcard/

$ adb shell '/data/local/tmp/rsync --daemon --config=/sdcard/rsyncd.conf --log-file=/data/local/tmp/foo &'

$ adb forward tcp:6010 tcp:1873

$ rsync -av --progress --stats rsync://localhost:6010/root/sdcard/ .

receiving file list ...

Wednesday 9 December 2015

Extract each track from a NI STEM mp4 file using ffmpeg

There's a new fancy format for mixing up tracks called, rather unoriginally "STEMS" from Native Instruments. When you buy one, it comes in an mp4 container, and you can treat this mp4 like any other mp4 or mkv container and extract each stream, or track, into a wav file for use in apps which don't (yet) support NI STEMS, like every app except Traktor at time of writing.

Get info about the mp4 file :

# ffmpeg -i test.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2015-11-06 12:29:51
    title           : Academic (Extended Mix)
    artist          : New Order
    album           : Academic (Extended Mix)
    track           : 1/1
    publisher       : Mute
    LABEL           : Mute
    AUDIOTYPE       : STEM
    ISRC            : GB-R8R-15-00458
    CATALOGNUMBER   : S7STUMM390STEMS
  Duration: 00:08:57.28, start: 0.000000, bitrate: 1219 kb/s
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 258 kb/s (default)
    Metadata:
      creation_time   : 1992-05-30 16:50:26
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 257 kb/s
    Metadata:
      creation_time   : 1996-02-18 23:12:18
    Stream #0:2(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 247 kb/s
    Metadata:
      creation_time   : 1999-11-09 05:34:10
    Stream #0:3(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 253 kb/s
    Metadata:
      creation_time   : 2003-01-17 07:35:46
    Stream #0:4(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 191 kb/s
    Metadata:
      creation_time   : 2005-09-14 05:17:06
    Stream #0:5: Video: png, rgb24, 1236x1236, 90k tbr, 90k tbn, 90k tbc

Stream 0 appears to be the full track, stream 1 onwards seem to be the separate parts.

Extract stream 1:

ffmpeg -i test.mp4 -map 0:1 -vn test1.wav

Extract stream 2:

ffmpeg -i test.mp4 -map 0:2 -vn test2.wav

etc....

Tuesday 15 September 2015

Adding an SSL certificate to Subsonic on MAC OSX

# Stop Subsonic first

# Combine your certificates into one file :
cat primary.crt intermediate.crt root.crt >> combined.crt

#generate a pkcs12 certificate (make all passwords "subsonic") :
openssl pkcs12 -export -inkey server.key -in combined.crt -out cert-chain.pkcs12

#create a keystore file (again, make all passwords "subsonic") :
keytool -importkeystore -srckeystore cert-chain.pkcs12 -srcstoretype PKCS12 -destkeystore subsonic.keystore

#combine the keystore file into the jar file in /Applications/Subsonic.app/Contents/Resources/Java/ :
sudo jar uf subsonic-booter-jar-with-dependencies.jar subsonic.keystore

#copy file into place (if you didn't generate it in place) :
sudo cp subsonic-booter-jar-with-dependencies.jar /Applications/Subsonic.app/Contents/Resources/Java/subsonic-booter-jar-with-dependencies.jar

#Start Subsonic

Wednesday 15 July 2015

Kolab 3.4 catch-all address

I found instructions here showing how to set up a "catchall" address on a Kolab 3.2 install which also worked on my 3.4 install, except that ALL emails went to the catch-all, including emails for existing, genuine users - their mailboxes were not receiving their mail, the catchall was.
I fiddled about with the query_filter in the config file to stop this behaviour. It is still not perfect, as it stops the "user+extrabit@domain.com" addresses from working unless "user+extrabit@domain.com" is setup up as an alias for the user. Perhaps someone cleverer than me can suggest a better query_filter. Anyway, here's the .cf file I used:

# cat virtual_alias_maps_catchall.cf
server_host = localhost
server_port = 389
version = 3
search_base = dc=blogger,dc=co,dc=uk
scope = sub
domain = ldap:/etc/postfix/ldap/mydestination.cf
bind_dn = uid=kolab-service,ou=Special Users,dc=blogger,dc=co,dc=uk
bind_pw = support
query_filter = (&(alias=catchall@%d)(!(alias=%s@%d)))
result_attribute = mail

Follow the rest of the instructions in the link I mentioned before.

This put me on the right track too.

Tuesday 7 July 2015

Change Kolab Directory Manager password (CentOS 7)

stop dirsrv@kolab :

# systemtctl stop dirsrv@kolab

generate a new password:

# pwdhash newpassword

edit /etc/dirsrv/slapd-kolab and change the line :

nsslapd-rootpw: {SSHA}sMenoLEtsTWzdvplg0dfAy1a+DnOaHe0D8a1yQ==

and replace the {SHA}... bit with the password you generated with pwdhash:

nsslapd-rootpw: {SSHA}qeeho8tNY7saCBF+ugdljuweDfeMTZIn2sq1CA==

restart the directory service:

# systemctl start dirsrv@kolab

UPDATE:
I found out to my cost, that the Directory Manager password is stored (in plaintext, FFS) in another, very important file ; /etc/kolab/kolab.conf

So find this snippet and change the plaintext password :

# vi /etc/kolab/kolab.conf

...
[ldap]
ldap_uri = ldap://localhost:389
supported_controls = 0,2,3
base_dn = dc=blogger,dc=com
bind_dn = cn=Directory Manager
bind_pw = newpasswordhere
...



Saturday 13 December 2014

ESP8266 temperature loggers




Arduino | ESP8266
 RX     -> UTXD
 TX     -> URXD
 CH_PD  -> 3.3v

Arduino | DS18B20 
 D2     -> DQ
 RESITOR between DQ and VD0 (3.3v)




*********************************
#include<stdlib.h>

#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
#define SSID "SSID"
#define PASS "password"
#define IP "10.10.10.5" // website to talk to...
String GET = "GET /temps/update.php?key=ESP2&tempc=";
SoftwareSerial monitor(10, 11); // RX, TX
void setup()
{
  monitor.begin(9600);
  Serial.begin(9600);
  //sendDebug("***");
  //sendDebug(__FILE__);
  //sendDebug("need a serial to usb attached to pins 10 and 11 to see output");
  sensors.begin();
//  monitor.println(__FILE__);
//  sendDebug("AT+RST");
  delay(2000);
  sendDebug("AT");
  
  delay(5000);
  if(Serial.find("OK")){
    monitor.println("RECEIVED: OK");
    connectWiFi();
  }else{
    monitor.println("Didn't run connectWiFi, at least, didn't get back an OK");
  }
}
void loop(){
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);
  //tempC = DallasTemperature::toFahrenheit(tempC);
  char buffer[10];
  String tempF = dtostrf(tempC, 5, 2, buffer);
  
  updateTemp(tempF);
  monitor.println(tempC);
  delay(60000);
}
void updateTemp(String tenmpF){
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  sendDebug(cmd);
  delay(2000);
  if(Serial.find("Error")){
    monitor.print("RECEIVED: Error");
    return;
  }
  cmd = GET;
  cmd += tenmpF;
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  if(Serial.find(">")){
    monitor.print(">");
    monitor.print(cmd);
    Serial.print(cmd);
  }else{
    sendDebug("AT+CIPCLOSE");
  }
  if(Serial.find("OK")){
    monitor.println("RECEIVED: OK");
  }else{
    monitor.println("RECEIVED: Error");
  }
}
void sendDebug(String cmd){
  monitor.print("SEND: ");
  monitor.println(cmd);
  Serial.println(cmd);
} 
 
boolean connectWiFi(){
  Serial.println("AT+CWMODE=1");
  delay(2000);
  String cmd="AT+CWJAP=\"";
  cmd+=SSID;
  cmd+="\",\"";
  cmd+=PASS;
  cmd+="\"";
  sendDebug(cmd);
  delay(5000);
  if(Serial.find("OK")){
    monitor.println("Connect RECEIVED: OK");
    return true;
  }else{
    monitor.println("Connect RECEIVED: Error");
    return false;
  }
}









Web site PHP:






<?php

$ESP=$_GET["key"];

$temp=$_GET["tempc"];

$FILE='FILE'.$ESP.".txt";

file_put_contents($FILE,$temp);

echo "<p>";

echo "$ESP | $temp";

echo "</p>";

?> 

Friday 5 September 2014

Hap-Pi and ScratchGPIO5 and the Raspberry Pi camera module

Hap-Pi and ScratchGPIO5 and the Raspberry Pi camera module

Intro

I backed the Hap-Pi robot kit on Kickstarter and my little robot arrived with few instructions. There were very good guides about how to put together the cardboard case and motors, and on how to solder the motor-control add-on board and these are available at the ever-expanding pi-school.com website. After my 8 and 10-year-old daughters had completed the assembly of our Hap-Pi and we had installed our Raspberry Pi on it, complete with rechargeable battery, we needed a way to control it. I had a dig around and discovered that Simon Walters had made his brilliant ScratchGPIO5 add-on for Scratch v1.4 compatible with the Hap-Pi. All that was needed was to make a Scratch sketch to control our little robot. With Wi-Fi and a battery for the motors and the Raspberry Pi itself, we were able to wander around following the Hap-Pi using the laptop like a remote-control unit. Then we wanted to go one better. What if we could put the Raspberry Pi camera module on the front of the Hap-Pi and stream video from it? That way we had a remote-control robot that we could control from the safety of an armchair. So we did, and this is how…

How to install ScratchGPIO5 on your Pi

ScratchGPIO5 is available here:
Do this part with your Raspberry Pi plugged into your monitor and with a keyboard and mouse plugged into its USB ports. We can look at getting remote access from a PC or laptop later. However, you do need to have the Raspberry Pi connected to the Internet.
Double-click “LXTerminal” and then type the following into the window that opens:


Wait for that to finish, it will output some info looking something like this:


The “isgh5.sh saved” bit is the part that tells you it worked ok. Next type:

sudo bash isgh5.sh

A lot of information should fly past the screen. Don’t worry about reading it all, but hopefully the last bit should look like this:


Now you are ready to roll. You should have a few new icons on your desktop that look like this: 
If not, give your Pi a quick restart (reboot) and when it all comes back, they should be there. You want to run the one called “ScratchGPIO 5plus” by double-clicking on that icon.

Program the arrow keys to run Hap-Pi from ScratchGPIO:

I was going to write a few paragraphs to show how to do this, but Stewart Dunn, the Hap-Pi designer beat me to it and produced a nice easy to understand video on YouTube, just here:
Also, since beginning on this document, pi-school.com has published a guide to using ScratchGPIO with the Hap-Pi: http://www.pi-school.com/index_htm_files/HapPi_Robot%20ScratchGPIO.pdf

Accessing the Raspberry Pi remotely

In order to run the Hap-Pi robot properly you’ll want to do a few things. Firstly you’ll need to use Wi-Fi to connect the Pi to your network and then you’ll want to run the Raspberry Pi from a battery and access it by connecting to the LX Desktop on the Pi by using some remote desktop software on your PC or laptop.
Connecting a Wi-Fi dongle and using that to connect to your Wi-Fi router has been covered a million times on the Internet. Use your favourite search site to find a guide, or try this one:

Now you want to connect to your Pi using a desktop sharing system called VNC. I followed the guide at raspberrypi.org here: http://www.raspberrypi.org/documentation/remote-access/vnc/

Open up “LXTerminal” again and the type:

sudo apt-get update && apt-get install tightvncserver

Then run TightVNC Server to set the password that you’ll need to type in when you want to connect to your Pi from you laptop using a VNC client. This doesn’t have to be the same as the “pi” user’s password, but it’s probably best for your sanity to set it the same. If you haven’t changed your “pi” user password since you created your SD card, then the default password is “raspberry”:

tightvncserver

The screenshot below is hopefully clear enough. I type “raspberry” as the password and said no to a view-only password. You now have a desktop available to connect to over the network from your laptop, but you (probably) don’t have any software on your laptop to connect with.



Install VNC viewer on your laptop

I like to use “Ultra VNC viewer” on my laptop, but there are many available, so shop around. UltraVNC for Windows is a free download from here: http://www.uvnc.com/downloads/ultravnc.html
At the time of writing, the latest version was 1.2.0.1. Download the file and you should have a file called something like “UltraVNC_1_2_01_X86_Setup.exe” in the Downloads folder on your PC. Go ahead and run this file and go through the setup but when you get to this screen:




Just choose to install the viewer part of the software by making sure only the “UltraVNC viewer” box is ticked (untick the others). When you’ve finished clicking on the “next” buttons and the “finish” button go ahead and find “UltraVNC Viewer” in your Start menu and run it. You’ll see this:


Type in the IP address or hostname of your Raspberry Pi in the box, followed by  “:1” (e.g. 192.168.1.123:1) and click connect. You will then be prompted to enter a password (leave any username box empty). I chose “raspberry” as my password earlier, so that’s what I type. You should hopefully now see the by now familiar Raspberry Pi desktop and you can get on and run Scratch to program and have fun with your Hap-Pi.
To make the VNC desktop run when you switch on your Pi, one of the many ways to do it is to add the following to the “/etc/rc.local” file. The following line needs to go in the file BEFORE the line “exit 0”:

su - pi -c '/usr/bin/vncserver :1 -geometry 1024x768 -depth 24'


Adding the camera module and streaming a picture from it

Follow the directions from raspberrypi.org on installing the camera module. http://www.raspberrypi.org/help/camera-module-setup/
Getting streaming working is a tricky affair and involves compiling the raspimjpeg (https://github.com/silvanmelchior/RPi_Cam_Web_Interface) software, but if you follow these steps carefully, you should be OK (provided my steps are correct!).
These instructions are based upon the instructions found on the raspberrypi.org message boards here : http://www.raspberrypi.org/forums/viewtopic.php?t=63276

git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
chmod +x RPi_Cam_Web_Interface_Installer.sh

Before you do the next part, be aware that it overwrites the /etc/rc.local file that we just edited. You should take a backup of it first, or redo adding the VNC line (and any of your own changes you have made to it) to /etc/rc.local afterwards.

./RPi_Cam_Web_Interface_Installer.sh install

This installs a tonne of stuff on your Pi, including the Apache web server. Reboot your Pi, then surf to it using your web browser, and you should see a live picture from your Pi camera module. Wave!



Now the way I started using this was I ran the browser and the VNC session together with the VNC session in the foreground so I could control the Hap-Pi movements and had the stream from the camera visible next to it but in the background.



This is fine for fun, but we are now working on a web interface which runs entirely from the Pi, with no need to use Scratch. It uses Python to control the robot. Watch this space for a write-up (when it’s finished!).