Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a07f1aa
First rough draft
dwolaver May 19, 2025
4c4f4f9
Cleaned up a bunch.
dwolaver May 20, 2025
5f6db0a
added some compile options
dwolaver May 21, 2025
50ad1cf
updating app interface to c++ obj
dwolaver May 26, 2025
5c1bcc5
Add emit by key name logic
dwolaver May 26, 2025
d9dddd2
added routing
dwolaver May 27, 2025
71d2406
added systemd notify
dwolaver May 29, 2025
6ffad2f
silenced repeat keys
dwolaver May 29, 2025
912b9d3
Merge branch 'feature/RDKEMW-4433_local_server_build_option' of githu…
dwolaver May 29, 2025
0f12922
Added low latency
dwolaver May 30, 2025
0b5f26e
increase pipe size. ignore voice key up
dwolaver May 30, 2025
b074ea3
increase interpacket timeout. print sizes in error message.
dwolaver May 30, 2025
6a06eba
Fix timeout packet tag
dwolaver May 30, 2025
80571dc
Stop audio when session ends.
dwolaver May 30, 2025
cceea8a
Changed logs to DEBUG
dwolaver May 30, 2025
f9c2e63
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver May 30, 2025
90098a8
Updated certificate handling
dwolaver Jun 6, 2025
95f7a09
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver Jun 6, 2025
5098e1d
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver May 4, 2026
583c1d8
fix compile issues
dwolaver May 4, 2026
c17769a
remove key write stuff
dwolaver May 5, 2026
f2b5fb8
fix line endings
dwolaver May 5, 2026
73f8d55
fix file mode
dwolaver May 5, 2026
e977b9f
add newline
dwolaver May 5, 2026
ecec4a2
fix startup logic
dwolaver May 5, 2026
cc8fbcd
minor updates
dwolaver May 7, 2026
cbc5fb0
init fixes
dwolaver May 11, 2026
0117363
add cert stuff
dwolaver May 12, 2026
745adc6
copilot fixes
dwolaver May 12, 2026
c2c3477
copilot stuff
dwolaver May 12, 2026
f565025
more copilot fixes
dwolaver May 13, 2026
fe22587
more copilot
dwolaver May 13, 2026
a455a6b
more copilot fixes
dwolaver May 13, 2026
4ec676f
more copilot
dwolaver May 13, 2026
e5d28b2
copilot fixes
dwolaver May 13, 2026
1936883
copilot.
dwolaver May 13, 2026
7233652
more copilot
dwolaver May 13, 2026
63e5381
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver May 15, 2026
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 @@ -39,6 +39,7 @@ 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(BUILD_CTRLM_SERVER "Build Control Server Daemon" OFF)
option(FDC_ENABLED "Enable FDC" OFF)
option(IP_ENABLED "Enable IP" OFF)
option(RF4CE_ENABLED "Enable RF4CE" ON)
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(USE_IARM_POWER_MANAGER)
target_sources(controlMgr PRIVATE
ipc/ctrlm_ipc_iarm_powermanager.cpp
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
54 changes: 54 additions & 0 deletions src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
##########################################################################
# 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_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(AUTH_ENABLED)
target_compile_definitions(controlServer PRIVATE CTRLMS_WSS_ENABLED)
target_link_libraries(controlServer ssl crypto RdkCertSelector rdkconfig secure_wrapper)
endif()

if(USE_SAFEC)
find_package(PkgConfig)
pkg_check_modules(SAFEC REQUIRED libsafec)
if(SAFEC_FOUND)
target_link_libraries(controlServer ${SAFEC_LIBRARIES})
endif()
else()
target_compile_definitions(controlServer PUBLIC SAFEC_DUMMY_API)
endif()
Comment thread
dwolaver marked this conversation as resolved.
Comment thread
dwolaver marked this conversation as resolved.

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
* 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.
*/
#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 = NULL;
};

#ifdef __cplusplus
extern "C" {
#endif

ctrlms_app_interface_t *ctrlms_app_interface_create(void);

#ifdef __cplusplus
}
#endif
135 changes: 135 additions & 0 deletions src/server/ctrlms_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <argp.h>
#include <unistd.h>
#include <signal.h>
#include <systemd/sd-daemon.h>
#include <ctrlm_log.h>
#include <rdkx_logger.h>
#include <ctrlms_version.h>
#include <ctrlms_ws.h>

#define CTRLMS_VERSION "1.0"

#define CTRLMS_WS_PORT_INT (9881)

typedef struct {
bool silent;
bool verbose;
} ctrlms_options_t;

static bool ctrlms_cmdline_args(int argc, char *argv[]);
static error_t ctrlms_parse_opt(int key, char *arg, struct argp_state *state);
static void ctrlms_signal_handler(int signum);

const char *argp_program_version = "controlServer " CTRLMS_VERSION;
const char *argp_program_bug_address = "<david_wolaver@cable.comcast.com>";

static char doc[] = "controlServer -- a server application";

static char args_doc[] = "";

static struct argp_option options[] = {
{"verbose", 'v', 0, 0, "Produce verbose output" },
{"quiet", 'q', 0, 0, "Don't produce any output" },
{ 0 }
};

