RDKEMW-16814: reduce ble status prints and events#235
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces log/event noise across the Control Manager (ctrlm-main) codebase, with the main functional change being throttling/coalescing of BLE “status print” output and BLE “status event” emissions.
Changes:
- Downgrade many high-frequency logs from
XLOGD_INFOtoXLOGD_DEBUG(DB access, controller lifecycle, BLE GATT services, etc.). - Add BLE-network scheduling to defer/coalesce pairing-table printing (
printStatus()) and IARM status events (iarm_event_rcu_status()), instead of printing/emitting on every status update. - Minor adjustments to BLE startup/status output and IR RF database printing verbosity.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/database/ctrlm_db_types.cpp | Reduce DB blob read/write log verbosity (INFO → DEBUG). |
| src/database/ctrlm_database.cpp | Reduce controller-create log verbosity (INFO → DEBUG). |
| src/ctrlm_network.h | Add new virtual request handlers for status print/event. |
| src/ctrlm_network.cpp | Provide base “not implemented” handlers for new status print/event requests. |
| src/ctrlm_ir_controller.cpp | Reduce IR input device name logging verbosity. |
| src/ctrlm_controller.cpp | Reduce controller ctor/dtor logging verbosity. |
| src/ble/hal/blercu/bluez/blegattnotifypipe.cpp | Reduce notify-thread launch logging verbosity. |
| src/ble/hal/blercu/bleservices/gatt/gatt_remotecontrolservice.cpp | Reduce several “request succeeded / initial value” logs to DEBUG. |
| src/ble/hal/blercu/bleservices/gatt/gatt_infraredsignal.cpp | Reduce IR characteristic discovery logs to DEBUG. |
| src/ble/hal/blercu/bleservices/gatt/gatt_infraredservice.cpp | Reduce IR support/code-id logs to DEBUG. |
| src/ble/hal/blercu/bleservices/gatt/gatt_deviceinfoservice.cpp | Reduce device-info milestone logs to DEBUG and shorten comment. |
| src/ble/hal/blercu/bleservices/gatt/gatt_batteryservice.cpp | Reduce battery change log to DEBUG. |
| src/ble/hal/blercu/bleservices/gatt/gatt_audioservice_rdk.cpp | Reduce audio property read logs to DEBUG. |
| src/ble/ctrlm_ble_rcu_interface.cpp | Reduce managed device listing log; enrich “input dev node found” log. |
| src/ble/ctrlm_ble_network.h | Add scheduling APIs + defer counters for BLE status print/event throttling. |
| src/ble/ctrlm_ble_network.cpp | Implement timers + deferred status print/event emission; adjust BLE startup/status logging. |
| src/ble/ctrlm_ble_controller.cpp | Reduce BLE controller ctor logging verbosity. |
| src/ble/ctrlm_ble_controller_attr_version.cpp | Reduce BLE version DB read/write logs to DEBUG. |
| src/attributes/ctrlm_attr_voice.cpp | Reduce voice metrics DB read/write logs to DEBUG. |
| src/attributes/ctrlm_attr_general.cpp | Reduce general attribute DB read/write logs to DEBUG. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/ble/ctrlm_ble_network.cpp:2018
- Same off-by-one issue as schedule_status_print():
event_status_defer_count_ > CTRLM_BLE_EVENT_STATUS_DEFER_MAXis evaluated before incrementing, which permits one extra deferral beyond the configured MAX before forcing an immediate event push. Consider changing the comparison (or the increment/check order) so the configured MAX is enforced as intended.
THREAD_ID_VALIDATE();
ctrlm_timeout_destroy(&g_ctrlm_ble_network.event_status_timer_tag);
if (immediately || event_status_defer_count_ > CTRLM_BLE_EVENT_STATUS_DEFER_MAX) {
event_status_defer_count_ = 0;
ctrlm_main_queue_msg_header_t msg;
errno_t safec_rc = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
ERR_CHK(safec_rc);
ctrlm_main_queue_handler_push(CTRLM_HANDLER_NETWORK, (ctrlm_msg_handler_network_t)&ctrlm_obj_network_t::req_process_event_status, &msg, sizeof(msg), NULL, id_);
} else {
event_status_defer_count_++;
g_ctrlm_ble_network.event_status_timer_tag = ctrlm_timeout_create(CTRLM_BLE_EVENT_STATUS_TIMEOUT, ctrlm_ble_event_status_timer_cb, &id_);
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/ble/ctrlm_ble_network.cpp:2011
- In schedule_status_event(), the defer-limit check uses
event_status_defer_count_ > CTRLM_BLE_EVENT_STATUS_DEFER_MAX, which effectively permits DEFER_MAX+1 deferrals before forcing an event. If the desired behavior is “trigger once the max is reached”, use>=here as well.
void ctrlm_obj_network_ble_t::schedule_status_event(bool immediately) {
XLOGD_DEBUG("immediately = <%s>, event_status_defer_count_ = <%d>", immediately ? "TRUE" : "FALSE", event_status_defer_count_);
THREAD_ID_VALIDATE();
ctrlm_timeout_destroy(&g_ctrlm_ble_network.event_status_timer_tag);
if (immediately || event_status_defer_count_ > CTRLM_BLE_EVENT_STATUS_DEFER_MAX) {
event_status_defer_count_ = 0;
ctrlm_main_queue_msg_header_t msg;
| XLOGD_TELEMETRY("BLE remote RF pairing state changed to <%s>", ctrlm_rf_pair_state_str(dqm->state)); | ||
| state_ = dqm->state; | ||
| if (state_ == CTRLM_RF_PAIR_STATE_COMPLETE || state_ == CTRLM_RF_PAIR_STATE_IDLE) { | ||
| // report status in a couple seconds to allow remote data to be received from bluez |
|
b'## WARNING: A Blackduck scan failure has been waived A prior failure has been upvoted
|
dwolaver
left a comment
There was a problem hiding this comment.
Looks solid to me. Ready for QA test
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/ble/ctrlm_ble_network.cpp:2002
- schedule_status_event() has the same off-by-one behavior as schedule_status_print(): the condition uses
event_status_defer_count_ > CTRLM_BLE_EVENT_STATUS_DEFER_MAXwhile the counter is incremented in theelsebranch, so you can deferDEFER_MAX + 1times before forcing an immediate event. Use>=(or increment before checking) if DEFER_MAX is meant to be a strict cap.
THREAD_ID_VALIDATE();
ctrlm_timeout_destroy(&g_ctrlm_ble_network.event_status_timer_tag);
if (immediately || event_status_defer_count_ > CTRLM_BLE_EVENT_STATUS_DEFER_MAX) {
event_status_defer_count_ = 0;
ctrlm_main_queue_msg_header_t msg;
errno_t safec_rc = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
ERR_CHK(safec_rc);
ctrlm_main_queue_handler_push(CTRLM_HANDLER_NETWORK, (ctrlm_msg_handler_network_t)&ctrlm_obj_network_t::req_process_event_status, &msg, sizeof(msg), NULL, id_);
} else {
event_status_defer_count_++;
g_ctrlm_ble_network.event_status_timer_tag = ctrlm_timeout_create(CTRLM_BLE_EVENT_STATUS_TIMEOUT, ctrlm_ble_event_status_timer_cb, &id_);
}
src/ble/ctrlm_ble_network.cpp:306
- The constructor explicitly resets the upgrade timer tags to 0, but the newly added
print_status_timer_tag/event_status_timer_tagfields ing_ctrlm_ble_networkare not similarly initialized here. Initializing them to 0 alongside the existing timers would be more robust/consistent, especially if the BLE network object is ever reconstructed in-process.
g_ctrlm_ble_network.upgrade_controllers_timer_tag = 0;
g_ctrlm_ble_network.upgrade_pause_timer_tag = 0;
| ctrlm_timeout_destroy(&g_ctrlm_ble_network.print_status_timer_tag); | ||
| if (immediately || print_status_defer_count_ > CTRLM_BLE_PRINT_STATUS_DEFER_MAX) { | ||
| print_status_defer_count_ = 0; | ||
| ctrlm_main_queue_msg_header_t msg; | ||
| errno_t safec_rc = memset_s(&msg, sizeof(msg), 0, sizeof(msg)); | ||
| ERR_CHK(safec_rc); | ||
| ctrlm_main_queue_handler_push(CTRLM_HANDLER_NETWORK, (ctrlm_msg_handler_network_t)&ctrlm_obj_network_t::req_process_print_status, &msg, sizeof(msg), NULL, id_); | ||
| } else { | ||
| print_status_defer_count_++; | ||
| g_ctrlm_ble_network.print_status_timer_tag = ctrlm_timeout_create(CTRLM_BLE_PRINT_STATUS_TIMEOUT, ctrlm_ble_print_status_timer_cb, &id_); | ||
| } |
| case CTRLM_HAL_BLE_PROPERTY_BATTERY_LEVEL: | ||
| controller->setBatteryPercent(dqm->rcu_data.battery_level, true); | ||
| print_status = false; | ||
| XLOGD_INFO("Controller <%s> battery level changed to <%u%%>", controller->ieee_address_get().to_string().c_str(), dqm->rcu_data.battery_level); |
No description provided.