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 CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ option(BLE_ENABLED "Enable BLE" OFF)
option(BLE_SERVICES "Enable BLE Services" OFF)
option(BREAKPAD "Enable BREAKPAD" OFF)
option(BUILD_CTRLM_FACTORY "Build Control Factory Test" OFF)
option(BUILD_CTRLM_SERVER "Build Control Server Daemon" ON)
option(CPC "Enable CPC" OFF)
option(DISABLE_BLE_VOICE "Disable BLE voice" OFF)
option(DEEPSLEEP_CLOSE_DB "Deep Sleep Close DB" OFF)
Expand Down
1 change: 1 addition & 0 deletions include/ctrlm_ipc_voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ typedef struct {
ctrlm_controller_id_t controller_id; ///< A unique identifier of the remote
unsigned long long ieee_address; ///< IEEE MAC address of the remote
ctrlm_iarm_call_result_t result; ///< OUT - The result of the operation.
unsigned char service_id;
} ctrlm_voice_iarm_call_voice_session_t;

typedef struct {
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ if(BUILD_FACTORY_TEST)
add_subdirectory(factory)
endif()

if(BUILD_CTRLM_SERVER)
add_subdirectory(server)
endif()

if(RF4CE_ENABLED)
target_sources(controlMgr PRIVATE
rf4ce/controller/attributes/ctrlm_rf4ce_controller_attr_battery.cpp
Expand Down
6 changes: 5 additions & 1 deletion src/ble/ctrlm_ble_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,14 @@ bool ctrlm_obj_controller_ble_t::is_stale(time_t stale_time_threshold) const {
return false;
}

bool ctrlm_obj_controller_ble_t::isVoiceKey(uint16_t key_code) const {
bool ctrlm_obj_controller_ble_t::isVoiceKey(uint16_t key_code, bool &listenForKeyNames) const {
if(key_code == voice_key_code_) {
return true;
}
if(key_code == KEY_F23) {
listenForKeyNames = true;
return true;
}
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ble/ctrlm_ble_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ctrlm_obj_controller_ble_t : public ctrlm_obj_controller_t {
void print_status();

virtual bool is_stale(time_t stale_time_threshold) const;
bool isVoiceKey(uint16_t key_code) const;
bool isVoiceKey(uint16_t key_code, bool &listenForKeyNames) const;

void setPressAndHoldSupport(bool supported);
bool getPressAndHoldSupport() const;
Expand Down
28 changes: 23 additions & 5 deletions src/ble/ctrlm_ble_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_begin(void *data, int si
controllers_[controller_id]->get_model().c_str(),
controllers_[controller_id]->get_sw_revision().to_string().c_str(),
controllers_[controller_id]->get_hw_revision().to_string().c_str(), 0.0,
false, NULL, NULL, NULL, true, pressAndHoldSupport);
false, NULL, NULL, NULL, true, pressAndHoldSupport, dqm->params->service_id, NULL, NULL, NULL, (dqm->params->service_id == 1) ? true : false);
if (!controllers_[controller_id]->get_capabilities().has_capability(ctrlm_controller_capabilities_t::capability::PAR) && (VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE == voice_status)) {
XLOGD_WARN("PAR voice is enabled but not supported by BLE controller treating as normal voice session");
voice_status = VOICE_SESSION_RESPONSE_AVAILABLE;
Expand Down Expand Up @@ -2102,8 +2102,9 @@ void ctrlm_obj_network_ble_t::ind_process_keypress(void *data, int size) {
ctrlm_obj_controller_ble_t *controller = controllers_[controller_id];

if (key_status == CTRLM_KEY_STATUS_DOWN) {
bool listenForKeyNames = false;

if (controller->isVoiceKey(dqm->event.code)) {
if (controller->isVoiceKey(dqm->event.code, listenForKeyNames)) {
rdkx_timestamp_t keyDownTime;
keyDownTime.tv_sec = dqm->event.time.tv_sec;
keyDownTime.tv_nsec = dqm->event.time.tv_usec * 1000;
Expand All @@ -2116,13 +2117,18 @@ void ctrlm_obj_network_ble_t::ind_process_keypress(void *data, int size) {

ctrlm_voice_iarm_call_voice_session_t v_params;
v_params.ieee_address = dqm->ieee_address;
v_params.service_id = listenForKeyNames ? 1 : 0;

ctrlm_main_queue_msg_voice_session_t msg;
errno_t safec_rc = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
ERR_CHK(safec_rc);
msg.params = &v_params;

req_process_voice_session_begin(&msg, sizeof(msg));

if (listenForKeyNames) {
XLOGD_WARN("listening for key names in the voice session");
}
}

if (controller->getUpgradeInProgress()) {
Expand Down Expand Up @@ -2157,9 +2163,10 @@ void ctrlm_obj_network_ble_t::ind_process_keypress(void *data, int size) {
}

} else if (key_status == CTRLM_KEY_STATUS_UP) {

if (controller->isVoiceKey(dqm->event.code)) {
if(!controller->getPressAndHoldSupport()) { // if the voice session is "Press and Release" then don't end session on voice key up event
bool listenForKeyNames = false;
if (controller->isVoiceKey(dqm->event.code, listenForKeyNames)) {
// TODO This needs to check if the voice session is "Press and Hold" or "Press and Release" based on the key code
if(!controller->getPressAndHoldSupport() || dqm->event.code == KEY_F23) { // if the voice session is "Press and Release" then don't end session on voice key up event
XLOGD_INFO("------------------------------------------------------------------------");
XLOGD_INFO("CODE_VOICE_KEY button RELEASED event for device: %s (ignored for PAR session)", controller->ieee_address_get().to_string().c_str());
XLOGD_INFO("------------------------------------------------------------------------");
Expand Down Expand Up @@ -2272,6 +2279,17 @@ void ctrlm_obj_network_ble_t::ind_process_voice_session_end(void *data, int size
XLOGD_ERROR("Controller object doesn't exist for controller id %u!", controller_id);
return;
}

unsigned long long ieee_address = controllers_[controller_id]->ieee_address_get().get_value();;

if (ble_rcu_interface_) {
int32_t audioDuration = -1;
if (!ble_rcu_interface_->stopAudioStreaming(ieee_address, audioDuration)) {
XLOGD_ERROR("failed to end voice session for controller id <%u>", controller_id);
} else {
XLOGD_INFO("voice session ended for controller id <%u>", controller_id);
}
}
}

// ==================================================================================================================================================================
Expand Down
8 changes: 8 additions & 0 deletions src/ble/hal/blercu/bleservices/gatt/gatt_audiopipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ GattAudioPipe::GattAudioPipe(uint8_t frameSize, uint32_t frameCountMax, cbFrameV
m_outputPipeWrFd = fds[1];
}

// Set the pipe size
uint32_t size = 256 * 1024;

int rc = fcntl(m_outputPipeWrFd, F_SETPIPE_SZ, size);
if(rc < (int)size) { // emit a warning if the kernel returns a pipe size smaller than we requested
XLOGD_WARN("set pipe size failed exp <%u> rxd <%d>", size, rc);
}

}

// -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ void GattAudioService::stopStreaming(uint32_t audioDuration, PendingReply<> &&re
}

if(m_missedSequences >= frameCountMax) {
XLOGD_ERROR("missed frames greater than frame count max");
XLOGD_ERROR("missed frames <%u> greater than frame count max <%u>", m_missedSequences, frameCountMax);
} else {
frameCountMax -= m_missedSequences; // compensate for missed frames

Expand Down
3 changes: 2 additions & 1 deletion src/ctrlm_config_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
"url_src_ptt" : "",
"url_src_ff" : "",
"url_src_mic_tap" : "",
"url_src_key_listen" : "vrng://localhost:9881/",
"vrex_request_timeout" : 30,
"enable_sat" : true,
"enable_mtls" : true,
Expand All @@ -245,7 +246,7 @@
"minimum_duration" : 300,
"ffv_leading_samples" : 1600,
"timeout_packet_initial" : 3200,
"timeout_packet_subsequent" : 250,
"timeout_packet_subsequent" : 1000,
"bitrate_minimum" : 64,
"time_threshold" : 1000,
"timeout_stats" : 3000,
Expand Down
3 changes: 3 additions & 0 deletions src/ctrlm_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,14 @@ void ctrlm_obj_controller_t::process_event_key(ctrlm_key_status_t key_status, ui
last_key_code_->set_value((uint64_t)key_code);
last_key_time_update();

// TODO This is a temporary hack to avoid printing REPEAT keys for the secondary voice button
if(key_status != CTRLM_KEY_STATUS_REPEAT) {
XLOGD_TELEMETRY("ind_process_keypress: %s - MAC Address <%s>, code = <%d> (%s key), status = <%s>", controller_type_str_get().c_str(),
ieee_address_get().to_string().c_str(),
mask ? -1 : key_code,
ctrlm_linux_key_code_str(key_code, mask),
ctrlm_key_status_str(key_status));
}
}

ctrlm_controller_capabilities_t ctrlm_obj_controller_t::get_capabilities() const {
Expand Down
1 change: 1 addition & 0 deletions src/ctrlm_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ static const map<uint16_t, tuple<const char*, const char*>> ctrlm_linux_key_name
{KEY_F20, {"Info", "Info"}},
{KEY_F21, {"Guide", "Guide"}},
{KEY_F22, {"Accessibility", "Accessibility"}},
{KEY_F23, {"Voice Alt", "Voice Alt"}},
{KEY_F8, {"Voice", "Voice"}},
{KEY_ESC, {"Dismiss", "Dismiss"}},
{KEY_F9, {"Quick Access Menu", "Quick Access Menu"}},
Expand Down
19 changes: 19 additions & 0 deletions src/input_event/ctrlm_input_event_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,25 @@ uint16_t ctrlm_input_event_writer::write_event(ctrlm_key_code_t code, ctrlm_key_
return param.key_code;
}

uint16_t ctrlm_input_event_writer::write_event_linux(uint16_t code, ctrlm_key_status_t status) {
if (!initialized_) {
XLOGD_ERROR("User input device is not yet initialized!");
return KEY_RESERVED;
}

if (ev_key_value_map.find(status) == ev_key_value_map.end()) {
XLOGD_ERROR("Key status <%d> not found in mapping", status);
return KEY_RESERVED;
}

// TODO the scan code may need to vary based on the key code
if (!write_event_internal(0, code, ev_key_value_map.at(status))) {
return KEY_RESERVED;
}

return code;
}

bool ctrlm_input_event_writer::get_meta_data(struct stat &file_meta_data) {
int ret = fstat(fd_, &file_meta_data);
if (ret == -1) {
Expand Down
1 change: 1 addition & 0 deletions src/input_event/ctrlm_input_event_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class ctrlm_input_event_writer {
bool init(std::string uinput_name, uint32_t vendor, uint32_t product);
void shutdown(void);
uint16_t write_event(ctrlm_key_code_t code, ctrlm_key_status_t status);
uint16_t write_event_linux(uint16_t code, ctrlm_key_status_t status);
bool get_meta_data(struct stat &file_meta_data);
};

Expand Down
58 changes: 58 additions & 0 deletions src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
##########################################################################

Check failure on line 1 in src/server/CMakeLists.txt

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 'src/server/CMakeLists.txt' (Match: rdkcmf/rdkc-rtmessage/2010, 17 lines, url: https://github.com/rdkcmf/rdkc-rtmessage/archive/RDK-DEV-2010.zip, file: rtSocket.c)
# If not stated otherwise in this file or this component's LICENSE
# file the following copyright and licenses apply:
#
# Copyright 2019 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.
##########################################################################

add_executable(controlServer ctrlms_main.c)

include_directories(
.
${CMAKE_SYSROOT}/usr/include/safeclib
${CMAKE_SYSROOT}/usr/include/libsafec
${CMAKE_SYSROOT}/usr/include/nopoll
${CMAKE_SYSROOT}/usr/include
)

target_sources(controlServer PRIVATE
ctrlms_version.c
ctrlms_utils.c
ctrlms_ws.cpp
)

target_compile_options(controlServer PUBLIC -fPIC -rdynamic -Wall -Werror)

target_link_libraries(controlServer c rdkversion pthread nopoll jansson xr-voice-sdk secure_wrapper systemd ${CMAKE_DL_LIBS})

#if(EXISTS ${CMAKE_SYSROOT}/usr/lib/libctrlm-hal-certificate.so)
# TODO This needs to be done in certselector. mountutils recipe with rdkconfig.a static library
# target_link_libraries(controlServer rdkconfig.a)

# add_compile_definitions(PRIVATE CTRLMS_WSS_ENABLED)
# target_link_libraries(controlServer ctrlm-hal-certificate ssl crypto)
#endif()

if(USE_SAFEC)
find_package(PkgConfig)
pkg_check_modules(SAFEC REQUIRED libsafec)
if(SAFEC_FOUND)
target_link_libraries(controlServer ${SAFEC_LIBRARIES})
endif()
else()
add_compile_definitions(PUBLIC SAFEC_DUMMY_API)
endif()

install(TARGETS controlServer DESTINATION bin)
49 changes: 49 additions & 0 deletions src/server/ctrlm_server_app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* If not stated otherwise in this file or this component's license file the

Check failure on line 2 in src/server/ctrlm_server_app.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 'src/server/ctrlm_server_app.h' (Match: rdkcentral/rdkservices/1, 15 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
*
* Licensed under the Apache License, Version 2.0 (the "License");

Check failure on line 7 in src/server/ctrlm_server_app.h

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'MIT' license found in local file 'src/server/ctrlm_server_app.h' (Match: Mesa3D/mesa/0, 15 lines, url: https://github.com/Mesa3D/mesa/archive/vn-sw-device-v0.tar.gz, file: include/android_stub/nativebase/nativebase.h)
* 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.
*/
#pragma once

#include <stdint.h>
#include <stdbool.h>
#include <jansson.h>

class ctrlms_app_interface_t
{
public:
virtual ~ctrlms_app_interface_t() {};

virtual void ws_connected(void);
virtual void ws_disconnected(void);
virtual bool ws_receive_audio(const unsigned char *payload, int payload_size);
virtual bool ws_receive_json(const json_t *json_obj);
void ws_send_json(const json_t *json_obj);
void ws_handle_set(void *handle);

private:
void *ws_handle;
};

#ifdef __cplusplus
extern "C" {
#endif

ctrlms_app_interface_t *ctrlms_app_interface_create(void);

#ifdef __cplusplus
}
#endif
48 changes: 48 additions & 0 deletions src/server/ctrlm_server_platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* If not stated otherwise in this file or this component's license file the

Check failure on line 2 in src/server/ctrlm_server_platform.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 'src/server/ctrlm_server_platform.h' (Match: rdkcentral/rdkservices/1, 15 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
*
* 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_SERVER_PLATFORM_H_
#define _CTRLM_SERVER_PLATFORM_H_

#include <stdint.h>

typedef enum {
CTRLM_FTA_PLATFORM_VOICE_CERT_TYPE_NONE = 0,
CTRLM_FTA_PLATFORM_VOICE_CERT_TYPE_P12 = 1,
CTRLM_FTA_PLATFORM_VOICE_CERT_TYPE_INVALID = 2
} ctrlm_fta_platform_voice_cert_type_t;

typedef struct {
ctrlm_fta_platform_voice_cert_type_t type;
char *filename;
char *password;
}ctrlm_fta_platform_cert_info_t;


#ifdef __cplusplus
extern "C" {
#endif

ctrlm_fta_platform_cert_info_t *ctrlm_fta_platform_cert_info_get(bool allow_expired);
void ctrlm_fta_platform_cert_info_free(ctrlm_fta_platform_cert_info_t *cert_info);

#ifdef __cplusplus
}
#endif

#endif
Loading
Loading