Skip to content

RDKB-62878:Enhance Sample App Automation and Remote Log Access#801

Open
Aniket0606 wants to merge 1 commit intordkcentral:developfrom
Aniket0606:csi_sample_app_support
Open

RDKB-62878:Enhance Sample App Automation and Remote Log Access#801
Aniket0606 wants to merge 1 commit intordkcentral:developfrom
Aniket0606:csi_sample_app_support

Conversation

@Aniket0606
Copy link
Contributor

Reason for change: Added support for providing the client MAC address
as an input to the sample app, enabling automation
of sample app execution. Also implemented a log upload
feature to the server to allow remote access to CSI
JSON files.
Test Procedure: 1) Load OneWifi Image.
2) Execute CSI sample APP.
wifi_events_consumer -e 7 -i 300 -n 20 -m C0:8D:51:A5:FA:74
3) Once log upload done then you will see below log.
Upload successful

Risks: Low
Priority: P1

Signed-off-by: apatel599@cable.comcast.com

@Aniket0606 Aniket0606 requested a review from a team as a code owner December 22, 2025 19:16
@rdkcmf-jenkins
Copy link
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 1 file pending identification.

  • Protex Server Path: /home/blackduck/github/OneWifi/801/rdkb/components/opensource/ccsp/OneWifi

  • Commit: aa52390

Report detail: gist'

@Aniket0606 Aniket0606 force-pushed the csi_sample_app_support branch from aa52390 to 85de41b Compare December 22, 2025 19:17
@rdkcmf-jenkins
Copy link
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 1 file pending identification.

  • Protex Server Path: /home/blackduck/github/OneWifi/801/rdkb/components/opensource/ccsp/OneWifi

  • Commit: 85de41b

Report detail: gist'

@rdkcmf-jenkins
Copy link
Contributor

b'## WARNING: A Blackduck scan failure has been waived

A prior failure has been upvoted

  • Upvote reason: OK

  • Commit: 85de41b
    '

