Skip to content

Commit

Permalink
apps/dtm: Fix handling of unmodulated carrier
Browse files Browse the repository at this point in the history
We now provide unmodulated carrier via DTM extension (payload=255).
Previously implemented command was never upstream and thus was not
working.
  • Loading branch information
sjanc committed Aug 10, 2023
1 parent d1110d8 commit dac3ecf
Showing 1 changed file with 3 additions and 99 deletions.
102 changes: 3 additions & 99 deletions apps/dtm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ cmd_tx_test(int argc, char **argv)
}

params.payload = parse_arg_uint8("payload", &rc);
if ((rc != 0) || ((params.payload > 7))) {
if ((rc != 0) || ((params.payload > 7 && params.payload != 255))) {
console_printf("invalid 'payload' parameter\n");
return rc;
}
Expand Down Expand Up @@ -205,75 +205,6 @@ cmd_set_antenna(int argc, char **argv)
return 0;
}

#define BLE_HCI_OCF_VS_TEST_CARRIER (0x0020)

static bool tx_carrier_running = false;

static int
cmd_tx_carrier(int argc, char **argv)
{
uint8_t cmd[2];
int rc;

rc = parse_arg_all(argc - 1, argv + 1);
if (rc != 0) {
return rc;
}

if (tx_carrier_running) {
console_printf("TX carrier already started\n");
return 0;
}

cmd[0] = 1;
cmd[1] = parse_arg_uint8("channel", &rc);
if ((rc != 0) || (cmd[1] > 39)) {
console_printf("invalid channel\n");
return rc;
}

rc = ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_TEST_CARRIER, &cmd, sizeof(cmd),
NULL, 0);
if (rc) {
console_printf("failed to start TX carrier\n");
return rc;
}

console_printf("TX carrier started\n");
tx_carrier_running = true;
return 0;
}

static int
cmd_stop_carrier(int argc, char **argv)
{
uint8_t cmd[2];
int rc;

rc = parse_arg_all(argc - 1, argv + 1);
if (rc != 0) {
return rc;
}

if (!tx_carrier_running) {
console_printf("TX carrier not started\n");
return 0;
}
cmd[0] = 0;
cmd[1] = 0;

rc = ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_TEST_CARRIER, &cmd, sizeof(cmd),
NULL, 0);
if (rc) {
console_printf("failed to stop TX carrier\n");
return rc;
}

console_printf("TX carrier stopped\n");
tx_carrier_running = false;
return 0;
}

static const struct shell_param cmd_rx_test_params[] = {
{"channel", "RX channel, usage: =[0-39]"},
{"phy", "usage: =[1M|2M], default: 1M"},
Expand All @@ -288,10 +219,10 @@ static const struct shell_cmd_help cmd_rx_test_help = {
};

static const struct shell_param cmd_tx_test_params[] = {
{"channel", "RX channel, usage: =[0-39]"},
{"channel", "TX channel, usage: =[0-39]"},
{"phy", "usage: =[1M|2M], default: 1M"},
{"data_length", "usage: =[0-255], default: 0"},
{"payload", "usage: =[0-7]"},
{"payload", "usage: =[0-7, 255]"},
{NULL}
};

Expand Down Expand Up @@ -329,23 +260,6 @@ static const struct shell_cmd_help cmd_set_antenna_help = {
.params = cmd_set_antenna_params,
};

static const struct shell_param cmd_tx_carrier_params[] = {
{"channel", "TX channel, usage: =[0-39]"},
{NULL}
};

static const struct shell_cmd_help cmd_tx_carrier_help = {
.summary = "TX unmodulated carrier",
.usage = NULL,
.params = cmd_tx_carrier_params,
};

static const struct shell_cmd_help cmd_stop_carrier_help = {
.summary = "stop TX unmodulated carrier",
.usage = NULL,
.params = NULL,
};

static const struct shell_cmd dtm_commands[] = {
{
.sc_cmd = "rx-test",
Expand All @@ -372,16 +286,6 @@ static const struct shell_cmd dtm_commands[] = {
.sc_cmd_func = cmd_set_antenna,
.help = &cmd_set_antenna_help,
},
{
.sc_cmd = "tx-carrier",
.sc_cmd_func = cmd_tx_carrier,
.help = &cmd_tx_carrier_help,
},
{
.sc_cmd = "stop-carrier",
.sc_cmd_func = cmd_stop_carrier,
.help = &cmd_stop_carrier_help,
},
{ }
};

Expand Down

0 comments on commit dac3ecf

Please sign in to comment.