Sunday, February 21, 2021

Logitech Speakerphone with Linux Mint

 My Logitech USB Speakarphone has stopped working since I did something wrong (which I don't remember).  Various troubleshooting and zillions of searches on the Internet did not fix the issue, until today.

The issue was the device did not make any sound at all.  Checking via ALSA and Kernel log said everything was fine as shown below:

$  lsusb

...

Bus 002 Device 011: ID 046d:0a06 Logitech, Inc. 

Bus 002 Device 009: ID 046d:c51c Logitech, Inc. 

...

$ inxi -A

Audio:     Device-1: Intel 82801I HD Audio driver: snd_hda_intel 

           Device-2: ViXS Systems XCode 2100 Series driver: N/A 

           Device-3: AMD Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series] driver: snd_hda_intel 

           Device-4: Logitech type: USB driver: snd-usb-audio 

           Sound Server: ALSA v: k4.15.0-135-generic 


$ dmesg | ack -i Logitech
[    4.347659] usb 2-7.3.1: Manufacturer: Logitech
[    4.351947] input: Logitech VoIP USB Dual RF Receiver as /devices/pci0000:00/0000:00:1d.7/usb2/2-7/2-7.3/2-7.3.1/2-7.3.1:1.0/0003:046D:C51C.0002/input/input5
[    4.408172] hid-generic 0003:046D:C51C.0002: input,hidraw1: USB HID v1.11 Keyboard [Logitech VoIP USB Dual RF Receiver] on usb-0000:00:1d.7-7.3.1/input0
[    4.412142] input: Logitech VoIP USB Dual RF Receiver as /devices/pci0000:00/0000:00:1d.7/usb2/2-7/2-7.3/2-7.3.1/2-7.3.1:1.1/0003:046D:C51C.0003/input/input6
[    4.472241] hid-generic 0003:046D:C51C.0003: input,hiddev1,hidraw2: USB HID v1.11 Mouse [Logitech VoIP USB Dual RF Receiver] on usb-0000:00:1d.7-7.3.1/input1
[    4.744033] usb 2-7.3.2: Product: Logitech EasyCall Speakerphone
[    4.744035] usb 2-7.3.2: Manufacturer: Logitech
[    4.936663] usb 2-7.7.2: Manufacturer: Logitech
[    4.944780] input: Logitech USB Laser Mouse as /devices/pci0000:00/0000:00:1d.7/usb2/2-7/2-7.7/2-7.7.2/2-7.7.2:1.0/0003:046D:C069.0006/input/input9
[    4.944928] hid-generic 0003:046D:C069.0006: input,hidraw5: USB HID v1.10 Mouse [Logitech USB Laser Mouse] on usb-0000:00:1d.7-7.7.2/input0


$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
...
...
card 3: Speakerphone [Logitech EasyCall Speakerphone], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0


$ cat /proc/asound/modules 
 0 snd_aloop
 1 snd_hda_intel
 2 snd_hda_intel
 3 snd_usb_audio


$ cat /proc/asound/cards 
 0 [Loopback       ]: Loopback - Loopback
                      Loopback 1
 1 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xfe7f4000 irq 32
 2 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                      HDA ATI HDMI at 0xfebfc000 irq 33
 3 [Speakerphone   ]: USB-Audio - Logitech EasyCall Speakerphone
                      Logitech Logitech EasyCall Speakerphone at usb-0000:00:1d.7-7.3.2, full speed


Tried to see from Pulse Audio control, it did not show the USB speakerphone device at all.

Turned out it was due to the presence of /etc/asound.conf.  After I renamed it to something else, my audio started to work!

Friday, February 19, 2021

Rename files with Regex rule

 In Linux, there is very powerful tool to rename files based on pattern we specify.  The pattern follows Perl-like regular expression.


For example, if I have files as follow:



01_-_bohemian_rhapsody_-_queen_-_greatest_hits_cd1.mp3

05_-_bicycle_race_-_queen_-_greatest_hits_cd1.mp3

"07_-_it's_a_hard_life_-_queen_-_greatest_hits_cd2.mp3"

