Friday 15 October 2021

Sky IPV6 on Mikrotik

 Sky UK IPv6 

Researching different techniques to make Sky UK use IPv6, this is what I used. After setting up the DHCPv6 client and the options.. the rest got routing working..

 

Setting IPv6 on Mikrotik

If your ISP offers IPv6 and you have Mikrotik router, it would be shame not to make use of it. My setup assumes you get /64 prefix from your ISP (Comcast in my case) via DHCPv6. Also assumed is empty IPv6 configuration.

First I like to disable default neighbor discovery interface. Blasting IPv6 router advertisements on all intefaces is not necessarily a good idea:

/ipv6 nd
set [ find default=yes ] disabled=yes

Next step is to setup DHCP client. Withing a few seconds, you should see the prefix being allocated:

/ipv6 dhcp-client
add add-default-route=yes interface=ether1 pool-name=general-pool6 request=prefix
:delay 5s
print
Flags: D - dynamic, X - disabled, I - invalid
# INTERFACE STATUS REQUEST PREFIX
0 ether1 bound prefix 2601:600:9780:ee2c::/64, 3d14h41m41s

At this time I love to allocate address ending with ::1 to the router itself:

/ipv6 address
add address=::1 from-pool=general-pool6 interface=bridge1 advertise=yes

Now it should be possible to ping its address from external computer (in this example address would be 2601:600:9780:ee2c::1). If this doesn’t work, do check if you have link-local addresses. If none are present, reboot the router and they will be regenerated.

With router reachable, it is time to delegate IPv6 prefix to internal machines too. For this purpose, setup RA (router announcement) over the bridge. While default interval settings are just fine, I like to make them a bit shorter (20-60 seconds):

/ipv6 nd
add interface=bridge1 ra-interval=20s-60s

And that’s all. Now your computers behind the router will have direct IPv6 route to the Internet. Do not forget to setup both router firewall and firewall of individual devices. There is no NAT to save your butt here.

PS: Here is the basic IPv6 firewall allowing all connections out while allowing only established back in:

/ipv6 firewall filter
add chain=input action=drop connection-state=invalid comment="Drop (invalid)"
add chain=input action=accept connection-state=established,related comment="Accept (established, related)"
add chain=input action=accept in-interface=ether1 protocol=udp src-port=547 limit=10,20:packet comment="Accept DHCP (10/sec)"
add chain=input action=drop in-interface=ether1 protocol=udp src-port=547 comment="Drop DHCP (>10/sec)"
add chain=input action=accept in-interface=ether1 protocol=icmpv6 limit=10,20:packet comment="Accept external ICMP (10/sec)"
add chain=input action=drop in-interface=ether1 protocol=icmpv6 comment="Drop external ICMP (>10/sec)"
add chain=input action=accept in-interface=!ether1 protocol=icmpv6 comment="Accept internal ICMP"
add chain=input action=drop in-interface=ether1 comment="Drop external"
add chain=input action=reject comment="Reject everything else"
add chain=output action=accept comment="Accept all"
add chain=forward action=drop connection-state=invalid comment="Drop (invalid)"
add chain=forward action=accept connection-state=established,related comment="Accept (established, related)"
add chain=forward action=accept in-interface=ether1 protocol=icmpv6 limit=20,50:packet comment="Accept external ICMP (20/sec)"
add chain=forward action=drop in-interface=ether1 protocol=icmpv6 comment="Drop external ICMP (>20/sec)"
add chain=forward action=accept in-interface=!ether1 comment="Accept internal"
add chain=forward action=accept out-interface=ether1 comment="Accept outgoing"
add chain=forward action=drop in-interface=ether1 comment="Drop external"
add chain=forward action=reject comment="Reject everything else"

 

Sunday 3 January 2021

HomeAssistant - ESPHome IR Controller SkyQ

 Using ESPHome IR for SkyQ

Using the ESPHome project, the Infrared plugin allows me to control my TV, Soundbox and SkyQ devices quite easily.
 

The Build

A simple build.. two IR transmitters and an optional IR receiver which I used to read the codes from my existing IR remote.

The ESP32 doesn't source enough current to light up the LED's to be useful, but a simple transistor driver solves that. I wont elaborate more as here is a link to a website that explains it better. Driving an IR

The diagram I used

The YAML

 
The IR.YAML link below contains the configuration for many of the keys.
 
Download the file and edit. Set your SSID and password. Customise for your GPIO input/outputs and run.
 
 

HomeAssistant




 

Saturday 2 January 2021

ESP32 Measuring gait symetery for performance - People or Horses

 Gait symmetry analysis using ESP32




Why!

I was pondering a method that could tell if I was favouring one side or the the other when running. For horses, it can tell if its lame as the symmetry whilst trotting will be mismatched.

Design

Using an ESP32, it has a nice MESH feature called ESPNOW. This allows an almost realtime transmission of data between nodes.

For this project, a MAIN node is plugged in to a PC via USB. This node controls the outstations.

NODEs are ESP32 devices with gyro sensors attached. These have the capability to record the X, Y and Z axis of motion,  but for this - I am only using one axis. (Although all 3 can be used as its the difference in the 2 sensors that are used)

Units have batteries, chargers and all the paraphernalia to last a few hours.


Taking measurements

Tucking the units in to my sock, I done a quick few laps of the garden. They weren't comfortable, but thats the nature of the prototype

Data

Making sense of the noise, I picked a simple FFT.  the Data is from myself running in my garden for about 30 seconds. Samples are at 10Hz for left and right leg.

 FFT

Using the data collected, the FFT plots for the left and right leg.

Sunday 18 October 2020

XILINX FPGA programming from Linux

Xilinx Playform Cable II - FPGA JTAG Programmer


Platform Cable USB II Data Sheet (DS593)


