Skip to content
Merged
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ All notable changes to this project will be documented in this file.

* In the future, generate this file by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [1.1.3] - 2025-08-19

### Changed
- Modify Remote Control plugin for RF4CE support (#80)
- Mac address fetch (#92)

### Added
- Runtime detection of ASB (#96)

## [1.1.2] - 2025-08-04

### Changed
Expand Down
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ project(ctrlm-main)
option(A5000_ENABLE "ES1 A5000 use libse051" OFF)
option(ANSI_CODES_DISABLED "Disable ANSI code logging" OFF)
option(ASSERT_ON_WRONG_THREAD "Assert on wrong thread" OFF)
option(ASB "Enable ASB" OFF)
option(AUTH_ENABLED "Enable AUTH" OFF)
option(BLE_ENABLED "Enable BLE" ON)
option(BLE_SERVICES "Enable BLE Services" OFF)
Expand Down Expand Up @@ -196,11 +195,6 @@ if(ANSI_CODES_DISABLED)
add_compile_definitions(ANSI_CODES_DISABLED)
endif()

if(ASB)
add_compile_definitions(ASB)
target_link_libraries(controlMgr ${ASB_LIBS})
endif()

if(ASSERT_ON_WRONG_THREAD)
add_compile_definitions(ASSERT_ON_WRONG_THREAD)
endif()
Expand Down
9 changes: 4 additions & 5 deletions include/ctrlm_ipc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's license file the

Check failure on line 2 in include/ctrlm_ipc.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'include/ctrlm_ipc.h' (Match: rdkcentral/rdkservices/1, 776 lines, url: https://github.com/rdkcentral/rdkservices/archive/GRT_v1.tar.gz, file: Tests/mocks/Ctrlm.h)
* following copyright and licenses apply:
*
* Copyright 2014 RDK Management
Expand Down Expand Up @@ -133,6 +133,7 @@
#define CTRLM_MAIN_IARM_CALL_GET_RCU_STATUS "Main_GetRcuStatus" ///< IARM Call get the RCU status info (same as what's provided by CTRLM_RCU_IARM_EVENT_RCU_STATUS)
#define CTRLM_MAIN_IARM_CALL_START_PAIRING "Main_StartPairing" ///< IARM Call to initiate searching for a remote to pair with
#define CTRLM_MAIN_IARM_CALL_START_PAIR_WITH_CODE "Main_StartPairWithCode" ///< IARM Call to initiate searching for a remote to pair with
#define CTRLM_MAIN_IARM_CALL_STOP_PAIRING "Main_StopPairing" ///< IARM Call to cancel an active search for a remote to pair with
#define CTRLM_MAIN_IARM_CALL_FIND_MY_REMOTE "Main_FindMyRemote" ///< IARM Call to trigger the Find My Remote alarm on a specified remote
#define CTRLM_MAIN_IARM_CALL_WRITE_RCU_WAKEUP_CONFIG "Main_WriteAdvertisingConfig" ///< IARM Call to write the advertising configuration on all connected remotes
#define CTRLM_MAIN_IARM_CALL_START_FIRMWARE_UPDATE "Main_StartFirmwareUpdate" ///< IARM Call to start a firmware update session
Expand Down Expand Up @@ -193,19 +194,15 @@
#define CTRLM_MIN_IR_COMMAND_REPEATS (1)
#define CTRLM_MAX_IR_COMMAND_REPEATS (10)

#ifdef ASB
#define CTRLM_ASB_ENABLED_DEFAULT (false)
#endif
#define CTRLM_OPEN_CHIME_ENABLED_DEFAULT (false)
#define CTRLM_CLOSE_CHIME_ENABLED_DEFAULT (true)
#define CTRLM_PRIVACY_CHIME_ENABLED_DEFAULT (true)
#define CTRLM_CONVERSATIONAL_MODE_DEFAULT (CTRLM_MAX_CONVERSATIONAL_MODE)
#define CTRLM_CHIME_VOLUME_DEFAULT (CTRLM_CHIME_VOLUME_MEDIUM)
#define CTRLM_IR_COMMAND_REPEATS_DEFAULT (3)

#ifdef ASB
#define CTRLM_ASB_ENABLED_LEN (1)
#endif
#define CTRLM_OPEN_CHIME_ENABLED_LEN (1)
#define CTRLM_CLOSE_CHIME_ENABLED_LEN (1)
#define CTRLM_PRIVACY_CHIME_ENABLED_LEN (1)
Expand Down Expand Up @@ -304,7 +301,8 @@
CTRLM_RCU_IARM_EVENT_RCU_STATUS = 34, ///< Generated when something changes in the BLE remote
CTRLM_RCU_IARM_EVENT_RF4CE_PAIRING_WINDOW_TIMEOUT = 35, ///< Indicates that a battery milestone event occured
CTRLM_RCU_IARM_EVENT_FIRMWARE_UPDATE_PROGRESS = 36, ///< Generated when an milestone is reached for remote firmware upgrade
CTRLM_MAIN_IARM_EVENT_MAX = 37 ///< Placeholder for the last event (used in registration)
CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS = 37, ///< Generated when the validation status changes
CTRLM_MAIN_IARM_EVENT_MAX = 38 ///< Placeholder for the last event (used in registration)
} ctrlm_main_iarm_event_t;

/// @brief Remote Control Key Status
Expand Down Expand Up @@ -699,6 +697,7 @@
ctrlm_network_id_t network_id; ///< Identifier of network or CTRLM_MAIN_NETWORK_ID_ALL for all networks
unsigned char pairing_mode; ///< Indicates the pairing mode
unsigned char restrict_by_remote; ///< Indicates the remote bucket (no restrictions, only voice remotes, only voice assistants)
unsigned char use_timeout; ///< Indicates whether to use a timeout for the pairing mode (0 - do not use timeout, otherwise use timeout)
unsigned int bind_status; ///< OUT - The bind status of the pairing session
} ctrlm_main_iarm_call_control_service_pairing_mode_t;

Expand Down
17 changes: 15 additions & 2 deletions src/asb/ctrlm_asb.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ typedef uint8_t asb_key_derivation_bitmask_t;
*/
typedef uint8_t asb_key_derivation_method_t;

#ifdef __cplusplus
extern "C" {
#endif

/* -- API Function Declarations -- */
/**
* @brief The ASB Library init function.
Expand All @@ -51,7 +55,7 @@ int asb_init();
*
* @return The bitmask of supported key derivation methods.
*/
asb_key_derivation_bitmask_t asb_key_derivation_methods_get();
asb_key_derivation_bitmask_t asb_key_derivation_methods_get(void);
/**
* @brief The ASB Library API for key derivation.
*
Expand All @@ -66,11 +70,20 @@ int asb_key_derivation(uint8_t *input, uint8_t *output,
* This function writes over the secrets with null data and then cleans up resources.
*
*/
void asb_destroy();
void asb_destroy(void);

#ifdef __cplusplus
}
#endif

/* -- Defines -- */
#define AES_KEY_LEN (16) ///< AES Key Length
#define ASB_KEY_DERIVATION_NONE (0b00000000) ///< Key Derivation Method None bit
#define ASB_KEY_DERIVATION_1 (0b10000000) ///< Key Derivation Method 1 bit

typedef int (*ctrlm_hal_rf4ce_asb_init_t)(void);
typedef asb_key_derivation_bitmask_t (*ctrlm_hal_rf4ce_asb_methods_get_t)(void);
typedef int (*ctrlm_hal_rf4ce_asb_key_derive_t)(uint8_t *input, uint8_t *output, asb_key_derivation_method_t method);
typedef void (*ctrlm_hal_rf4ce_asb_destroy_t)(void);

#endif
51 changes: 43 additions & 8 deletions src/ble/ctrlm_ble_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,35 +609,70 @@ void ctrlm_obj_network_ble_t::req_process_start_pairing(void *data, int size) {
g_assert(dqm);
g_assert(size == sizeof(ctrlm_main_queue_msg_start_pairing_t));

dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());

if (!ready_) {
XLOGD_FATAL("Network is not ready!");
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());
} else if(!dqm->params->scan_enable) {
XLOGD_INFO("scan enable is not requested");
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_SUCCESS, network_id_get());
} else {
if (ble_rcu_interface_) {
bool ret = true;
if (dqm->params->ieee_address_list.size() == 0) {
if(!ble_rcu_interface_->pairAutoWithTimeout(dqm->params->timeout * 1000)) {
XLOGD_ERROR("failed to start BLE remote scan");
ret = false;
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());
} else {
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_SUCCESS, network_id_get());
}
} else {
XLOGD_INFO("Starting pairing with a list of mac addresses! Pairing with first available...");
if(!ble_rcu_interface_->pairWithMacAddrs(dqm->params->ieee_address_list)) {
XLOGD_ERROR("failed to start BLE remote scan");
ret = false;
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());
} else {
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_SUCCESS, network_id_get());
}
}
if (ret) {
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_SUCCESS, network_id_get());
}
} else {
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());
}
}
if(dqm->semaphore) {
sem_post(dqm->semaphore);
}
}

