BLE scan with ThinkPad X1 on Ubuntu - bluetooth

Ubuntu 21.04, ThinkPad X1.
I am failing to scan BLE:
$ hcitool lescan
Set scan parameters failed: Input/output error
Running sudo btmon while running the above command yields:
# RAW Open: hcitool (privileged) version 2.22 {0x0002} 13.597363
# RAW Close: hcitool {0x0002} 13.597386
# RAW Open: hcitool (privileged) version 2.22 {0x0002} [hci0] 13.597399
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 #396 [hci0] 13.597462
Type: Active (0x01)
Interval: 10.000 msec (0x0010)
Window: 10.000 msec (0x0010)
Own address type: Public (0x00)
Filter policy: Accept all advertisement (0x00)
> HCI Event: Command Complete (0x0e) plen 4 #397 [hci0] 13.712003
LE Set Scan Parameters (0x08|0x000b) ncmd 1
Status: Command Disallowed (0x0c)
# RAW Close: hcitool
I'm a bit surprised by the Interval and Window being the same. If scanning 100 % of the time, how can for example my bluetooth mouse work at the same time?
Anyway, this scans successfully (it actually stopped working for a while, but power off / power on solved it. MX Anywhere 2S is my bluetooth mouse):
$ bluetoothctl
[MX Anywhere 2S]# menu scan
[MX Anywhere 2S]# clear
[MX Anywhere 2S]# transport le
[MX Anywhere 2S]# back
[MX Anywhere 2S]# scan on
All the beacons I'm looking for are there in the output of btmon.
Yet on the other hand, hcitool lescan still says "Set scan parameters failed: Input/output error". How do I solve that?
This might be relevant:
$ ps aux|grep blue
gauthier 260395 0.0 0.0 45708 6900 ? Ss 10:45 0:00 /usr/lib/bluetooth/obexd
root 261745 0.2 0.0 11276 5700 ? Ss 10:53 0:01 /usr/lib/bluetooth/bluetoothd
gauthier 262297 0.0 0.0 20636 2896 pts/2 S+ 11:01 0:00 grep --color=auto blue
$ hciconfig -a
hci0: Type: Primary Bus: USB
BD Address: 04:56:E5:E7:1A:34 ACL MTU: 1021:4 SCO MTU: 96:6
UP RUNNING
RX bytes:37504193 acl:540593 sco:0 events:539220 errors:0
TX bytes:815046 acl:258 sco:0 commands:3643 errors:0
Features: 0xbf 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'taket'
Class: 0x3c010c
Service Classes: Rendering, Capturing, Object Transfer, Audio
Device Class: Computer, Laptop
HCI Version: 5.2 (0xb) Revision: 0x2279
LMP Version: 5.2 (0xb) Subversion: 0x2279
Manufacturer: Intel Corp. (2)

Related

AF_XDP zero copy - Operation not supported error

