Hello all,
I am working on an application that uses BLE as a server in an ESP32. Clients connect to it and send a code to open a door. This works fine but I need to do this when the RSSI of the device goes above a certain threshold or power to make sure the Client device is close to the chip server.
I implemented this using the Arduino BLE abstraction of ESP32 using the server mechanism.
Is there a way to retrieve the RSSI value when a characteristic is written to? Like in a server or characteristic callback ?
Ir a way to retrieve the connected clients to the server so we can read or get their respective RSSI VALUÉ?
Any help would be appreciated.
BLE server, need the RSSI of its clients to perform action.
Re: BLE server, need the RSSI of its clients to perform action.
Anyone?
Should I switch to client instead of server ? But I need multiple connections.
Any help welcomed.
Should I switch to client instead of server ? But I need multiple connections.
Any help welcomed.
Re: BLE server, need the RSSI of its clients to perform action.
Just in case someone needs to do this. The way I Solved it is by doing the following:
1) Right after:
Add:
Where : my_gap_event_handler is a callback function that looks like this:
In here, you check the param to extract the RSSI :
In order to request the RSSi you need to ask for it somewhere, in my case, I do this in the BLECharacteristicCallbacks function OnWrite because it fits my application, but this can be done anywhere you have access to the remote device address. You just call:
I hope this helps someone!
1) Right after:
Code: Select all
BLEDevice::init("DeviceName");
Code: Select all
BLEDevice::setCustomGapHandler(my_gap_event_handler);
Code: Select all
static void my_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param) {
}
Code: Select all
static void my_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param) {
String devAddress = String(*param->read_rssi_cmpl.remote_addr);
int8_t rssi = param->read_rssi_cmpl.rssi;
}
In order to request the RSSi you need to ask for it somewhere, in my case, I do this in the BLECharacteristicCallbacks function OnWrite because it fits my application, but this can be done anywhere you have access to the remote device address. You just call:
Code: Select all
esp_err_t rc = ::esp_ble_gap_read_rssi(param->read.bda);
I hope this helps someone!
Re: BLE server, need the RSSI of its clients to perform action.
Thanks for this, ive been looking for exactly this online for a while now.
oh btw did you use the server example in the end?
and what security did you use?
i see it was a while ago u posted this so hopefully your still active, and even better have progressed with it.
Thanks again
oh btw did you use the server example in the end?
and what security did you use?
i see it was a while ago u posted this so hopefully your still active, and even better have progressed with it.
Thanks again
Who is online
Users browsing this forum: No registered users and 74 guests