void ctrlm_obj_network_ble_t::req_process_stop_pairing(void *data, int size) {
XLOGD_DEBUG("Enter...");
THREAD_ID_VALIDATE();
ctrlm_main_queue_msg_stop_pairing_t *dqm = (ctrlm_main_queue_msg_stop_pairing_t *)data;

g_assert(dqm);
g_assert(size == sizeof(ctrlm_main_queue_msg_stop_pairing_t));

if (!ready_) {
XLOGD_FATAL("Network is not ready!");
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());
} else if(!dqm->params->scan_disable) {
XLOGD_INFO("scan disable is not requested");
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_SUCCESS, network_id_get());
} else {
if (ble_rcu_interface_) {
XLOGD_INFO("Cancel pairing operations.");
if(!ble_rcu_interface_->pairCancel()) {
XLOGD_ERROR("failed to cancel BLE remote scan");
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());
} else {
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_SUCCESS, network_id_get());
}
} else {
dqm->params->set_result(CTRLM_IARM_CALL_RESULT_ERROR, network_id_get());
}
}
if(dqm->semaphore) {
sem_post(dqm->semaphore);
}
}

void ctrlm_obj_network_ble_t::req_process_pair_with_code(void *data, int size) {
XLOGD_DEBUG("Enter...");
Expand Down
1 change: 1 addition & 0 deletions src/ble/ctrlm_ble_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class ctrlm_obj_network_ble_t : public ctrlm_obj_network_t {
virtual void req_process_voice_session_end(void *data, int size);

virtual void req_process_start_pairing(void *data, int size);
virtual void req_process_stop_pairing(void *data, int size);
virtual void req_process_pair_with_code(void *data, int size);
virtual void req_process_program_ir_codes(void *data, int size);
virtual void req_process_ir_clear_codes(void *data, int size);
Expand Down
16 changes: 16 additions & 0 deletions src/ble/ctrlm_ble_rcu_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,22 @@ bool ctrlm_ble_rcu_interface_t::pairAutoWithTimeout(int timeoutMs)
return true;
}

bool ctrlm_ble_rcu_interface_t::pairCancel()
{
if (!m_controller) {
XLOGD_ERROR("m_controller is NULL!!!");
return false;
}

XLOGD_INFO("Canceling BLE pairing operations.");
if (!m_controller->cancelPairing()) {
BleRcuError error = m_controller->lastError();
XLOGD_ERROR("controller failed to cancel pairing, %s: %s", error.name().c_str(), error.message().c_str());
return false;
}
return true;
}

bool ctrlm_ble_rcu_interface_t::unpairDevice(uint64_t ieee_address)
{
BleAddress address(ieee_address);
Expand Down
1 change: 1 addition & 0 deletions src/ble/ctrlm_ble_rcu_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ctrlm_ble_rcu_interface_t
bool pairWithMacHash(unsigned int code);
bool pairWithMacAddrs(const std::vector<uint64_t> &macAddrList);
bool pairAutoWithTimeout(int timeoutMs);
bool pairCancel();
bool unpairDevice(uint64_t ieee_address);

bool findMe(uint64_t ieee_address, ctrlm_fmr_alarm_level_t level);
Expand Down
3 changes: 3 additions & 0 deletions src/ctrlm.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef enum {
typedef enum {
// Network based messages
CTRLM_MAIN_QUEUE_MSG_TYPE_BIND_VALIDATION_BEGIN = 0,
CTRLM_MAIN_QUEUE_MSG_TYPE_BIND_VALIDATION_KEY,
CTRLM_MAIN_QUEUE_MSG_TYPE_BIND_VALIDATION_END,
CTRLM_MAIN_QUEUE_MSG_TYPE_BIND_CONFIGURATION_COMPLETE,
CTRLM_MAIN_QUEUE_MSG_TYPE_NETWORK_PROPERTY_SET,
Expand Down Expand Up @@ -431,6 +432,7 @@ gboolean ctrlm_main_iarm_init(void);
void ctrlm_main_iarm_terminate(void);
gboolean ctrlm_is_production_build(void);
gboolean ctrlm_is_rf4ce_enabled(void);
gboolean ctrlm_is_rf4ce_asb_supported(void);
void ctrlm_network_list_get(std::vector<ctrlm_network_id_t> *list);
gboolean ctrlm_network_id_is_valid(ctrlm_network_id_t network_id);
gboolean ctrlm_controller_id_is_valid(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id);
Expand Down Expand Up @@ -489,6 +491,7 @@ gboolean ctrlm_main_iarm_call_control_service_can_find_my_remote(ctrlm_main_iarm
gboolean ctrlm_main_iarm_call_control_service_start_pairing_mode(ctrlm_main_iarm_call_control_service_pairing_mode_t *pairing);
void ctrlm_main_iarm_call_control_service_start_pairing_mode_(ctrlm_main_iarm_call_control_service_pairing_mode_t *pairing);
gboolean ctrlm_main_iarm_call_control_service_end_pairing_mode(ctrlm_main_iarm_call_control_service_pairing_mode_t *pairing);
void ctrlm_main_iarm_call_control_service_end_pairing_mode_(ctrlm_main_iarm_call_control_service_pairing_mode_t *pairing);
gboolean ctrlm_main_iarm_call_chip_status_get(ctrlm_main_iarm_call_chip_status_t *status);

ctrlm_power_state_t ctrlm_main_get_system_power_state(void);
Expand Down
Loading
Loading