# 05-07 Get RSSI from advertisement
# Problem
Noble is an old package and does not seem to work that great. Below are some Github issues about RPi connections failing randomly. Luckily I do not even have to connect to the BLE servers.
# Solution of problem above
I do not have to connect to a device to get its RSSI. This is what I initially did with the ESP32 Client until I moved to connections to alleviate memory issues. Somehow it was stuck in my head that I have to connect. This is false. The advertisement packets of BLE servers also contain the RSSI and by allowing the scanner to include duplicates, I can continuously scan for devices with a given service UUID. The measurement stream outputs roughly 6 measurements per second for each server. The benefit of this setup is that it is increadibly simple (25 lines of code) and it supports a virtually unlimited amount of BLE Servers. Connections would be limited to roughly 5 peer devices. The program hovers stable around 75% RAM usage, but nodejs allows me to allocate more RAM if necessary.
# The super simple scanner logic
const scanForDevices = () => {
// look for items with the unique IPS Beacon service UUID, allow duplicates
BLEController.startScanning("3dc5bb11819b48f5b889c862079161f2", true);
}
// as soon as BLE adapter changes state
BLEController.on('stateChange', (state: any) => {
if (state === 'poweredOn') {
scanForDevices()
}
});
// handle scanner stop event
BLEController.on('scanStop', () => {
console.log('stopped scanning, restarting scan');
scanForDevices()
});
BLEController.on('discover', (server: Peripheral) => {
ipsCoordinator.registerServer(server);
if (server.address && server.rssi) {
ipsCoordinator.addMeasurementToUploadQueue({
rssi: server.rssi,
server_addr: server.address,
});
}
});
# Collection of connection issue reports with noble
Noble is really old and not very well supported for Raspbian OS. There is simply not a whole lot of demand for BLE programming on the Raspberry pi as a central device, since it is often used as a peripheral.