HOSTNAME

http://www.howtogeek.com/167195/how-to-change-your-raspberry-pi-or-other-linux-devices-hostname/

make your user part of the openhab group to be able to edit config files using openhag designer using a share:
useradd username group-name

SAMBA

To share your openhab config to your pc running openhad designer:
http://raspberrypihq.com/how-to-share-a-folder-with-a-windows-computer-from-a-raspberry-pi/

http://superuser.com/questions/271034/list-samba-users

Do smbstatus as SUDO; normal user can not get access and get a NT_STATUS_ACCESS_DENIED
sudo smbstatus

sudo vi /etc/samba/smb.conf

sudo pdbedit -Lv

sudo service smbd restart

sudo smbd -b | grep PRIVATE_DIR
PRIVATE_DIR: /var/lib/samba/private

See
https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/install.html

Added to standard config, but encrypt should be defualt yes
encrypt passwords = yes

To be able to use to edit the config files in /etc/openhab2, change owner and group of this folder to ‘openhab’, and set permissition for this folder
sudo chmod g+w /etc/openhab2

sudo smbpasswd -a
sudo usermod -a -G openhab

And at end:
[OpenHABShare]
comment=OpenHAB Configuration Share
path=/etc/openhab2
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
available=yes

OpenHAB2

Automation/Orchestration Design Patterns
https://community.openhab.org/t/automation-orchestration-design-patterns/1967/20

https://github.com/openhab/openhab/wiki/Samples-Tricks#how-start-openhab-automatically-on-linux-using-systemd

systemctl status openhab.service

tail -f /etc/openhab2/userdata/logs/openhab.log

OpenhabDesigner windows on Raspberry by

Add (empty) file ‘openhab_default.cfg’ to /etc/openhab2
https://community.openhab.org/t/using-openhab-designer-on-windows-with-openhab-on-linux/4687/3

openhab sample rules

next turns on lights on motion with timeout and switch items..
https://github.com/openhab/openhab/wiki/Taking-Rules-to-New-Heights

Auto reboot pi

sudo crontab -e
sudo crontab -l

30 1 * * * sudo reboot

http://docs.openhab.org/administration/console.html

https://mysmarthomeweb.wordpress.com/2016/07/31/small-examples-yahoo-weather-ntp-and-systems-service/

KARAF:
ssh openhab@localhost -p 8101

restart to reread config files:
bundle:list -s
bundle:restart org.eclipse.smarthome.model.core

BT+Wifi adapter
https://sites.google.com/site/easylinuxtipsproject/reserve-7

Mopidy and Spotifyd

$ sudo systemctl status mopidy.service
● mopidy.service - Mopidy music server
   Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
   Active: active (running) since
  Process:  ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS)
  Process:  ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS)
 Main PID:  (mopidy)
   CGroup: /system.slice/mopidy.service
           ├─ /usr/bin/python /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf
           ├─ dbus-daemon --fork --session --print-address=1 --print-pid=1
           └─ /usr/lib/dleyna-server/dleyna-server-service
systemctl --user enable spotifyd.service
systemctl --user start spotifyd.service

To run at startup

sudo loginctl enable-linger [USER]
$ systemctl --user status spotifyd.service
● spotifyd.service - A spotify playing daemon
   Loaded: loaded (
/etc/systemd/user/spotifyd.service
; enabled; vendor preset: enabled) Active: active (running) since Tue 2018-08-07 22:38:10 CEST; 22s ago Docs: https://github.com/Spotifyd/spotifyd Main PID: 729 (spotifyd) CGroup: /user.slice/user-1001.slice/user@1001.service/spotifyd.service └─729 /usr/bin/spotifyd --no-daemon -c /etc/spotifyd.conf Aug 07 22:38:10 xxx systemd[653]: Started A spotify playing daemon. Aug 07 22:38:10 xxx spotifyd[729]: 22:38:10 [INFO] Using alsa volume controller. Aug 07 22:38:10 xxx spotifyd[729]: 22:38:10 [INFO] Connecting to AP "gew1-accesspoint-b-sp6x.ap.spotify.com:4070" Aug 07 22:38:10 xxx spotifyd[729]: 22:38:10 [INFO] Authenticated as "xxx" ! Aug 07 22:38:10 xxx spotifyd[729]: 22:38:10 [INFO] Using alsa sink Aug 07 22:38:11 xxx spotifyd[729]: 22:38:11 [INFO] Country: "xx"
$ cat /etc/asound.conf

pcm.hifiberry {
  type hw
  card 2
} 