Comment on lines 219 to 223
if (execute_system_command_with_status(
"/usr/bin/rdkssacli \"{STOR=GET,SRC=kquhqtoczcbx,DST=/dev/stdout}\"",
output_key,
output_len,
NULL) != 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of filling this buffer at this place if it might fail or will be overwritten later with another command output at lines https://github.com/rdkcentral/OneWifi/pull/801/files#diff-1d7faf20d911b0287acf3399680c51aa629b17b99f49a25cbb6ca2c9286ccc0eR235-R239

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You supply output_key and output_len here to fill that buffer and later you fill it again overwriting whatever it was filled in here.

size_t len = 0;

if (!cmd || !cmd_output || output_size == 0) {
errno = EINVAL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

int get_server_password(char *output_key, size_t output_len)
{
if (!output_key || output_len == 0) {
errno = EINVAL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You set errno in here and print error in other cases.
Please choose single approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if (len + buf_len < output_size - 1) {
memcpy(cmd_output + len, buffer, buf_len);
len += buf_len;
cmd_output[len] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be moved outside the while loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

char curl_output[1024];
int curl_exit_code;

#if defined (_XB7_PRODUCT_REQ_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined (_XB7_PRODUCT_REQ_)
#ifdef _XB7_PRODUCT_REQ_


int upload_file_to_cloud(const char *file_name)
{
static char password[256] = { 0 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it static?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting password onetime and then using the same password later.

Comment on lines +269 to +310
if (strlen(password) == 0) {
if (get_server_password(password, sizeof(password)) != 0) {
fprintf(stderr, "Failed to get server password\n");
return -1;
}
}

for (int attempt = 0; attempt < 2; attempt++) {
snprintf(curl_cmd, sizeof(curl_cmd),
"curl -s "
"--cert-type P12 "
"--cert %s:%s "
"-F \"data=@%s\" "
"https://devprimary.vbautobot.comcast.com:6002/post_csi_file",
cert_file_name,
password,
file_name);

if (execute_system_command_with_status(
curl_cmd,
curl_output,
sizeof(curl_output),
&curl_exit_code) != 0)
{
fprintf(stderr, "Failed to execute curl\n");
return -1;
}

printf("Curl Output:\n%s\n", curl_output);

if (curl_exit_code == 0) {
printf("Upload successful\n");
return 0;
}

if (curl_exit_code == 58 && attempt == 0) {
printf("PKCS12 password invalid, regenerating and retrying once...\n");

memset(password, 0, sizeof(password));
if (get_server_password(password, sizeof(password)) != 0) {
fprintf(stderr, "Failed to regenerate password\n");
return -1;
}
continue;
}

fprintf(stderr, "Upload failed (curl exit code %d)\n", curl_exit_code);
}
Copy link
Contributor

@Pavlo-Uvarov Pavlo-Uvarov Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (strlen(password) == 0) {
if (get_server_password(password, sizeof(password)) != 0) {
fprintf(stderr, "Failed to get server password\n");
return -1;
}
}
for (int attempt = 0; attempt < 2; attempt++) {
snprintf(curl_cmd, sizeof(curl_cmd),
"curl -s "
"--cert-type P12 "
"--cert %s:%s "
"-F \"data=@%s\" "
"https://devprimary.vbautobot.comcast.com:6002/post_csi_file",
cert_file_name,
password,
file_name);
if (execute_system_command_with_status(
curl_cmd,
curl_output,
sizeof(curl_output),
&curl_exit_code) != 0)
{
fprintf(stderr, "Failed to execute curl\n");
return -1;
}
printf("Curl Output:\n%s\n", curl_output);
if (curl_exit_code == 0) {
printf("Upload successful\n");
return 0;
}
if (curl_exit_code == 58 && attempt == 0) {
printf("PKCS12 password invalid, regenerating and retrying once...\n");
memset(password, 0, sizeof(password));
if (get_server_password(password, sizeof(password)) != 0) {
fprintf(stderr, "Failed to regenerate password\n");
return -1;
}
continue;
}
fprintf(stderr, "Upload failed (curl exit code %d)\n", curl_exit_code);
}
for (int attempt = 0; attempt < 2; attempt++) {
if (get_server_password(password, sizeof(password)) != 0) {
fprintf(stderr, "Failed to get server password\n");
return -1;
}
snprintf(curl_cmd, sizeof(curl_cmd),
"curl -s "
"--cert-type P12 "
"--cert %s:%s "
"-F \"data=@%s\" "
"https://devprimary.vbautobot.comcast.com:6002/post_csi_file",
cert_file_name,
password,
file_name);
if (execute_system_command_with_status(
curl_cmd,
curl_output,
sizeof(curl_output),
&curl_exit_code) != 0)
{
fprintf(stderr, "Failed to execute curl\n");
return -1;
}
printf("Curl Output:\n%s\n", curl_output);
if (curl_exit_code == 0) {
printf("Upload successful\n");
return 0;
}
if ((curl_exit_code != 58) || (attempt != 0)) {
fprintf(stderr, "Upload failed (curl exit code %d)\n", curl_exit_code);
break;
}
printf("Retrying\n");
}

Comment on lines 1142 to 1146
if ((i + 1) % 3 == 0) {
if (mac[i] != ':') {
return false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((i + 1) % 3 == 0) {
if (mac[i] != ':') {
return false;
}
}
if (((i + 1) % 3 == 0) && (mac[i] != ':')) {
return false;
}

printf(" number of samples to be collected : %d\n", g_num_of_samples);
break;
case 'm':
if (!optarg || (validate_mac_list(optarg) == false)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!optarg || (validate_mac_list(optarg) == false)) {
if (!optarg || !validate_mac_list(optarg)) {

Reason for change: Added support for providing the client MAC address
                   as an input to the sample app, enabling automation
		   of sample app execution. Also implemented a log upload
		   feature to the server to allow remote access to CSI
		   JSON files.
Test Procedure: 1) Load OneWifi Image.
                2) Execute CSI sample APP.
		   wifi_events_consumer -e 7 -i 300 -n 20 -m C0:8D:51:A5:FA:74
		3) Once log upload done then you will see below log.
		   Upload successful

Risks: Low
Priority: P1

Signed-off-by: apatel599@cable.comcast.com
@Aniket0606 Aniket0606 force-pushed the csi_sample_app_support branch from 85de41b to 5088620 Compare January 6, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants