WiFi stereo Internet Digital Radio Player with web interface

sezione dedicata ai sistemi operativi alternativi Open Source

Re: WiFi stereo Internet Digital Radio Player with web inter

Messaggio da leggereda root » 08/09/2016, 19:37

Improve use of memory and increase stability of the Internet Radio by using Zram.

zram (also called zRAM and, initially, compcache) is a Linux kernel feature that provides a form of virtual memory compression. zram increases performance by avoiding paging to disk and using a compressed block device in RAM instead, inside which paging takes place until it is necessary to use the swap space on a hard disk drive. Since using zram is an alternative way to provide swapping on RAM, zram allows Linux to make a better use of RAM when swapping/paging is required, especially on older computers with less RAM installed.
zram offers advantages for low-end hardware devices such as embedded devices, such devices usually use flash-based storage, which has limited lifespan due to write amplification, and also use it to provide swap space. The reduction in swap usage as a result of using zram effectively reduces the amount of wear placed on such flash-based storage, resulting in prolonging its usable life. Also, using zram results in a significantly reduced I/O for Linux systems that require swapping.
Google uses zram in Android since its version 4.4

In our case it stops the router from beeing reset by watchdog/low memory and "virtually" increase the total free RAM available ;)
Zram uses a little CPU power but in our case we have no problem with CPU, we have shortage of RAM instead, so it's a perfect solution!
-----------------------------------------------

OpenWRT Barrier Breaker install instructions:

prerequisites: you need at least 300 Kbytes of free flash space, check it with "df" command.

opkg update
opkg install zram-swap


then reboot.

After reboot you'll have a device called /dev/zram0

check free memory with "free" command, you should get something like this:

root@(none):/dev# free
total used free shared buffers
Mem: 28860 27724 1136 0 1244
-/+ buffers: 26480 2380
Swap: 0 0 0


now insert the following lines right at the begginning of the file "/etc/rc.local" to activate a Zram of 10 Megabytes:

/bin/echo $((10*1024*1024)) > /sys/block/zram0/disksize
/usr/sbin/mkswap /dev/zram0
/usr/sbin/swapon /dev/zram0


Reboot the router and check again with "free" command:

root@(none):/dev# free
total used free shared buffers
Mem: 28860 27376 1484 0 1248
-/+ buffers: 26128 2732
Swap: 10236 0 10236



That's all :)


Note, if your router has more of 32 Mbytes of RAM, you may increase the Zram size, the best choice is about 30% of total ram.
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Re: WiFi stereo Internet Digital Radio Player with web inter

Messaggio da leggereda root » 28/12/2016, 16:36

Add an external serial LCD display to our Internet Radio (first part)


To display the current MPD channel and the playing song, this is the command:

while true; do mpc current | tr '\012' '\015'; sleep 1; done
(real time output)

or if you want a more exaustive output:

echo "currentsong" | nc localhost 6600
(one shoot output)

or even:

echo "currentsong" | nc localhost 6600 | grep -e "^Title: " -e "^Name: "

you can redirect this information to an output device connected to the router's serial port, by this way:

while true; do mpc current | tr '\012' '\015'; sleep 1; done > /dev//dev/ttyATH0

However, the serial port’s default speed of 115200 baud is too fast for some external serial displays, so we need to change the speed of the serial port from it’s default value of 115200 to 9600 baud.
This can be easily done by using the "stty" command.

First you need to install stty with the following commands:

opkg update
opkg install coreutils-stt


then you can change the speed of the serial port by adding the following command to "/etc/rc.local" just before the "exit 0" line:

/usr/bin/stty -F /dev/ttyATH0 9600 clocal cread cs8 -cstopb -parenb

to check that the speed has been correctly set at 9600 baud, use the following comand:

/usr/bin/stty -F /dev/ttyATH0
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Re: WiFi stereo Internet Digital Radio Player with web inter

Messaggio da leggereda root » 28/12/2016, 16:36

where to find the internal connections for the serial port of our Internet Radio (TP-Link TL-WR 710):