pcm.dmixer {
  type dmix
  ipc_key 321456 # any unique value
  ipc_key_add_uid false # let multiple users share
  ipc_perm 0666 # mixing for all users
  slave {
    pcm "hifiberry"
    channels 2
    period_time 0
    period_size 1024
    rate 44100
    #buffer_size 4096 # needs to be set!
    buffer_size 16384
  }
  bindings {
    0 0
    1 1
  }
}

pcm.equalizer {
  type equal
  slave.pcm "plug:dmixer"
}

pcm.!default {
  type plug
  #slave.pcm "dmixer"
  slave.pcm equalizer
}

ctl.!default {
  type hw
  card 2
}

ctl.dmixer {
  type hw
  card 2
}

ctl.equal {
  type equal;
}
sudo cat /etc/mopidy/mopidy.conf


mixer = alsamixer
mixer_volume = 100
output = alsasink
buffer_time = [alsamixer] enabled=true card=2 control=Digital min_volume = 0 max_volume = 80 volume_scale = cubic

Bind port 80 to 6680:

https://serverfault.com/questions/112795/how-to-run-a-server-on-port-80-as-a-normal-user-on-linux

$ sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 6680
$ sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 6680
 $ cat /etc/systemd/user/spotifyd.service
[Unit]
Description=A spotify playing daemon
Documentation=https://github.com/Spotifyd/spotifyd
After=avahi-daemon.service
After=dbus.service
After=network.target
After=nss-lookup.target
After=pulseaudio.service
After=remote-fs.target
After=sound.target
After=mopidy.service

[Service]
ExecStart=/usr/bin/spotifyd --no-daemon -c /etc/spotifyd.conf
Restart=always
RestartSec=12

[Install]
WantedBy=default.target

$ cat /etc/spotifyd.conf
[global]
username = xxx
password = yyy
backend = alsa
device = default
mixer = Digital
volume-control = alsa # or alsa_linear, or softvol
#onevent = command_run_on_playback_event
device_name = zzz
bitrate = 96|160|320
cache_path = cache_directory
volume-normalisation = false
normalisation-pregain = 1

Additional thoughts
https://github.com/chundermike/rotary_alsa_volume/blob/master/rotary_alsa_volume.c
https://www.linuxquestions.org/questions/slackware-14/alsa-with-pre-amp-4175527907/
Just test mic input using some source:
https://bbs.archlinux.org/viewtopic.php?id=127048
https://askubuntu.com/questions/393234/turn-off-audio-loopback-from-microphone

And two softvol
https://forums.gentoo.org/viewtopic-t-842120-start-0.html
http://mailman.alsa-project.org/pipermail/alsa-devel/2008-April/007069.html

And for bluetooth support
https://www.instructables.com/id/Turn-your-Raspberry-Pi-into-a-Portable-Bluetooth-A/
https://www.raspberrypi.org/forums/viewtopic.php?t=191019

HifiBerry Amp2

Headless RPi install

https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0
https://www.raspberrypi.org/documentation/installation/installing-images/README.md
https://etcher.io/

https://www.raspberrypi.org/forums/viewtopic.php?t=97314

Select “Advanced Options” from the menu, then either “SPI” or “I2C”, and enable the interfaces there. If you want the driver modules to load automatically (and you probably do) then answer “Yes” to the follow-up question. raspi-config can also be used to disable and re-enable Device Tree.

distributing audio:
https://github.com/badaix/snapcast

https://github.com/pimusicbox/pimusicbox/tree/master

https://docs.mopidy.com/en/latest/installation/debian/#debian-install

ALSA
https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=143528

Set default output:

https://superuser.com/questions/626606/how-to-make-alsa-pick-a-preferred-sound-device-automatically

> cat /proc/asound/cards
0 [ALSA ]: bcm2835 – bcm2835 ALSA
bcm2835 ALSA
1 [sndrpihifiberry]: HifiberryDacp – snd_rpi_hifiberry_dacplus
snd_rpi_hifiberry_dacplus

$ cat /proc/asound/modules
0 snd_bcm2835
1 snd_soc_hifiberry_dacplus

$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
hifiberry
dmixer
default
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
dmix:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample mixing device
dmix:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample snooping device
hw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Hardware device with all software conversions
sysdefault:CARD=sndrpihifiberry
snd_rpi_hifiberry_dacplus,
Default Audio Device
dmix:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus,
Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus,
Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus,
Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus,
Hardware device with all software conversions