I am trying to enable AF_XDP zero copy mode and i see the error in Cent OS 8(kernel 4.18), but SKB mode and DRV mode with copy works fine. The driver is ixgbe 5.6.5 which supports AF_XDP zero copy as per the documentation. strace shows the failure is during bind
./af_xdp_user -d eth2 -z -q 1
bind(3, {sa_family=0x2c /* AF_??? */, sa_data="\4\0006\1\0\0\0\0\0\0\0\0\0\0"}, 16) = -1 EOPNOTSUPP (Operation not supported)
The ethtool shows i have combined queues and not separate rx/tx queues. Is that a problem?
[root#localhost ~]# ethtool -l eth2
Channel parameters for eth2:
Pre-set maximums:
RX: 0
TX: 0
Other: 1
Combined: 63
Current hardware settings:
RX: 0
TX: 0
Other: 1
Combined: 9
[root#localhost ~]# ethtool -i eth2
driver:
ixgbe
version: 5.6.5
firmware-version: 0x61c10001
expansion-rom-version:
bus-info: 0000:00:06.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes
Any ideas what is missing?

Pulseaudio set/check default source

So the question is,
How can I set the default source?
How can I list the current default source?
Details
I have 4 sound input sources on my linux device. Here is the result of pactl list sources:
1 alsa_input.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
2 alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo module-alsa-card.c s16le 2ch 48000Hz SUSPENDED
3 alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo.2 module-alsa-card.c s16le 2ch 48000Hz SUSPENDED
5 alsa_output.pci-0000_00_1b.0.hdmi-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
I tried to set the source 1 alsa_input.pci-0000_00_1b.0.analog-stereo as my default source by several ways:
1.change /etc/pulse/client.conf, add following lines:
default-sink = alsa_output.pci-0000_00_1b.0.hdmi-stereo
default-source = alsa_input.pci-0000_00_1b.0.analog-stereo
2.change /etc/pulse/default.pa, add following lines:
### Make some devices default
set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo
After configuration complete, I tried pulseaudio -D and reboot the device, but the config take no effect. I don't know how to list the current default source and sink, so I use following command to verify:
$> pactl load-module module-loopback latency_msec=500
$> pactl list sources short | grep RUNNING
3 alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo.2 module-alsa-card.c s16le 2ch 48000Hz RUNNING
The pactl still use my usb camera's microphone as its default source.
System Info
Linux kernel:
Linux D2-A109 4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
PulseAudio version:
$> pulseaudio --version
11.1
Any advice is welcome!
Finally..I find it's just caused by the microphone "unplugged"... And the way to set the default source is correct.
And I find the answer of Q2."How can I list the current default source?":
$> pacmd list-sources | grep -e 'index:' -e device.string -e 'name:' -e 'available'
* index: 1
name: <alsa_input.pci-0000_00_1b.0.analog-stereo>
device.string = "front:0"
analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: yes)
analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: no)
index: 2
name: <alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo>
device.string = "plug:front:1"
analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
index: 3
name: <alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo.2>
device.string = "plug:front:2"
analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
index: 7
name: <alsa_output.pci-0000_00_1b.0.hdmi-stereo.monitor>
device.string = "0"
Corresponding to PulseAudio wiki, The * in front of the index indicates the current default input.
To avoid someone being stupit as me, we can determine if the microphone(source) is plugged, by checking 'available' in the printing result of sources.
How can I list the current default source?
With pulseaudio 15.0 you can now just run pactl get-default-source to get the device string without resorting to running sed/awk/grep etc on the output.

No DHCP response when connecting to WEP wifi

I am unable to connect to WEP wifi on Linux (Mint): I get no DHCP offer.
My bash script (that I launch as root) does the following:
pkill dhclient
pkill wpa_supplicant #just in case
ip link set dev wlan0 down
ip addr flush dev wlan0
iwconfig wlan0 essid "MyWifi"
iwconfig wlan0 enc off
ip link set dev wlan0 up
dhclient -v wlan0
When I launch it, I get no DHCP offer:
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/e8:4e:06:24:b2:9e
Sending on LPF/wlan0/e8:4e:06:24:b2:9e
Sending on Socket/fallback
DHCPREQUEST of 192.168.100.101 on wlan0 to 255.255.255.255 port 67 (xid=0x19efd6f2)
DHCPREQUEST of 192.168.100.101 on wlan0 to 255.255.255.255 port 67 (xid=0x19efd6f2)
DHCPREQUEST of 192.168.100.101 on wlan0 to 255.255.255.255 port 67 (xid=0x19efd6f2)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3 (xid=0x17d23b2f)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3 (xid=0x17d23b2f)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5 (xid=0x17d23b2f)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11 (xid=0x17d23b2f)
...
Important:
I do not have NetworkManager (not running and removed - I saw that was a common issue) and I prefer to use command line.
When I scan for my wifi, I see it no problem:
sudo iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 20:C9
[..]
Cell 02 - Address: 02:26:C6:2F:46:7E
Channel:9
Frequency:2.452 GHz (Channel 9)
Quality=54/70 Signal level=-56 dBm
Encryption key:off
ESSID:"MyWifi"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 48 Mb/s
54 Mb/s; 6 Mb/s; 9 Mb/s
Bit Rates:12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
Mode:Ad-Hoc
Extra:tsf=0000000001ed4e21
Extra: Last beacon: 32ms ago
IE: Unknown: 000B6950686F6E65204D795769
IE: Unknown: 010882848B96606C0C12
IE: Unknown: 030109
IE: Unknown: 06020000
IE: Unknown: 2A0100
IE: Unknown: 320418243048
I know that wifi works as I have other equipments connect to it
I know my wifi dongle works too as I manage to connect to other wifi (WPA).
Ok I found the solution. I was using mode 'managed' by default. But in the iwlist scan, it says 'ad-hoc':
Mode:Ad-Hoc
So, the correct script to connect to my Wifi is:
#!/bin/bash
pkill dhclient
pkill wpa_supplicant #just in case
ip link set dev wlan0 down
ip addr flush dev wlan0
iwconfig wlan0 essid "MyWifi"
iwconfig wlan0 enc off
iwconfig wlan0 key off
iwconfig wlan0 mode Ad-Hoc
ip link set dev wlan0 up
dhclient -v wlan0
and that works :)

