söndag 9 oktober 2016

Wi-Fi Direct on raspberry pi 2 (jessie)

Wifi device: Plugable usb 2 wifi adapter with RTL8188CUS.

Several issues at start:

  • Can't list the device with iw list
  • Can't initiate P2P commands from wpa_cli
(however, ifconfig and iwconfig works as expected and the device can connect to wlan. wpa_supplicant.conf established previously with another device)

Installation, see RTL8188CUS.

Configuration, see wifi how-to-use. In my case I added wlan1 to /etc/network/interfaces. wpa_supplicant.conf was already configured for the existing wlan.

Install RTL drivers and software enabling wifi-direct, follow these instructions. Try to run the P2P_UI following these instructions. Tried connecting with LG G2 android. Success on some rare occassions. Most often received "UI unkown failed" (same as for teksaport).

Tried with a pristine jessie img and updated installation instructions provided by bass0324  on Wed Jul 30, 2014 2:39 am.  Same issue as above. Will soon test with TP-Link WN725N.


lördag 1 oktober 2016

Wi-Fi Protected Setup, WPS, on raspberry pi

There are many tutorials that explain how to connect a raspberry to a wifi hotspot, but I haven't seen this before.

You have a wi-fi dongle and want to configure your (headless) raspberry to connect to a wifi hotspot. I assume that you can use ssh to log into your rpi and that you can execute as sudo. I also assume that your router has a wps button.

As you probably know, wifi settings are stored in the file /etc/wpa_supplicant/wpa_supplicant.conf. If not previously configured, the content of this file might look like this:

>sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

Check that the wifi dongle is recognized by the system:

>iwconfig
wlan0     IEEE 802.11bgn  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
(device attached to wlan0)

Now, to set up wifi, you execute the following command (install wpa_cli if not already on the system):

>sudo wpa_cli wps_pbc
Selected interface 'wlan0'
OK

...and press the wps button on your router (within 2 minutes).

Check connection status with iwconfig or wpa_cli. On my system:

>sudo wpa_cli status
Selected interface 'wlan0'
bssid=e0:3f:49:09:a9:78
freq=2437
ssid=ASUS
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
address=40:a5:ef:05:50:f5
uuid=de509928-92bf-5eda-8b02-83a0641a95ca

The important parameter is wpa_state, and that it's state is COMPLETED.

IP-address can be checked with;

> hostname -I
192.168.1.93 192.168.1.21

Two addresses, one for eth0, and the other is for the wlan0.

Check that wpa_supplicant.conf file has been updated and verify that rpi reconnects to the hotspot after reboot.

Refs:

lördag 20 augusti 2016

github: fork, clone and sync

Problem: We have forked a repo. It's been updated and our fork is not in sync.

I assume that we have cloned the original repo to a local machine, and that we have added our private fork to the local clone. With mopidy repo as example (see also mopidy docs):

Creating local clone (creates a new folder - mopidy), and rename origin with upstream:
git clone https://github.com/mopidy/mopidy.git
git remote rename origin upstream

Check remote info:
git remote -v
>upstream https://github.com/mopidy/mopidy.git (fetch)
>upstream https://github.com/mopidy/mopidy.git (push)

Add privat github repo of mopidy:
git remote add alexjaw git@github.com:alexjaw/mopidy.git

Check remote info:
git remote -v
>alexjaw git@github.com:alexjaw/mopidy.git (fetch)
>alexjaw git@github.com:alexjaw/mopidy.git (push)
>upstream https://github.com/mopidy/mopidy.git (fetch)
>upstream https://github.com/mopidy/mopidy.git (push

Fetch to local clone (does not affect the local clone):
git remote update
>...

Merge updates in branch develop from original repo mopidy/mopidy (upstream):
git pull upstream develop

Finally, update your private repo branch develop (on Github):
git push alexjaw develop

Check on Github that the private repo is in sync with original repo.

söndag 14 augusti 2016

workon not found

virtualenvwrapper is handy for admin of envs. But some times workon is not longer recognized by the shell - workon: command not found.

A dirty way to handle this is to use the path of the virtual env. For mopidy I use:

source ~/Env/mopidy/bin activate

Deactivate as usaul with deactivate.

There is a SO discussion about this, see here.

A BETTER way is to add some info to ~/.bashrc as explained in the docs.
# load virtualenvwrapper for python
export WORKON_HOME=$HOME/Envs
export PROJECT_HOME=$HOME/mopidy-dev
source /usr/local/bin/virtualenvwrapper.sh

Folder Env will contain the virtual envs.

fredag 12 augusti 2016

scipy installation on raspberry pi

Have tried to install scipy on wheezy and jessie with pip without success (could only install numpy with pip). However, it's easy to install with

    sudo apt-get update
    sudo apt-get install python-scipy

Observe that the first time you try to install the package you might get the message

    E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Running the following command fixed the problem

    sudo apt-get --fix-missing

The versions installed were

  • numpy 1.8.2
  • scipy 0.14.0


apt-get and pip

Often both can be used when installing python packages. If apt is used, the installed python package will still be visible when using "pip list".

One issue with apt is that the package versions might be somewhat old.

Example (raspberry pi running debian jessie):
sudo pip install pyserial, pip list says pyserial 3.1.1

sudo apt-get install python-serial, pip list says pyserial 2.6