Create SoftAP with Hostapd on Ubuntu and Rpi.md
In Ubuntu 14.04
Check whether the module 8188eu is load lsmod|grep 8188
or lsusb
Download and compile latest hostapd with RTL8188 drivers
1 | git clone https://github.com/lostincynicism/hostapd-rtl8188 |
The complete options in /usr/share/doc/hostapd/examples/hostadp.8188eu.conf
1 | interface=wlan0 |
Fix “Cannot find the ssid problem”
1 | sudo nmcli nm wifi off |
Following maybe not work but for reference
1 | sudo systemctl disable NetworkManager.service |
Start hostapd
1 | cd hostapd-rtl8188/hostapd |
In Raspberry Pi
Configure IP sudo ifconfig wlan0 192.168.42.100
Scan ssid iwlist wlan0 scan
Connect to ssid “Soft-AP”
1 | # wpa_cli |
Others
In Ubuntu
- Set proxy
java -cp lib/log4j-1.2.16.jar:lib/jboss-common-logging-spi.jar:lib/netty.jar org.jboss.netty.example.proxy.HexDumpProxy 8081 10.13.135.115 8080
In RaspPi
- Setting Up apt-get with proxy. Add file proxy.conf in “/etc/apt/“ with content
Acquire::http::Proxy "http://192.168.42.1:8081/";
- Setting Up http proxy by
1
2export http_proxy=http://192.168.42.1:8081/
export https_proxy=http://192.168.42.1:8081/ - Run
sudo apt-get install apt-transport-https
if problem “E: The method driver /usr/lib/apt/methods/https could not be found.” occurs whensudo apt-get update
- Install mpv from https://nwgat.ninja/quick-easy-compiling-mpv-for-raspberry-pi/
- Install livestreamer
- Download setuptools from https://pypi.python.org/pypi/setuptools#downloads
- Install setuptools
python setup.py install
andsudo -E easy_install livestreamer
- Test the audio
livestreamer --https-proxy=http://192.168.42.1:8081 --http-proxy=http://192.168.42.1:8081 hlsvariant://http://rthkaudio1-lh.akamaihd.net/i/radio1_1@355864/master.m3u8 best -p mpv
- Change the volumn by
4.1amixer controls
to show the Master Playback Volume
4.2 Get details of the master playback volume control byamixer cget numid=3
, it shows a pair of volume values=65536,65536(for left and right channels)
alsamixer
, save volumn level viasudo alsactl store
amixer cset numid=1 -- 80%
oramixer cset numid=3 80%
Oramixer set Master 100%
4.3 To mute the sound byamixer cset numid=4 off
(Control 4), this also affects the volume values on control 3
Reference http://blog.scphillips.com/posts/2013/01/sound-configuration-on-raspberry-pi-with-alsa/ - Set audio output device
amixer cset numid=3 N
(N=0=auto, 1=analog, 2=hdmi)
- Start openssh-server
sudo service ssh start
- Install openvpn
sudo apt-get install openvpn
- Install adb and fastboot by
sudo apt-get install android-tools-adb android-tools-fastboot
- Configure udev service for detecting the pluged phone
1
2
3sudo wget -O /etc/udev/rules.d/51-android.rules https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/51-android.rules
sudo chmod a+r /etc/udev/rules.d/51-android.rules
sudo service udev restart - Plug the mobile and mount the sdcard by
sudo mount /dev/sda1 /mnt
Check the disk by1
2
3sudo fdisk -l /dev/sda
sudo lsblk
df -h - USB tethering
1
2adb forward tcp:41927 tcp:41927
sudo openvpn azilink.ovpn
- Write PiCast application with golang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107package main
import (
"fmt"
"github.com/gorilla/mux"
"io/ioutil"
"net/http"
"os"
"os/exec"
"strings"
"syscall"
)
func main() {
r := mux.NewRouter()
r.HandleFunc("/", Home)
//r.HandleFunc("/yt-stream/{args}", Youtube)
r.HandleFunc("/yt-stream", Youtube)
bind := fmt.Sprintf("%s:%s", os.Getenv("HOST"), os.Getenv("PORT"))
fmt.Printf("listening on %s...\n", bind)
err := http.ListenAndServe(bind, r)
if err != nil {
panic(err)
}
}
func Home(res http.ResponseWriter, req *http.Request) {
fmt.Fprint(res, "Welcome to PiCAST! In the URL, type what you want to do...\n")
}
func Youtube(res http.ResponseWriter, req *http.Request) {
body := readReqBody(req)
url := body["url"]
if url == "" {
args := body["args"]
url = "https://www.youtube.com/watch?v=" + args
}
p := body["proxy"]
http_proxy := ""
https_proxy := ""
if p != "" {
http_proxy = "--https-proxy=" + p
https_proxy = "--http-proxy=" + p
}
args := []string{http_proxy, https_proxy, url, "best", "--player=mpv"}
fmt.Println(args)
run(args)
}
func run(args []string) {
exec.Command("killall livestreamer").Run()
binary, lookErr := exec.LookPath("livestreamer")
if lookErr != nil {
panic(lookErr)
}
env := os.Environ()
execErr := syscall.Exec(binary, args, env)
if execErr != nil {
fmt.Println("execErr", execErr)
}
}
func runOld(args []string) {
cmd := exec.Command("livestreamer", args...)
fmt.Println(cmd.Path)
fmt.Println(cmd.Args)
fmt.Println(cmd.Env)
if err := cmd.Start(); err != nil {
fmt.Printf("cmd.Start: %v\n", err)
}
if err := cmd.Wait(); err != nil {
if exiterr, ok := err.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
fmt.Printf("Exit Status: %d\n", status.ExitStatus())
}
} else {
fmt.Printf("cmd.Wait: %v\n", err)
}
}
}
func readReqBody(req *http.Request) map[string]string {
body, _ := ioutil.ReadAll(req.Body)
// Info.Println("body = ", string(body))
m := make(map[string]string)
content := strings.Split(string(body), "&")
for _, c := range content {
p := strings.Split(c, "=")
if len(p) == 2 {
m[p[0]] = p[1]
}
}
return m
}
Cross compile this web application in linux
1
2env GOOS=linux GOARCH=arm go build -ldflags="-s -w" main.go
scp -i id_rsa main pi@192.168.42.100:/home/pi/Install tmux on ubuntu
sudo apt-get install tmux
ctrl+b % - split window vertically ctrl+b " - split window horizontally ctrl+b o - Goto next pane ctrl+b c - Create new window ctrl+b w - List all windows ctrl+b l - Move to the previously selected window
Reference
ADB FIFO example
USB tethering
https://github.com/lanceseidman/PiCAST