Fix for CmndHDMIAddr function. (#19866)

* Fix for CmndHDMIAddr function.
1. Typical values for XdrvMailbox.payload are 0x1000...0x4000. Hence the
   check should be (value > 0).
2. Don't overwrite the user supplied value with value read from the hardware.

* Correct the condition in CEC_Device::OnReady.
We should check for _on_ready_cb before calling _on_ready_cb.
This commit is contained in:
anishsane 2023-10-29 21:44:44 +05:30 committed by GitHub
parent b034e5bb93
commit be94a6cac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -1116,7 +1116,7 @@ bool IRAM_ATTR CEC_Device::setLineState(bool state, bool check)
// manage callbacks
void CEC_Device::OnReady(int logical_address)
{
if (_on_rx_cb) { _on_ready_cb(this, logical_address); }
if (_on_ready_cb) { _on_ready_cb(this, logical_address); }
// This is called after the logical address has been allocated
int physical_address = getPhysicalAddress();

View File

@ -284,13 +284,13 @@ uint16_t HDMIGetPhysicalAddress(void) {
void CmndHDMIAddr(void) {
if (XdrvMailbox.data_len > 0) {
if ((XdrvMailbox.payload < 1)) {
if ((XdrvMailbox.payload > 0)) {
uint16_t hdmi_addr = XdrvMailbox.payload;
Settings->hdmi_addr[0] = (hdmi_addr) & 0xFF;
Settings->hdmi_addr[1] = (hdmi_addr >> 8) & 0xFF;
}
}
uint16_t hdmi_addr = HDMIGetPhysicalAddress();
uint16_t hdmi_addr = HDMI_CEC_device->discoverPhysicalAddress();
Response_P(PSTR("{\"%s\":\"0x%04X\"}"), XdrvMailbox.command, hdmi_addr);
}