$ amixer
Simple mixer control ‘DSP Program’,0
Capabilities: enum
Items: ‘FIR interpolation with de-emphasis’ ‘Low latency IIR with de-emphasis’ ‘High attenuation with de-emphasis’ ‘Fixed process flow’ ‘Ringing-less low latency FIR’
Item0: ‘Low latency IIR with de-emphasis’
Simple mixer control ‘Analogue’,0
Capabilities: pvolume
Playback channels: Front Left – Front Right
Limits: Playback 0 – 1
Mono:
Front Left: Playback 1 [100%] [0.00dB]
Front Right: Playback 1 [100%] [0.00dB]
Simple mixer control ‘Analogue Playback Boost’,0
Capabilities: volume
Playback channels: Front Left – Front Right
Capture channels: Front Left – Front Right
Limits: 0 – 1
Front Left: 1 [100%] [0.80dB]
Front Right: 1 [100%] [0.80dB]
Simple mixer control ‘Auto Mute’,0
Capabilities: pswitch
Playback channels: Front Left – Front Right
Mono:
Front Left: Playback [on]
Front Right: Playback [on]
Simple mixer control ‘Auto Mute Mono’,0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control ‘Auto Mute Time Left’,0
Capabilities: enum
Items: ’21ms’ ‘106ms’ ‘213ms’ ‘533ms’ ‘1.07s’ ‘2.13s’ ‘5.33s’ ‘10.66s’
Item0: ’21ms’
Simple mixer control ‘Auto Mute Time Right’,0
Capabilities: enum
Items: ’21ms’ ‘106ms’ ‘213ms’ ‘533ms’ ‘1.07s’ ‘2.13s’ ‘5.33s’ ‘10.66s’
Item0: ’21ms’
Simple mixer control ‘Clock Missing Period’,0
Capabilities: enum
Items: ‘1s’ ‘2s’ ‘3s’ ‘4s’ ‘5s’ ‘6s’ ‘7s’ ‘8s’
Item0: ‘1s’
Simple mixer control ‘Deemphasis’,0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control ‘Digital’,0
Capabilities: pvolume pswitch
Playback channels: Front Left – Front Right
Limits: Playback 0 – 207
Mono:
Front Left: Playback 124 [60%] [-41.50dB] [on]
Front Right: Playback 124 [60%] [-41.50dB] [on]
Simple mixer control ‘Max Overclock DAC’,0
Capabilities: volume volume-joined
Playback channels: Mono
Capture channels: Mono
Limits: 0 – 40
Mono: 0 [0%]
Simple mixer control ‘Max Overclock DSP’,0
Capabilities: volume volume-joined
Playback channels: Mono
Capture channels: Mono
Limits: 0 – 40
Mono: 0 [0%]
Simple mixer control ‘Max Overclock PLL’,0
Capabilities: volume volume-joined
Playback channels: Mono
Capture channels: Mono
Limits: 0 – 20
Mono: 0 [0%]
Simple mixer control ‘Volume Ramp Down Emergency Rate’,0
Capabilities: enum
Items: ‘1 sample/update’ ‘2 samples/update’ ‘4 samples/update’ ‘Immediate’
Item0: ‘1 sample/update’
Simple mixer control ‘Volume Ramp Down Emergency Step’,0
Capabilities: enum
Items: ‘4dB/step’ ‘2dB/step’ ‘1dB/step’ ‘0.5dB/step’
Item0: ‘4dB/step’
Simple mixer control ‘Volume Ramp Down Rate’,0
Capabilities: enum
Items: ‘1 sample/update’ ‘2 samples/update’ ‘4 samples/update’ ‘Immediate’
Item0: ‘1 sample/update’
Simple mixer control ‘Volume Ramp Down Step’,0
Capabilities: enum
Items: ‘4dB/step’ ‘2dB/step’ ‘1dB/step’ ‘0.5dB/step’
Item0: ‘1dB/step’
Simple mixer control ‘Volume Ramp Up Rate’,0
Capabilities: enum
Items: ‘1 sample/update’ ‘2 samples/update’ ‘4 samples/update’ ‘Immediate’
Item0: ‘1 sample/update’
Simple mixer control ‘Volume Ramp Up Step’,0
Capabilities: enum
Items: ‘4dB/step’ ‘2dB/step’ ‘1dB/step’ ‘0.5dB/step’
Item0: ‘1dB/step’

$ amixer sget Digital
Simple mixer control ‘Digital’,0
Capabilities: pvolume pswitch
Playback channels: Front Left – Front Right
Limits: Playback 0 – 207
Mono:
Front Left: Playback 124 [60%] [-41.50dB] [on]
Front Right: Playback 124 [60%] [-41.50dB] [on]

alsamixer

> aplay -l | awk -F \: ‘/,/{print $2}’ | awk ‘{print $1}’ | uniq
ALSA
sndrpihifiberry

> cat /proc/asound/modules
0 snd_bcm2835
1 snd_soc_hifiberry_dacplus