09_-_who_wants_to_live_forever_-_queen_-_greatest_hits_cd2.mp3

11_-_the_miracle_-_queen_-_greatest_hits_cd2.mp3

15_-_friends_will_be_friends_-_queen_-_greatest_hits_cd2.mp3

16_-_the_show_must_go_on_-_queen_-_greatest_hits_cd2.mp3

16_-_we_will_rock_you_-_queen_-_greatest_hits_cd1.mp3

17_-_we_are_the_champions_-_queen_-_greatest_hits_cd1.mp3


and I want to rename them by replacing the "_-_" part to be just "-".  The single command to do that is:




$ rename -n -v 's/_-_/-/g' *

rename(01_-_bohemian_rhapsody_-_queen_-_greatest_hits_cd1.mp3, 01-bohemian_rhapsody-queen-greatest_hits_cd1.mp3)

rename(05_-_bicycle_race_-_queen_-_greatest_hits_cd1.mp3, 05-bicycle_race-queen-greatest_hits_cd1.mp3)

rename(07_-_it's_a_hard_life_-_queen_-_greatest_hits_cd2.mp3, 07-it's_a_hard_life-queen-greatest_hits_cd2.mp3)

rename(09_-_who_wants_to_live_forever_-_queen_-_greatest_hits_cd2.mp3, 09-who_wants_to_live_forever-queen-greatest_hits_cd2.mp3)

rename(11_-_the_miracle_-_queen_-_greatest_hits_cd2.mp3, 11-the_miracle-queen-greatest_hits_cd2.mp3)

rename(15_-_friends_will_be_friends_-_queen_-_greatest_hits_cd2.mp3, 15-friends_will_be_friends-queen-greatest_hits_cd2.mp3)

rename(16_-_the_show_must_go_on_-_queen_-_greatest_hits_cd2.mp3, 16-the_show_must_go_on-queen-greatest_hits_cd2.mp3)

rename(16_-_we_will_rock_you_-_queen_-_greatest_hits_cd1.mp3, 16-we_will_rock_you-queen-greatest_hits_cd1.mp3)

rename(17_-_we_are_the_champions_-_queen_-_greatest_hits_cd1.mp3, 17-we_are_the_champions-queen-greatest_hits_cd1.mp3)


(the argument "-n" above is to tell rename not to actually perform renaming, but just to display what it would do).  I use "/g" in the regular expression to tell it to rename all occurrences of "_-_" throughout the file name, not just for the first time it encounters it.

Linux script to display Some information of MP3 files

 The following bash script utilizes mediainfo command line to retrieve various metadata inside an MP3 (or any media file, in fact):


#!/bin/sh

i=0
for f in "$@"
do
    i=$((i+1))
    printf "%d," $i
    mediainfo --Inform="General;%CompleteName%,%Format%,%OverallBitRate_Mode%,%BitRate%,%FileSize/String4%" "${f}"
done





For example (I put the above into a script named 'bitrate.sh'):

$ bitrate.sh *.mp3
1,01_-_bohemian_rhapsody_-_queen_-_greatest_hits_cd1.mp3,MPEG Audio,CBR,256000,10.94 MiB
2,05_-_bicycle_race_-_queen_-_greatest_hits_cd1.mp3,MPEG Audio,CBR,256000,5.612 MiB
3,07_-_it's_a_hard_life_-_queen_-_greatest_hits_cd2.mp3,MPEG Audio,CBR,256000,7.620 MiB
4,09_-_who_wants_to_live_forever_-_queen_-_greatest_hits_cd2.mp3,MPEG Audio,CBR,256000,9.075 MiB
5,11_-_the_miracle_-_queen_-_greatest_hits_cd2.mp3,MPEG Audio,CBR,256000,9.002 MiB
6,15_-_friends_will_be_friends_-_queen_-_greatest_hits_cd2.mp3,MPEG Audio,CBR,256000,7.599 MiB
7,16_-_the_show_must_go_on_-_queen_-_greatest_hits_cd2.mp3,MPEG Audio,CBR,256000,8.048 MiB
8,16_-_we_will_rock_you_-_queen_-_greatest_hits_cd1.mp3,MPEG Audio,CBR,256000,3.741 MiB
9,17_-_we_are_the_champions_-_queen_-_greatest_hits_cd1.mp3,MPEG Audio,CBR,256000,5.542 MiB