static struct argp argp = { options, ctrlms_parse_opt, args_doc, doc };

static ctrlms_options_t g_ctrlms_opts = { .silent = false,
.verbose = false
};

void ctrlms_signal_handler(int signum) {
if(signum == SIGTERM) {
ctrlms_ws_term();
}
Comment thread
dwolaver marked this conversation as resolved.
}

int main(int argc, char* argv[]) {
int result = -1;
if(signal(SIGTERM, ctrlms_signal_handler) == SIG_ERR) {
XLOGD_ERROR("ctrlms_main: failed to set SIGTERM handler <%s>", strerror(errno));
}

// Parse command line arguments
if(!ctrlms_cmdline_args(argc, argv)) {
return(result);
}

xlog_level_t level = XLOG_LEVEL_WARN;
if(g_ctrlms_opts.silent) {
level = XLOG_LEVEL_ERROR;
} else if(g_ctrlms_opts.verbose) {
level = XLOG_LEVEL_INFO;
// TODO Add option to allow debug level logging
//} else if() {
// level = XLOG_LEVEL_DEBUG;
}

if(!ctrlms_init(level)) {
XLOGD_ERROR("ctrlms_main: init failed");
} else {
// Start listening for connections
if(!ctrlms_ws_init(CTRLMS_WS_PORT_INT, true)) {
XLOGD_ERROR("ctrlms_main: ws init failed");
} else {
Comment thread
dwolaver marked this conversation as resolved.
result = 0;
XLOGD_INFO("Notifying systemd of successful initialization");
sd_notifyf(0, "READY=1\nSTATUS=ctrlm-server has successfully initialized\nMAINPID=%lu", (unsigned long)getpid());
ctrlms_ws_listen();
}
Comment thread
dwolaver marked this conversation as resolved.
Comment thread
dwolaver marked this conversation as resolved.
XLOGD_INFO("ctrlms_main: main loop ended");
}
ctrlms_term();
XLOGD_INFO("ctrlms_main: return");

return(result);
}

error_t ctrlms_parse_opt(int key, char *arg, struct argp_state *state) {
// Get the input argument from argp_parse, which we know is a pointer to our arguments structure.
ctrlms_options_t *arguments = state->input;

switch(key) {
case 'q': {
arguments->silent = true;
break;
}
case 'v': {
arguments->verbose = true;
break;
}
case ARGP_KEY_ARG: {
argp_usage(state);
return(ARGP_ERR_UNKNOWN);
}
case ARGP_KEY_END: {
break;
}
default: {
return(ARGP_ERR_UNKNOWN);
}
}

return(0);
}

bool ctrlms_cmdline_args(int argc, char *argv[]) {
argp_parse(&argp, argc, argv, 0, 0, &g_ctrlms_opts);

#if 0
if() { // Nothing to do
printf("Invalid options specified. Try 'controlServer --help' or 'controlServer --usage' for more information.\n");
return(false);
}
#endif

XLOGD_INFO("verbose <%s>", g_ctrlms_opts.verbose ? "YES" : "NO");
XLOGD_INFO("silent <%s>", g_ctrlms_opts.silent ? "YES" : "NO");

return(true);
}
57 changes: 57 additions & 0 deletions src/server/ctrlms_version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctrlm_log.h>
#include <rdkx_logger.h>
#include <rdkversion.h>
#include <ctrlms_version.h>

Comment thread
dwolaver marked this conversation as resolved.
typedef struct {
bool initialized;
bool is_production;
} ctrlms_global_t;

ctrlms_global_t g_ctrlms = {
.initialized = false,
.is_production = true
};

bool ctrlms_init(xlog_level_t level) {
rdk_version_info_t info;
int ret_val = rdk_version_parse_version(&info);

if(ret_val != 0) {
XLOGD_ERROR("parse error <%s>\n", info.parse_error == NULL ? "" : info.parse_error);
Comment thread
dwolaver marked this conversation as resolved.
rdk_version_object_free(&info);
return(false);
}

g_ctrlms.is_production = info.production_build;

rdk_version_object_free(&info);

int rc = xlog_init(XLOG_MODULE_ID, NULL, 0, true, false);
xlog_level_set_all(level);

if(rc != 0) {
XLOGD_ERROR("failed to init xlog");
return(false);
}

g_ctrlms.initialized = true;
return(true);
}

void ctrlms_term(void) {
g_ctrlms.initialized = false;
xlog_term();
}

bool ctrlms_is_initialized(void) {
return(g_ctrlms.initialized);
}

bool ctrlms_is_production(void) {
return(g_ctrlms.is_production);
}

40 changes: 40 additions & 0 deletions src/server/ctrlms_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 _CTRLMS_VERSION_H_
#define _CTRLMS_VERSION_H_

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

#ifdef __cplusplus
extern "C" {
#endif

bool ctrlms_init(xlog_level_t level);
void ctrlms_term(void);

bool ctrlms_is_initialized(void);
bool ctrlms_is_production(void);

#ifdef __cplusplus
}
#endif

#endif
Loading
Loading