Bluetooth LE Signal Strength Linux

Hello is there any way to get the signal strength of near by bluetooth le devises in linux? Or any good libraries for nodejs, php or mono (I do know some c++ or python but would prefer to say away from them) if a tool does not exisst but would be fairly easy to write.
On Linux, the way to do this is with the hcitool command. However, you have to be connected to get the rssi of a device. If you want to achieve this from the command line, try:
#hcitool rssi AA:BB:CC:DD:EE:FF
If you want to see the actual C code to achieve this, take a look at the bluez tools/hcitool.c file, under the cmd_rssi function.
static void cmd_rssi(int dev_id, int argc, char **argv)
{
...
}
For Bluetooth Low Energy, I only know one way to do this, and that is using the #btmon command. Run btmon in the background then scan for Bluetooth Low Energy devices:
#./btmon &
# hcitool lescan
The results displayed on the monitor should be similar to this:
> HCI Event: LE Meta Event (0x3e) plen 12
LE Advertising Report (0x02)
Num reports: 1
Event type: Scan response - SCAN_RSP (0x04)
Address type: Public (0x00)
Address: AA:BB:CC:DD:EE:FF (<Vendor Name>)
Data length: 0
***RSSI: -34 dBm (0xde)***
AA:BB:CC:DD:EE:FF <Device Name>
Note that when using btmon you do not have to connect to get the rssi of a BLE device.
No need to connect when using btmgmt
$ sudo btmgmt find
Discovery started
hci0 type 7 discovering on
hci0 dev_found: 50:8C:FD:99:0A:EC type LE Random rssi -80 flags 0x0000
AD flags 0x06
eir_len 23
…
The relative signal strength indicator is rssi -80, but the list is much longer containing more information about this and other devices.
To spy on your Bluetooth neighbourhood showing only unique MAC addresses with their strongest RSSI, run the following command:
$ sudo btmgmt find |grep rssi |sort -n |uniq -w 33
hci0 dev_found: 40:43:42:B3:71:11 type LE Random rssi -53 flags 0x0000
hci0 dev_found: 44:DA:5F:EA:C6:CF type LE Random rssi -78 flags 0x0000
hci0 dev_found: 7F:7D:08:6B:E0:37 type LE Random rssi -74 flags 0x0000
hci0 dev_found: A4:58:0F:21:A1:8C type BR/EDR rssi -79 flags 0x0000
You can use a combination of:
sudo hcitool lescan --duplicates & ;
sudo hcidump --raw
that will provide you the raw dump of all the bluetooth packets which contain all relevant information you must be interested in such as : UUID, Major, Minor, RSSI, TxPower. You will have to run some kind of script to parse and filter LE packets and make them into readable form.
One of the scripts written with Bash and S editor was provided by jjnebaker here with the problem and solution discussed here
The Other option is to use PyBluez using the example code here
But you might find the solution provided by Switchdoc labs useful according to your needs as well. here
This works for c language, but has an error when casting the bytes that have the information about de rssi signal.
https://github.com/glock45/intel-edison-playground/blob/master/scan.c
this line 121:
printf("%s - RSSI %d\n", addr, (**char**)info->data[info->length]);
should be:
printf("%s - RSSI %d\n", addr, (**int8_t**)info->data[info->length]);
I found these by looking inside bluez-version/monitor/*.c, where btmon program is. You can see the data types and structs, hcidump.c is very useful and packets.c, and main.c too, but there are many to learn about the hci sockets.
I also found a program I was able to edit to do what I wanted as well
I through it up on my github account
https://github.com/tholum/bluez/blob/master/blue.py
i found several solutions, but most were too slow for my needs to use as a tracking function.
check out https://github.com/abandonware/noble containing some examples.
my standalone scanner is also based on abandonware's module and can be found here:
https://github.com/efeuentertainment/BLE-continuous-RSSI-scan
node index.js BLEMAC
continuously lists the RSSI with an update frequency of about 2 per second / depending on BLE device.
also fast updates based on bash is:
sudo hcitool lescan --duplicates &
combined with one of the following lines:
continuous updates
sudo hcidump | grep "E6:4E:57:09:74:E4" -A 4
sudo btmon | grep "E6:4E:57:09:74:E4" -A 7
only the next received update
sudo hcidump | grep -m 1 "E6:4E:57:09:74:E4" -A 4 | grep "RSSI"
sudo btmon | grep -m 1 "E6:4E:57:09:74:E4" -A 7 | grep "RSSI"
hope that helps. it's an old thread but my search engine lead me here anyway.
try :
$ bluez-test-discovery
output :
[ 18:7A:93:05:E4:B1 ]
Name = AMIYJ_E4B1
Paired = 0
LegacyPairing = 0
Alias = AMIYJ_E4B1
Broadcaster = 0
UUIDs = dbus.Array([dbus.String(u'0000fff0-0000-1000-8000-00805f9b34fb')], signature=dbus.Signature('s'), variant_level=1)
Address = 18:7A:93:05:E4:B1
RSSI = -65
Class = 0x000000
gives you : RSSI = -65
For connected devices you can use btmgmt conn-info
e.g.
$ sudo btmgmt conn-info -t 2 E4:0C:E6:59:B6:FC
Connection Information for E4:0C:E6:59:B6:FC (LE Random)
RSSI -78 TX power 0 maximum TX power 0
(You have the code for that command at https://github.com/bluez/bluez/blob/150bbff449c787f26b7de3e6006bdb2ea6365b08/tools/btmgmt.c#L3984-L4030 ).
I think you may also be able to use BlueZ's DBus RSSI property of the org.bluez.Device1 interface :
int16 RSSI [readonly, optional]
Received Signal Strength Indicator of the remote
device (inquiry or advertising).
but that didn't work for me:
$ dbus-send --print-reply=literal --system --dest=org.bluez /org/bluez/hci0/dev_E4_0C_E6_59_B6_FC org.freedesktop.DBus.Properties.Get string:"org.bluez.Device1" string:"RSSI"
Error org.freedesktop.DBus.Error.InvalidArgs: No such property 'RSSI'
Maybe because the property is optional. Some other properties did work for me:
$ dbus-send --print-reply=literal --system --dest=org.bluez /org/bluez/hci0/dev_E4_0C_E6_59_B6_FC org.freedesktop.DBus.Properties.Get string:"org.bluez.Device1" string:"Name"
variant eono BTC 01

Raspberry Pi ad-hoc networking

I want to try some networking projects with Raspberry Pis, and I need to just send packets between a pair of pis. I would be happy as a first step just being able to ping between to Raspberry Pis in ad-hoc mode. I have not successfully done this despite looking at several tutorials and examples online.
I have 2x Raspberry Pis with the Debian Wheezy OS installed. I am using the following USB adapter which I installed firmware for on both pis and tested that they work by connected them in managed mode to a router:
Bus 001 Device 004: ID 050d:945a Belkin Components F7D1101 v1 Basic Wireless Adapter [Realtek RTL8188SU]
Here are is some printouts about the networking information:
/etc/network/interfaces at each pi:
pi1#raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet manual
address 192.168.2.1
netmask 255.255.255.0
wireless-channel 4
wireless-essid pi-ad-hoc
wireless-mode ad-hoc
pi2#raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet manual
address 192.168.2.2
netmask 255.255.255.0
wireless-channel 4
wireless-essid pi-ad-hoc
wireless-mode ad-hoc
ifconfig at each pi:
pi1#raspberrypi ~ $ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr ec:1a:59:46:8e:5a
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:26 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
pi2#raspberrypi ~ $ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr ec:1a:59:46:59:0a
inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:6 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
iwconfig at each pi:
pi1#raspberrypi ~ $ iwconfig wlan0
wlan0 IEEE 802.11bg ESSID:"pi-ad-hoc" Nickname:"rtl_wifi"
Mode:Ad-Hoc Cell: 02:11:87:FA:4A:02 Bit Rate:54 Mb/s
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
pi2#raspberrypi ~ $ iwconfig wlan0
wlan0 IEEE 802.11bg ESSID:"pi-ad-hoc" Nickname:"rtl_wifi"
Mode:Ad-Hoc Cell: 02:11:87:C4:F2:01 Bit Rate:54 Mb/s
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
route at one pi (identical on other pi):
pi1#raspberrypi ~ $ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 0 0 0 wlan0
iwlist scan at each pi:
pi1#raspberrypi ~ $ sudo iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 02:11:87:FA:4A:02
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Quality:0 Signal level:0 Noise level:0
Cell 04 - Address: 02:11:87:C4:F2:01
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Signal level=100/100
pi2#raspberrypi ~ $ sudo iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 02:11:87:C4:F2:01
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Quality:0 Signal level:0 Noise level:0
Cell 02 - Address: 02:11:87:FA:4A:02
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Signal level=100/100
Ping does not work, and no networking seems to work between them. From iwconfig, you can see that they each have a different "Cell" address (not the same Cell as in the iwlist scan) which is the pseudo-base station ID that is used to define an ad-hoc network (my best understanding from what I've read). Also, from the iwlist, each pi can see their own plus the other pi's ad-hoc network. I assume they need to select the same Cell id to communicate, and I'm unsure how to get them to do this automatically. I tried statically forcing these to be the same with the following command at each pi which did not change the cell id and therefore did not work:
sudo iwconfig wlan0 ap (some address)
I also tried a solution which uses ap_scan=2 in the wpa_supplicant config which did not seem to help.
Anyone have any idea what I've done wrong?
Thanks,
Andy.
After some searching I found that the Belkin USB adapter I was using apparently didn't have ad-hoc mode support with the linux drivers. I bought some other wireless USB adapaters that worked great "Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter". They are cheaper, smaller, and they worked in ad-hoc mode without even needing to worry drivers. The details I put for troubleshooting can be used as a guide if you are also wanting to do ad-hoc raspberry PI projects.
This works for me in /etc/network/interfaces:
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
wireless-essid "MYPINET"
wireless-channel 3
wireless-mode ad-hoc
wireless-ap 11:5F:02:38:5C:45
address 192.168.10.1
netmask 255.255.255.0
The essid, channel and ap can be any valid value (same on all your Pi's). Make sure to assign different addresses on the same subnet to your different Pi's and you should be fine. The ap defines the cell ID that was mentioned above. FWIW I am using a TP-link WN725N. It has the RTL8188CUS chipset and works fine out of the box even though dmesg indicates the Pi is treating it as an RTL8192.
I was unsuccessful with any adapter using the RTL8188CUS chipset. Luckily, I had a number of Ralink RT5370 dongles (from this kit) that support the nl80211 interface and ad-hoc mode.
My solution involves using wpa_supplicant and is configured with 2 files. Ensure that the nl80211 driver is installed:
sudo apt-get install libnl1
Next, create the following wpa_supplicant configuration file called /etc/wpa_supplicant-adhoc.conf on each Pi:
ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=2
network={
ssid="pihoc_wpa"
mode=1
frequency=2462
proto=WPA
key_mgmt=WPA-NONE
pairwise=NONE
group=TKIP
psk="password"
}
where you can choose the ssid, frequency (look here for valid values), and psk. Make sure that you are part of the user group net-dev using the command
getent group netdev
and if not, you can add yourself using
sudo usermod -a -G netdev userName
Next, add the following block to the /etc/network/interfaces file on each Pi:
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 10.10.2.1
netmask 255.255.255.0
pre-up wpa_supplicant -B -D nl80211 -i wlan0 -c /etc/wpa_supplicant-adhoc.conf
where each Pi has a different address field beginning with 10.10.2.. Also, if your RT5370 adapter is using an interface other than wlan0 (e.g. wlan1, wlan2, etc.), be sure to use that interface name instead.
At this point, the Pis should automatically join the network upon being rebooted. Test the connection by pinging or using ssh, for example run the following from the agent with IP address 10.10.2.1:
ssh 10.10.2.2
to access the agent with IP address 10.10.2.2.
The steps listed here are adapted from this Arch Linux wiki article and this Raspberry Pi forum discussion.

Resources