11static const char *
const TAG =
"ble_rssi_sensor";
20 LOG_SENSOR(
"",
"BLE Client RSSI Sensor",
this);
21 ESP_LOGCONFIG(TAG,
" MAC address : %s", this->
parent()->address_str());
22 LOG_UPDATE_INTERVAL(
this);
26 esp_ble_gattc_cb_param_t *param) {
28 case ESP_GATTC_CLOSE_EVT: {
33 case ESP_GATTC_SEARCH_CMPL_EVT: {
34 this->
node_state = espbt::ClientState::ESTABLISHED;
49 case ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT:
50 if (param->read_rssi_cmpl.status == ESP_BT_STATUS_SUCCESS) {
51 int8_t rssi = param->read_rssi_cmpl.rssi;
52 ESP_LOGI(TAG,
"ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT RSSI: %d", rssi);
63 if (this->
node_state != espbt::ClientState::ESTABLISHED) {
64 ESP_LOGW(TAG,
"[%s] Cannot poll, not connected", this->
get_name().c_str());
71 ESP_LOGV(TAG,
"requesting rssi from %s", this->
parent()->address_str());
72 auto status = esp_ble_gap_read_rssi(this->
parent()->get_remote_bda());
74 ESP_LOGW(TAG,
"esp_ble_gap_read_rssi error, address=%s, status=%d", this->
parent()->address_str(),
status);
void status_set_warning(const char *message=nullptr)
void disable_loop()
Disable this component's loop.
void status_clear_warning()
const StringRef & get_name() const
espbt::ClientState node_state
void dump_config() 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
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
void publish_state(float state)
Publish a new state to the front-end.