https://support.hifiberry.com/hc/en-us/community/posts/206509299-Raspbian-Amp-no-sounds

We often see people having problem with speaker-test. I recommend sox.
sudo apt-get install sox
play -n synth sine 1000

Using Raspbian no Master and Channels, but Digital:
> amixer get Digital
> amixer sset Digital 40%

Use ALSA dmix works out of the box for stretch so no pulseaudio
https://raspberrypi.stackexchange.com/questions/639/how-to-get-pulseaudio-running

mpg123 4234.mp3 &

aplay -vv somefile.wav
mp123

speaker-test -c 2

https://www.hifiberry.com/build/documentation/guide-adding-equalization-using-alsaeq/

Mopidy

https://docs.mopidy.com/en/latest/installation/debian/#debian-install

https://docs.mopidy.com/en/latest/service/#service-management-on-debian

https://discourse.mopidy.com/t/cant-setup-web-extension/548/2
sudo apt-get install python-pip

https://docs.mopidy.com/en/latest/service/

https://raspberrypi.stackexchange.com/questions/27973/how-to-reach-my-mopidy-server-without-port

https://rasspberrypi.wordpress.com/2012/09/04/mounting-and-automounting-windows-shares-on-raspberry-pi/

https://www.mopidy.com/authenticate/#spotify

https://github.com/lfcabend/mopidy-spotify-web
pip install Mopidy-Spotify-Web

RTL-SDR

http://osmocom.org/projects/sdr/wiki/rtl-sdr
https://learn.adafruit.com/freq-show-raspberry-pi-rtl-sdr-scanner/installation
https://pa3ang.nl/archives/3405

jamesmead@floehopper.local:~$ sudo dd bs=1m if=/Users/jamesmead/Downloads/2015-02-16-raspbian-wheezy.img of=/dev/disk2
pi@raspberrypi ~ $ sudo raspi-config
# Choose option 1 to "Expand Filesystem" - Ensures that all of the SD card storage is available to the OS
# Choose Finish & reboot

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get upgrade
pi@raspberrypi ~ $ cat <<EOF >no-rtl.conf
blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830
EOF
pi@raspberrypi ~ $ sudo mv no-rtl.conf /etc/modprobe.d/

pi@raspberrypi ~ $ sudo apt-get install git-core
pi@raspberrypi ~ $ sudo apt-get install git
pi@raspberrypi ~ $ sudo apt-get install cmake
pi@raspberrypi ~ $ sudo apt-get install libusb-1.0-0-dev
pi@raspberrypi ~ $ sudo apt-get install build-essential

pi@raspberrypi ~ $ git clone https://gitea.osmocom.org/sdr/rtl-sdr.git
pi@raspberrypi ~ $ cd rtl-sdr/
pi@raspberrypi ~/rtl-sdr $ mkdir build
pi@raspberrypi ~/rtl-sdr $ cd build
pi@raspberrypi ~/rtl-sdr/build $ cmake ../ -DINSTALL_UDEV_RULES=ON
pi@raspberrypi ~/rtl-sdr/build $ make
pi@raspberrypi ~/rtl-sdr/build $ sudo make install
pi@raspberrypi ~/rtl-sdr/build $ sudo ldconfig
pi@raspberrypi ~/rtl-sdr/build $ cd ~
pi@raspberrypi ~ $ sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
pi@raspberrypi ~ $ sudo reboot

pi@raspberrypi ~ $ rtl_test
Found 1 device(s):
  0:  Generic, RTL2832U, SN: 77771111153705700

Using device 0: Generic RTL2832U
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...

pi@raspberrypi ~ $ sudo apt-get install libasound-dev
pi@raspberrypi ~ $ sudo apt-get install libpulse-dev

pi@raspberrypi ~ $ wget  http://www.aishub.net/downloads/aisdecoder-1.0.0.tar.gz
pi@raspberrypi ~ $ tar zxvf aisdecoder-1.0.0.tar.gz
pi@raspberrypi ~ $ cd aisdecoder-1.0.0/
pi@raspberrypi ~/aisdecoder-1.0.0 $ mkdir build
pi@raspberrypi ~/aisdecoder-1.0.0 $ cd build/
pi@raspberrypi ~/aisdecoder-1.0.0/build $ cmake ../ -DCMAKE_BUILD_TYPE=Release
pi@raspberrypi ~/aisdecoder-1.0.0/build $ make
pi@raspberrypi ~/aisdecoder-1.0.0/build $ sudo cp aisdecoder /usr/local/bin
pi@raspberrypi ~/aisdecoder-1.0.0/build $ cd ~
pi@raspberrypi ~ $

