# Measurement and Analysis of RSS Using Bluetooth Mesh Network for Localization Applications
## 4 Bluetooth Mesh Network for Experimental Studies of RSS Measurements
### Design of Communication Protocols for Channel-Aware Multi-Device RSS Measurements  
Bluetooth mesh network implements the internode communication using a publish/subscribe messaging system [22, 25]. With such a system, messages may be published to a unicast address, group address, or virtual address. When a node publishes a message to a particular address, all the nodes that have subscribed to that address will receive a copy of the message. In this research, we designed several communication protocols over the standard mesh network messaging system to control the data collection process as illustrated in Figure 4. The communication protocols are implemented using the vendor client/server model that is defined in the ESP Bluetooth mesh networking framework [25]. Figure 3: System architecture of the measurement mesh network. Figure 2: (a) ESP32-WROOM-32U and the 2.4 GHz 6 dBi omnidirectional antenna, and (b) ESP32-WROOM-32D development board with the onboard PCB antenna. In our design of communication protocols, beacon nodes publish advertising messages periodically at the advertising interval. The time-to-live (TTL) parameter of advertising messages is set to 0 to limit the receiving nodes to those within direct radio communication range. Gateway node can multicast a message to beacon nodes to change advertising interval during the runtime. It also multicasts to scanner nodes to start the data collection process. After scanner nodes have collected a specified number of data, they use unicast to send data to gateway node, which then forwards the data to control station for storage and postprocessing. To reduce collisions among scanner nodes when sending data to gateway node, a random delay is added by each scanner node at the end of data collection process before sending data to gateway node. The payload of each adverting message is limited to 29 bytes as specified by the Bluetooth mesh network standard [26]. The payload of the data message published by scanner node to gateway node is limited to 377 bytes, which is then segmented into smaller packets at the transport layer for transmission over BLE [26]. When beacon nodes publish an advertising message, the message is broadcasted by the underlying BLE layer in advertising events using three advertising channels one after another in quick succession as shown in Figure 5. Scanner nodes adopt a scan cycle that cycles over the three advertising channels in sequence, trying to capture advertising packets. Scanner nodes measure RSS using the advertising packet received from beacon nodes. The BLE specification for advertisement reception does not require BLE device to report from which advertising channel it has received each of the advertising packets [5]. Therefore, in order to study and compare the characteristics of the three advertising channels, we designed a communication protocol to associate channel ID information to each of the advertising packets. Specifically, as shown in Figure 5, we configured the BLE layer to use only one advertising channel to transmit in each advertising event, instead of using all three channels as in the standard advertising events. The same advertising channel will be used in  
Figure 4: Communication protocol in the mesh network for data collection. Figure 5: Modified adverting event for channel-aware advertising and scanning of the beacon advertising messages. multiple advertising events in sequence before cycling to the next channel to achieve reliable reception by scanner nodes. In addition, the payload of advertising messages is designed to include the ID number of the channel used for the current advertising event. As a result, after a scanner node receives an advertising message, it can parse the message to find out from which advertising channel it has received the message. The advertising message also contains a message sequence ID number in the payload, which is used in postprocessing to match the RSS measurements collected from multiple scanner nodes.