This CLI (Command Line Interface) is based mbed-os. Both NNN50 and NQ620 are supported.

Fork of NNN40_CLI by Delta

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

/media/uploads/tsungta/mbed_serial_port_1.png

Please open the com port at 115200 8n1 as default

Committer:
tsungta
Date:
Mon Sep 19 02:26:11 2016 +0000
Revision:
17:03c8af30087a
Parent:
4:b52035367aee
Child:
18:4f5b317c04b9
BLE CLI based mbed-os.; Both NNN40 and NQ620 are supported.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tsungta 17:03c8af30087a 1 #include <mbed-events/events.h>
tsungta 17:03c8af30087a 2 #include <mbed.h>
tsungta 17:03c8af30087a 3
gillwei7 0:5c195ab2f696 4 #include "Gap.h"
gillwei7 0:5c195ab2f696 5 #include "command-interpreter.h"
gillwei7 3:38ec8ad317f4 6 #include "nrf_gpio.h"
gillwei7 0:5c195ab2f696 7
tsungta 17:03c8af30087a 8 #include "ble_cli.h"
tsungta 17:03c8af30087a 9
tsungta 17:03c8af30087a 10 #define uart_buffer_size 512 //Do not increase uart_buffer_size to prevent out of memory
tsungta 17:03c8af30087a 11 #define uart_baudrate 1200 //supported baudrate range between 1200 to 230400 (57600) for NQ620 (NNN40)
tsungta 17:03c8af30087a 12 unsigned char uart_buf[uart_buffer_size];
tsungta 17:03c8af30087a 13 unsigned int i = 0;
tsungta 17:03c8af30087a 14
tsungta 17:03c8af30087a 15 #if defined(TARGET_NRF52_DK)//temp use only
tsungta 17:03c8af30087a 16 Serial console(p12, p11);
tsungta 17:03c8af30087a 17 #else
tsungta 17:03c8af30087a 18 Serial console(USBTX, USBRX);
tsungta 17:03c8af30087a 19 #endif
tsungta 17:03c8af30087a 20
tsungta 17:03c8af30087a 21 void CLI_execute() {
tsungta 17:03c8af30087a 22 // if (i>=2)
tsungta 17:03c8af30087a 23 // if (uart_buf[i-2] == 0x0D && uart_buf[i-1] == 0x0A){//detecting CR LF
tsungta 17:03c8af30087a 24 if (console.readable()) return;//retrun if it is not the end of packet
tsungta 17:03c8af30087a 25 for (int j=0; j<i; j++)
tsungta 17:03c8af30087a 26 cyntecProcessCommandInput(uart_buf[j]);
tsungta 17:03c8af30087a 27 //console.putc(uart_buf[j]);//used for debug only
tsungta 17:03c8af30087a 28 i=0;
tsungta 17:03c8af30087a 29 // }
tsungta 17:03c8af30087a 30 }
tsungta 17:03c8af30087a 31 void uart_interrupt() {
tsungta 17:03c8af30087a 32 uart_buf[i++] = console.getc();
tsungta 17:03c8af30087a 33 CLI_execute();
tsungta 17:03c8af30087a 34 }
gillwei7 4:b52035367aee 35
gillwei7 0:5c195ab2f696 36 int main(void)
gillwei7 0:5c195ab2f696 37 {
gillwei7 3:38ec8ad317f4 38
tsungta 17:03c8af30087a 39 console.attach(&uart_interrupt);
tsungta 17:03c8af30087a 40 console.baud(uart_baudrate);
tsungta 17:03c8af30087a 41 console.printf("\r\nBLE initialized\r\n");
tsungta 17:03c8af30087a 42 cynBLEInitCommand();
gillwei7 0:5c195ab2f696 43 }