view raw

install.md

hosted with ❤ by GitHub

rtl_fm -f 96.5M -M fm -s 170k -A fast -r 32k -l 0 -E deemp -g 1000 | play -r 32k -t raw -e s -b 16 -c 1 -V1 –

rtl_fm -M wbfm -f 96.5M | play -r 32k -t raw -e s -b 16 -c 1 -V1 –

rtl_fm -f 96.5M -M fm -s 170k -A fast -r 44100 -l 0 -E deemp -g 1000 | play -r 44100 -t raw -e s -b 16 -c 1 -V1 –

Click to access cqqso201607_rtlsdrrpi_on7cfi_0.pdf

https://raspberrytips.nl/fm-radio-dvb-t-usb-stick/

GSM USB Modem on RPI using usb_modeswitch

https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial

sudo apt-get update
sudo apt-get install ppp usb-modeswitch wvdial

$ lsusb
Bus 001 Device 009: ID 05c6:1000 Qualcomm, Inc. Mass Storage Device

idVendor=05c6, idProduct=1000

Next switch usb device until next reboot:

/tmp $ sudo usb_modeswitch -W -v 05c6 -p 1000 -K
[sudo] password for :
Take all parameters from the command line

* usb_modeswitch: handle USB devices with multiple modes
* Version 2.2.0 (C) Josua Dietze 2014
* Based on libusb1/libusbx

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x05c6
DefaultProduct= 0x1000

StandardEject=1
NeedResponse=0

Look for default devices ...
found USB ID 05c6:1000
vendor ID matched
product ID matched
found USB ID 0658:0200
found USB ID 0424:ec00
found USB ID 0424:9514
found USB ID 1d6b:0002
Found devices in default mode (1)
Access device 009 on bus 001
Current configuration number is 1
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: Qualcomm, Incorporated
Product: Qualcomm CDMA Technologies MSM
Serial No.: 351602000025260
-------------------------
Sending standard EJECT sequence
Looking for active driver ...
OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
Read the response to message 1 (CSW) ...
Response successfully read (13 bytes).
Trying to send message 2 to endpoint 0x01 ...
OK, message successfully sent
Read the response to message 2 (CSW) ...
Response reading failed (error -1)
Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

/tmp $ lsusb
Bus 001 Device 010: ID 05c6:6000 Qualcomm, Inc. Siemens SG75
Bus 001 Device 007: ID 0658:0200 Sigma Designs, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

/tmp $ lsusb -v -d 05c6:6000

Bus 001 Device 010: ID 05c6:6000 Qualcomm, Inc. Siemens SG75
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x05c6 Qualcomm, Inc.
idProduct 0x6000 Siemens SG75

http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2670
http://cateee.net/lkddb/web-lkddb/USB_SERIAL_ZTE.html
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2565
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2565

usb_modeswitch -v 05c6 -p 1000-V 05c6 -P 6000 -M 55534243123456780000000000000011060000000000000000000000000000

dmesg:
[ 11.902783] usb 1-1.5: Product: Qualcomm CDMA Technologies MSM
[ 11.902793] usb 1-1.5: Manufacturer: Qualcomm, Incorporated
[ 11.902803] usb 1-1.5: SerialNumber: 351602000025260
[ 11.905794] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[ 11.906923] scsi host0: usb-storage 1-1.5:1.0
[ 22.390696] random: crng init done
[ 40.917405] usb 1-1.5: USB disconnect, device number 8
[ 41.210686] usb 1-1.5: new high-speed USB device number 9 using dwc_otg
[ 41.343387] usb 1-1.5: New USB device found, idVendor=05c6, idProduct=6000
[ 41.343411] usb 1-1.5: New USB device strings: Mfr=3, Product=2, SerialNumber=4
[ 41.343423] usb 1-1.5: Product: Qualcomm CDMA Technologies MSM
[ 41.343434] usb 1-1.5: Manufacturer: Qualcomm, Incorporated
[ 41.343444] usb 1-1.5: SerialNumber: 351602000025260
[ 41.349624] usb-storage 1-1.5:1.4: USB Mass Storage device detected
[ 41.352063] scsi host0: usb-storage 1-1.5:1.4
[ 41.386810] usbcore: registered new interface driver usbserial
[ 41.386968] usbcore: registered new interface driver usbserial_generic
[ 41.387091] usbserial: USB Serial support registered for generic
[ 41.407558] usbcore: registered new interface driver option
[ 41.407726] usbserial: USB Serial support registered for GSM modem (1-port)
[ 41.408638] option 1-1.5:1.0: GSM modem (1-port) converter detected
[ 41.434694] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB0
[ 41.441886] option 1-1.5:1.1: GSM modem (1-port) converter detected
[ 41.449887] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB1
[ 41.450324] option 1-1.5:1.2: GSM modem (1-port) converter detected
[ 41.452242] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB2
[ 41.452665] option 1-1.5:1.3: GSM modem (1-port) converter detected
[ 41.453470] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB3
[ 42.412601] scsi 0:0:0:0: Direct-Access WCDMA MMC Storage 2.31 PQ: 0 ANSI: 2
[ 42.428977] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 42.429125] sd 0:0:0:0: [sda] Attached SCSI removable disk

