ESP8266 Introduction to the Alios-things Development Guide (ii) ESP8266 open CLI function and add CLI function __ function

Source: Internet
Author: User
Tags kinit

Alios-things supports several debugging methods, specific functions and the use of reference link to address

Https://github.com/alibaba/AliOS-Things/wiki/Debugging-Overview.zh

Today we focus primarily on the opening of CLI debugging and the addition of CLI functions.

1, modify the ENTRY.C code in the kinit variable cli_ebable value is 1

Static kinit_t kinit = {
    . argc = 0,
    . argv = NULL,
    . cli_enable = 1
};

The "entry.c" file is located in "xxx\alios-things\platform\mcu\esp8266\bsp".

2. Adding CLI functions to the project

Here, I use example's Netmgrapp for this project code as an example.

Open the NCMDS structure array for the "netmgrapp.c" file and add the code as shown below

static void Handle_jack_cmd (char *pwbuf, int blen, int argc, char **argv)
{
    aos_cli_printf ("Call me jack,please\r \ n ");
}

static struct Cli_command ncmds[] = {
    {
        . Name = ' Test ',
        . Help = ' Test ',
        . function = Handle_test_cmd
    } ,
    {
        . Name = "Jack",
        . Help = "Jack",
        . function = Handle_jack_cmd
    },
#ifdef Test_wifi_hal_ Only
    {
        . Name = ' Test_wifi_hal ',
        . Help = "Test_wifi_hal [Start|scan|scan_adv|monitor [mngt]|80211send| Get_mac|ip_info|all] ",
        . function = Handle_test_wifi_cmd
    }
#endif
};

After saving, execute the following instructions in the Docker compilation environment

AOS make netmgrapp@esp8266

Burn the generated Netmgrapp@esp8266-0x1000.bin files to the Development Board.

3, the use of serial tools to run CLI command

Send help instructions to the MCU in the serial tool to enter the CLI. From the parameters returned from the CLI, we can see that we have just added an instruction "Jack".
Then we send the Jack command to the MCU via the serial tool, and we can see the print information we added: "Call me Jack,please"

The results of the operation are shown in the following figure


Since then, you can add your own CLI functions to debug the development of product features.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.