Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of NNN40_CLI by
main.cpp
- Committer:
- tsungta
- Date:
- 2016-10-19
- Revision:
- 19:e2de6c1776eb
- Parent:
- 18:4f5b317c04b9
- Child:
- 20:bd1760975052
File content as of revision 19:e2de6c1776eb:
#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, 64 should be enough for BLE usage 
#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();
}
            
    