1 #include "ble_rssi_sensor.h" 10 namespace ble_client {
12 static const char *
const TAG =
"ble_rssi_sensor";
17 LOG_SENSOR(
"",
"BLE Client RSSI Sensor",
this);
18 ESP_LOGCONFIG(TAG,
" MAC address : %s", this->
parent()->address_str().c_str());
19 LOG_UPDATE_INTERVAL(
this);
23 esp_ble_gattc_cb_param_t *param) {
25 case ESP_GATTC_CLOSE_EVT: {
30 case ESP_GATTC_SEARCH_CMPL_EVT: {
31 this->
node_state = espbt::ClientState::ESTABLISHED;
46 case ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT:
47 if (param->read_rssi_cmpl.status == ESP_BT_STATUS_SUCCESS) {
48 int8_t rssi = param->read_rssi_cmpl.rssi;
49 ESP_LOGI(TAG,
"ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT RSSI: %d", rssi);
60 if (this->
node_state != espbt::ClientState::ESTABLISHED) {
61 ESP_LOGW(TAG,
"[%s] Cannot poll, not connected", this->
get_name().c_str());
68 ESP_LOGV(TAG,
"requesting rssi from %s", this->
parent()->address_str().c_str());
69 auto status = esp_ble_gap_read_rssi(this->
parent()->get_remote_bda());
71 ESP_LOGW(TAG,
"esp_ble_gap_read_rssi error, address=%s, status=%d", this->
parent()->address_str().c_str(),
status);
void dump_config() override
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
void publish_state(float state)
Publish a new state to the front-end.
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
Implementation of SPI Controller mode.
const StringRef & get_name() const
espbt::ClientState node_state