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
main.cpp
- Committer:
- tsungta
- Date:
- 2016-10-19
- Revision:
- 20:bd1760975052
- Parent:
- 19:e2de6c1776eb
- Child:
- 21:72d7a6e85d7f
File content as of revision 20:bd1760975052:
#include <mbed-events/events.h> #include <mbed.h> #include "Gap.h" #include "command-interpreter.h" #include "nrf_gpio.h" #include "ble_cli.h" #define uart_buffer_size 64 //Do not increase uart_buffer_size to prevent out of memory, #define uart_baudrate 38400 //supported baudrate range between 1200 to 230400 (38400) for NQ620 (NNN40) unsigned char uart_buf[uart_buffer_size]; unsigned int i = 0; Serial console(USBTX, USBRX); void CLI_execute() { // if (i>=2) // if (uart_buf[i-2] == 0x0D && uart_buf[i-1] == 0x0A){//detecting CR LF if (console.readable()) return;//retrun if it is not the end of packet for (int j=0; j<i; j++) cyntecProcessCommandInput(uart_buf[j]); //console.putc(uart_buf[j]);//used for debug only i=0; // } } void uart_interrupt() { uart_buf[i++] = console.getc(); CLI_execute(); } int main(void) { console.attach(&uart_interrupt); console.baud(uart_baudrate); console.printf("\r\nBLE initialized\r\n"); cynBLEInitCommand(); }