
Chapter 6. Future Use Case: Real-Time Indoor Localization Frameworks
During a Multipeer Connectivity session, each device can send data to all connected
peers. In this proof-of-concept system, the exchanged data includes the user’s name and
image. Every time a device sends data, it also includes its unique peer ID. As a result, all
shared data within the session is labeled with the sender’s peer ID. To store and manage
data received from other devices, a list called ‘peers’ is used. This list holds objects
of a custom type named ‘aPeer’, which was created specifically for this project. Each
‘aPeer’ object contains four pieces of information: i)the peer ID, ii)the user’s name, iii
their selected image, and iv)the distance from the current device (based on the ‘accuracy’
value). In this way, the peers list keeps a separate object for each nearby device, recording
their ID, name, picture, and relative distance.
When the system receives data from other devices, it first checks if the device is already
listed. If it is not, a new ‘aPeer’ object is created using the received peer ID, name, and
picture, and added to the list. If the peer is already known, the existing object is updated
with any new data. It is also possible to create a peer object with missing information,
allowing the rest to be added later during the session. For example, if a device starts
sharing its data, the name might arrive before the picture, due to network delays. In such
a case, the system creates a peer object with the peer ID and name. When the image
arrives later, the system finds the existing object and fills in the missing picture.
However, a key challenge in this system is linking each device’s beacon signal, which
provides relative distance to other peers, with the peer-to-peer session data, specifically
the user’s name and image. Since the Bluetooth Low Energy and Multipeer Connectivity
signals operate on different protocols, the system must find a way to associate them
correctly. To achieve this, the software must identify which BLE and MC signals come
from the same device. The pairing process works as follows (also depicted in Figure 6.8):
Each BLE signal provides two unique identifiers, Major and Minor values. These values
are combined into a single string, using a slash (‘/’) as a separator. For instance, if a
device has a Major value of ‘172’ and a Minor value of ‘8376’, the combined identifier
becomes ‘172/8376’. This string is then stored in the device’s ‘myPeerId’ attribute.
As a result, the device will advertise itself as a beacon using the Major/Minor values
‘172/8376’, and also participate in the peer-to-peer MC session using the same identifier.
When the software detects a BLE signal from a virtual beacon device and simultaneously
receives data from an MC peer, it combines the Major/Minor values of the beacon signal
into a string variable, separated by a slash punctuation mark (‘/’). Thus, the BLE Ma-
jor/Minor values ‘172’ and ‘8376’ will again form ‘172/8376’ on the receiving end. The
software then compares this new string variable from the BLE signal with the received
ID of the MC peer. If they match, it confirms that both signals originate from the same
device. If not, the software continues to compare the signals until all are correctly paired.
This straightforward and efficient solution effectively combines beacon signals with
peer-to-peer session data. By using this approach, each device can correctly identify
which signals belong to the same device, allowing the software to calculate their relative
distance based on the BLE signal. As a result, the distance attribute for each peer object
in the device’s list is updated accordingly. The integration of BLE signals with peer-
to-peer session data ensures that each device can accurately associate signals with the
144