Bug in usb_modeswitch
Follow
https://bugs.launchpad.net/raspbian/+bug/1593669
to have systemd startup correctly do switch modem

Setup a file containing the default vendor and product id. In the contents of this file you have to set the target vendor and product id one has obtained by manually switching the mode of the device.
I selected the MessageContent which occurs the most for simular devices…

$ ls /etc/usb_modeswitch.d/
05c6:1000

$ cat /etc/usb_modeswitch.d/05c6\:1000
DefaultVendor= 0x05c6
DefaultProduct=0x1000

TargetVendor= 0x05c6
TargetProduct= 0x6000

MessageContent="5553424312345678000000000000061b000000020000000000000000000000"

StandardEject=1

$ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Jun 10 21:55 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Jun 10 21:55 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Jun 10 21:55 /dev/ttyUSB2
crw-rw---- 1 root dialout 188, 3 Jun 10 21:55 /dev/ttyUSB3

$ sudo wvdialconf
Editing `/etc/wvdial.conf'.

Scanning your serial ports for a modem.

ttyUSB0: ATQ0 V1 E1 -- OK
ttyUSB0: ATQ0 V1 E1 Z -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB0: Modem Identifier: ATI -- Manufacturer: QUALCOMM INCORPORATED
ttyUSB0: Speed 9600: AT -- OK
ttyUSB0: Max speed is 9600; that should be safe.
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB1: ATQ0 V1 E1 -- OK
ttyUSB1: ATQ0 V1 E1 Z -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB1: Modem Identifier: ATI -- Manufacturer: QUALCOMM INCORPORATED
ttyUSB1: Speed 9600: AT -- OK
ttyUSB1: Max speed is 9600; that should be safe.
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB2: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB2: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB2: ATQ0 V1 E1 -- and failed too at 115200, giving up.
ttyUSB3: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB3: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB3: ATQ0 V1 E1 -- and failed too at 115200, giving up.

Found a modem on /dev/ttyUSB0.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”
ttyUSB1: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”

To be able to access the modem, one has to add the user to the dialout group:

$ sudo apt-get install cu
$ sudo adduser myuser dialout
$ sudo adduser root dialout
$ groups
$ awk -F':' '/dialout/{print $4}' /etc/group

To take effect one first has to reboot ;-(
$ sudo reboot

$ cu -l /dev/ttyUSB0
And if you cannot see what you type:
$ cu -h -l /dev/ttyUSB1

https://hristoborisov.com/index.php/projects/turning-the-raspberry-pi-into-a-sms-center-using-python/

OpenHAB2 using ZWave on RaspberryPi B 2

Raspbian update

sudo apt-get update; sudo apt-get dist-upgrade

https://community.openhab.org/t/signature-problem-with-apt-get-update/6036

openhab version
http://1.30.1.212:8080/rest/

ZWave usb

/dev/ttyACM0

HOSTNAME

How to Change Your Raspberry Pi (or Other Linux Device’s) Hostname

make your user part of the openhab group to be able to edit config files using openhap designer using a share:
useradd username group-name

have new user in same groups as pi”
Better (to avoid typing groups)
for GROUP in $(groups pi | sed ‘s/.*:\spi//’); do sudo adduser username $GROUP; done
[https://raspberrypi.stackexchange.com/questions/36168/how-to-create-new-user-in-raspberry-pi-who-has-equal-privileges-as-default-user]

sudo deluser username sudo
groups username

SAMBA

To share your openhab config to your pc running openhad designer:

How-To: Share a folder with a Windows computer from a Raspberry Pi

http://superuser.com/questions/271034/list-samba-users

Do smbstatus as SUDO; normal user can not get access and get a NT_STATUS_ACCESS_DENIED
sudo smbstatus

sudo vi /etc/samba/smb.conf

sudo pdbedit -Lv

sudo service smbd restart

sudo smbd -b | grep PRIVATE_DIR
PRIVATE_DIR: /var/lib/samba/private

See
https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/install.html

Added to standard config, but encrypt should be defualt yes
encrypt passwords = yes

To be able to use to edit the config files in /etc/openhab2, change owner and group of this folder to ‘openhab’, and set permissition for this folder
sudo chmod g+w /etc/openhab2

sudo smbpasswd -a
sudo usermod -a -G openhab

And at end:
[OpenHABShare]
comment=OpenHAB Configuration Share
path=/etc/openhab2
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
available=yes

OpenHAB2

Automation/Orchestration Design Patterns
https://community.openhab.org/t/automation-orchestration-design-patterns/1967/20

https://github.com/openhab/openhab/wiki/Samples-Tricks#how-start-openhab-automatically-on-linux-using-systemd

systemctl status openhab2.service

tail -f /var/log/openhab2/openhab.log

OpenhabDesigner windows on Raspberry by

Add (empty) file ‘openhab_default.cfg’ to /etc/openhab2
https://community.openhab.org/t/using-openhab-designer-on-windows-with-openhab-on-linux/4687/3

openhab sample rules

next turns on lights on motion with timeout and switch items..
https://github.com/openhab/openhab/wiki/Taking-Rules-to-New-Heights

Auto reboot pi

sudo crontab -e
sudo crontab -l

30 1 * * * sudo reboot

http://docs.openhab.org/administration/console.html

https://mysmarthomeweb.wordpress.com/2016/07/31/small-examples-yahoo-weather-ntp-and-systems-service/

KARAF:
ssh openhab@localhost -p 8101

restart to reread config files:
bundle:list -s
bundle:restart org.eclipse.smarthome.model.core

setup mail:
http://openhab2.wermescher.com/action-mail-gmail/

Cleanup items and links using karaf
https://community.openhab.org/t/cannot-clean-the-mess-in-items/11271/4

https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial

sudo apt-get update
sudo apt-get install ppp usb-modeswitch wvdial

$ lsusb
Bus 001 Device 009: ID 05c6:1000 Qualcomm, Inc. Mass Storage Device

idVendor=05c6, idProduct=1000

/tmp $ sudo usb_modeswitch -W -v 05c6 -p 1000 -K
[sudo] password for juno:
Take all parameters from the command line

* usb_modeswitch: handle USB devices with multiple modes
* Version 2.2.0 (C) Josua Dietze 2014
* Based on libusb1/libusbx

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x05c6
DefaultProduct= 0x1000

StandardEject=1
NeedResponse=0

Look for default devices …
found USB ID 05c6:1000
vendor ID matched
product ID matched
found USB ID 0658:0200
found USB ID 0424:ec00
found USB ID 0424:9514
found USB ID 1d6b:0002
Found devices in default mode (1)
Access device 009 on bus 001
Current configuration number is 1
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
————————-
Manufacturer: Qualcomm, Incorporated
Product: Qualcomm CDMA Technologies MSM
Serial No.: 351602000025260
————————-
Sending standard EJECT sequence
Looking for active driver …
OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending …
Trying to send message 1 to endpoint 0x01 …
OK, message successfully sent
Read the response to message 1 (CSW) …
Response successfully read (13 bytes).
Trying to send message 2 to endpoint 0x01 …
OK, message successfully sent
Read the response to message 2 (CSW) …
Response reading failed (error -1)
Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

/tmp $ lsusb
Bus 001 Device 010: ID 05c6:6000 Qualcomm, Inc. Siemens SG75
Bus 001 Device 007: ID 0658:0200 Sigma Designs, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

/tmp $ lsusb -v -d 05c6:6000

Bus 001 Device 010: ID 05c6:6000 Qualcomm, Inc. Siemens SG75
Couldn’t open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x05c6 Qualcomm, Inc.
idProduct 0x6000 Siemens SG75

http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2670
http://cateee.net/lkddb/web-lkddb/USB_SERIAL_ZTE.html
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2565
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2565

usb_modeswitch -v 05c6 -p 1000-V 05c6 -P 6000 -M 55534243123456780000000000000011060000000000000000000000000000

dmesg:
[ 11.902783] usb 1-1.5: Product: Qualcomm CDMA Technologies MSM
[ 11.902793] usb 1-1.5: Manufacturer: Qualcomm, Incorporated
[ 11.902803] usb 1-1.5: SerialNumber: 351602000025260
[ 11.905794] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[ 11.906923] scsi host0: usb-storage 1-1.5:1.0
[ 22.390696] random: crng init done
[ 40.917405] usb 1-1.5: USB disconnect, device number 8
[ 41.210686] usb 1-1.5: new high-speed USB device number 9 using dwc_otg
[ 41.343387] usb 1-1.5: New USB device found, idVendor=05c6, idProduct=6000
[ 41.343411] usb 1-1.5: New USB device strings: Mfr=3, Product=2, SerialNumber=4
[ 41.343423] usb 1-1.5: Product: Qualcomm CDMA Technologies MSM
[ 41.343434] usb 1-1.5: Manufacturer: Qualcomm, Incorporated
[ 41.343444] usb 1-1.5: SerialNumber: 351602000025260
[ 41.349624] usb-storage 1-1.5:1.4: USB Mass Storage device detected
[ 41.352063] scsi host0: usb-storage 1-1.5:1.4
[ 41.386810] usbcore: registered new interface driver usbserial
[ 41.386968] usbcore: registered new interface driver usbserial_generic
[ 41.387091] usbserial: USB Serial support registered for generic
[ 41.407558] usbcore: registered new interface driver option
[ 41.407726] usbserial: USB Serial support registered for GSM modem (1-port)
[ 41.408638] option 1-1.5:1.0: GSM modem (1-port) converter detected
[ 41.434694] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB0
[ 41.441886] option 1-1.5:1.1: GSM modem (1-port) converter detected
[ 41.449887] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB1
[ 41.450324] option 1-1.5:1.2: GSM modem (1-port) converter detected
[ 41.452242] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB2
[ 41.452665] option 1-1.5:1.3: GSM modem (1-port) converter detected
[ 41.453470] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB3
[ 42.412601] scsi 0:0:0:0: Direct-Access WCDMA MMC Storage 2.31 PQ: 0 ANSI: 2
[ 42.428977] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 42.429125] sd 0:0:0:0: [sda] Attached SCSI removable disk

Bug in usb_modeswitch
Follow
https://bugs.launchpad.net/raspbian/+bug/1593669
to have systemd startup correctly do switch modem

$ ls /etc/usb_modeswitch.d/
05c6:1000

$ cat /etc/usb_modeswitch.d/05c6\:1000
DefaultVendor= 0x05c6
DefaultProduct=0x1000

TargetVendor= 0x05c6
TargetProduct= 0x6000

MessageContent=”5553424312345678000000000000061b000000020000000000000000000000″

StandardEject=1

$ ls -l /dev/ttyUSB*
crw-rw—- 1 root dialout 188, 0 Jun 10 21:55 /dev/ttyUSB0
crw-rw—- 1 root dialout 188, 1 Jun 10 21:55 /dev/ttyUSB1
crw-rw—- 1 root dialout 188, 2 Jun 10 21:55 /dev/ttyUSB2
crw-rw—- 1 root dialout 188, 3 Jun 10 21:55 /dev/ttyUSB3

$ sudo wvdialconf
Editing `/etc/wvdial.conf’.

