-
Notifications
You must be signed in to change notification settings - Fork 1
/
BT_Discovery_Protocol
82 lines (53 loc) · 2.57 KB
/
BT_Discovery_Protocol
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
Example device names when on "receive" mode:
xx:xx:xx:A7:6B:16
IzdJOVL8n14AAAAAAAAAIyLe0ocONEH3GtJSL-NuRXJZEVRlbGVmb25lIGRlIERpb2dv
IzdJOVL8n14AAAAAAAAAIyKp4M61YgF3ZRkxBoJ60L_ZEVRlbGVmb25lIGRlIERpb2dv
xx:xx:xx:3C:07:8B
IzlRSkT8n14AAAAAAAAAFwLgZfG9UTrDaojDIMFJjCtcBU1pIEEx
IzlRSkT8n14AAAAAAAAAFwIO4-okxaSu3o5taaa7cYF7BU1pIEEx
IzlRSkT8n14AAAAAAAAAFwLikXM7S-M1GDWPisM-4C5XBU1pIEEx
I0NYVkT8n14AAAAAAAAAFwLnjMrL1sRqoQaiDR6iA-4mBU1pIEEx
I0NYVkT8n14AAAAAAAAAFwIkztTpNPxEd3h7nbokY-_WBU1pIEEx
I1owMDb8n14AAAAAAAAAFwKJQzA45dCrRjN21kn19Vh5BU1pIEEx
Decode with URLBase64
----------
byte 0 : 1 BYTE 3bit version + 5 bit PCP
byte 1-5 : 4 bytes endpoint ID
byte 6-9 : 3 bytes service ID hash
byte 10 : 1 byte WebRTC state
byte 11-16: 6 bytes reserved
byte 17 : 1 byte lenght endpoint info
byte 18-32: remaining endpoint info
byte 33: Device name length
-----------
From connections/implementation/pcp.h on google's nearby repo:
// The PreConnectionProtocol (PCP) defines the combinations of interactions
// between the techniques (ultrasound audio, Bluetooth device names, BLE
// advertisements) used for offline Advertisement + Discovery, and identifies
// the steps to go through on each device.
PCP values:
kUnknown = 0,
kP2pStar = 1,
kP2pCluster = 2,
kP2pPointToPoint = 3
PCP is not clear, in case of google's implementation of nearby share for files seems to always be P2P, other applications may use other modes
-----------
Endpoint ID seems to change on every boot or when disabling and reenabling nearby share
-----------
Service ID appears to be attached to the application using the nearby protocol, in case of android's nearby share, this value is FC 9F 5E
core.h states:
// service_id - An identifier to advertise your app to other endpoints.
// This can be an arbitrary string, so long as it uniquely
// identifies your service. A good default is to use your
// app's package name.
The service ID is for "NearbySharing" -> fc9f5ed42c8a5e9e94684076ef3bf938a809c60ad354992b0435aebbdc58b97b
As we are implementing for Nearby Share, the service ID should match this hash
-----------
WebRTC might be for implementations where both devices are already on the same network, in this case, 0 because the phones were not connected to a network
-----------
Endpoint info may have some sort of authentication/encryption keys, couldn't find any reference to it yet
-----------
34th byte is the length of the device name
-----------
Bluetooth Service ID for nearby (or nearby share)
a82efa21-ae5c-3dde-9bbc-f16da7b16c5a