Project 8  Bluetooth
Neff Site
Enumerations | Functions
cli.h File Reference

This module implements a command line interface for the Bluetooth click. More...

Go to the source code of this file.

Enumerations

enum  cli_command_t { CLI_CMD_ON, CLI_CMD_OFF, CLI_CMD_BLINK }
 
enum  cli_state_t {
  CLI_STATE_GET_COMMAND, CLI_STATE_GET_LED_ARGUMENT, CLI_STATE_GET_BLINK_ARGUMENT1, CLI_STATE_GET_BLINK_ARGUMENT2,
  CLI_STATE_GET_TERMINAL, CLI_STATE_EXECUTE, CLI_STATE_ERROR
}
 

Functions

cli_state_t cli_parse_command (char token, cli_command_t *command)
 Parse command. More...
 
cli_state_t cli_parse_led_argument (char token, uint8_t *argument)
 Parse LED argument. More...
 
cli_state_t cli_parse_blink_argument1 (char token, uint8_t *argument)
 Parse first blink argument. More...
 
cli_state_t cli_parse_blink_argument2 (char token, uint8_t *argument)
 Parse second blink argument. More...
 
cli_state_t cli_parse_terminal (char token)
 Parse terminal. More...
 
cli_state_t cli_execute (cli_command_t command, uint8_t argument1, uint8_t argument2)
 Execute command. More...
 
cli_state_t cli_error (void)
 Print error message. More...
 

Detailed Description

This module implements a command line interface for the Bluetooth click.

Protocol Definition
Author
Wolfgang Neff
Version
2.0
Date
2018-11-25
History
Created: 2018-07-09
Modified: 2018-11-25

Enumeration Type Documentation

◆ cli_command_t

Enumerator
CLI_CMD_ON 
CLI_CMD_OFF 
CLI_CMD_BLINK 

◆ cli_state_t

Enumerator
CLI_STATE_GET_COMMAND 
CLI_STATE_GET_LED_ARGUMENT 
CLI_STATE_GET_BLINK_ARGUMENT1 
CLI_STATE_GET_BLINK_ARGUMENT2 
CLI_STATE_GET_TERMINAL 
CLI_STATE_EXECUTE 
CLI_STATE_ERROR 

Function Documentation

◆ cli_error()

cli_state_t cli_error ( void  )

Print error message.

Prints an error message if an error occured. The subsequent state is CLI_STATE_GET_COMMAND.

Returns
The subsequent state.

◆ cli_execute()

cli_state_t cli_execute ( cli_command_t  command,
uint8_t  argument1,
uint8_t  argument2 
)

Execute command.

Executes the provided command with the given argument. It returns CLI_STATE_GET_COMMAND if no error occured.

Parameters
commandThe command to be executed.
argument1The first argument for the command.
argument2The second argument for the command.
Returns
The subsequent state.

◆ cli_parse_blink_argument1()

cli_state_t cli_parse_blink_argument1 ( char  token,
uint8_t *  argument 
)

Parse first blink argument.

This routine parses the first argument that follows the CLI_CMD_BLINK command. The subsequent state is returnd. It will be CLI_STATE_PARSE_ERROR if the argument is not valid. This argument is the LED which shall blink. Valid LED numbers are [0-7].

Parameters
tokenThe input token.
argumentThe number of the LED.
Returns
The subsequent state.

◆ cli_parse_blink_argument2()

cli_state_t cli_parse_blink_argument2 ( char  token,
uint8_t *  argument 
)

Parse second blink argument.

This routine parses the second argument that follows the CLI_CMD_BLINK command. The subsequent state is returnd. It will be CLI_STATE_PARSE_ERROR if the argument is not valid. This argument is the number of blinkings.

Parameters
tokenThe input token.
argumentThe number of blinkings.
Returns
The subsequent state.

◆ cli_parse_command()

cli_state_t cli_parse_command ( char  token,
cli_command_t command 
)

Parse command.

A parser analyzes input tokens and determins their meaning. Their meaning is defined by the protocol. This routine parses the input token and determins the specified command. It also returns the subsequent state. A CLI_STATE_PARSE_ERROR is returned if no valid command is found.

Parameters
tokenThe input token.
commandThe parsed command.
Returns
The subsequent state.

◆ cli_parse_led_argument()

cli_state_t cli_parse_led_argument ( char  token,
uint8_t *  argument 
)

Parse LED argument.

This routine parses the argument that follows the CLI_CMD_ON or the CLI_CMD_OFF command. The subsequent state is returnd. It will be CLI_STATE_PARSE_ERROR if the the argument is not valid. The argument is the LED which shall be turned on or off. Valid LED numbers are [0-7].

Parameters
tokenThe input token.
argumentThe number of the LED.
Returns
The subsequent state.

◆ cli_parse_terminal()

cli_state_t cli_parse_terminal ( char  token)

Parse terminal.

Terminal symbols are symbols which terminate a command. This routine checks if the token passed is a terminal. It returns CLI_STATE_EXECUTE if a terminal symbol was found or CLI_STATE_PARSE_ERROR otherwise.

Parameters
tokenThe input token.
Returns
The subsequent state.
Contact