diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 00000000..c58b1b0b --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,20 @@ +name: "CLA" + +permissions: + contents: read + pull-requests: write + actions: write + statuses: write + +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened, closed, synchronize] + +jobs: + CLA-Lite: + name: "Signature" + uses: rdkcentral/cmf-actions/.github/workflows/cla.yml@v1 + secrets: + PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_ASSISTANT }} diff --git a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml b/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml index da02b8b4..7b8c1cba 100644 --- a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml +++ b/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml @@ -1,11 +1,18 @@ name: Fossid Stateless Diff Scan -on: pull_request +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: read jobs: call-fossid-workflow: - uses: rdkcentral/build_tools_workflows/.github/workflows/fossid_integration_stateless_diffscan.yml@develop - secrets: + if: ${{ ! github.event.pull_request.head.repo.fork }} + uses: rdkcentral/build_tools_workflows/.github/workflows/fossid_integration_stateless_diffscan.yml@1.0.0 + secrets: FOSSID_CONTAINER_USERNAME: ${{ secrets.FOSSID_CONTAINER_USERNAME }} FOSSID_CONTAINER_PASSWORD: ${{ secrets.FOSSID_CONTAINER_PASSWORD }} FOSSID_HOST_USERNAME: ${{ secrets.FOSSID_HOST_USERNAME }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 08c6b307..9eed8a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,26 @@ 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.4] - 2025-09-17 + +### Changed +- move certselector logic into ctrlm-main repo (#102) +- use version/branch from recipe (#109) + +### Added +- update AMC APP key mapping (#98) + +### Fixed +- getNetStatus call time out due to SAT download retries (#97) +- remove device from bluez during factory reset (#100) +- Missing Thunder cflags in ctrlm implemenation (#103) + +### Removed +- remove ctrlm compile flags (#104) +- remove ctrlm build flags - CPC, DUNFELL (#105) +- remove ctrlm build flags - RF4CE_PACKET_ANALYSIS (#107) +- remove ctrlm build flags - DISABLE_BLE_VOICE (#106) + ## [1.1.3] - 2025-08-19 ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index 90f4cfee..61dbb8e0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ set(CMAKE_BUILD_TYPE Release) set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) # PROJECT -project(ctrlm-main) +project(ctrlm-main VERSION ${CMAKE_PROJECT_VERSION}) # OPTIONS option(A5000_ENABLE "ES1 A5000 use libse051" OFF) @@ -42,15 +42,11 @@ option(BLE_ENABLED "Enable BLE" ON) option(BLE_SERVICES "Enable BLE Services" OFF) option(BREAKPAD "Enable BREAKPAD" OFF) option(BUILD_CTRLM_FACTORY "Build Control Factory Test" OFF) -option(CPC "Enable CPC" OFF) -option(DISABLE_BLE_VOICE "Disable BLE voice" OFF) option(DEEPSLEEP_CLOSE_DB "Deep Sleep Close DB" OFF) -option(DUNFELL_BUILD_SUPPORT "Enable DUNFELL_BUILD_SUPPORT" OFF) option(ENABLE_NETWORKED_STANDBY_MODE "Enable Networked Standby Mode)" OFF) option(FACTORY_AUDIO_PLAYBACK "Factory test audio playback" OFF) option(FACTORY_CUSTOM_AUDIO_ANALYSIS "Factory custom audio analysis" OFF) option(FDC_ENABLED "Enable FDC" OFF) -option(GIT_BRANCH, "Repository Branch" OFF) option(IP_ENABLED "Enable IP" OFF) option(LOCAL_MIC "Local Microphone" OFF) option(LOCAL_MIC_DISABLE_VIA_PRIVACY "Use Privacy to disable microphone" OFF) @@ -58,9 +54,8 @@ option(MEM_DEBUG "Enable memory debugging" OFF) option(MEMORY_LOCK "Memory Lock" OFF) option(MIC_TAP "Enable MIC_TAP" OFF) option(RF4CE_ENABLED "Enable RF4CE" ON) -option(RF4CE_PACKET_ANALYSIS "Enable RF4CE_PACKET_ANALYSIS" OFF) option(TELEMETRY_SUPPORT "Enable TELEMETRY_SUPPORT" OFF) -option(THUNDER "Enable THUNDER" OFF) +option(THUNDER "Enable THUNDER" ON) option(THUNDER_SECURITY "Enable THUNDER_SECURITY" OFF) option(USE_SAFEC "Use safec" OFF) option(USE_IARM_POWER_MANAGER "Use IARM Power Manager" OFF) @@ -84,7 +79,7 @@ set(BEEP_ON_KWD_FILE "NONE" CACHE STRING "Keyword Beep file name") set(CMAKE_ENABLE_EXPORTS ON) # EXECUTABLE(S) -add_executable(controlMgr src/ctrlm_config_default.json ctrlm_version_build.h ctrlm_config_default.h ${CMAKE_CURRENT_SOURCE_DIR}/src/ctrlm_config_default.c ${CMAKE_CURRENT_SOURCE_DIR}/src/voice/ipc/ctrlm_voice_ipc_request_type.c) +add_executable(controlMgr src/ctrlm_config_default.json ctrlm_version_build.h ctrlm_config_default.h ${CMAKE_CURRENT_SOURCE_DIR}/src/ctrlm_config_default.c) if(BUILD_CTRLM_FACTORY) add_library(ctrlm-fta) @@ -146,7 +141,7 @@ add_subdirectory(src) # COMPILER OPTIONS target_compile_options(controlMgr PUBLIC -fPIC -rdynamic -Wall -Werror) -add_compile_definitions(_REENTRANT _POSIX_C_SOURCE=200809L _GNU_SOURCE SYSTEMD_NOTIFY XR15_704 _REENTRANT) +add_compile_definitions(_REENTRANT _POSIX_C_SOURCE=200809L _GNU_SOURCE _REENTRANT) target_link_libraries( controlMgr @@ -199,25 +194,6 @@ if(ASSERT_ON_WRONG_THREAD) add_compile_definitions(ASSERT_ON_WRONG_THREAD) endif() -if(AUTH_ENABLED) - if(EXISTS ${CMAKE_SYSROOT}/usr/lib/libctrlm-hal-certificate.so) - add_compile_definitions(AUTH_ENABLED) - add_compile_definitions(AUTH_ACCOUNT_ID) - add_compile_definitions(AUTH_DEVICE_ID) - add_compile_definitions(AUTH_PARTNER_ID) - add_compile_definitions(AUTH_SAT_TOKEN) - if(AUTH_ACTIVATION_STATUS) - add_compile_definitions(AUTH_ACTIVATION_STATUS) - endif() - #By default disabled but can be enabled - #add_compile_definitions(AUTH_EXPERIENCE) - target_link_libraries(controlMgr ctrlm-hal-certificate) - else() - message(WARNING "ctrlm-hal-certificate library is not provided, disabling authentication") - unset(AUTH_ENABLED) - endif() -endif() - if(BLE_ENABLED) target_link_libraries(controlMgr BTMgr) if(BLE_SERVICES) @@ -231,18 +207,10 @@ if(BREAKPAD) add_compile_definitions(BREAKPAD_SUPPORT) endif() -if(CPC_ENABLED) - target_link_libraries(controlMgr ${CTRLM_CPC_LIBRARY}) -endif() - if(DEEPSLEEP_CLOSE_DB) add_compile_definitions(DEEPSLEEP_CLOSE_DB) endif() -if(DISABLE_BLE_VOICE) - add_compile_definitions(DISABLE_BLE_VOICE) -endif() - if(ENABLE_ASYNC_SRVR_MSG) add_compile_definitions(SUPPORT_ASYNC_SRVR_MSG) endif() @@ -263,10 +231,6 @@ if(IP_ENABLED) add_compile_definitions(CTRLM_NETWORK_IP CTRLM_IP_HAL_LOG_ENABLED) endif() -if(THUNDER) - add_compile_definitions(CTRLM_THUNDER) -endif() - if(LOCAL_MIC) add_compile_definitions(CTRLM_LOCAL_MIC) if(MIC_TAP) @@ -306,11 +270,23 @@ if(THUNDER) if(WPE_FRAMEWORK_PROTO_TRACING) target_link_libraries(controlMgr WPEFrameworkProtocols WPEFrameworkTracing) endif() -endif() - -if(THUNDER_SECURITY) - add_compile_definitions(THUNDER_SECURITY) - target_link_libraries(controlMgr WPEFrameworkSecurityUtil) + if(THUNDER_SECURITY) + add_compile_definitions(THUNDER_SECURITY) + target_link_libraries(controlMgr WPEFrameworkSecurityUtil) + endif() + if(AUTH_ENABLED) + add_compile_definitions(AUTH_ENABLED) + add_compile_definitions(AUTH_ACCOUNT_ID) + add_compile_definitions(AUTH_DEVICE_ID) + add_compile_definitions(AUTH_PARTNER_ID) + add_compile_definitions(AUTH_SAT_TOKEN) + if(AUTH_ACTIVATION_STATUS) + add_compile_definitions(AUTH_ACTIVATION_STATUS) + endif() + #By default disabled but can be enabled + #add_compile_definitions(AUTH_EXPERIENCE) + target_link_libraries(controlMgr RdkCertSelector) + endif() endif() if(USE_IARM_POWER_MANAGER) @@ -343,15 +319,14 @@ install(FILES ${CMAKE_BINARY_DIR}/ctrlm_config.json.template DESTINATION ${CMAKE # GENERATED FILES add_custom_command( OUTPUT ctrlm_version_build.h - COMMAND echo "#define CTRLM_MAIN_VER_MAJOR \"1\"" > ctrlm_version_build.h - COMMAND echo -n "#define CTRLM_MAIN_VER_MINOR \"" >> ctrlm_version_build.h - COMMAND bash -c "echo -n $(git -C ${CMAKE_CURRENT_SOURCE_DIR} rev-list --count 4b825dc642cb6eb9a060e54bf8d69288fbee4904..HEAD) >> ctrlm_version_build.h" - COMMAND git -C ${CMAKE_CURRENT_SOURCE_DIR} diff --quiet || echo -n "++" >> ctrlm_version_build.h + COMMAND echo -n "#define CTRLM_MAIN_BRANCH \"" >> ctrlm_version_build.h + COMMAND git -C ${CMAKE_CURRENT_SOURCE_DIR} branch --all --contains | sed -n -e "s/^\\s*remotes\\/origin\\///" -e "2p" | tr -d "\\n" >> ctrlm_version_build.h COMMAND echo "\"" >> ctrlm_version_build.h - COMMAND echo "#define CTRLM_MAIN_BRANCH \"${GIT_BRANCH}\"" >> ctrlm_version_build.h COMMAND echo -n "#define CTRLM_MAIN_COMMIT_ID " >> ctrlm_version_build.h COMMAND git -C ${CMAKE_CURRENT_SOURCE_DIR} log --format=\"%H\" -n 1 >> ctrlm_version_build.h - COMMAND echo "#define CTRLM_MAIN_VERSION (CTRLM_MAIN_VER_MAJOR \".\" CTRLM_MAIN_VER_MINOR)" >> ctrlm_version_build.h + COMMAND echo -n "#define CTRLM_MAIN_VERSION \"${CMAKE_PROJECT_VERSION}" >> ctrlm_version_build.h + COMMAND git -C ${CMAKE_CURRENT_SOURCE_DIR} diff --quiet || echo -n "++" >> ctrlm_version_build.h + COMMAND echo "\"" >> ctrlm_version_build.h VERBATIM ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1959af78..ab20447c 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,7 +81,6 @@ target_sources(controlMgr PRIVATE voice/endpoints/ctrlm_voice_endpoint_ws_nsp.cpp voice/ipc/ctrlm_voice_ipc_iarm_all.cpp voice/ipc/ctrlm_voice_ipc_iarm_legacy.cpp - voice/ipc/ctrlm_voice_ipc_request_type.c ) if(BLE_ENABLED) @@ -174,16 +173,6 @@ if(RF4CE_ENABLED) rf4ce/rib/ctrlm_rf4ce_rib.cpp rf4ce/rib/ctrlm_rf4ce_rib_attr.cpp ) - - if(RF4CE_PACKET_ANALYSIS) - target_sources(controlMgr PRIVATE - ctrlm_rf4ce_voice_packet_analysis.cpp - ) - else() - target_sources(controlMgr PRIVATE - stubs/stubs_voice_packet_analysis.cpp - ) - endif() endif() if(TELEMETRY_SUPPORT) @@ -209,12 +198,14 @@ if(THUNDER) thunder/plugins/ctrlm_thunder_plugin_system.cpp ipc/ctrlm_rcp_ipc_iarm_thunder.cpp voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp + voice/ipc/ctrlm_voice_ipc_request_type.c ) if(AUTH_ENABLED) target_sources(controlMgr PRIVATE auth/ctrlm_auth.cpp auth/ctrlm_auth_thunder.cpp + auth/ctrlm_auth_certificate.cpp auth/ctrlm_thunder_plugin_authservice.cpp ) endif() diff --git a/src/auth/ctrlm_auth_certificate.cpp b/src/auth/ctrlm_auth_certificate.cpp new file mode 100644 index 00000000..63ff900c --- /dev/null +++ b/src/auth/ctrlm_auth_certificate.cpp @@ -0,0 +1,171 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2015 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ +#include +#include +#include +#include +#include +#include +#include +#include "rdkcertselector.h" +#include "ctrlm_auth_certificate.h" +#include "ctrlm_utils.h" +#include "ctrlm_log.h" + +#define CERT_FILENAME_PREFIX "file://" + +ctrlm_auth_certificate_t *ctrlm_auth_certificate_get() { + return(new(ctrlm_auth_certificate_t)); +} + +ctrlm_auth_certificate_t::ctrlm_auth_certificate_t() { + + this->device_cert.type = CTRLM_VOICE_CERT_TYPE_NONE; + this->ocsp_verify_stapling = false; + this->ocsp_verify_ca = false; + + char *cert_path = NULL; + char *cert_password = NULL; + rdkcertselector_h cert_selector = rdkcertselector_new( NULL, NULL, "MTLS" ); + + if(cert_selector == NULL){ + XLOGD_TELEMETRY("cert selector init failed"); + } else { + rdkcertselectorStatus_t cert_status = rdkcertselector_getCert(cert_selector, &cert_path, &cert_password); + + if(cert_status != certselectorOk) { + XLOGD_TELEMETRY("cert selector retrieval failed"); + } else { + if(cert_path == NULL || cert_password == NULL) { + XLOGD_TELEMETRY("cert selector get failed"); + } else { + + char *local_path = cert_path; + if(strncmp(local_path, CERT_FILENAME_PREFIX, strlen(CERT_FILENAME_PREFIX)) == 0) { + local_path += strlen(CERT_FILENAME_PREFIX); + } + if(!this->device_cert_p12_set(local_path, cert_password)) { + XLOGD_TELEMETRY("unable to set device certificate <%s>", local_path); + } else { + struct stat file_info; + // OCSP is a global setting that is enabled via RFC in systemd service ocsp-support + if(stat("/tmp/.EnableOCSPStapling", &file_info) == 0) { + XLOGD_TELEMETRY("OCSP verification enabled (stapling)"); + this->ocsp_verify_stapling = true; + } + if(stat("/tmp/.EnableOCSPCA", &file_info) == 0) { + XLOGD_TELEMETRY("OCSP verification enabled (CA)"); + this->ocsp_verify_ca = true; + } + if(!this->ocsp_verify_stapling && !this->ocsp_verify_ca) { + XLOGD_TELEMETRY("OCSP verification disabled"); + } + } + } + } + } + + if(cert_selector != NULL) { + rdkcertselector_free(&cert_selector); + } +} + +ctrlm_auth_certificate_t::~ctrlm_auth_certificate_t() { + if(this->device_cert.type == CTRLM_VOICE_CERT_TYPE_P12) { + if(this->device_cert.cert.p12.certificate != NULL) { + free((void *)this->device_cert.cert.p12.certificate); + } + if(this->device_cert.cert.p12.passphrase != NULL) { + free((void *)this->device_cert.cert.p12.passphrase); + } + } +} + +bool ctrlm_auth_certificate_t::device_cert_get(ctrlm_voice_cert_t &device_cert, bool &ocsp_verify_stapling, bool &ocsp_verify_ca) { + + device_cert = this->device_cert; + ocsp_verify_stapling = this->ocsp_verify_stapling; + ocsp_verify_ca = this->ocsp_verify_ca; + return(true); +} + +bool ctrlm_auth_certificate_t::device_cert_p12_set(const char *certificate, const char *passphrase) { + bool cert_valid = false; + + // Extract the certificate, private key and additional certificates + PKCS12 *p12_cert = NULL; + EVP_PKEY *pkey = NULL; + X509 *x509_cert = NULL; + STACK_OF(X509) *additional_certs = NULL; + + do { + FILE *fp = fopen(certificate, "rb"); + if(fp == NULL) { + XLOGD_ERROR("unable to open P12 certificate <%s>", certificate); + break; + } + + d2i_PKCS12_fp(fp, &p12_cert); + fclose(fp); + fp = NULL; + + if(p12_cert == NULL) { + XLOGD_ERROR("unable to read P12 certificate <%s>", certificate); + break; + } + + if(1 != PKCS12_parse(p12_cert, passphrase, &pkey, &x509_cert, &additional_certs)) { + XLOGD_ERROR("unable to parse P12 certificate <%s>", certificate); + break; + } + + this->device_cert.type = CTRLM_VOICE_CERT_TYPE_P12; + this->device_cert.cert.p12.certificate = strdup(certificate); + this->device_cert.cert.p12.passphrase = strdup(passphrase); + + // Ensure the strings were duplicated + if(this->device_cert.cert.p12.certificate == NULL || this->device_cert.cert.p12.passphrase == NULL) { + this->device_cert.type = CTRLM_VOICE_CERT_TYPE_NONE; + if(this->device_cert.cert.p12.certificate != NULL) { + free((void *)this->device_cert.cert.p12.certificate); + } + if(this->device_cert.cert.p12.passphrase != NULL) { + free((void *)this->device_cert.cert.p12.passphrase); + } + } else { + cert_valid = true; + } + + } while(0); + + if(p12_cert != NULL) { + PKCS12_free(p12_cert); + } + if(pkey != NULL) { + EVP_PKEY_free(pkey); + } + if(x509_cert != NULL) { + X509_free(x509_cert); + } + if(additional_certs != NULL) { + sk_X509_pop_free(additional_certs, X509_free); + } + + return(cert_valid); +} diff --git a/src/auth/ctrlm_hal_certificate.h b/src/auth/ctrlm_auth_certificate.h similarity index 89% rename from src/auth/ctrlm_hal_certificate.h rename to src/auth/ctrlm_auth_certificate.h index 93e6f039..cdf8719f 100644 --- a/src/auth/ctrlm_hal_certificate.h +++ b/src/auth/ctrlm_auth_certificate.h @@ -17,8 +17,8 @@ * limitations under the License. */ -#ifndef __CTRLM_HAL_CERTIFICATE_H__ -#define __CTRLM_HAL_CERTIFICATE_H__ +#ifndef __CTRLM_AUTH_CERTIFICATE_H__ +#define __CTRLM_AUTH_CERTIFICATE_H__ #include #include @@ -62,10 +62,10 @@ typedef struct { } cert; } ctrlm_voice_cert_t; -class ctrlm_hal_certificate_t { +class ctrlm_auth_certificate_t { public: - ctrlm_hal_certificate_t(); - virtual ~ctrlm_hal_certificate_t(); + ctrlm_auth_certificate_t(); + virtual ~ctrlm_auth_certificate_t(); virtual bool device_cert_get(ctrlm_voice_cert_t &device_cert, bool &ocsp_verify_stapling, bool &ocsp_verify_ca); @@ -77,6 +77,6 @@ class ctrlm_hal_certificate_t { bool ocsp_verify_ca; }; -ctrlm_hal_certificate_t *ctrlm_hal_certificate_get(); +ctrlm_auth_certificate_t *ctrlm_auth_certificate_get(); #endif diff --git a/src/auth/ctrlm_thunder_plugin_authservice.cpp b/src/auth/ctrlm_thunder_plugin_authservice.cpp index aaaa4e17..60c57d7a 100644 --- a/src/auth/ctrlm_thunder_plugin_authservice.cpp +++ b/src/auth/ctrlm_thunder_plugin_authservice.cpp @@ -22,8 +22,6 @@ #include #include -#define SAT_TIMEOUT_RETRIES (2) - using namespace Thunder; using namespace AuthService; using namespace WPEFramework; @@ -148,7 +146,7 @@ bool ctrlm_thunder_plugin_authservice_t::get_experience(std::string &experience) bool ctrlm_thunder_plugin_authservice_t::get_sat(std::string &sat, time_t &expiration) { bool ret = false; JsonObject params, response; - if(this->call_plugin("getServiceAccessToken", (void *)¶ms, (void *)&response, SAT_TIMEOUT_RETRIES)) { + if(this->call_plugin("getServiceAccessToken", (void *)¶ms, (void *)&response)) { if(response["success"].Boolean()) { // If success doesn't exist, it defaults to false which is fine. if(response["status"].Number() == 0) { std::string temp = response["token"].String(); diff --git a/src/ble/ctrlm_ble_network.cpp b/src/ble/ctrlm_ble_network.cpp index 3de8077f..dca4c78f 100644 --- a/src/ble/ctrlm_ble_network.cpp +++ b/src/ble/ctrlm_ble_network.cpp @@ -58,6 +58,7 @@ using namespace std; #define CTRLM_VENDOR_BLE_NETWORK_DISABLE_FILE "/etc/vendor/input/ble_network_disable" #define CTRLM_VENDOR_BLE_REMOTE_WHITELIST_FILE "/etc/vendor/input/ble_remote_whitelist.json" +#define CTRLM_VENDOR_BLE_NETWORK_OPTIONS_FILE "/etc/vendor/input/ble_network_options.json" #define CTRLM_VENDOR_BLE_NETWORK_TIMEOUTS_FILE "/etc/vendor/input/ble_network_timeouts.json" typedef struct { @@ -172,6 +173,46 @@ static int ctrlm_ble_network_factory(vendor_network_opts_t *opts, json_t *json_c } } + + // If the vendor supplied options are provided, use them. Otherwise use the default values. + const char *vendor_options_file = CTRLM_VENDOR_BLE_NETWORK_OPTIONS_FILE; + + if(ctrlm_file_exists(vendor_options_file)) { + XLOGD_INFO("Using vendor options file: %s", vendor_options_file); + + json_t *json_obj_vendor_options = json_load_file(vendor_options_file, JSON_REJECT_DUPLICATES, NULL); + + if(json_obj_vendor_options == NULL || !json_is_object(json_obj_vendor_options)) { + XLOGD_ERROR("invalid vendor options file format"); + } else { + // Make sure the json_obj_net_ble object is valid + if(json_obj_net_ble == NULL) { // Create a json object + json_obj_net_ble = json_object(); + } + if(json_obj_net_ble == NULL) { + XLOGD_ERROR("invalid BLE network json object"); + } else { // Update the "options" section in the json_obj_net_ble object + int rc = 0; + json_t *obj_options = json_object_get(json_obj_net_ble, JSON_OBJ_NAME_NETWORK_BLE_OPTIONS); + if(obj_options == NULL || !json_is_object(obj_options)) { + rc = json_object_set_new(json_obj_net_ble, JSON_OBJ_NAME_NETWORK_BLE_OPTIONS, json_obj_vendor_options); + } else { + rc = json_object_update(obj_options, json_obj_vendor_options); + } + if(rc != 0) { + XLOGD_ERROR("failed to update vendor options in BLE network json object"); + } else { + XLOGD_INFO("successfully updated vendor options in BLE network json object"); + json_obj_vendor_options = NULL; + } + } + } + if(json_obj_vendor_options != NULL) { + json_decref(json_obj_vendor_options); + json_obj_vendor_options = NULL; + } + } + // If the vendor supplied timeouts are provided, use them. Otherwise use the default timeouts. const char *vendor_timeouts_file = CTRLM_VENDOR_BLE_NETWORK_TIMEOUTS_FILE; @@ -246,10 +287,25 @@ ctrlm_obj_network_ble_t::ctrlm_obj_network_ble_t(ctrlm_network_type_t type, ctrl version_ = "unknown"; init_result_ = CTRLM_HAL_RESULT_ERROR; ready_ = false; + voice_disabled_ = false; g_ctrlm_ble_network.upgrade_controllers_timer_tag = 0; g_ctrlm_ble_network.upgrade_pause_timer_tag = 0; + if(json_obj_net_ble != NULL) { + // Process network options + json_t *obj_options = json_object_get(json_obj_net_ble, JSON_OBJ_NAME_NETWORK_BLE_OPTIONS); + if(obj_options != NULL && json_is_object(obj_options)) { + json_t *json_value = json_object_get(obj_options, JSON_BOOL_NAME_NETWORK_BLE_OPTIONS_DISABLE_VOICE); + if(json_value != NULL && json_is_boolean(json_value)) { + voice_disabled_ = json_boolean_value(json_value); + if(voice_disabled_) { + XLOGD_INFO("BLE voice support is disabled by config"); + } + } + } + } + ctrlm_rfc_t *rfc = ctrlm_rfc_t::get_instance(); if(rfc) { rfc->add_changed_listener(ctrlm_rfc_t::attrs::BLE, std::bind(&ctrlm_obj_network_ble_t::rfc_retrieved_handler, this, std::placeholders::_1)); @@ -451,12 +507,11 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_begin(void *data, int si dqm->params->result = CTRLM_IARM_CALL_RESULT_ERROR; -#ifdef DISABLE_BLE_VOICE - XLOGD_WARN("BLE Voice is disabled in ControlMgr, so not starting a voice session."); - dqm->params->result = CTRLM_IARM_CALL_RESULT_SUCCESS; -#else - if (!ready_) { + if(!ready_) { XLOGD_FATAL("Network is not ready!"); + } else if(voice_disabled_) { + XLOGD_WARN("BLE Voice is disabled in ControlMgr, so not starting a voice session."); + dqm->params->result = CTRLM_IARM_CALL_RESULT_SUCCESS; } else { ctrlm_controller_id_t controller_id; unsigned long long ieee_address = dqm->params->ieee_address; @@ -536,7 +591,6 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_begin(void *data, int si } } } -#endif //DISABLE_BLE_VOICE if(dqm->semaphore) { sem_post(dqm->semaphore); } @@ -577,11 +631,11 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_end(void *data, int size g_assert(size == sizeof(ctrlm_main_queue_msg_voice_session_t)); dqm->params->result = CTRLM_IARM_CALL_RESULT_ERROR; -#ifdef DISABLE_BLE_VOICE - dqm->params->result = CTRLM_IARM_CALL_RESULT_SUCCESS; -#else + if (!ready_) { XLOGD_FATAL("Network is not ready!"); + } else if(voice_disabled_) { + dqm->params->result = CTRLM_IARM_CALL_RESULT_SUCCESS; } else { ctrlm_controller_id_t controller_id; unsigned long long ieee_address = dqm->params->ieee_address; @@ -595,7 +649,6 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_end(void *data, int size } } } -#endif //DISABLE_BLE_VOICE if(dqm->semaphore) { sem_post(dqm->semaphore); } @@ -1126,9 +1179,11 @@ void ctrlm_obj_network_ble_t::factory_reset(void) { XLOGD_INFO("Sending RCU action unpair to all controllers."); - // Since we are factory resetting anyway, don't waste time unpairing the remote after the - // remote notifies us of unpair reason through RemoteControl service - this->unpair_on_remote_request_ = false; + // Need to unpair the remote on the target side as well even though a factory + // reset will clear out the entire pairing table. This is because a reconnection + // attempt could occur with the remote before factory reset completes which would + // prevent the remote from auto-pairing after the reset. + this->unpair_on_remote_request_ = true; for (auto const &controller : controllers_) { if (ble_rcu_interface_) { diff --git a/src/ble/ctrlm_ble_network.h b/src/ble/ctrlm_ble_network.h index cd804015..92868ca1 100644 --- a/src/ble/ctrlm_ble_network.h +++ b/src/ble/ctrlm_ble_network.h @@ -204,6 +204,7 @@ class ctrlm_obj_network_ble_t : public ctrlm_obj_network_t { ctrlm_controller_id_t find_controller_from_upgrade_session_uuid(const std::string &uuid); json_t * json_config_ = NULL; + bool voice_disabled_ = false; bool upgrade_in_progress_ = false; bool unpair_on_remote_request_ = true; ctrlm_ble_unpair_metrics_t last_rcu_unpair_metrics_; diff --git a/src/ble/hal/blercu/bleservices/gatt/gatt_upgradeservice.cpp b/src/ble/hal/blercu/bleservices/gatt/gatt_upgradeservice.cpp index b49b7620..1ac11a01 100644 --- a/src/ble/hal/blercu/bleservices/gatt/gatt_upgradeservice.cpp +++ b/src/ble/hal/blercu/bleservices/gatt/gatt_upgradeservice.cpp @@ -885,7 +885,12 @@ static gboolean timerEvent(gpointer user_data) result = us->m_ptr->onTimeout(); } - delete us; + /* GLib timeout repeats on true so it needs this data + * only delete when the timer is complete (e.g. returns false) + * */ + if (!result) { + delete us; + } return result; } diff --git a/src/ctrlm.h b/src/ctrlm.h index 18d0f99c..68fa1818 100644 --- a/src/ctrlm.h +++ b/src/ctrlm.h @@ -29,7 +29,6 @@ #include "ctrlm_hal.h" #include "ctrlm_hal_rf4ce.h" #include "ctrlm_hal_ble.h" -#include "ctrlm_hal_certificate.h" #include "ctrlm_hal_ip.h" #include "ctrlm_ipc.h" #include "ctrlm_ipc_rcu.h" diff --git a/src/ctrlm_config_default.json b/src/ctrlm_config_default.json index e9550415..a30bde8a 100755 --- a/src/ctrlm_config_default.json +++ b/src/ctrlm_config_default.json @@ -219,6 +219,9 @@ } }, "network_ble" : { + "options": { + "disable_voice" : false + }, "timeouts": { "discovery": 15000, "pair": 20000, diff --git a/src/ctrlm_device_update.cpp b/src/ctrlm_device_update.cpp index 552cf711..92c21a13 100644 --- a/src/ctrlm_device_update.cpp +++ b/src/ctrlm_device_update.cpp @@ -197,9 +197,9 @@ typedef struct { guint32 rf4ce_session_active_count; guint32 rf4ce_session_count; map rf4ce_sessions; -#ifdef XR15_704 + gboolean xr15_crash_update; -#endif + vector *sessions; } ctrlm_device_update_t; @@ -276,10 +276,9 @@ void ctrlm_device_update_init(json_t *json_obj_device_update) { g_ctrlm_device_update.prefs.update_dirs.push_back(JSON_ARRAY_VAL_STR_DEVICE_UPDATE_DEVICE_UPDATE_DIRS_3); g_ctrlm_device_update.prefs.update_dirs.push_back(JSON_ARRAY_VAL_STR_DEVICE_UPDATE_DEVICE_UPDATE_DIRS_4); g_ctrlm_device_update.prefs.update_dirs.push_back(JSON_ARRAY_VAL_STR_DEVICE_UPDATE_DEVICE_UPDATE_DIRS_5); - -#ifdef XR15_704 + g_ctrlm_device_update.xr15_crash_update = false; -#endif + g_ctrlm_device_update.sessions = NULL; // Create an asynchronous queue to receive incoming messages from the networks @@ -859,15 +858,12 @@ void ctrlm_device_update_process_device_file(const std::string &file_path_archiv g_ctrlm_device_update.rf4ce_images->at(image_info.id) = image_info; } - // HACK FOR XR15-704 -#ifdef XR15_704 version_software_t version_bug = {XR15_DEVICE_UPDATE_BUG_FIRMWARE_MAJOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_MINOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_REVISION, XR15_DEVICE_UPDATE_BUG_FIRMWARE_PATCH}; if(RF4CE_CONTROLLER_TYPE_XR15 == controller_type && ctrlm_device_update_rf4ce_is_software_version_min_met(image_info.version_software, version_bug)) { XLOGD_INFO("XR15v1 image >= 2.0.0.0 available, enabling crash code for XR15v1s running < 2.0.0.0"); g_ctrlm_device_update.xr15_crash_update = true; } -#endif - // HACK FOR XR15-704 + if(ctrlm_is_rf4ce_enabled()) { // Firmware Notify message errno_t safec_rc = -1; @@ -2445,11 +2441,9 @@ string ctrlm_device_update_get_software_version(guint16 image_id){ return string(sw_version); } -#ifdef XR15_704 gboolean ctrlm_device_update_xr15_crash_update_get() { return g_ctrlm_device_update.xr15_crash_update; } -#endif void ctrlm_device_update_rf4ce_session_resume(vector *sessions) { // Store sessions vector diff --git a/src/ctrlm_device_update.h b/src/ctrlm_device_update.h index a46d7464..04973081 100644 --- a/src/ctrlm_device_update.h +++ b/src/ctrlm_device_update.h @@ -28,14 +28,10 @@ #define CTRLM_DEVICE_UPDATE_EXTENDED_TIMEOUT_VALUE (45) #define CTRLM_DEVICE_UPDATE_USE_DEFAULT_TIMEOUT (0) -// HACK FOR XR15-704 -#ifdef XR15_704 #define XR15_DEVICE_UPDATE_BUG_FIRMWARE_MAJOR (2) #define XR15_DEVICE_UPDATE_BUG_FIRMWARE_MINOR (0) #define XR15_DEVICE_UPDATE_BUG_FIRMWARE_REVISION (0) #define XR15_DEVICE_UPDATE_BUG_FIRMWARE_PATCH (0) -#endif -// HACK FOR XR15-704 typedef enum { // locations to check for firmware and audio updates @@ -138,9 +134,7 @@ std::string ctrlm_device_update_get_software_version(guint16 image_id); void ctrlm_device_update_rf4ce_session_resume(std::vector *sessions); guint32 ctrlm_device_update_request_timeout_get(void); -#ifdef XR15_704 gboolean ctrlm_device_update_xr15_crash_update_get(); -#endif #ifdef __cplusplus } diff --git a/src/ctrlm_main.cpp b/src/ctrlm_main.cpp index f0be11e5..e12749c5 100644 --- a/src/ctrlm_main.cpp +++ b/src/ctrlm_main.cpp @@ -62,7 +62,7 @@ #endif #ifdef AUTH_ENABLED #include "ctrlm_auth.h" -#include "ctrlm_hal_certificate.h" +#include "ctrlm_auth_certificate.h" #endif #include "ctrlm_rfc.h" #include "ctrlm_telemetry.h" @@ -75,9 +75,7 @@ #include "dsMgr.h" #include "dsRpc.h" #include "dsDisplay.h" -#ifdef SYSTEMD_NOTIFY #include -#endif #include #include "xr_voice_sdk.h" #include "ctrlm_voice_obj.h" @@ -278,7 +276,7 @@ typedef struct { ctrlm_cs_values_t cs_values; #ifdef AUTH_ENABLED ctrlm_auth_t *authservice; - ctrlm_hal_certificate_t *hal_certificate; + ctrlm_auth_certificate_t *auth_certificate; #endif #ifdef CTRLM_THUNDER Thunder::DeviceInfo::ctrlm_thunder_plugin_device_info_t *thunder_device_info; @@ -448,7 +446,7 @@ int main(int argc, char *argv[]) { // Set stdout to be line buffered setvbuf(stdout, NULL, _IOLBF, 0); - XLOGD_INFO("name <%-24s> version <%-7s> branch <%-20s> commit <%s>", "ctrlm-main", CTRLM_MAIN_VERSION, CTRLM_MAIN_BRANCH, CTRLM_MAIN_COMMIT_ID); + XLOGD_INFO("name <%-24s> version <%-9s> branch <%-20s> commit <%s>", "ctrlm-main", CTRLM_MAIN_VERSION, CTRLM_MAIN_BRANCH, CTRLM_MAIN_COMMIT_ID); #ifdef MEMORY_LOCK clnl_init(); @@ -517,7 +515,7 @@ int main(int argc, char *argv[]) { for(uint32_t index = 0; index < qty_vsdk; index++) { vsdk_version_info_t *entry = &version_info[index]; if(entry->name != NULL) { - XLOGD_INFO("name <%-24s> version <%-7s> branch <%-20s> commit <%s>", entry->name ? entry->name : "NULL", entry->version ? entry->version : "NULL", entry->branch ? entry->branch : "NULL", entry->commit_id ? entry->commit_id : "NULL"); + XLOGD_INFO("name <%-24s> version <%-9s> branch <%-20s> commit <%s>", entry->name ? entry->name : "NULL", entry->version ? entry->version : "NULL", entry->branch ? entry->branch : "NULL", entry->commit_id ? entry->commit_id : "NULL"); } } vsdk_init(); @@ -694,14 +692,14 @@ int main(int argc, char *argv[]) { #ifdef AUTH_ENABLED XLOGD_INFO("ctrlm_auth init"); - g_ctrlm.authservice = ctrlm_auth_service_create(g_ctrlm.server_url_authservice); - g_ctrlm.hal_certificate = ctrlm_hal_certificate_get(); + g_ctrlm.authservice = ctrlm_auth_service_create(g_ctrlm.server_url_authservice); + g_ctrlm.auth_certificate = ctrlm_auth_certificate_get(); ctrlm_voice_cert_t device_cert; bool ocsp_verify_stapling = false; bool ocsp_verify_ca = false; - if(!g_ctrlm.hal_certificate->device_cert_get(device_cert, ocsp_verify_stapling, ocsp_verify_ca)) { + if(!g_ctrlm.auth_certificate->device_cert_get(device_cert, ocsp_verify_stapling, ocsp_verify_ca)) { XLOGD_ERROR("unable to get device certificate"); } else { if(!g_ctrlm.voice_session->voice_stb_data_device_certificate_set(device_cert, ocsp_verify_stapling, ocsp_verify_ca)) { @@ -809,10 +807,12 @@ int main(int argc, char *argv[]) { g_ctrlm.ir_controller->db_load(); g_ctrlm.ir_controller->print_status(); + #ifdef CTRLM_THUNDER ctrlm_rcp_ipc_iarm_thunder_t *rcp_ipc = ctrlm_rcp_ipc_iarm_thunder_t::get_instance(); if (rcp_ipc) { rcp_ipc->register_ipc(); } + #endif XLOGD_INFO("init voice"); g_ctrlm.voice_session->voice_configure_config_file_json(json_obj_voice, json_obj_vsdk, g_ctrlm.local_conf ); @@ -6058,10 +6058,9 @@ gboolean ctrlm_start_iarm(gpointer user_data) { ctrlm_main_iarm_init(); -#ifdef SYSTEMD_NOTIFY XLOGD_INFO("Notifying systemd of successful initialization"); sd_notifyf(0, "READY=1\nSTATUS=ctrlm-main has successfully initialized\nMAINPID=%lu", (unsigned long)getpid()); -#endif + return false; } diff --git a/src/ctrlm_network.cpp b/src/ctrlm_network.cpp index 31d04b7d..74ff4129 100644 --- a/src/ctrlm_network.cpp +++ b/src/ctrlm_network.cpp @@ -113,12 +113,14 @@ ctrlm_obj_network_t::~ctrlm_obj_network_t() { } } + #ifdef CTRLM_THUNDER ctrlm_rcp_ipc_iarm_thunder_t *rcp_ipc = ctrlm_rcp_ipc_iarm_thunder_t::get_instance(); if (rcp_ipc) { rcp_ipc->deregister_ipc(); } // No need to also destroy rcp_ipc instance here because its a singleton and will get // automatically destroyed at ctrlm-main shutdown. + #endif } ctrlm_network_id_t ctrlm_obj_network_t::network_id_get() const { @@ -1020,6 +1022,7 @@ ctrlm_rf_pair_state_t ctrlm_obj_network_t::get_rf_pair_state() const { void ctrlm_obj_network_t::iarm_event_rcu_status(void) { XLOGD_DEBUG("Enter..."); + #ifdef CTRLM_THUNDER ctrlm_rcp_ipc_net_status_t msg; msg.populate_status(*this); @@ -1030,11 +1033,13 @@ void ctrlm_obj_network_t::iarm_event_rcu_status(void) { if (!rcp_ipc->on_status(msg)) { XLOGD_ERROR("Error broadcasting IARM message"); } + #endif } void ctrlm_obj_network_t::iarm_event_rcu_validation_status(void) { XLOGD_DEBUG("Enter..."); + #ifdef CTRLM_THUNDER ctrlm_rcp_ipc_validation_status_t msg; msg.populate_status(*this); @@ -1045,10 +1050,13 @@ void ctrlm_obj_network_t::iarm_event_rcu_validation_status(void) { if (!rcp_ipc->on_validation_status(msg)) { XLOGD_ERROR("Error broadcasting IARM message"); } + #endif } void ctrlm_obj_network_t::iarm_event_rcu_firmware_status(const ctrlm_obj_controller_t &rcu) { XLOGD_DEBUG("Enter..."); + + #ifdef CTRLM_THUNDER ctrlm_rcp_ipc_iarm_thunder_t *rcp_ipc = ctrlm_rcp_ipc_iarm_thunder_t::get_instance(); if (!rcp_ipc->is_thunder_device_update_enabled()) { @@ -1064,4 +1072,5 @@ void ctrlm_obj_network_t::iarm_event_rcu_firmware_status(const ctrlm_obj_control if (!rcp_ipc->on_firmware_update_progress(msg)) { XLOGD_ERROR("Error broadcasting IARM message"); } + #endif } diff --git a/src/ctrlm_rf4ce_voice_packet_analysis.cpp b/src/ctrlm_rf4ce_voice_packet_analysis.cpp deleted file mode 100644 index cdb0f6cd..00000000 --- a/src/ctrlm_rf4ce_voice_packet_analysis.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * If not stated otherwise in this file or this component's LICENSE file - * the following copyright and licenses apply: - * - * Copyright 2023 RDK Management - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ctrlm_voice_packet_analysis.h" -#include "ctrlm_log.h" - -#define SEQUENCE_NUM_INVALID (0xFF) - -class ctrlm_voice_packet_analysis_rf4ce_t : public ctrlm_voice_packet_analysis { - public: - ctrlm_voice_packet_analysis_rf4ce_t(); - virtual void reset(); - virtual ctrlm_voice_packet_analysis_result_t packet_check(const void* header, unsigned long header_len, const void* data, unsigned long data_len); - virtual void stats_get(ctrlm_voice_packet_analysis_stats_t& stats) const; - private: - uint8_t sequence_num_last; - uint32_t total_packets; - uint32_t duplicated_packets; - uint32_t lost_packets; - uint32_t sequence_error_count; -}; - - - -ctrlm_voice_packet_analysis_rf4ce_t::ctrlm_voice_packet_analysis_rf4ce_t() : - sequence_num_last(SEQUENCE_NUM_INVALID), - total_packets(0), - duplicated_packets(0), - lost_packets(0), - sequence_error_count(0) - { - } - -void ctrlm_voice_packet_analysis_rf4ce_t::reset() { - sequence_num_last = 0x20; - total_packets = 0; - duplicated_packets = 0; - lost_packets = 0; - sequence_error_count = 0; -} - -ctrlm_voice_packet_analysis_result_t ctrlm_voice_packet_analysis_rf4ce_t::packet_check(const void* header, unsigned long header_len, const void* data, unsigned long data_len) { - ctrlm_voice_packet_analysis_result_t result = CTRLM_VOICE_PACKET_ANALYSIS_GOOD; - // sanity check - if (header_len != sizeof(uint8_t)) { - XLOGD_INFO("header_len != 1"); - return (result = CTRLM_VOICE_PACKET_ANALYSIS_ERROR); - } - - uint8_t seqnum_act = *(uint8_t*)header; - uint8_t seqnum_exp = sequence_num_last+1 > 0x3F ? 0x20 : sequence_num_last+1; - - if(seqnum_act == sequence_num_last) { - XLOGD_INFO("Sequence duplicate: rec:%x exp:%x", (unsigned)seqnum_act, (unsigned)seqnum_exp); - ++total_packets; - ++duplicated_packets; - return (result = CTRLM_VOICE_PACKET_ANALYSIS_DUPLICATE); // don't propagate repeated voice packets - } - - if(seqnum_act != seqnum_exp) { - XLOGD_INFO("Sequence discontinuity: rec:%x exp:%x", (unsigned)seqnum_act, (unsigned)seqnum_exp); - ++sequence_error_count; - uint8_t missing_packets; - if(seqnum_act > seqnum_exp) { - missing_packets = seqnum_act - seqnum_exp; - } else { - missing_packets = 0x20 - seqnum_exp + seqnum_act; - } - lost_packets += missing_packets; - total_packets += missing_packets; - result = CTRLM_VOICE_PACKET_ANALYSIS_DISCONTINUITY; - } - - sequence_num_last = seqnum_act; - total_packets++; - return result; -} - -void ctrlm_voice_packet_analysis_rf4ce_t::stats_get(ctrlm_voice_packet_analysis_stats_t& stats) const { - stats.total_packets = total_packets; - stats.bad_packets = 0; - stats.duplicated_packets = duplicated_packets; - stats.lost_packets = lost_packets; - stats.sequence_error_count = sequence_error_count; -} - -ctrlm_voice_packet_analysis* ctrlm_voice_packet_analysis_factory() { - return new ctrlm_voice_packet_analysis_rf4ce_t; -} - - - - - diff --git a/src/ctrlm_utils.cpp b/src/ctrlm_utils.cpp index cc94fa02..7166aba5 100644 --- a/src/ctrlm_utils.cpp +++ b/src/ctrlm_utils.cpp @@ -1317,6 +1317,7 @@ static const map> ctrlm_linux_key_name {KEY_F21, {"Guide", "Guide"}}, {KEY_EPG, {"Guide", "Guide"}}, {KEY_F22, {"Accessibility", "Accessibility"}}, + {KEY_F23, {"AMC App", "AMC App"}}, {KEY_F8, {"Voice", "Voice"}}, {KEY_ESC, {"Dismiss", "Dismiss"}}, {KEY_F9, {"Quick Access Menu", "Quick Access Menu"}}, diff --git a/src/ctrlm_voice_packet_analysis.h b/src/ctrlm_voice_packet_analysis.h deleted file mode 100644 index f75b4e95..00000000 --- a/src/ctrlm_voice_packet_analysis.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * If not stated otherwise in this file or this component's license file the - * following copyright and licenses apply: - * - * Copyright 2014 RDK Management - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ -#ifndef CTRLM_VOICE_PACKET_ANALYSIS_H_ -#define CTRLM_VOICE_PACKET_ANALYSIS_H_ - -#include - -enum ctrlm_voice_packet_analysis_result_t { - CTRLM_VOICE_PACKET_ANALYSIS_GOOD, - CTRLM_VOICE_PACKET_ANALYSIS_DUPLICATE, - CTRLM_VOICE_PACKET_ANALYSIS_DISCONTINUITY, - CTRLM_VOICE_PACKET_ANALYSIS_BAD, - CTRLM_VOICE_PACKET_ANALYSIS_ERROR -}; - -struct ctrlm_voice_packet_analysis_stats_t { - uint32_t total_packets; - uint32_t bad_packets; - uint32_t duplicated_packets; - uint32_t lost_packets; - uint32_t sequence_error_count; -}; - -class ctrlm_voice_packet_analysis { - public: - ctrlm_voice_packet_analysis(){}; - virtual ~ctrlm_voice_packet_analysis(){}; - virtual void reset()=0; - virtual ctrlm_voice_packet_analysis_result_t packet_check(const void* header, unsigned long header_len, const void* data, unsigned long data_len) =0; - virtual void stats_get(ctrlm_voice_packet_analysis_stats_t& stats) const=0; -}; - -ctrlm_voice_packet_analysis* ctrlm_voice_packet_analysis_factory(); - -#endif /* CTRLM_VOICE_PACKET_ANALYSIS_H_ */ diff --git a/src/irdb/ctrlm_irdb_interface.cpp b/src/irdb/ctrlm_irdb_interface.cpp index 0ea07577..1bc55ffd 100644 --- a/src/irdb/ctrlm_irdb_interface.cpp +++ b/src/irdb/ctrlm_irdb_interface.cpp @@ -397,18 +397,18 @@ bool ctrlm_irdb_interface_t::get_ir_codes_by_autolookup(ctrlm_autolookup_ranked_ if(ir_codes.size() > 0) { if(type != CTRLM_IRDB_DEV_TYPE_INVALID) { codes[type].insert(codes[type].end(), ir_codes.begin(), ir_codes.end()); + ret = true; } else { XLOGD_ERROR("edid dev type invalid"); } } else { - XLOGD_WARN("no codes for edid data"); + XLOGD_ERROR("no codes for edid data"); } - ret = true; } else { XLOGD_ERROR("Failed getting codes by edid"); } } else { - XLOGD_INFO("No EDID data"); + XLOGD_ERROR("No EDID data"); } } else { XLOGD_ERROR("display_settings is NULL"); @@ -426,19 +426,19 @@ bool ctrlm_irdb_interface_t::get_ir_codes_by_autolookup(ctrlm_autolookup_ranked_ if(ir_codes.size() > 0) { if(type != CTRLM_IRDB_DEV_TYPE_INVALID) { codes[type].insert(codes[type].end(), ir_codes.begin(), ir_codes.end()); + ret = true; } else { XLOGD_ERROR("cec dev type invalid"); } } else { XLOGD_WARN("no code for cec device <%s>", itr.osd.c_str()); } - ret = true; } else { XLOGD_WARN("Failed to get codes for cec device <%s>", itr.osd.c_str()); } } } else { - XLOGD_INFO("No CEC device data"); + XLOGD_ERROR("No CEC device data"); } } else { XLOGD_ERROR("cec is NULL"); @@ -456,18 +456,18 @@ bool ctrlm_irdb_interface_t::get_ir_codes_by_autolookup(ctrlm_autolookup_ranked_ if(ir_codes.size() > 0) { if(type != CTRLM_IRDB_DEV_TYPE_INVALID) { codes[type].insert(codes[type].end(), ir_codes.begin(), ir_codes.end()); + ret = true; } else { - XLOGD_WARN("port %d infoframe dev type invalid", itr.first); + XLOGD_ERROR("port %d infoframe dev type invalid", itr.first); } } else { XLOGD_WARN("no code for port %d infoframe", itr.first); } - ret = true; } else { XLOGD_WARN("Failed to get codes for port %d infoframe", itr.first); } } else { - XLOGD_INFO("no infoframe for port %d", itr.first); + XLOGD_WARN("no infoframe for port %d", itr.first); } } } else { @@ -485,19 +485,19 @@ bool ctrlm_irdb_interface_t::get_ir_codes_by_autolookup(ctrlm_autolookup_ranked_ if(ir_codes.size() > 0) { if(type != CTRLM_IRDB_DEV_TYPE_INVALID) { codes[type].insert(codes[type].end(), ir_codes.begin(), ir_codes.end()); + ret = true; } else { - XLOGD_WARN("cec dev type invalid"); + XLOGD_ERROR("cec dev type invalid"); } } else { XLOGD_WARN("no code for cec device <%s>", itr.osd.c_str()); } - ret = true; } else { XLOGD_WARN("Failed to get codes for cec device <%s>", itr.osd.c_str()); } } } else { - XLOGD_INFO("No CEC device data"); + XLOGD_ERROR("No CEC device data"); } } else { XLOGD_ERROR("cec_sink is NULL"); diff --git a/src/rf4ce/controller/attributes/ctrlm_rf4ce_controller_attr_irdb.cpp b/src/rf4ce/controller/attributes/ctrlm_rf4ce_controller_attr_irdb.cpp index c4938b79..3d3238fa 100644 --- a/src/rf4ce/controller/attributes/ctrlm_rf4ce_controller_attr_irdb.cpp +++ b/src/rf4ce/controller/attributes/ctrlm_rf4ce_controller_attr_irdb.cpp @@ -351,7 +351,7 @@ ctrlm_rf4ce_rib_attr_t::status ctrlm_rf4ce_controller_ir_rf_database_status_t::r } else { // Normal Read data[0] = this->ir_rf_status; *len = IR_RF_STATUS_LEN; -#ifdef XR15_704 + if(this->controller && this->controller->needs_reset() && !ctrlm_device_update_is_controller_updating(this->controller->network_id_get(), this->controller->controller_id_get(), true)) { if(ctrlm_device_update_xr15_crash_update_get()) { XLOGD_INFO("ENTERING XR15 CRASH CODE: XR15-10 running less then 2.0.0.0, need to force reboot for device update... Setting proper IR RF Status bits"); @@ -362,7 +362,7 @@ ctrlm_rf4ce_rib_attr_t::status ctrlm_rf4ce_controller_ir_rf_database_status_t::r (data[0] & ctrlm_rf4ce_ir_rf_database_status_t::flag::DOWNLOAD_AVR_5_DIGIT_CODE) ? "YES" : "NO",(data[0] & ctrlm_rf4ce_ir_rf_database_status_t::flag::CLEAR_ALL_5_DIGIT_CODES) ? "YES" : "NO"); } } -#endif + if(this->controller && this->ir_rf_status & ctrlm_rf4ce_ir_rf_database_status_t::flag::DB_DOWNLOAD_YES) { XLOGD_INFO("Creating timer for download flag reset"); ctrlm_timeout_create(200, ir_rf_database_status_download_timeout, (void *)this->controller); diff --git a/src/rf4ce/ctrlm_rf4ce_controller.cpp b/src/rf4ce/ctrlm_rf4ce_controller.cpp index c2babdb8..6dd7387d 100644 --- a/src/rf4ce/ctrlm_rf4ce_controller.cpp +++ b/src/rf4ce/ctrlm_rf4ce_controller.cpp @@ -135,10 +135,8 @@ ctrlm_obj_controller_rf4ce_t::ctrlm_obj_controller_rf4ce_t(ctrlm_controller_id_t rib_configuration_complete_status_(RF4CE_RIB_CONFIGURATION_COMPLETE_PAIRING_INCOMPLETE), asb_key_derivation_method_used_(ASB_KEY_DERIVATION_NONE), metrics_tag_ (0), -#ifdef XR15_704 needs_reset_(false), did_reset_(false), -#endif mfg_test_result_(1) { XLOGD_INFO("constructor - %u", controller_id); @@ -1037,12 +1035,9 @@ void ctrlm_obj_controller_rf4ce_t::validation_result_set(ctrlm_rcu_binding_type_ validation_type_ = validation_type; db_create(); db_store(); - // HACK for XR15-704, possible duplicate pairing -#ifdef XR15_704 + // possible duplicate pairing needs_reset_ = false; did_reset_ = false; -#endif - // HACK for XR15-704 // Telemetry needs to keep track of binding. log_binding_for_telemetry(); @@ -2049,8 +2044,7 @@ guchar ctrlm_obj_controller_rf4ce_t::property_read_ir_rf_database(guchar index, } } len = obj_network_rf4ce_->property_read_ir_rf_database(index, data, length); - // HACK for XR15-704 -#ifdef XR15_704 + if(needs_reset_) { if(!ctrlm_device_update_is_controller_updating(network_id_get(), controller_id_get(), true)) { if(len < 2) { @@ -2071,8 +2065,7 @@ guchar ctrlm_obj_controller_rf4ce_t::property_read_ir_rf_database(guchar index, needs_reset_ = false; XLOGD_INFO("EXITING XR15 CRASH CODE: XR15 was reset <%s>", (did_reset_ ? "TRUE" : "FALSE")); } -#endif - // HACK for XR15-704 + return(len); } @@ -2842,8 +2835,6 @@ void ctrlm_obj_controller_rf4ce_t::print_remote_firmware_debug_info(ctrlm_rf4ce_ } -// These functions are HACKS for XR15-704 -#ifdef XR15_704 void ctrlm_obj_controller_rf4ce_t::set_reset() { ctrlm_sw_version_t version_bug(XR15_DEVICE_UPDATE_BUG_FIRMWARE_MAJOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_MINOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_REVISION, XR15_DEVICE_UPDATE_BUG_FIRMWARE_PATCH); @@ -2857,8 +2848,6 @@ void ctrlm_obj_controller_rf4ce_t::set_reset() { bool ctrlm_obj_controller_rf4ce_t::needs_reset() { return(needs_reset_); } -#endif -// These functions are HACKS for XR15-704 // Polling Functions void ctrlm_obj_controller_rf4ce_t::polling_action_push(ctrlm_rf4ce_polling_action_msg_t *action) { diff --git a/src/rf4ce/ctrlm_rf4ce_controller.h b/src/rf4ce/ctrlm_rf4ce_controller.h index 8420f95c..8fa7bd9f 100644 --- a/src/rf4ce/ctrlm_rf4ce_controller.h +++ b/src/rf4ce/ctrlm_rf4ce_controller.h @@ -600,12 +600,8 @@ class ctrlm_obj_controller_rf4ce_t : public ctrlm_obj_controller_t bool init_uinput_writer(void); - // These functions are HACKS for XR15-704 -#ifdef XR15_704 void set_reset(); bool needs_reset(); -#endif - // These functions are HACKS for XR15-704 ctrlm_sw_version_t version_software_get(); ctrlm_sw_version_t version_audio_data_get(); @@ -769,12 +765,9 @@ class ctrlm_obj_controller_rf4ce_t : public ctrlm_obj_controller_t guint metrics_tag_; - // HACK for XR15-704 -#ifdef XR15_704 gboolean needs_reset_; gboolean did_reset_; -#endif - // HACK for XR15-704 + guint8 mfg_test_result_; ctrlm_timestamp_t checkin_time_; ///< OUT - Timestamp indicating the most recent poll indication of the controller diff --git a/src/rf4ce/ctrlm_rf4ce_device_update.cpp b/src/rf4ce/ctrlm_rf4ce_device_update.cpp index 29d8136a..81391246 100644 --- a/src/rf4ce/ctrlm_rf4ce_device_update.cpp +++ b/src/rf4ce/ctrlm_rf4ce_device_update.cpp @@ -166,12 +166,10 @@ void ctrlm_obj_controller_rf4ce_t::device_update_image_check_request(ctrlm_times gboolean manual_poll = false; errno_t safec_rc = -1; -#ifdef XR15_704 if(did_reset_) { XLOGD_INFO("CHECK IMAGE REQUEST due to XR15 reset code!"); did_reset_ = false; } -#endif // is image type supported? switch(image_type) { @@ -233,10 +231,8 @@ void ctrlm_obj_controller_rf4ce_t::device_update_image_check_request(ctrlm_times download_in_progress_ = true; } -#ifdef XR15_704 - // HACK: We need to make XR15s running < 2.0.0.0 do not get an image pending flag to avoid bug on device. + // We need to make XR15s running < 2.0.0.0 do not get an image pending flag to avoid bug on device. ctrlm_sw_version_t version_bug(XR15_DEVICE_UPDATE_BUG_FIRMWARE_MAJOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_MINOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_REVISION, XR15_DEVICE_UPDATE_BUG_FIRMWARE_PATCH); -#endif if(!image_available || !ready_to_download) { guchar flags_check = IMAGE_CHECK_RESPONSE_FLAG_NO_IMAGE; @@ -249,10 +245,7 @@ void ctrlm_obj_controller_rf4ce_t::device_update_image_check_request(ctrlm_times if (is_controller_type_z()) { ota_failure_type_z_cnt_set(ota_failure_type_z_cnt_get() + 1); } - } -#ifdef XR15_704 - // HACK: We need to make XR15s running < 2.0.0.0 do not get an image pending flag to avoid bug on device. - else if(RF4CE_CONTROLLER_TYPE_XR15 == controller_type_ && *version_software_ < version_bug) { + } else if(RF4CE_CONTROLLER_TYPE_XR15 == controller_type_ && *version_software_ < version_bug) { XLOGD_INFO("Image Check response - Image is pending - XR15v1 running < 2.0.0.0, sending No image available"); print_remote_firmware_debug_info(RF4CE_PRINT_FIRMWARE_LOG_IMAGE_DOWNLOAD_PENDING, ctrlm_device_update_get_software_version(image_info.id)); if(begin_info.when == RF4CE_DEVICE_UPDATE_IMAGE_CHECK_POLL_TIME) { @@ -260,9 +253,7 @@ void ctrlm_obj_controller_rf4ce_t::device_update_image_check_request(ctrlm_times } else { next_check_time = update_polling_period_get() * 60 * 60; // Use update polling rib entry - convert to seconds } - } -#endif - else { + } else { flags_check = IMAGE_CHECK_RESPONSE_FLAG_IMAGE_PENDING; XLOGD_INFO("Image Check response - Image is pending"); print_remote_firmware_debug_info(RF4CE_PRINT_FIRMWARE_LOG_IMAGE_DOWNLOAD_PENDING, ctrlm_device_update_get_software_version(image_info.id)); @@ -423,8 +414,7 @@ void ctrlm_obj_controller_rf4ce_t::device_update_image_load_request(ctrlm_timest std::string log_string = ctrlm_device_update_get_software_version(image_id) + ". "; -#ifdef XR15_704 - // HACK: We need to make XR15s running < 2.0.0.0 load ASAP to avoid bug on device. + // We need to make XR15s running < 2.0.0.0 load ASAP to avoid bug on device. ctrlm_sw_version_t version_bug(XR15_DEVICE_UPDATE_BUG_FIRMWARE_MAJOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_MINOR, XR15_DEVICE_UPDATE_BUG_FIRMWARE_REVISION, XR15_DEVICE_UPDATE_BUG_FIRMWARE_PATCH); if(RF4CE_CONTROLLER_TYPE_XR15 == controller_type_ && *version_software_ < version_bug) { @@ -432,7 +422,6 @@ void ctrlm_obj_controller_rf4ce_t::device_update_image_load_request(ctrlm_timest load_info.when = RF4CE_DEVICE_UPDATE_IMAGE_LOAD_NOW; log_string += "Load scheduled: Immediately."; } -#endif if(load_info.when == RF4CE_DEVICE_UPDATE_IMAGE_LOAD_NOW) { load_response = RF4CE_DEVICE_UPDATE_IMAGE_LOAD_RSP_NOW; diff --git a/src/rf4ce/ctrlm_rf4ce_network.cpp b/src/rf4ce/ctrlm_rf4ce_network.cpp index e43fe6b9..f01c52d5 100644 --- a/src/rf4ce/ctrlm_rf4ce_network.cpp +++ b/src/rf4ce/ctrlm_rf4ce_network.cpp @@ -1205,9 +1205,7 @@ void ctrlm_obj_network_rf4ce_t::controller_insert(ctrlm_controller_id_t controll } else { controllers_[controller_id] = new ctrlm_obj_controller_rf4ce_t(controller_id, *this, ieee_address, CTRLM_RF4CE_RESULT_VALIDATION_SUCCESS, CTRLM_RCU_CONFIGURATION_RESULT_SUCCESS); controllers_[controller_id]->db_load(); -#ifdef XR15_704 controllers_[controller_id]->set_reset(); -#endif controllers_[controller_id]->update_polling_configurations(); } } diff --git a/src/stubs/stubs_voice_packet_analysis.cpp b/src/stubs/stubs_voice_packet_analysis.cpp deleted file mode 100644 index 59b1eb93..00000000 --- a/src/stubs/stubs_voice_packet_analysis.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * If not stated otherwise in this file or this component's license file the - * following copyright and licenses apply: - * - * Copyright 2015 RDK Management - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ -#include "../ctrlm_voice_packet_analysis.h" -#include "../ctrlm_log.h" - - -class stubs_ctrlm_voice_packet_analysis : public ctrlm_voice_packet_analysis { - public: - stubs_ctrlm_voice_packet_analysis(); - virtual ~stubs_ctrlm_voice_packet_analysis(); - virtual void reset(); - virtual ctrlm_voice_packet_analysis_result_t packet_check(const void* header, unsigned long header_len, const void* data, unsigned long data_len); - virtual void stats_get(ctrlm_voice_packet_analysis_stats_t& stats) const; - private: - uint32_t total_packets; -}; - -stubs_ctrlm_voice_packet_analysis::stubs_ctrlm_voice_packet_analysis() : total_packets(0) { - XLOGD_INFO("STUB Constructor"); -} - -stubs_ctrlm_voice_packet_analysis::~stubs_ctrlm_voice_packet_analysis() { - XLOGD_INFO("STUB Destructor"); -} - -void stubs_ctrlm_voice_packet_analysis::reset() { - XLOGD_INFO("STUB"); - total_packets = 0; -} - -ctrlm_voice_packet_analysis_result_t stubs_ctrlm_voice_packet_analysis::packet_check(const void* header, unsigned long header_len, const void* data, unsigned long data_len) { - XLOGD_INFO("STUB"); - ++total_packets; - return CTRLM_VOICE_PACKET_ANALYSIS_GOOD; -} - -void stubs_ctrlm_voice_packet_analysis::stats_get(ctrlm_voice_packet_analysis_stats_t& stats) const { - XLOGD_INFO("STUB"); - stats.total_packets = total_packets; - stats.bad_packets = 0; - stats.duplicated_packets = 0; - stats.lost_packets = 0; - stats.sequence_error_count = 0; -} - -ctrlm_voice_packet_analysis* ctrlm_voice_packet_analysis_factory() { - return new stubs_ctrlm_voice_packet_analysis; -} diff --git a/src/voice/ctrlm_voice_obj.h b/src/voice/ctrlm_voice_obj.h index f20644f4..70ddb4c7 100644 --- a/src/voice/ctrlm_voice_obj.h +++ b/src/voice/ctrlm_voice_obj.h @@ -28,6 +28,7 @@ #include "ctrlm_ipc_voice.h" #include "ctrlm.h" #include "ctrlm_auth.h" +#include "ctrlm_auth_certificate.h" #include "jansson.h" #include "json_config.h" #include "xr_timestamp.h" diff --git a/src/voice/ipc/ctrlm_voice_ipc_iarm_all.cpp b/src/voice/ipc/ctrlm_voice_ipc_iarm_all.cpp index 561c0aba..fc90e063 100644 --- a/src/voice/ipc/ctrlm_voice_ipc_iarm_all.cpp +++ b/src/voice/ipc/ctrlm_voice_ipc_iarm_all.cpp @@ -24,7 +24,9 @@ #include "jansson.h" ctrlm_voice_ipc_iarm_all_t::ctrlm_voice_ipc_iarm_all_t(ctrlm_voice_t *obj_voice): ctrlm_voice_ipc_t(obj_voice) { + #ifdef CTRLM_THUNDER this->ipc.push_back(new ctrlm_voice_ipc_iarm_thunder_t(obj_voice)); + #endif this->ipc.push_back(new ctrlm_voice_ipc_iarm_legacy_t(obj_voice)); } diff --git a/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp b/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp index 7a80ad09..1dfa80b8 100644 --- a/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp +++ b/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp @@ -653,8 +653,9 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::voice_session_request(void *data) json_t *obj_type = json_object_get(obj, "type"); std::string str_type = ""; - std::string str_transcription = ""; - std::string str_audio_file = ""; + std::string str_transcription = ""; + std::string str_audio_file = ""; + std::string str_name_of_source = "APPLICATION"; int fd = -1; if(obj_type == NULL || !json_is_string(obj_type)) { XLOGD_ERROR("request type parameter not present"); @@ -776,6 +777,14 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::voice_session_request(void *data) } } } + json_t *obj_name_of_source = json_object_get(obj, "name"); + if(obj_name_of_source != NULL) { + if(!json_is_string(obj_name_of_source)) { + XLOGD_WARN("name parameter is not a string - ignoring"); + } else { + str_name_of_source = std::string(json_string_value(obj_name_of_source)); + } + } } } } @@ -783,7 +792,7 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::voice_session_request(void *data) if (true == result) { ctrlm_voice_session_response_status_t voice_status = voice_obj->voice_session_req( CTRLM_MAIN_NETWORK_ID_INVALID, CTRLM_MAIN_CONTROLLER_ID_INVALID, - request_config.device, request_config.format, NULL, "APPLICATION", "0.0.0.0", "0.0.0.0", 0.0, + request_config.device, request_config.format, NULL, str_name_of_source.c_str(), "0.0.0.0", "0.0.0.0", 0.0, false, NULL, NULL, NULL, (fd >= 0) ? true : false, true, str_transcription.empty() ? NULL : str_transcription.c_str(), str_audio_file.empty() ? NULL : str_audio_file.c_str(), &request_uuid, request_config.low_latency, request_config.low_cpu_util, fd); if (voice_status != VOICE_SESSION_RESPONSE_AVAILABLE && voice_status != VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE) {