I am trying to capture samples from an USRP X310 using uhd 4.0.0 on fedora 34.
I keep having issues with "timeout" that interrupt streaming instantaneously but I found no reason for this and also no help on the internet ...
I give you the detailed code below.
Thanks for your help !
PS : I have the same results with ./rx_samples_to_file without parameter
[user#computer examples]$ ./rx_samples_to_file --freq=1000000000 --bw=500000 --rate 200000 --duration=0.5 --file=x310_test.bin
Creating the usrp device with: ...
[INFO] [UHD] linux; GNU C++ version 11.0.1 20210324 (Red Hat 11.0.1-0); Boost_107500; UHD_4.0.0.0-0-unknown
[INFO] [X300] X300 initialization sequence...
[INFO] [X300] Maximum frame size: 1472 bytes.
[INFO] [X300] Radio 1x clock: 200 MHz
Using Device: Single USRP:
Device: X-Series Device
Mboard 0: X310
RX Channel: 0
RX DSP: 0
RX Dboard: A
RX Subdev: TwinRX RX0
RX Channel: 1
RX DSP: 1
RX Dboard: A
RX Subdev: TwinRX RX1
RX Channel: 2
RX DSP: 2
RX Dboard: B
RX Subdev: Unknown (0xffff) - 0
TX Channel: 0
TX DSP: 0
TX Dboard: B
TX Subdev: Unknown (0xffff) - 0
Setting RX Rate: 0.200000 Msps...
Actual RX Rate: 0.200000 Msps...
Setting RX Freq: 1000.000000 MHz...
Setting RX LO Offset: 0.000000 MHz...
Actual RX Freq: 1000.000000 MHz...
Setting RX Bandwidth: 0.500000 MHz...
Actual RX Bandwidth: 0.500000 MHz...
Waiting for "lo_locked": ++++++++++ locked.
Press Ctrl + C to stop streaming...
Timeout while streaming
Done!
I also tried benchmark function but it ended the same :
EDIT : I stopped firewalld.services
[usr#computer examples]$ ./benchmark_rate --args="type=x300,addr=192.168.10.2,serial=320179E" --channels 0,1 --rx_rate 2e6 --duration 5
[INFO] [UHD] linux; GNU C++ version 11.0.1 20210324 (Red Hat 11.0.1-0); Boost_107500; UHD_4.0.0.0-0-unknown
[00:00:00.000390] Creating the usrp device with: type=x300,addr=192.168.10.2,serial=320179E...
[INFO] [X300] X300 initialization sequence...
[INFO] [X300] Maximum frame size: 1472 bytes.
[INFO] [X300] Radio 1x clock: 200 MHz
[WARNING] [RFNOC::GRAPH] One or more blocks timed out during flush!
Using Device: Single USRP:
Device: X-Series Device
Mboard 0: X310
RX Channel: 0
RX DSP: 0
RX Dboard: A
RX Subdev: TwinRX RX0
RX Channel: 1
RX DSP: 1
RX Dboard: A
RX Subdev: TwinRX RX1
RX Channel: 2
RX DSP: 2
RX Dboard: B
RX Subdev: Unknown (0xffff) - 0
TX Channel: 0
TX DSP: 0
TX Dboard: B
TX Subdev: Unknown (0xffff) - 0
[00:00:03.664016092] Setting device timestamp to 0...
[INFO] [MULTI_USRP] 1) catch time transition at pps edge
[INFO] [MULTI_USRP] 2) set times next pps (synchronously)
[WARNING] [0/Radio#0] Attempting to set tick rate to 0. Skipping.
[00:00:04.934122870] Testing receive rate 2.000000 Msps on 2 channels
[00:00:05.85737158] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.185992285] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.286246070] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.386497035] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.486745394] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.587001598] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.687253152] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.787508452] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.887760249] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:05.988013669] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.88264700] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.188520367] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.288770879] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.389026502] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.489276462] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.589533078] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.689791950] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.790041080] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.890288133] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:06.990543703] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.90798580] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.191062617] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.291319218] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.391574410] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.491830205] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.592097982] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.692351705] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.792602183] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.892874187] Receiver error: ERROR_CODE_TIMEOUT, continuing...
[00:00:07.993127880] Receiver error: ERROR_CODE_TIMEOUT, continuing...
O[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
O[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
OO[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
O[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
OO[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
O[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
O[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
OO[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
OO[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
OO[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
OO[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
O[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
OO[WARNING] [0/Radio#0] Cannot process RX-related async message to invalid chan 1
[00:00:10.123329222] Benchmark complete.
Benchmark rate summary:
Num received samples: 0
Num dropped samples: 0
Num overruns detected: 20
Num transmitted samples: 0
Num sequence errors (Tx): 0
Num sequence errors (Rx): 0
Num underruns detected: 0
Num late commands: 0
Num timeouts (Tx): 0
Num timeouts (Rx): 30
Done!
I know this topic is a bit old, but after days of troubleshooting this error, I HAVE to share how I fixed it without having to buy a SFP+ adapter.
In my case, I had a method checking the health and status of the onboard FPGA of the USRP. But, in the python desktop side, we actually checked the status too often, which was causing CPU issus, leading to a timeout and performance loss: Linux was almost usable.
I just had to add a small 0.01s temporisation between two checks, and now it works like a charm with no issues at all. I guess the SFP+ module allows higher speed, which make the 0.01s temporisation useless because we are not cpu bottleneking anymore. But it can still happen in higher speeds.
The most common cause for this is your PC filtering out the network packets containing data. This might be firewall rules, or a strangely configured MTU, for example.
Other than that:
--bw=500000: No USRP hardware has a frontend filter that can be made that narrow. It usually also wouldn't help anything, so chances are you don't want to specify this at all
--rx_rate 2e5 That's really at the least least least end of possible sampling rates. This is rarely useful, you'll see the roll-off of the digital filters, probably. Recommendation: Modern PCs are fast. Use 1e6 as rate, and filter and decimate to whatever rate you need in software.
enable_tx_dual_eth=1 omit this. (as it reconfigures networking, this might also solve your issue) I don't see how that makes any sense when your USRP doesn't even have TX daughterboards.
Related
We have bought a CAN Connect module for our Revpi Connect, and set it up as can been seen in this thread on the Kunbus forum. As far as we understand this will provide the proper termination.
We have also followed this guide provided by Revolution PI.
When checking that the drivers for the CAN module is properly loaded, everything looks fine:
$ dmesg | grep can
[ 4.616900] hi3110 spi0.0 can0: 3110 successfully initialized.
[ 107.049422] IPv6: ADDRCONF(NETDEV_UP): can0: link is not ready
[ 107.049463] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
Checking ip statistics gives this result:
$ ip -det -statistics link show can0
5: can0: mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 50000 sample-point 0.875
tq 1250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
hi3110: tseg1 2..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
However, when we turn on candump and send a message using cansend, candump does not show any traffic.
If we check dmesg for CAN again, we get this result:
$ dmesg | grep can
[ 4.616900] hi3110 spi0.0 can0: 3110 successfully initialized.
[ 107.049422] IPv6: ADDRCONF(NETDEV_UP): can0: link is not ready
[ 107.049463] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 292.285353] can: controller area network core (rev 20170425 abi 9)
[ 292.297811] can: raw protocol (rev 20170425)
And if we check ip -statistics again, we can see that the state of the connection has gone into ERROR-PASSIVE:
$ ip -det -statistics link show can0
5: can0: mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-PASSIVE (berr-counter tx 128 rx 0) restart-ms 0
bitrate 50000 sample-point 0.875
tq 1250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
hi3110: tseg1 2..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 1 1 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
We are trying to communicate with a computer with and Ixxat USB2CAN v2, at 50kbps, with both highspeed and FT settings, but nothing seems to work. Resetting the connection, seems to put it back into ERROR-ACTIVE state.
When trying to communicate with mentioned computer, using another computer with Socketcan and another Ixxat USB2CAN v2 device, everything works fine.
I should perhaps also mention that if we turn loopback on, we can see the messages we are sending.
We are struggling to understand whether this a hardware or software error. Is our termination in order? Are there any magical settings in SocketCAN we have overlooked? Where should we start debugging this issue?
Any help would be greatly appreciated.
As it turns out, the schematic printed directly on the device is wrong.The schematic on their website is correct.
Hopefully this can help someone else avoid pulling their hair out in the future.
Consider the following piece of code:
#include
#include
int main () {
char *str;
/* Initial memory allocation */
str = (char *) malloc(15);
strcpy(str, "tutorialspoint");
printf("String = %s, Address = %u\n", str, str);
str = NULL;
free(str);
return(0);
}
Why does the above program cause a memory leak? How do I avoid this?
An error is thought to occur in "str = NULL;". Why?
valgrind log:
==4143== Memcheck, a memory error detector
==4143== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4143== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==4143== Command: ./a.out
==4143==
String = tutorialspoint, Address = 86097984
==4143==
==4143== HEAP SUMMARY:
==4143== in use at exit: 15 bytes in 1 blocks
==4143== total heap usage: 2 allocs, 1 frees, 1,039 bytes allocated
==4143==
==4143== 15 bytes in 1 blocks are definitely lost in loss record 1 of 1
==4143== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4143== by 0x1086EB: main (in /home/stack/a.out)
==4143==
==4143== LEAK SUMMARY:
==4143== definitely lost: 15 bytes in 1 blocks
==4143== indirectly lost: 0 bytes in 0 blocks
==4143== possibly lost: 0 bytes in 0 blocks
==4143== still reachable: 0 bytes in 0 blocks
==4143== suppressed: 0 bytes in 0 blocks
==4143==
==4143== For counts of detected and suppressed errors, rerun with: -v
==4143== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
free(str); frees the space pointed to by str, where str is the space obtained by malloc. Because of the line str = NULL; happens before the free, free is attempting to deallocate the memory position at location 0. By definition in the C standard, this does nothing. It is common to set a pointer to 0 after it is deleted, so that if one were to accidentally attempt to delete it again, nothing happens.
To fix you code, you simply need to swap the lines str = NULL; and free(str);
I am trying to automate the exporting of full dissections of a pcap to a .txt file using tshark. I am aware of the file->export packet dissections as option, but I am working to automate that. Right now I have tshark -X lua_script: -r > . The files enclosed in <> are paths. The lone > is the command for printing text. It will export packet summaries but not the full dissection. IS there any way to export the full dissection to the command line. These sample line are what is exported right now,
1 0.000000000 02:00:00:00:00:67 -> IPv4mcast_01:05:ee 0x8903 1467 Data Center Ethernet (DCE) protocol(Cisco)
2 0.000001180 10.81.130.23 -> 239.1.5.238 ST 1451 Messages: 14
3 0.006327070 02:00:00:00:00:67 -> IPv4mcast_01:05:ee 0x8903 1467 Data Center Ethernet (DCE) protocol(Cisco)
4 0.006328250 10.81.130.23 -> 239.1.5.238 ST 1451 Messages: 14
5 0.019039770 02:00:00:00:00:67 -> IPv4mcast_01:05:ee 0x8903 1467 Data Center Ethernet (DCE) protocol(Cisco)
This is what I want the exports to look like
No. Time Source Destination Protocol Length Info
2 0.000001180 10.81.130.23 239.1.5.238 ST 1451 Messages: 14
Frame 2: 1451 bytes on wire (11608 bits), 1451 bytes captured (11608 bits)
Ethernet II, Src: Solarfla_0e:e4:a1 (00:0f:53:0e:e4:a1), Dst: IPv4mcast_01:05:ee (01:00:5e:01:05:ee)
Internet Protocol Version 4, Src: 10.81.130.23 (10.81.130.23), Dst: 239.1.5.238 (239.1.5.238)
User Datagram Protocol, Src Port: 43464 (43464), Dst Port: 25238 (25238)
ST Block
Block Header
Sanity: 23559 (Should be 23559)
Header Version (Major: 0 Minor: 1)
Header Size in Bytes: 19
Payload Size in Bytes: 1386
Messages: 14
Environment Id: 0
Feed Id: 1 (Uqdf)
Compression Type: 0
Sender Id: 1
Sequence: 37495844
Message Header
Header Version (Major: 0 Minor: 1)
Header Length in Bytes: 31
Msg Type: 1 (Equity Quote)
Message Version (Major: 0 Minor: 1)
Msg Length in Bytes: 68
Flags: 0
Data Type: 1 (Equity)
Feed Id: 1 (Uqdf)
Feed Line: 1
Feed Seq Num: 7123431
Feed Sub Seq Num: 0
Exchange Time (10:59:59.978517000)
High: 9220
Low: 380047880
Note: this is what the packet dissections look like when using file->export packet dissections
Thank you in advance!
After looking at the problem I have figured it out. It is tshark -X lua_script:filename -r p.pcap -V -T text > file.txt.
The key was the -V, as that prints packet details.
i am not able to render or capture video on ios.
After successful SDP negtiation i tried to add video call for existing audio call, in on_call_media_state callback i observed that the media is not active for video.
When i hung up the call i get the following log which shows #1 video H263-1998, inactive, peer=10.11.201.147:50858.
According to Siphon some are able to get the video stream on ios devices.
Any help would be appreciated
3-11-15 14:59:39.075 ipjsua[220:6007] 14:59:39.075 pjsua_app.c .....Call 1 is DISCONNECTED [reason=200 (Normal call clearing)]
2013-11-15 14:59:39.093 ipjsua[220:6007] 14:59:39.093 pjsua_app.c .....
2013-11-15 14:59:39.097 ipjsua[220:6007] [DISCONNCTD] To: "102" <sip:102#10.11.201.147>;tag=bf76b652
Call time: 00h:04m:04s, 1st res in 121 ms, conn in 674ms
#0 audio speex #16kHz, sendrecv, peer=10.11.201.147:22268
SRTP status: Not active Crypto-suite: (null)
RX pt=100, last update:00h:00m:00.627s ago
total 12.1Kpkt 1.29MB (1.78MB +IP hdr) #avg=42.2Kbps/58.2Kbps
pkt loss=4 (0.0%), discrd=0 (0.0%), dup=0 (0.0%), reord=0 (0.0%)
(msec) min avg max last dev
loss period: 20.000 20.000 20.000 20.000 0.000
jitter : 0.000 6.258 32.187 14.500 3.978
TX pt=100, ptime=20, last update:00h:00m:02.013s ago
total 8.3Kpkt 249.0KB (581.7KB +IP hdr) #avg=8.1Kbps/19.0Kbps
pkt loss=152 (1.8%), dup=0 (0.0%), reorder=0 (0.0%)
(msec) min avg max last dev
loss period: 20.000 49.836 140.000 120.000 25.816
jitter : 5.500 20.248 75.750 33.250 14.885
RTT msec : 5.966 50.438 146.325 131.000 33.555
#1 video H263-1998, inactive, peer=10.11.201.147:50858
SRTP status: Not active Crypto-suite: (null)
RX last update:00h:01m:30.404s ago
total 12pkt 48B (528B +IP hdr) #avg=2bps/22bps
pkt loss=0 (0.0%), discrd=0 (0.0%), dup=0 (0.0%), reord=0 (0.0%)
(msec) min avg max last dev
loss period: 0.000 0.000 0.000 0.000 0.000
jitter : -0.001 0.000 0.000 0.000 0.000
TX last update:00h:01m:03.332s ago
total 0pkt 0B (0B +IP hdr) #avg=0bps/0bps
pkt loss=1 (100.0%), dup=0 (0.0%), reorder=0 (0.0%)
(msec) min avg max last dev
loss period: 0.000 0.000 0.000 0.000 0.000
jitter : 0.000 0.000 0.000 0.000 0.000
RTT msec : 0.000 0.000 0.000 0.000 0.000
#2 video H263-1998, inactive, peer=10.11.201.147:22264
SRTP status: Not active Crypto-suite: (null)
RX last update:00h:01m:39.059s ago
total 15pkt 60B (660B +IP hdr) #avg=2bps/27bps
pkt loss=0 (0.0%), discrd=2 (13.3%), dup=2 (13.3%), reord=0 (0.0%)
(msec) min avg max last dev
loss period: 0.000 0.000 0.000 0.000 0.000
jitter : -0.001 0.000 0.000 0.000 0.000
TX last update:00h:01m:08.467s ago
total 0pkt 0B (0B +IP hdr) #avg=0bps/0bps
pkt loss=1 (100.0%), dup=0 (0.0%), reorder=0 (0.0%)
(msec) min avg max last dev
loss period: 0.000 0.000 0.000 0.000 0.000
jitter : 0.000 0.000 0.000 0.000 0.000
RTT msec : 0.000 0.000 0.000 0.000 0.000
2013-11-15 14:59:39.214 ipjsua[220:6007] 14:59:39.214 pjsua_media.c .....Call 1: deinitializing media..
2013-11-15 14:59:39.231 ipjsua[220:6007] 14:59:39.231 pjsua_media.c .......Media stream call01:0 is destroyed
2013-11-15 14:59:39.253 ipjsua[220:6007] 14:59:39.253 pjsua_vid.c .......Stopping video stream..
2013-11-15 14:59:39.259 ipjsua[220:6007] 14:59:39.259 pjsua_media.c .......Media stream call01:1 is destroyed
2013-11-15 14:59:39.264 ipjsua[220:6007] 14:59:39.264 pjsua_vid.c .......Stopping video stream..
2013-11-15 14:59:39.276 ipjsua[220:6007] 14:59:39.276 pjsua_media.c .......Media stream call01:2 is destroyed
2013-11-15 14:59:40.232 ipjsua[220:6007] 14:59:40.231 pjsua_aud.c Closing sound device after idle for 1 second(s)
2013-11-15 14:59:40.234 ipjsua[220:6007] 14:59:40.234 pjsua_app.c .Turning sound device OFF
2013-11-15 14:59:40.253 ipjsua[220:6007] 14:59:40.252 pjsua_aud.c .Closing iPhone IO device sound playback device and iPhone IO device sound capture device
2013-11-15 14:59:40.415 ipjsua[220:6007] 14:59:40.415 coreaudio_dev. .core audio stream stopped
2013-11-15 15:00:33.609 ipjsua[220:6007] 15:00:33.608 pjsua_core.c .RX 719 bytes Request msg SUBSCRIBE/cseq=52 (rdata0xa41a14) from UDP 10.11.201.147:5060:
SUBSCRIBE sip:101#10.11.208.114:5060;ob SIP/2.0
2013-11-15 15:19:54.347 ipjsua[220:6007] 15:19:54.347 pjsua_app.c .....Call 2 is DISCONNECTED [reason=200 (Normal call clearing)]
PJSIP on iOS does not currently implement Video Media.
The data sheet states which OSs video is implemented for:
Video Media
Platforms:
Windows,
Linux,
Mac
Codecs:
H.263-1998 (ffmpeg),
H.264 (ffmpeg and x264)
Capture devices:
colorbar (all platforms)
DirectShow (Windows)
Video4Linux2 (Linux)
QuickTime (Mac OS X)
Rendering devices:
SDL (Windows, Linux, and Mac OS X)
DirectShow (Windows)
http://trac.pjsip.org/repos/wiki/PJSIP-Datasheet
Further, the video user guide states that mobile OSs are not yet supported:
Video is available on PJSIP version 2.0 and later. Only desktop platforms are supported, mobile devices such as iOS are not yet supported.
http://trac.pjsip.org/repos/wiki/Video_Users_Guide
I'm interested in connecting to iOS-based devices over Bluetooth. I can see that the "Local Network" service is exposed, but I cannot find any extra information about it. Property stored under key 0x0204 looks like a Bonjour key.
Which protocol is used? How can one talk to the iOS device using Linux, Mac or one's own embedded device equipped with a Bluetooth chip?
Here's SDP data extracted using Bluetooth Explorer under OS X while the iOS device runs Gameloft's Star Battalion.
{
0x0000 = uint32(1330188565),
0x0200 = uint32(2),
0x0202 = string(004wD7l1A..0|0|0|ivucic-À'),
0x030a = uint32(0),
0x0009 = { { uuid16(11 15), uint16(256) } },
0x0201 = string(_657o30a6rmst07À),
0x0005 = { uuid16(10 02) },
0x0100 = string(Local Network),
0x0001 = { uuid16(11 15) },
0x0203 = string(004wd7l1a..0|0|0|ivucic-_657o30a6rmst07À
0xf000 = uint8(2),
0x0204 = string( txtvers=1state=A),
0x0008 = uint8(255),
0x0006 = { uint16(25966), uint16(106), uint16(256), uint16(26226), uint16(106), uint16(272), uint16(25701), uint16(106), uint16(288), uint16(27233), uint16(106), uint16(304) },
0x0004 = { { uuid16(01 00), uint16(15) }, { uuid16(00 0f), uint16(256), { uint16(2048), uint16(2054) } } },
0x0002 = uint32(0)
},
Other partially relevant questions:
PAN with Linux, iOS, Bluetooth, Bonjour, GameKit — Possible? - Person can solve problem using Wi-Fi. Not solution here because embedded device will not have the way more expensive Wi-Fi chip.
Bonjour over bluetooth WITHOUT Gamekit? - Best answer does not end up providing technical details
iOS bluetooth without GameKit - Provides a solution for a jailbroken device, which is not applicable here.
Researching further with Apple's Bluetooth Explorer in OS X and sdptool in GNU/Linux, I have discovered that key 0x0001 (standing for "protocol class"), containing value of 0x1115, stands for the "PANU" variant of "PAN" - a peer2peer variant. It is notable that OS X does not provide service-side ('hosting') support for this protocol, despite supporting creation of a 0x1116 network, which is the "NAP" variant of "PAN" - a client/server variant.
This might be good news, but only if GameKit's session protocol does not have to be used. Hijacking the media-layer connection established by GameKit in order to send other UDP traffic would be ideal.
I'll still have to research whether or not this GameKit connection really is 0x1115; that is, if it really is "PANU". Does anyone have any further information?
Note while Bonjour automatically announced this Bluetooth service after iOS 3, this has changed with iOS 5. See the answer I posted on how to establish Bluetooth connection without GameKit, where I handily documented information from Apple's Technical Q&A QA1753.
A small amount of research with GNU/Linux did not result in a successful connection. It may be due to lack of knowledge on how to properly use pand. It may also be due to Bluetooth MAC based blocking. I'd love info anyone may have to offer. If I research this further and stumble upon something interesting, I'll update this answer.
Results under Ubuntu. The service appears only when Bluetooth Bonjour is active.
ivucica#ivucica-MacBook:~$ sdptool browse $ADDR #relevant data only
Browsing ADDRESS_HERE ...
Service Name: Local Network
Service RecHandle: 0x4f491115
Service Class ID List:
"PAN User" (0x1115)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 15
"BNEP" (0x000f)
Version: 0x0100
SEQ8: 0 6
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
code_ISO639: 0x6672
encoding: 0x6a
base_offset: 0x110
code_ISO639: 0x6465
encoding: 0x6a
base_offset: 0x120
code_ISO639: 0x6a61
encoding: 0x6a
base_offset: 0x130
Profile Descriptor List:
"PAN User" (0x1115)
Version: 0x0100
... and so on ...
Here's the attempt to connect:
ivucica#ivucica-MacBook:~$ pand --connect $ADDR -n
pand[3237]: Bluetooth PAN daemon version 4.98
pand[3237]: Connecting to ADDRESS_HERE
pand[3237]: Connect to ADDRESS_HERE failed. Connection refused(111)
Is some sort of authorization required? Enabling encryption, authentication, secure connection and forcing becoming a master doesn't seem to make any difference (-AESM options in various combinations).
Anyone has any ideas?
Huh!
ivucica#ivucica-MacBook:~$ sudo hcidump
HCI sniffer - Bluetooth packet analyzer ver 2.2
device: hci0 snap_len: 1028 filter: 0xffffffff
HCI Event: Command Status (0x0f) plen 4
Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Role Change (0x12) plen 8
status 0x00 bdaddr ADDRESS_HERE role 0x01
Role: Slave
> HCI Event: Connect Complete (0x03) plen 11
status 0x00 handle 12 bdaddr ADDRESS_HERE type ACL encrypt 0x00
HCI Event: Command Status (0x0f) plen 4
Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
> HCI Event: Read Remote Supported Features (0x0b) plen 11
status 0x00 handle 12
Features: 0xbf 0xfe 0x8f 0xfe 0x9b 0xff 0x79 0x83
HCI Event: Command Status (0x0f) plen 4
Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Max Slots Change (0x1b) plen 3
handle 12 slots 5
> HCI Event: Read Remote Extended Features (0x23) plen 13
status 0x00 handle 12 page 1 max 1
Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
HCI Event: Command Status (0x0f) plen 4
Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Remote Name Req Complete (0x07) plen 255
status 0x00 bdaddr ADDRESS_HERE name 'Evil iPad'
HCI Event: Command Status (0x0f) plen 4
Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
> HCI Event: Link Key Request (0x17) plen 6
bdaddr ADDRESS_HERE
HCI Event: Command Complete (0x0e) plen 10
Link Key Request Reply (0x01|0x000b) ncmd 1
status 0x00 bdaddr ADDRESS_HERE
> HCI Event: Auth Complete (0x06) plen 3
status 0x00 handle 12
HCI Event: Command Status (0x0f) plen 4
Set Connection Encryption (0x01|0x0013) status 0x00 ncmd 1
> HCI Event: Encrypt Change (0x08) plen 4
status 0x00 handle 12 encrypt 0x01
HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 1
> ACL data: handle 12 flags 0x02 dlen 16
L2CAP(s): Info rsp: type 2 result 0
Extended feature mask 0x02a8
Enhanced Retransmission mode
FCS Option
Fixed Channels
Unicast Connectless Data Reception
HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 1
> ACL data: handle 12 flags 0x02 dlen 20
L2CAP(s): Info rsp: type 3 result 0
Fixed channel list 0x00000006
L2CAP Signalling Channel
L2CAP Connless
HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 1
> ACL data: handle 12 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0000 scid 0x0040 result 2 status 0
Connection refused - PSM not supported
> HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 12 reason 0x13
Reason: Remote User Terminated Connection
This?
> ACL data: handle 12 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0000 scid 0x0040 result 2 status 0
Connection refused - PSM not supported
According to this interesting site :
http://code.google.com/p/btstack/wiki/iPhoneBluetooth Apple are using a special chip besides their Bluetooth RF chip which denies any connection for a device without that chip - this means its a lock on the hardware level.
Maybe a bit delayed, but technologies have evolved since so there is certainly new info around which draws fresh light on the matter...
The traditional GameKit has been replaced by Multiper Connectivity together with introducing support for WiFi Direct on iOS, however the framework still remains iOS only. I assume there is proprietary stuff going on in there.
Also, as iOS has yet to open up a direct API for WiFi Direct I believe the best way to approach this is to use BLE, which is supported by both platforms (some better than others).
On iOS a device can act both as a BLE Central and BLE Peripheral at the same time, on Android the situation is more complex as not all devices support the BLE Peripheral state. Also the Android BLE stack is very unstable (to date).
If your use case is feature driven, I would suggest to look at Frameworks and Libraries that can achieve cross platform communication for you, without you needing to build it up from scratch.
For example: http://p2pkit.io or google nearby
Disclaimer: I work for Uepaa, developing p2pkit.io for Android and iOS.