This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Calling CLI lists without console

Hi,

In the Thread API under the Command Line Interface section, there are the following functions:

void otCliConsoleInit(otInstance *aInstance, otCliConsoleOutputCallback aCallback, void *aContext)

void otCliConsoleInputLine(char *aBuf, uint16_t aBufLength)	

I'm assuming these functions can be used to manually input in main() an OpenThread command from the list shown here and log the output response without using the CLI console?

I hope someone can shed some light on this.

Parents
  • Hello Roger!

    Yes you are right! What is more, there is no requirement to run otCliUartInit simultanously (but it is possible).

    I have just run following code:

    otCliConsoleInit(m_app.p_ot_instance, console_output, NULL);
    
    char command[] = "help\n";
    otCliConsoleInputLine(command, strlen(command));
    

    The result (whole list of commands) is passed then to console_output function as a non-null terminated string and its size.

    Give me know if you need more details on this feature.

  • Hi Lukasz,

    Thanks for your reply, it is very much appreciated.

    I'm having some difficulties running the code for a while now.

    How does one pass the second argument console_output to typedef int(* otCliConsoleOutputCallback)(const char * aBuf, uint16_t aBufLength, void * aContext)?

    I tried the following: otCliConsoleInit(m_app.p_ot_instance, (otCliConsoleOutputCallback)console_output, NULL) where I declared console_output as a character array. I then tried to print console_output, but with no success. At the moment, my code executes when a key from SEGGER RTT viewer is detected.

Reply
  • Hi Lukasz,

    Thanks for your reply, it is very much appreciated.

    I'm having some difficulties running the code for a while now.

    How does one pass the second argument console_output to typedef int(* otCliConsoleOutputCallback)(const char * aBuf, uint16_t aBufLength, void * aContext)?

    I tried the following: otCliConsoleInit(m_app.p_ot_instance, (otCliConsoleOutputCallback)console_output, NULL) where I declared console_output as a character array. I then tried to print console_output, but with no success. At the moment, my code executes when a key from SEGGER RTT viewer is detected.

Children
No Data
Related