Delta / Mbed OS Delta_CLI

Fork of NNN40_CLI by Delta

Committer:
silviaChen
Date:
Fri Sep 23 01:41:28 2016 +0000
Revision:
18:4f5b317c04b9
Parent:
17:03c8af30087a
Child:
19:e2de6c1776eb
CLI V1.15, Fix the connect command issue

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
silviaChen 18:4f5b317c04b9 11 #define uart_baudrate 115200 //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 }