12static const char *
const TAG =
"ble_rssi_sensor";
21 LOG_SENSOR(
"",
"BLE Client RSSI Sensor",
this);
22 ESP_LOGCONFIG(TAG,
" MAC address : %s", this->
parent()->address_str().c_str());
23 LOG_UPDATE_INTERVAL(
this);
27 esp_ble_gattc_cb_param_t *param) {
29 case ESP_GATTC_CLOSE_EVT: {
34 case ESP_GATTC_SEARCH_CMPL_EVT: {
35 this->
node_state = espbt::ClientState::ESTABLISHED;
50 case ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT:
51 if (param->read_rssi_cmpl.status == ESP_BT_STATUS_SUCCESS) {
52 int8_t rssi = param->read_rssi_cmpl.rssi;
53 ESP_LOGI(TAG,
"ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT RSSI: %d", rssi);
64 if (this->
node_state != espbt::ClientState::ESTABLISHED) {
65 ESP_LOGW(TAG,
"[%s] Cannot poll, not connected", this->
get_name().c_str());
72 ESP_LOGV(TAG,
"requesting rssi from %s", this->
parent()->address_str().c_str());
73 auto status = esp_ble_gap_read_rssi(this->
parent()->get_remote_bda());
75 ESP_LOGW(TAG,
"esp_ble_gap_read_rssi error, address=%s, status=%d", this->
parent()->address_str().c_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.
Providing packet encoding functions for exchanging data with a remote host.