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.

  • Hello Lukasz,

    Many thanks for the detailed description. It works very well.

    One more thing I noticed when trying different CLI commands is when I give the following command, for example:

    otCliConsoleInit(m_app.p_ot_instance, console_output, NULL);
    
    c = SEGGER_RTT_GetKey();
        if (c == 'a')
        {
              SEGGER_RTT_WriteString(0, "Get key character 'a' pressed\r\n");
              char command[] = "ping FF03::1\n";
              // void otCliConsoleInputLine(char * aBuf, uint16_t aBufLength)
              // This method is called to feed in a console input line
              otCliConsoleInputLine(command, strlen(command));
        }
    

    I'm able to ping the node at first, but the MCU freezes after the key was pressed. Any ideas why this might be happening?

Reply
  • Hello Lukasz,

    Many thanks for the detailed description. It works very well.

    One more thing I noticed when trying different CLI commands is when I give the following command, for example:

    otCliConsoleInit(m_app.p_ot_instance, console_output, NULL);
    
    c = SEGGER_RTT_GetKey();
        if (c == 'a')
        {
              SEGGER_RTT_WriteString(0, "Get key character 'a' pressed\r\n");
              char command[] = "ping FF03::1\n";
              // void otCliConsoleInputLine(char * aBuf, uint16_t aBufLength)
              // This method is called to feed in a console input line
              otCliConsoleInputLine(command, strlen(command));
        }
    

    I'm able to ping the node at first, but the MCU freezes after the key was pressed. Any ideas why this might be happening?

Children
No Data
Related