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@19:e2de6c1776eb, 2016-10-19 (annotated)
- Committer:
- tsungta
- Date:
- Wed Oct 19 06:49:09 2016 +0000
- Revision:
- 19:e2de6c1776eb
- Parent:
- 18:4f5b317c04b9
- Child:
- 20:bd1760975052
Change platfrom parameter setting to fit for usage of NNN40.
; NNN40 is tested that can handle in total of 4 service among with 12 char.
; Knowing issue: scanStart will hangup if scanStart is called repeatedly
Who changed what in which revision?
User | Revision | Line number | New 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 | 19:e2de6c1776eb | 10 | #define uart_buffer_size 64 //Do not increase uart_buffer_size to prevent out of memory, 64 should be enough for BLE usage |
tsungta | 19:e2de6c1776eb | 11 | #define uart_baudrate 38400 //supported baudrate range between 1200 to 230400 (38400) 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 | Serial console(USBTX, USBRX); |
tsungta | 17:03c8af30087a | 16 | |
tsungta | 17:03c8af30087a | 17 | void CLI_execute() { |
tsungta | 17:03c8af30087a | 18 | // if (i>=2) |
tsungta | 17:03c8af30087a | 19 | // if (uart_buf[i-2] == 0x0D && uart_buf[i-1] == 0x0A){//detecting CR LF |
tsungta | 17:03c8af30087a | 20 | if (console.readable()) return;//retrun if it is not the end of packet |
tsungta | 17:03c8af30087a | 21 | for (int j=0; j<i; j++) |
tsungta | 17:03c8af30087a | 22 | cyntecProcessCommandInput(uart_buf[j]); |
tsungta | 17:03c8af30087a | 23 | //console.putc(uart_buf[j]);//used for debug only |
tsungta | 17:03c8af30087a | 24 | i=0; |
tsungta | 17:03c8af30087a | 25 | // } |
tsungta | 17:03c8af30087a | 26 | } |
tsungta | 17:03c8af30087a | 27 | void uart_interrupt() { |
tsungta | 17:03c8af30087a | 28 | uart_buf[i++] = console.getc(); |
tsungta | 17:03c8af30087a | 29 | CLI_execute(); |
tsungta | 17:03c8af30087a | 30 | } |
gillwei7 | 4:b52035367aee | 31 | |
gillwei7 | 0:5c195ab2f696 | 32 | int main(void) |
gillwei7 | 0:5c195ab2f696 | 33 | { |
gillwei7 | 3:38ec8ad317f4 | 34 | |
tsungta | 17:03c8af30087a | 35 | console.attach(&uart_interrupt); |
tsungta | 17:03c8af30087a | 36 | console.baud(uart_baudrate); |
tsungta | 17:03c8af30087a | 37 | console.printf("\r\nBLE initialized\r\n"); |
tsungta | 17:03c8af30087a | 38 | cynBLEInitCommand(); |
gillwei7 | 0:5c195ab2f696 | 39 | } |
tsungta | 19:e2de6c1776eb | 40 |