This CLI (Command Line Interface) is based mbed-os. Both NNN50 and NQ620 are supported.
Fork of NNN40_CLI by
BLE CLI Document can be downloaded here .
Note that when evaluate using Windows PC as the host, the Serial driver need to be installed in advance. The instruction is explained in the link below
https://developer.mbed.org/handbook/Windows-serial-configuration
Once installed, a device called 'mbed Serial Port (COM#)' should be recognized in Device Manager, as shown below
Please open the com port at 115200 8n1 as default
CLI_Source/command-interpreter.h@25:1423b707b705, 2017-05-12 (annotated)
- Committer:
- tsungta
- Date:
- Fri May 12 01:53:35 2017 +0000
- Revision:
- 25:1423b707b705
- Parent:
- 21:72d7a6e85d7f
update mbed-os to revision 2992; Note that NNN50 is temporary not supported due to the memory constraint
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gillwei7 | 0:5c195ab2f696 | 1 | /** @file command-interpreter.h |
gillwei7 | 0:5c195ab2f696 | 2 | * @brief Processes commands coming from the serial port. |
gillwei7 | 0:5c195ab2f696 | 3 | * See @ref commands for documentation. |
gillwei7 | 0:5c195ab2f696 | 4 | * |
gillwei7 | 0:5c195ab2f696 | 5 | * Copyright 2014 by DELTA Corporation. All rights reserved. |
gillwei7 | 0:5c195ab2f696 | 6 | */ |
gillwei7 | 0:5c195ab2f696 | 7 | |
gillwei7 | 0:5c195ab2f696 | 8 | #ifndef COMMAND_INTERPRETER_H |
gillwei7 | 0:5c195ab2f696 | 9 | #define COMMAND_INTERPRETER_H |
gillwei7 | 0:5c195ab2f696 | 10 | |
gillwei7 | 0:5c195ab2f696 | 11 | #include <stdbool.h> |
gillwei7 | 0:5c195ab2f696 | 12 | #include <stdint.h> |
gillwei7 | 3:38ec8ad317f4 | 13 | #include "mbed.h" |
gillwei7 | 3:38ec8ad317f4 | 14 | //#inlcude "nordic/boards.h" |
gillwei7 | 0:5c195ab2f696 | 15 | |
gillwei7 | 0:5c195ab2f696 | 16 | #define DELTA_BLE_ON 1 |
tsungta | 17:03c8af30087a | 17 | #define DELTA_WIFI_ON 0 |
gillwei7 | 5:ee474e3133eb | 18 | #define SIMPLE_CMD_NAME 0 |
gillwei7 | 0:5c195ab2f696 | 19 | |
gillwei7 | 0:5c195ab2f696 | 20 | #ifndef CYNTEC_COMMAND_BUFFER_LENGTH |
gillwei7 | 0:5c195ab2f696 | 21 | #define CYNTEC_COMMAND_BUFFER_LENGTH 255 |
gillwei7 | 0:5c195ab2f696 | 22 | #endif |
gillwei7 | 0:5c195ab2f696 | 23 | |
gillwei7 | 0:5c195ab2f696 | 24 | #ifndef MAX_TOKEN_COUNT |
gillwei7 | 0:5c195ab2f696 | 25 | #define MAX_TOKEN_COUNT 16 |
gillwei7 | 0:5c195ab2f696 | 26 | #endif |
gillwei7 | 0:5c195ab2f696 | 27 | |
gillwei7 | 0:5c195ab2f696 | 28 | #ifdef __cplusplus |
gillwei7 | 0:5c195ab2f696 | 29 | extern "C" { |
gillwei7 | 0:5c195ab2f696 | 30 | #endif |
gillwei7 | 0:5c195ab2f696 | 31 | |
gillwei7 | 0:5c195ab2f696 | 32 | enum { |
gillwei7 | 0:5c195ab2f696 | 33 | CYNTEC_CMD_SUCCESS, |
gillwei7 | 0:5c195ab2f696 | 34 | CYNTEC_CMD_ERR_NO_SUCH_COMMAND, |
gillwei7 | 0:5c195ab2f696 | 35 | CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS, |
gillwei7 | 0:5c195ab2f696 | 36 | CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE, |
gillwei7 | 0:5c195ab2f696 | 37 | CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR, |
gillwei7 | 0:5c195ab2f696 | 38 | CYNTEC_CMD_ERR_NO_MATCHED_ARGUMENT, |
gillwei7 | 0:5c195ab2f696 | 39 | CYNTEC_CMD_ERR_WRONG_CMD_ORDER, |
gillwei7 | 0:5c195ab2f696 | 40 | CYNTEC_CMD_ERR_INVALID_STATE_TO_PERFORM_OPERATION, |
gillwei7 | 0:5c195ab2f696 | 41 | CYNTEC_CMD_ERR_CALL_FAIL |
gillwei7 | 0:5c195ab2f696 | 42 | }; |
gillwei7 | 0:5c195ab2f696 | 43 | |
gillwei7 | 0:5c195ab2f696 | 44 | typedef void (*CommandAction)(void); |
gillwei7 | 0:5c195ab2f696 | 45 | |
gillwei7 | 0:5c195ab2f696 | 46 | typedef const struct { |
gillwei7 | 0:5c195ab2f696 | 47 | /** Use letters, digits, and underscores, '_', for the command name. |
gillwei7 | 0:5c195ab2f696 | 48 | * Command names are case-sensitive. |
gillwei7 | 0:5c195ab2f696 | 49 | */ |
gillwei7 | 0:5c195ab2f696 | 50 | const char *name; |
gillwei7 | 0:5c195ab2f696 | 51 | /** A reference to a function in the application that implements the |
gillwei7 | 0:5c195ab2f696 | 52 | * command. |
gillwei7 | 0:5c195ab2f696 | 53 | * If this entry refers to a nested command, then action field |
gillwei7 | 0:5c195ab2f696 | 54 | * has to be set to NULL. |
gillwei7 | 0:5c195ab2f696 | 55 | */ |
gillwei7 | 0:5c195ab2f696 | 56 | CommandAction action; |
gillwei7 | 0:5c195ab2f696 | 57 | /* |
gillwei7 | 0:5c195ab2f696 | 58 | * In case of a nested command (action is NULL), then this field |
gillwei7 | 0:5c195ab2f696 | 59 | * contains a pointer to the nested CyntecCommandEntry array. |
gillwei7 | 0:5c195ab2f696 | 60 | */ |
gillwei7 | 0:5c195ab2f696 | 61 | const char *subMenu; |
gillwei7 | 0:5c195ab2f696 | 62 | /** A description of the command. |
gillwei7 | 0:5c195ab2f696 | 63 | */ |
gillwei7 | 0:5c195ab2f696 | 64 | const char *description; |
gillwei7 | 0:5c195ab2f696 | 65 | } CyntecCommandEntry; |
gillwei7 | 0:5c195ab2f696 | 66 | |
gillwei7 | 0:5c195ab2f696 | 67 | extern CyntecCommandEntry cyntecCommandTable[]; |
gillwei7 | 0:5c195ab2f696 | 68 | |
gillwei7 | 0:5c195ab2f696 | 69 | uint8_t cyntecAtoi(uint8_t *str, uint8_t len); |
tsungta | 21:72d7a6e85d7f | 70 | int cyntecAtoInt(uint8_t *str); |
gillwei7 | 0:5c195ab2f696 | 71 | uint8_t cyntecArgToUint8(uint8_t *str, uint8_t len); |
gillwei7 | 0:5c195ab2f696 | 72 | uint16_t cyntecAtoiUint16(uint8_t *str, uint8_t len); |
gillwei7 | 0:5c195ab2f696 | 73 | uint16_t cyntecArgToUint16(uint8_t *str, uint8_t len); |
gillwei7 | 3:38ec8ad317f4 | 74 | uint32_t cyntecHexToUint32(uint8_t *str, uint8_t len); |
gillwei7 | 0:5c195ab2f696 | 75 | uint8_t cyntecStrCmp(uint8_t *src, uint8_t *dst, uint8_t len); |
gillwei7 | 0:5c195ab2f696 | 76 | |
gillwei7 | 0:5c195ab2f696 | 77 | /** |
gillwei7 | 0:5c195ab2f696 | 78 | * @brief Process the given char as a command. |
gillwei7 | 0:5c195ab2f696 | 79 | **/ |
gillwei7 | 0:5c195ab2f696 | 80 | void cyntecProcessCommandInput(uint8_t input); |
gillwei7 | 0:5c195ab2f696 | 81 | |
gillwei7 | 0:5c195ab2f696 | 82 | /** @brief Initialize the command interpreter. |
gillwei7 | 0:5c195ab2f696 | 83 | */ |
gillwei7 | 0:5c195ab2f696 | 84 | void cyntecCommandReaderInit(void); |
gillwei7 | 0:5c195ab2f696 | 85 | |
gillwei7 | 0:5c195ab2f696 | 86 | /** Retrieves unsigned integer arguments. */ |
gillwei7 | 0:5c195ab2f696 | 87 | uint8_t *cyntecGetCommandArgument(uint8_t argNum, uint8_t *length); |
gillwei7 | 0:5c195ab2f696 | 88 | uint8_t *cyntecGetMinusArgument(uint8_t argNum, uint8_t *length); |
gillwei7 | 0:5c195ab2f696 | 89 | extern void clearBuffer(void); |
gillwei7 | 0:5c195ab2f696 | 90 | |
gillwei7 | 0:5c195ab2f696 | 91 | /** Retrieves the token count. */ |
gillwei7 | 0:5c195ab2f696 | 92 | uint8_t cyntecGetCommandTokenCnt(void); |
gillwei7 | 0:5c195ab2f696 | 93 | |
gillwei7 | 3:38ec8ad317f4 | 94 | //gill add for accept blank in name 20150904 |
gillwei7 | 0:5c195ab2f696 | 95 | //uint8_t *cyntecGetCommandBuffer(void); |
gillwei7 | 0:5c195ab2f696 | 96 | uint8_t *cyntecGetCommandTotalBuffer(void); |
gillwei7 | 0:5c195ab2f696 | 97 | void cyntecWriteToTotalBuffer(uint8_t input); |
gillwei7 | 0:5c195ab2f696 | 98 | uint8_t cyntecGetTotalIndex(void); |
gillwei7 | 3:38ec8ad317f4 | 99 | |
gillwei7 | 0:5c195ab2f696 | 100 | #ifdef __cplusplus |
gillwei7 | 0:5c195ab2f696 | 101 | } |
gillwei7 | 0:5c195ab2f696 | 102 | #endif |
gillwei7 | 0:5c195ab2f696 | 103 | #endif |
gillwei7 | 0:5c195ab2f696 | 104 | |
gillwei7 | 0:5c195ab2f696 | 105 |