diff --git a/README.html b/README.html index cce5d90..d474968 100644 --- a/README.html +++ b/README.html @@ -13,10 +13,10 @@ discovery using a Bluetooth LE “beacon” (as an alternative to Bonjour/Rendezvous DNS-SD service discovery). The user must set up a Bluetooth LE “beacon”, (a USB 4.0 or later “dongle” can be used). See instructions below. The beacon runs independently of UxPlay and -regularly broadcasts a Bluetooth LE (“Low Energy”) 44 byte packet +regularly broadcasts a Bluetooth LE (“Low Energy”) 46 byte packet informing nearby iOS/macOS devices of the local IPv4 network address of -the UxPlay server, which they can use to contact it on TCP port 7000. -Instructions for manually setting up such a beacon in Linux are given below. It is hoped that users will submit Pull Requests contributing scripts for automating beacon setup on all platforms. (Python may be an appropriate language @@ -1455,31 +1455,42 @@ this to see even more of the GStreamer inner workings.

Discovery, as an alternative to DNS-SD (Bonjour/Rendezvous) service discovery, start it with the option “-ble <path-to-writeable-file>”, which at startup -writes a data file containing the uxplay process ID and process name, -and is deleted when uxplay terminates normally. This file is not +writes a data file containing the uxplay TCP port for receiving replies +to the advertisement, plus the uxplay process ID and process name, and +is deleted when uxplay terminates normally. This file is not used in the simple manual method for creating a beacon described below.

Bluetooth LE Service discovery uses a “beacon” broadcasting a simple -12-byte advertisement “0B FF 4C 00 09 06 03 30 XX XX XX XX” -where XX XX XX XX is an IPv4 internet address of the UxPlay host -translated into hexadecimal octets: For example, -“XX XX XX XX” = “C0 A8 01 FD” means -192.168.2.253. UxPlay must be able to receive messages on TCP port 7000 -at this address. The uxplay option “-p” sets up uxplay to -listen on port 7000 for these messages.

-

The full translation of this message is that it has length 0B = 0x0b -= 11 octets, and is a single “Advertising Protocol Data Unit” (PDU) of +14-byte advertisement +“0D FF 4C 00 09 08 13 30 XX XX XX XX YY YY” where XX XX XX +XX is an IPv4 internet address (and port YY YY) of the UxPlay host +translated into hexadecimal octets. For example, +“XX XX XX XX YY YY” = “C0 A8 01 FD 1B 58” +means 192.168.2.253 port 0x1b58 (decimal value 7000). UxPlay must be +able to receive messages on this TCP port at this address. The uxplay +option “-p” sets up uxplay to listen on the default port +7000 for these messages, as used in the example above. Otherwise the +port in the beacon message should be the first (<n>) +of the 3 open TCP ports specified with uxplay option +-p <n>. If the -p option is not used +(which is only possible if there is no active firewall) the TCP port is +selected at random, and its value must be taken from the beginning of +the file written with the -ble option.

+

The full translation of this message is that it has length 0D = 0x0d += 13 octets, and is a single “Advertising Protocol Data Unit” (PDU) of type “FF”, called “Manufacturer-Specific Data”, with “manufacturer code” “4C 00” = 0x004c = Apple (note the reversal of octet order when two octets are combined to make a two-byte -unsigned short integer), and “09 06 03 30 XX XX XX XX” is -the Apple-specific data.

+unsigned short integer), and +“09 08 13 30 XX XX XX XX YY YY” is the Apple-specific +data.

The Apple-specific data contains a single Apple Data Unit with Apple -type = 09 (Airplay), Apple Data length 06 (0x06 = 6 octets) and Apple -Data “03 30 XX XX XX XX” where 03 = 0000 0011 is Apple -Flags, 30 is a seed (which will be ignored), and XX XX XX XX is the IPv4 -internet address. This is smaller than the “iBeacon” Apple Data Unit, -which has Apple type 02 and Apple length 15 (0x15 = 21 octets).

+type = 09 (Airplay), Apple Data length 08 (0x08 = 8 octets) and Apple +Data “13 30 XX XX XX XX YY YY” where 13 = 0001 0011 is +Apple Flags, 30 is a seed (which will be ignored), XX XX XX XX is the +IPv4 internet address and YY YY is the port. This is smaller than the +“iBeacon” Apple Data Unit, which has Apple type 02 and Apple length 15 +(0x15 = 21 octets).

In addition to creating the message, we need to set the “Advertising type” (ADV_NONCONN_IND) and “Advertising interval” range [AdvMin, AdvMax], where 0x00a0 = 100 msec <= AdvMin <= AdvMax <= 0x4000 @@ -1547,13 +1558,14 @@ three advertising channels.

Step 2. Set the advertising message with HCI LE command 0x0008. For this command, hcitool requires a 32 octet message after sudo hcitool -i hci0 cmd 0x08 0x0008: The first octet -is the length 0C = 0x0c = 12 of the “significant part” of the following -31 octets, followed by the 12 octets of the advertisement, then padded -with 19 zeroes to a total length of 32 octets. The example below sends -an IPv4 address 192.168.1.253 as “0xc0 0xa8 0x01 0xfd”:

-
$ sudo hcitool -i hci0 cmd 0x08 0x0008 0x0c 0x0b 0xff 0x4c 0x00 0x09 0x06 0x03 0x30  0xc0 0xa8 0x01 0xfd  0x00 0x00 0x00 0x00  0x00 0x00 0x00 0x00  0x00 0x00 0x00 0x00  0x00 0x00 0x00 0x00  0x00 0x00 0x00
+is the length 0E = 0x0e = 14 of the “significant part” of the following
+31 octets, followed by the 14 octets of the advertisement, then padded
+with 17 zeroes to a total length of 32 octets. The example below sends
+an IPv4 address 192.168.1.253 as “0xc0 0xa8 0x01 0xfd” and
+the TCP port as 0x1b 0x58 (port 7000 = 0x1b58):

+
$ sudo hcitool -i hci0 cmd 0x08 0x0008 0x0e 0x0d 0xff 0x4c 0x00 0x09 0x08 0x13 0x30  0xc0 0xa8 0x01 0xfd  0x1b 0x58 0x00 0x00  0x00 0x00 0x00 0x00  0x00 0x00 0x00 0x00  0x00 0x00 0x00 0x00  0x00 0x00 0x00
 < HCI Command: ogf 0x08, ocf 0x0008, plen 32
-  0C 0B FF 4C 00 09 06 03 30 C0 A8 01 FD 00 00 00 00 00 00 00 
+  0E 0D FF 4C 00 09 08 13 30 C0 A8 01 FD 1B 58 00 00 00 00 00 
   00 00 00 00 00 00 00 00 00 00 00 00 
 > HCI Event: 0x0e plen 4
   01 08 20 00 
@@ -1564,7 +1576,7 @@ an IPv4 address 192.168.1.253 as “0xc0 0xa8 0x01 0xfd”:

01 > HCI Event: 0x0e plen 4 02 0A 20 00
-

The full length of the broadcasted beacon message is 43 bytes. To +

The full length of the broadcasted beacon message is 46 bytes. To stop the beacon, use this command to send the 1-byte message “0x00” = “off”.