The output is in CSV, suitable to be imported as a table in spreadsheet.

Sunday, December 20, 2020

Plex Server inaccessible with LG TV nor Ipone

 I recently had access issue to my Plex server (running on Linux).  It was fine sometime ago, but lately everytime I tried to access it from my LG TV or my phone, they said the server was offline. I'd followed various instructions and troubleshooting I found on the Internet with no luck.  Here is the list of steps I did:

  • Ensure no VPN running on all devices and server
  • Select "Preferred" for secure connection
  • Added my private subnet in the "List of IP addresses and networks that are allowed without auth"
  • Upgrade the Plex server to the latest
  • Restart the server (e.g., "sudo service plexmediaserver restart")
  • Verify I am able to access the server through its IP (e.g, http://192.168.1.103:32400)
  • Enable DLNA server
  • Revert the Plex on TV to last publicly available version
  • Power down TV, wait 2 minutes and turn it back on

Turned out it was due to IPv6 connection was enabled on the Plex server! Once I disabled it, now I could watch my movies or stream my music to other devices.  My LG TV apparently did not support IPv6 yet.

Saturday, November 14, 2020

My Indentation configuration

 The content of $HOME/.indent.pro:


-as

-lp

-bad

-bap

-bbb

-bbo

-bli0

-nbc -c33 -cd33 -ncdb -nce -ci4 -cli0

-c4

-ncdw

-cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i8 -ip0 -l75 -lp -npcs

-nprs -npsl -saf -sai -saw -nsc -nsob -nss

-v

Sunday, July 5, 2020

Refoss Smart Wi-Fi Garage Door Opener

I bought an "add-on" device that will enable my garage door opener accessible via WiFi, as well as other automated processes as part of my home automation project last year.  I bought it on Amazon: https://www.amazon.com/Refoss-Garage-Control-Compatible-Assistant/dp/B07PM59X4J/ref=cm_cr_arp_d_product_top?ie=UTF8&th=1

It had been working perfectly since I installed it last year, but since the last few days ago it has stopped.  I thought it must be something with the networking, so I followed the procedure instructed on the manual to configure it as a new device added to the eHomeLife on my iPhone, but with no luck.  The manual says, if the WiFi LED blinks rapidly, the device has been correctly set to access our home network.  But, I have not been able to connect my app to the device.

Curious to see what was going on, I logged on to my AP router and could see the device had been assigned a valid IP address (192.168.1.55) and I could even ping it.  That's all. I then did nmap to the device to see what ports were open.  I could only see the following:

nmap -O -sO 192.168.1.55
WARNING: Disabling OS Scan (-O) as it is incompatible with the IPProto Scan (-sO)
Starting Nmap 7.80 ( https://nmap.org ) at 2020-07-05 21:44 Pacific Daylight Time
Nmap scan report for 192.168.1.55
Host is up (0.021s latency).
Not shown: 252 closed protocols
PROTOCOL STATE         SERVICE
1        open          icmp
6        open          tcp
17       open          udp
41       open|filtered ipv6
MAC Address: 48:E1:E9:51:07:50 (Chengdu Meross Technology)

Actually, if I press the WiFi button for more than 5 seconds to make it goes to configuration mode and then use the SSID of the device (it becomes an "AP" device temporarily), then open a browser to access it (at IP address 10.10.10.1, because my phone's IP was assigned 10.10.10.2), I could see basic web interface to set WIFI as well as to upgrade firmware.

Googling for "Meross" or "Refoss" firmware couldn't give anything.  The company's website also doesn't give any link or information about any firmware upgrade.  Also, What's the difference between "Meross" and "Refoss"? Is Refoss is a knock-off of Meross?  Both are Chinese companies.

Honestly, I am now tempted to develop a similar by myself, probably using ESP32 (as using Raspberry-Pi for such thing is too much for such thing, not to consider more power-hungry).