Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/ctrlm_hal_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ typedef struct {
int pairing_code;
ctrlm_hal_ble_RcuProperty_t property_updated;
ctrlm_hal_ble_rcu_data_t rcu_data;
char ir_fail_reason[CTRLM_MAX_PARAM_STR_LEN];
} ctrlm_hal_ble_RcuStatusData_t;

typedef struct {
Expand Down
25 changes: 23 additions & 2 deletions src/ble/ctrlm_ble_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ctrlm_controller.h"
#include "ctrlm_hal_ip.h"
#include "blercu/bleservices/blercuupgradeservice.h"
#include "ctrlm_telemetry_event.h"

#include <sstream>
#include <iterator>
Expand Down Expand Up @@ -534,19 +535,30 @@ void ctrlm_obj_controller_ble_t::setSupportedIrdbs(uint8_t vendor_support_bitmas

if (irdb == NULL) {
XLOGD_ERROR("IRDB interface is NULL!!!");
#ifdef TELEMETRY_SUPPORT
char t2_buf[256];
snprintf(t2_buf, sizeof(t2_buf), "[0,0x%02X,\"unknown\",0x00,0]", vendor_support_bitmask);
ctrlm_telemetry_event_t<std::string> ev(MARKER_IRDB_VENDOR_SET, t2_buf);
ev.event();
#endif
return;
}

ctrlm_irdb_vendor_info_t rcu_vendor_info{};
rcu_vendor_info.rcu_support_bitmask = vendor_support_bitmask;
if (!irdb->set_vendor(rcu_vendor_info)) {
bool set_result = irdb->set_vendor(rcu_vendor_info);
if (!set_result) {
XLOGD_ERROR("Failed to set IRDB vendor info for controller <%s> with bitmask <0x%X>.",
ieee_address_get().to_string().c_str(), vendor_support_bitmask);
}

ctrlm_irdb_vendor_info_t vendor_info{};
vendor_info.name = "unknown";
vendor_info.rcu_support_bitmask = 0xFF;
bool supported = false;
if (irdb->get_vendor_info(vendor_info)) {
if (isSupportedIrdb(vendor_info)) {
supported = isSupportedIrdb(vendor_info);
if (supported) {
XLOGD_INFO("Controller <%s> IRDBs supported bitmask = <0x%X>, which DOES support the loaded IRDB plugin vendor <%s>",
ieee_address_get().to_string().c_str(), vendor_support_bitmask, vendor_info.name.c_str());
} else {
Expand All @@ -557,6 +569,15 @@ void ctrlm_obj_controller_ble_t::setSupportedIrdbs(uint8_t vendor_support_bitmas
XLOGD_WARN("Controller <%s> IRDBs supported bitmask = <0x%X>, couldn't retrieve IRDB plugin vendor info.",
ieee_address_get().to_string().c_str(), vendor_support_bitmask);
}
#ifdef TELEMETRY_SUPPORT
char t2_buf[256];
snprintf(t2_buf, sizeof(t2_buf), "[%d,0x%02X,\"%s\",0x%02X,%d]",
(int)set_result,vendor_support_bitmask,
vendor_info.name.c_str(), vendor_info.rcu_support_bitmask,
(int)supported);
ctrlm_telemetry_event_t<std::string> ev(MARKER_IRDB_VENDOR_SET, t2_buf);
ev.event();
#endif
}

uint8_t ctrlm_obj_controller_ble_t::getSupportedIrdbs() const {
Expand Down
42 changes: 42 additions & 0 deletions src/ble/ctrlm_ble_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <time.h>
#include <unordered_map>
#include "ctrlm_rcp_ipc_iarm_thunder.h"
#include "ctrlm_telemetry_event.h"

using namespace std;

Expand Down Expand Up @@ -775,6 +776,16 @@ void ctrlm_obj_network_ble_t::req_process_program_ir_codes(void *data, int size)
XLOGD_ERROR("Controller doesn't exist!");
} else if (!controllers_[controller_id]->isSupportedIrdb(dqm->vendor_info)) {
XLOGD_ERROR("Unsupported IRDB - not continuing with ir code download!");
#ifdef TELEMETRY_SUPPORT
char t2_buf[256];
snprintf(t2_buf, sizeof(t2_buf), "[%d,\"unsupported\",0x%02X,\"%s\",0x%02X]",
(int)CTRLM_IR_STATE_FAILED,
controllers_[controller_id]->getSupportedIrdbs(),
dqm->vendor_info.name.c_str(),
dqm->vendor_info.rcu_support_bitmask);
ctrlm_telemetry_event_t<std::string> ev(MARKER_IRDB_PROGRAM_RESULT, t2_buf);
ev.event();
#endif
} else {
if(dqm->ir_codes) {

Expand Down Expand Up @@ -1699,6 +1710,37 @@ void ctrlm_obj_network_ble_t::ind_process_rcu_status(void *data, int size) {
case CTRLM_HAL_BLE_PROPERTY_IR_STATE:
XLOGD_TELEMETRY("BLE remote IR programming state changed to <%s>", ctrlm_ir_state_str(dqm->ir_state));
ir_state_ = dqm->ir_state;
#ifdef TELEMETRY_SUPPORT
{
ctrlm_irdb_vendor_info_t vendor_info{};
vendor_info.name = "unknown";
vendor_info.rcu_support_bitmask = 0xFF;

ctrlm_irdb_interface_t *irdb = ctrlm_main_irdb_get();
if (irdb) { irdb->get_vendor_info(vendor_info); }
char t2_buf[256];
if (dqm->ir_state == CTRLM_IR_STATE_COMPLETE || dqm->ir_state == CTRLM_IR_STATE_FAILED) {
ctrlm_controller_id_t controller_id;
uint8_t rcu_bitmask = 0xFF;
if (false == getControllerId(dqm->rcu_data.ieee_address, &controller_id)) {
XLOGD_ERROR("Controller <%s> NOT found in the network!!",
ctrlm_convert_mac_long_to_string(dqm->rcu_data.ieee_address).c_str());
} else {
auto controller = controllers_[controller_id];
rcu_bitmask = controller->getSupportedIrdbs();
}

snprintf(t2_buf, sizeof(t2_buf), "[%d,\"%s\",0x%02X,\"%s\",0x%02X]",
(int)dqm->ir_state,
dqm->ir_fail_reason,
rcu_bitmask,
vendor_info.name.c_str(),
vendor_info.rcu_support_bitmask);
ctrlm_telemetry_event_t<std::string> ev(MARKER_IRDB_PROGRAM_RESULT, t2_buf);
ev.event();
}
}
#endif
break;
default:
{
Expand Down
22 changes: 16 additions & 6 deletions src/ble/ctrlm_ble_rcu_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ bool ctrlm_ble_rcu_interface_t::programIrSignalWaveforms(uint64_t ieee_address,
uint8_t vendor)
{
// lambda invoked when the request returns
auto replyHandler = [this](PendingReply<> *reply) mutable
auto replyHandler = [this, ieee_address](PendingReply<> *reply) mutable
{
bool success = false;

Expand All @@ -1173,9 +1173,13 @@ bool ctrlm_ble_rcu_interface_t::programIrSignalWaveforms(uint64_t ieee_address,
success = true;
}

ctrlm_hal_ble_RcuStatusData_t params;
ctrlm_hal_ble_RcuStatusData_t params = {};
params.property_updated = CTRLM_HAL_BLE_PROPERTY_IR_STATE;
params.ir_state = success ? CTRLM_IR_STATE_COMPLETE : CTRLM_IR_STATE_FAILED;
params.rcu_data.ieee_address = ieee_address;
if (!success) {
snprintf(params.ir_fail_reason, CTRLM_MAX_PARAM_STR_LEN, "%s", reply->errorMessage().c_str());
}
m_rcuStatusChangedSlots.invoke(&params);
};

Expand Down Expand Up @@ -1241,9 +1245,10 @@ bool ctrlm_ble_rcu_interface_t::programIrSignalWaveforms(uint64_t ieee_address,
success = false;
}

ctrlm_hal_ble_RcuStatusData_t params;
ctrlm_hal_ble_RcuStatusData_t params = {};
params.property_updated = CTRLM_HAL_BLE_PROPERTY_IR_STATE;
params.ir_state = success ? CTRLM_IR_STATE_WAITING : CTRLM_IR_STATE_FAILED;
params.rcu_data.ieee_address = ieee_address;
m_rcuStatusChangedSlots.invoke(&params);

return success;
Expand All @@ -1252,7 +1257,7 @@ bool ctrlm_ble_rcu_interface_t::programIrSignalWaveforms(uint64_t ieee_address,
bool ctrlm_ble_rcu_interface_t::eraseIrSignals(uint64_t ieee_address)
{
// lambda invoked when the request returns
auto replyHandler = [this](PendingReply<> *reply) mutable
auto replyHandler = [this, ieee_address](PendingReply<> *reply) mutable
{
bool success = false;

Expand All @@ -1265,9 +1270,13 @@ bool ctrlm_ble_rcu_interface_t::eraseIrSignals(uint64_t ieee_address)
success = true;
}

ctrlm_hal_ble_RcuStatusData_t params;
ctrlm_hal_ble_RcuStatusData_t params = {};
params.property_updated = CTRLM_HAL_BLE_PROPERTY_IR_STATE;
params.ir_state = success ? CTRLM_IR_STATE_COMPLETE : CTRLM_IR_STATE_FAILED;
params.rcu_data.ieee_address = ieee_address;
if (!success) {
snprintf(params.ir_fail_reason, CTRLM_MAX_PARAM_STR_LEN, "%s", reply->errorMessage().c_str());
}
m_rcuStatusChangedSlots.invoke(&params);
};

Expand All @@ -1289,9 +1298,10 @@ bool ctrlm_ble_rcu_interface_t::eraseIrSignals(uint64_t ieee_address)
success = false;
}

ctrlm_hal_ble_RcuStatusData_t params;
ctrlm_hal_ble_RcuStatusData_t params = {};
params.property_updated = CTRLM_HAL_BLE_PROPERTY_IR_STATE;
params.ir_state = success ? CTRLM_IR_STATE_WAITING : CTRLM_IR_STATE_FAILED;
params.rcu_data.ieee_address = ieee_address;
m_rcuStatusChangedSlots.invoke(&params);

return success;
Expand Down
Loading
Loading