TP_IN = Rx (NOTconnected)
TP_OUT= Tx to be connected to Rx pin of the display
GND = USB metal case (big solder pad under USB port)
5 Vcc to power out the external LCD display = square solder pad under C209 (see picture)

Note that the internal serial is 3.3V-logic, so we need a serial display that has the same 3.3 V signal voltage.

Immagine
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Re: WiFi stereo Internet Digital Radio Player with web inter

Messaggio da leggereda root » 28/12/2016, 16:37

Immagine

Immagine
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Re: WiFi stereo Internet Digital Radio Player with web inter

Messaggio da leggereda root » 30/12/2016, 23:44

You'll find all files for configuring my Internet Radio (as described above) here:

http://www.lovisolo.com/asterisk/software/openwrt/Radio-Internet/

The above configuration files work for A.A., B.B. and C.C. OpenWRT releases, just overwrite the original ones (if present) and copy all the other files in the same directories of your router.
To move the files to your router install vsftpd, start it then connect it with your preferred FTP client (use the router's root credentials), or else use wget from inside the router.
You'll also find the modified firmware for the TP-Link TL-WR710n router, but you can use any model of OpenWRT compatible router to make this radio.


my Triggerhappy configuration file is programmed to work with this type of USB keypad:

Immagine

Key Enter = start playing MPD (first station listed in /etc/rc.local)
Key Slash (/) = next station (there are 42 stations already listed)
Key Asterisk (*) = prev station
Key + = Volume up: +2% for each press
Key - = Volume down: -2% for each press
Key Backspace (<-) = mute: lower the volume at minimum audible level
Ket dot/Del (.) = stop playing

Keys 0 to 9 = 10 preset stations (my 10 preferred stations ;) )

and also to work with with this infrared remote command (optional):
Note: it is better to fisically remove (or cut it at the top) the red power key because it crashes triggerhappy when pressed :(

Immagine

Press once "NumLook" key to enable 0-9 keys (preset stations),
blue keys "page up" and "page down" = mpd "next" and "prev" station,
key ||> (above fullscreen key) = mpd "play first station",
key "square" (next to play key) = "stop" playing.



This is the best sounding USB audio adapter I found:

Immagine

but you can also use one of those two:

Immagine

Immagine


This is the web interface you see when you connect to http://router-ip-address/music
by this interface you can play/stop and change radio stations, also you can see the station, the artist and song that is currently playing.

Immagine


This is the vacuum tubes Hi-Fi amplifier I designed and built specifically for this internet radio (the router is located inside),
I think it is probably the only one Brand New Vacuum Tubes Hi-Fi Stereo Internet Radio in the whole world :D

Immagine

in case you want to build it ;) this is the schematic I designed (one channel) [be careful!! HIGH VOLTAGE 500 Vac max]:

Immagine

Happy listening :)
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Re: WiFi stereo Internet Digital Radio Player with web inter

Messaggio da leggereda root » 31/12/2016, 11:57

If you want to see in real time (updated every second) the WiFi signal in client mode of your router, this is the shell single line "multi-commands" for you:

while true; do iw dev wlan0 station dump | grep -i signal: | tr '\012' '\015'; sleep 1; done
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Router says local & public IP addresses through the speakers

Messaggio da leggereda root » 02/01/2017, 23:30

Since my router is without any display, I was wondering how I could find the WAN IP address (dhcp) of the router.
The answer was to use a text to speech engine and let the router to say the ip address through the speakers. :)
By googling I found a very good and light TTS (text to speech) for Openwrt, so I created two scripts to have the router to say the current IP addresses (local and public), at startup or at request by pressing a button.
Svox (pico2wave) is an offline text-to-speech engine with good voices in many languages, you can simply change language by using the -l parameter, example: "-l de-DE" speaks German, "-l fr-FR" speaks French, "-l es-ES" speaks Spanish, "-l it-IT" speaks Italian, and so on, default langage is English: "-l en-US".
Svox unfortunately is only available on Chaos Calmer, so if you have installed A.A or B.B. OpenWRT releases, you can't use it without upgrading to C.C.

Quick How-To:

You just need to install svox and some other packages (you probably have already installed) on the OpenWRT router.
Note: svox needs a lot of space, so if you don't have at least 5 megabytes of free space, you need to use an external USB overlay.

opkg update
opkg install svox
opkg install kmod-sound-core
opkg install kmod-usb-audio
opkg install alsa-utils


then create the following two scripts:

vi say-local-ip.sh

#!/bin/sh
IP=$(/sbin/ifconfig br-lan | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
cadena=$(echo $IP | sed 's/\.1\./\.one\./g')
cadena=$(echo $cadena | sed 's/\./point/g')
pico2wave -l en-US -w /tmp/text.wav "the Local IP address is "$cadena
aplay -f S16_LE -D plughw:0,0 /tmp/text.wav


note: eventually change "br-lan" with your LAN interface name, discover it with "ifconfig" command.

vi say-public-ip.sh

#!/bin/sh
IP=$(wget http://ipecho.net/plain -O - -q ; echo)
cadena=$(echo $IP | sed 's/\.1\./\.one\./g')
cadena=$(echo $cadena | sed 's/\./point/g')
pico2wave -l en-US -w /tmp/text.wav "the Public IP address is "$cadena
aplay -f S16_LE -D plughw:0,0 /tmp/text.wav


save and give them the right permissions:

chmod 755 say-local-ip.sh
chmod 755 say-public-ip.sh

then you can test both scripts:

/bin/sh /root/say-local-ip.sh
/bin/sh /root/say-public-ip.sh


you shoud hear a female voice saying your local and public IP addresses through the speakers.

--------------------------------------------------------------------------------

Scripts in Italian:

ip-pubblico.sh:

#!/bin/sh
IP=$(wget http://ipecho.net/plain -O - -q ; echo)
cadena=$(echo $IP | sed 's/\.1\./\.uno\./g')
cadena=$(echo $cadena | sed 's/\./punto/g')
pico2wave -l it-IT -w /tmp/text.wav "il tuo indirizzo IP pubblico e' '"$cadena
aplay -f S16_LE -D plughw:0,0 /tmp/text.wav


ip-locale.sh:

#!/bin/sh
IP=$(/sbin/ifconfig br-lan | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
cadena=$(echo $IP | sed 's/\.1\./\.uno\./g')
cadena=$(echo $cadena | sed 's/\./punto/g')
pico2wave -l it-IT -w /tmp/text.wav "il tuo indirizzo IP privato e' '"$cadena
aplay -f S16_LE -D plughw:0,0 /tmp/text.wav


--------------------------------------------------------------------------

Ref.: http://openwrt.tuinstituto.es/script-para-reproduccion-por-altavoces-de-nuestra-direccion-ip-publica (in Spanish)
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Re: WiFi stereo Internet Digital Radio Player with web inter

Messaggio da leggereda root » 03/01/2017, 20:53

Following the previous post I've created an hotplug trigger that, when an hardware key is pressed on the router, it says the local and the public IP addresses through the speakers.
This is an example how to attach to the WiFi button of the router Huawei EchoLife HG553 (Vodafone Station) the above function, if the button is pressed for less than 1 second, the router says the local (LAN) IP address, if the button is pressed for more than two seconds, the router says the public (WAN) IP address.

I've just edited the "/etc/rc.button/rfkill" file in this way:

#!/bin/sh

[ "${ACTION}" = "released" ] || exit 0

. /lib/functions.sh

logger "$BUTTON pressed for $SEEN seconds"

if [ "$SEEN" -lt 1 ]
then
/root/say-local-ip.sh


elif [ "$SEEN" -gt 2 ]
then
/root/say-public-ip.sh
fi


return 0
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

How to remove the stupid vi as a default editor and use nano

Messaggio da leggereda root » 08/01/2017, 14:16

opkg update
opkg install nano
mv /bin/vi /bin/vi.stupid
ln -s /usr/bin/nano /bin/vi


;)
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 347
Iscritto il: 10/04/2012, 10:55
Località: Ovada

PrecedenteProssimo

Torna a OpenWRT e sistemi operativi vari

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite

cron