For linux, the older FPGA instructions dont work anymore - below is the replacement.

mkdir ~/Xilinx
cd ~/Xilinx/
git clone git://git.zerfleddert.de/usb-driver
cd usb-driver/
sudo apt-get install fxload libusb-dev
make
./setup_pcusb /opt/Xilinx/14.7/ISE_DS/ISE   <------------- YOUR PATH HERE
sudo udevadm control --reload-rules

Unplug and replug - and you should see a red light.

export LD_PRELOAD=/opt/Xilinx/usb-driver/libusb-driver.so
ise

 

Happy Verilogging! 

Saturday 9 May 2020

DMR Hotspot - with Retevis RT3

Duplex MMDVM PiStar HAT (with Retevis RT3)

I decided to get in to DMR radio, this I thought was a good idea at the time and due to the local repeater being out of comission, I bought a DMR hotspot on Ebay. You have to realise I knew nothing about DMR at the time apart from the theory of operation.

Simplex and Duplex DMR MMDVM hats..


 I selected the Duplex version of the MMDVM as what is better than simplex!  That where things went awry. I later on bought a simplex radio just for comparisons (but that is now fitted with Nextion display) 

 Conclusion.. (read down for more of the detail)

The Retevis RT3  handheld radio using stock firmware and the Pistar MMDVM Duplex hat do not play nicely together. I ended up configuring the duplex radio as a SIMPLEX and disconnected antenna 2.





The Saga..

 Plugged in and running..

Challenge 1:

On the packet, there was a crystal offset of -474. Using that number in PiStar,  the radio would connect but the bit error rate was high. Pulling out the SDR and running pistart-mmdvmcal application to output a carrier, the actual error is -400.  Voila!, BER was below 1%

Challenge 2:

Using the pistar mmdvm upgrade application, it failed to initiatlise the hardware completely!




The board would not flash the new firmware. To fix, a solder-blob needed to be placed to allow upgrades to happen. (Red Circle!)




Challenge 3:

I Failed!  Using the Duplex radio with a Retevis RT3 radio, keying up and talking work a treat - but after a few minutes audio stops working. I really dont know how to make it work properly with this radio as all calibrations I tried failed.


Notes

If you know how to get it to work in Duplex mode and still have audio after an hour, I would love to hear from you! Two handheld radios below.. one linked to a Simplex Hotspot, the other a duplex. Both are on the same TG91 Talkgroup. After a few minutes, the duplex handheld goes silent. To resotore audio, PTT needs to be keyed.



Thursday 26 December 2019

Yaesu 450D CAT Control

CAT Control on Yaesu 450D

Equipment needed

A PC, RS232 cables and luck..
Nothing special on the PC is needed. A simple USB->RS232 adapter and a CAT audio interface to connect to the data port. I used a Line In/Out audio interface to connect as I didn't have get the quality I wanted from a Microphone input on a cheap-n-nasty interface.

Audio Interface (PC)

 



The Behringer UCA202 from Ebay was picked as it used Line input and output levels. The interface is more suited for 600 Ohm line terminations that the Yaesu prefers.









For the Radio, I used the diagram at this site to connect to two RCA plugs. I tried with and without 600Ohm audio transformers but I didn't see any performance difference.


Digital interface

Nothing special here... a 1:1 straight through cable is needed. Pins 2,3,5 and 7,8 are wired 1:1 on a Female to Female DB-9 and that's all



PC Software

As most of the time I am on FT8 or WSPR, I will be showing how WSJT software setup works. I have had very ropey results with the CAT software and things go bad quite often.

To setup the PC, (WSJT-X)



I originally left everything at DEFAULT but that seemed to be the cause of randomness. I ended up adding an oscilloscope trace to the serial port and noticed that data was not being received properly - and thats when I realised things were not good.

Playing with numbers, I managed to get it all working again using 8 Data Bits, 2 Stop Bits and no handshaking

I set the baud rate to 4800 baud to give the best chance of good data over the link. 

The Radio

On the radio, using the (F)unction menu, The option CAT TOT was set to 1000 (its defaulted at 10) and CAT RTS/CTS was disabled
















Saturday 2 November 2019

[Linux] Automounting NFS using PAM_EXEC

Linux - Using PAM_EXEC to mount userspaces


PAM_EXEC - What is it?

On a Linux box, users are authenticated via a PAM module. These modules check passwords, and do tasks before the shell is presented.
PAM_EXEC will allow you to run a script when the user logs on/out or changes passwords.

My Mission

The main aim was to mount a NFS space under the users $HOME directory when they login. This allows for shared storage to be used and no-matter what server the user logs in to, their NFS shares are present.

My script

A file named  /usr/local/bin/mounthome.sh with the below contents. Set the file permissions to execute using chmod +x /usr/local/bin/mounthome.sh

Change the mount server and volumes to suit your own server needs. The below will create a directory called nfs and mount the NFS server under it

 

#!/bin/bash
#   
#        "User: $PAM_USER"
#        "Remote Host: $PAM_RHOST"
#        "Service: $PAM_SERVICE"
#        "TTY: $PAM_TTY"

if [ "$PAM_TYPE" == "open_session" ]
then
        mkdir /home/$PAM_USER/nfs
        mount -t nfs -o user server.local:/volume1/$PAM_USER /home/$PAM_USER/nfs
        chmod 777 /home/$PAM_USER/nfs
        chown $PAM_USER:$PAM_USER /home/$PAM_USER/nfs
fi

if [ "$PAM_TYPE" == "close_session" ]
then
        umount /home/$PAM_USER/nfs
fi

exit 0


Executing it using PAM

Modify /etc/pam.d/common-session file accordingly:

session    optional     pam_exec.so    /usr/local/bin/mounthome.sh

And thats all it takes!