-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Feature Request: Add BLE RSSI (BLE Signal Strength) Access to calling program.
RadiaCode Library - BLE RSSI Patch
Status: TESTED AND WORKING
Date: March 2026
Compatible With: RadiaCode library by Markus Geiger (mkgeiger)
This patch adds RSSI (signal strength) access to the RadiaCode Arduino library.
What This Patch Does
Adds a getRSSI() method to access BLE signal strength from your RadiaCode device.
Returns:
-30to-90dBm: Connected (typical range)-100: Not connected or error
Installation Instructions
You need to edit 4 files in your RadiaCode library folder:
Location: Documents/Arduino/libraries/RadiaCode/src/
FILE 1: BluetoothTransport.h
FIND the public section:
public:
BluetoothTransport(const char* mac);
virtual ~BluetoothTransport(void);
virtual BytesBuffer execute(const uint8_t* request, size_t length) override;ADD this line after the execute() line:
int getRSSI(); // Get BLE signal strengthResult should look like:
public:
BluetoothTransport(const char* mac);
virtual ~BluetoothTransport(void);
virtual BytesBuffer execute(const uint8_t* request, size_t length) override;
int getRSSI(); // Get BLE signal strengthFILE 2: BluetoothTransport.cpp
SCROLL TO THE VERY END of the file (after the last function's closing brace)
ADD this complete function:
int BluetoothTransport::getRSSI() {
#ifdef BT_SUPPORT_ENABLED
if (_peripheral) {
BLEClient* pClient = (BLEClient*)_peripheral;
if (pClient->isConnected()) {
return pClient->getRssi();
}
}
#endif
return -100; // Not connected
}FILE 3: RadiaCode.h
FIND the public section (around line 90):
// Direct sensor reading methods
float getTemperature(void);ADD this line after getTemperature():
int getRSSI(); // Get BLE signal strength in dBmResult should look like:
// Direct sensor reading methods
float getTemperature(void);
int getRSSI(); // Get BLE signal strength in dBmFILE 4: RadiaCode.cpp
FIRST - Check the #include section at the top of the file.
MAKE SURE this line exists (add it if missing):
#include "BluetoothTransport.h"THEN - SCROLL TO THE VERY END of the file (after the last function)
ADD this complete function:
int RadiaCode::getRSSI() {
if (!_connection) {
return -100; // No connection
}
// Safe cast on ESP32 - _connection is always BluetoothTransport
BluetoothTransport* bt = (BluetoothTransport*)_connection;
return bt->getRSSI();
}⚠️ Critical Notes
1. Add Functions at the END of Files
DO NOT add functions INSIDE other functions!
- Always add at the END of
.cppfiles - Look for the last closing brace
}of existing code - Add your new function AFTER that
2. Use C-Style Cast (Not dynamic_cast)
Arduino doesn't support RTTI, so use simple casting:
// ✅ CORRECT - C-style cast
BluetoothTransport* bt = (BluetoothTransport*)_connection;
// ❌ WRONG - dynamic_cast not supported
BluetoothTransport* bt = dynamic_cast<BluetoothTransport*>(_connection);3. Include BluetoothTransport.h
Make sure RadiaCode.cpp includes the header:
#include "BluetoothTransport.h"Usage in Your Sketch
After patching, you can use:
RadiaCode* radiacode = new RadiaCode(RADIACODE_MAC);
int blerssi = radiacode->getRSSI();
Serial.printf("BLE Signal: %d dBm\n", blerssi);Signal Quality Guide
| RSSI (dBm) | Quality | Description |
|---|---|---|
| -30 to -50 | Excellent | Very close, strong signal |
| -50 to -60 | Good | Normal operating distance |
| -60 to -70 | Fair | Edge of reliable range |
| -70 to -90 | Weak | Connection may be unstable |
| -90 to -100 | Very weak | About to disconnect |
| -100 | Disconnected | No connection |
More negative = weaker signal
Test it:
void loop() {
int blerssi = radiacode->getRSSI();
if (blerssi != -100) {
Serial.printf("BLE RSSI: %d dBm\n", blerssi);
}
delay(5000);
}Why This Patch is Needed
The RadiaCode library doesn't expose RSSI by default. This patch:
- Adds
getRSSI()toBluetoothTransport(accesses BLE client) - Adds
getRSSI()toRadiaCode(public API) - Uses safe casting to access the underlying BLE client
- Returns -100 when not connected (safe default)
Tested With
- Arduino IDE: 1.8.19
- Board: ESP32S3 Dev Module
- RadiaCode Library: Version by Markus Geiger (mkgeiger)
- Device: RadiaCode-110
- Date: March 2026
Request to the RadiaCode library repository so all users can benefit from RSSI access!
Version: 1.0 (Final)
Author: Based on RadiaCode ESP32 Monitor project
License: Same as RadiaCode library