Hello Support
I have an error when I try to add a custom CLI command with the API "otCliSetUserCommands()". I added two commands for my example. The commands work fine but if I make a typo, usually the info "Error 35: InvalidCommand" pops up. But as soon as I set my own commands the programm crashes somewhere with no error. Am I doing something wrong with the initialization? The code below shows how I implemented my two user defined cli commands.
I work with:
- SDK for Thread and Zigbee Version 4.1.0
- CLI Example for the PCA10059 (Addad just the code below and call the init function in the main)
- NRF52840 Dongle
#include "bm_master_cli.h" #include "nrf_log_ctrl.h" #include "nrf_log.h" #include "nrf_log_default_backends.h" #include <openthread/cli.h> void bm_cli_benchmark_start(uint8_t aArgsLength, char *aArgs[]); void bm_cli_benchmark_stop(uint8_t aArgsLength, char *aArgs[]); otCliCommand bm_cli_usercommands[2] = { {"benchmark_start", bm_cli_benchmark_start}, {"benchmark_stop" , bm_cli_benchmark_stop} }; void bm_cli_benchmark_start(uint8_t aArgsLength, char *aArgs[]) { NRF_LOG_INFO("Benchmark start"); otCliOutput("done \r\n", sizeof("done \r\n")); } void bm_cli_benchmark_stop(uint8_t aArgsLength, char *aArgs[]) { NRF_LOG_INFO("Benchmark stop"); otCliOutput("done \r\n", sizeof("done \r\n")); } /**@brief Function for initialize custom cli commands */ void bm_custom_cli_init(void){ otCliSetUserCommands(bm_cli_usercommands, sizeof(bm_cli_usercommands)); }