Scanning your serial ports for a modem.

ttyUSB0: ATQ0 V1 E1 — OK
ttyUSB0: ATQ0 V1 E1 Z — OK
ttyUSB0: ATQ0 V1 E1 S0=0 — OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 — OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyUSB0: Modem Identifier: ATI — Manufacturer: QUALCOMM INCORPORATED
ttyUSB0: Speed 9600: AT — OK
ttyUSB0: Max speed is 9600; that should be safe.
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyUSB1: ATQ0 V1 E1 — OK
ttyUSB1: ATQ0 V1 E1 Z — OK
ttyUSB1: ATQ0 V1 E1 S0=0 — OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 — OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyUSB1: Modem Identifier: ATI — Manufacturer: QUALCOMM INCORPORATED
ttyUSB1: Speed 9600: AT — OK
ttyUSB1: Max speed is 9600; that should be safe.
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyUSB2: ATQ0 V1 E1 — failed with 2400 baud, next try: 9600 baud
ttyUSB2: ATQ0 V1 E1 — failed with 9600 baud, next try: 9600 baud
ttyUSB2: ATQ0 V1 E1 — and failed too at 115200, giving up.
ttyUSB3: ATQ0 V1 E1 — failed with 2400 baud, next try: 9600 baud
ttyUSB3: ATQ0 V1 E1 — failed with 9600 baud, next try: 9600 baud
ttyUSB3: ATQ0 V1 E1 — and failed too at 115200, giving up.

Found a modem on /dev/ttyUSB0.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”
ttyUSB1: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”

$ sudo apt-get install cu
$ sudo adduser myuser dialout
$ sudo adduser root dialout
$ groups
$ awk -F’:’ ‘/dialout/{print $4}’ /etc/group
to take effect ;-(
$ sudo reboot
$ cu -l /dev/ttyUSB0
And if you cannot see what you type:
$ cu -h -l /dev/ttyUSB1

https://hristoborisov.com/index.php/projects/turning-the-raspberry-pi-into-a-sms-center-using-python/