一、在cli.c中添加自定义命令入口
二、在cuostom_cli.h声明
#ifndef CUSTOM_CLI_H
#define CUSTOM_CLI_H
#ifdef EMBER_AF_ENABLE_CUSTOM_COMMANDS
extern EmberCommandEntry emberAfCustomCommands[];
#ifndef CUSTOM_SUBMENU_NAME
#define CUSTOM_SUBMENU_NAME "custom"
#endif
#ifndef CUSTOM_SUBMENU_DESCRIPTION
#define CUSTOM_SUBMENU_DESCRIPTION "Custom commands defined by the developer"
#endif
#define CUSTOM_COMMANDS emberCommandEntrySubMenu(CUSTOM_SUBMENU_NAME, emberAfCustomCommands, CUSTOM_SUBMENU_DESCRIPTION),
#else
#ifndef CUSTOM_COMMANDS
#define CUSTOM_COMMANDS
#endif
#endif
#endif
三、在自定义.c中实现
void led_clean(void)
{
uint8_t index = (uint8_t)emberUnsignedCommandArgument(0);
uint8_t mode = (uint8_t)emberUnsignedCommandArgument(1);
logic_ctrl_clean(index, mode);
}
EmberCommandEntry emberAfCustomCommands[] = {
/* Sample Custom CLI commands */
// emberCommandEntrySubMenu("sub-menu", customSubMenu, "Sub menu of custom commands"),
// emberCommandEntryAction("action", actionFunction, "", "Description of action command."),
emberCommandEntryAction("recv_print", recv_packet_num_print, "","print the recv packet num"),
emberCommandEntryAction("recv_clear", recv_packet_num_clear, "","clear the recv packet num"),
emberCommandEntryAction("print_ctrl", printf_ctrl_func, "u","control the switch of the debug"),
emberCommandEntryAction("move_level", level_ctrl_move, "u", "move level to set value in transtime"),
emberCommandEntryAction("move_stop", level_stop, "", "stop moving"),
emberCommandEntryAction("move_step", level_step, "uu", "step moving"),
emberCommandEntryAction("level_ctrl", level_ctrl, "uu", ""),
emberCommandEntryAction("mode_change", pwm_mode_ctrl, "u", ""),
emberCommandEntryAction("pwm_max", pwm_max_level_set, "u", ""),
emberCommandEntryAction("proxi_int", proximity_interrupt_set, "u", ""),
emberCommandEntryAction("led_start", led_start, "uu", ""),
emberCommandEntryAction("led_clean", led_clean, "uu", ""),
emberCommandEntryTerminator()
};