BLE Client UART function

Dependencies:   RingBuffer

This is a BLE Client (Central) program for nRF51.
You can communicate with mbed BLE using "BLE_Uart_Server" program as follows.
/users/kenjiArai/code/BLE_Uart_Server/
Please refer following my notebook.
/users/kenjiArai/notebook/ble-client-and-peripheral-using-switch-sience-ty51/#

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sun Feb 11 02:04:44 2018 +0000
Parent:
4:342b665fb826
Commit message:
use Mbed-os5 dedicated class "CircularBuffer"

Changed in this revision

RingBuffer.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RingBuffer.lib	Fri Feb 09 22:31:19 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://os.mbed.com/users/ykuroda/code/RingBuffer/#ea6d02ba96ae
--- a/main.cpp	Fri Feb 09 22:31:19 2018 +0000
+++ b/main.cpp	Sun Feb 11 02:04:44 2018 +0000
@@ -9,8 +9,8 @@
  *
  *      Started:  April     8th, 2016
  *      Revised:  June     13th, 2016
- *      Revised:  October  22nd, 2017   Run on mbed-OS-5.6.2
  *      Revised:  Feburary 10th, 2018   Not set mac addr but use device name
+ *      Revised:  Feburary 11th, 2018   use mbed-os5.7.4 with CircularBuffer
  *
  *  Original program (see original.cpp file):
  *      S130 potential unstability case [closed] by Fabien Comte
@@ -32,7 +32,7 @@
 #include "DiscoveredCharacteristic.h"
 #include "DiscoveredService.h"
 #include "UARTService.h"
-#include "RingBuffer.h"
+#include "CircularBuffer.h"
 
 //  Definition -----------------------------------------------------------------
 //#define     USE_MAC           // if you use mac address, please define it
@@ -56,7 +56,7 @@
 Serial      pc(USBTX, USBRX, 115200);
 //Serial      pc(P0_3, P0_1, 115200);     // for another board
 Ticker      ticker;
-RingBuffer  ser_bf(1536);
+CircularBuffer<char, 1536> ser_bf;
 Thread      tsk;
 
 //  ROM / Constant data --------------------------------------------------------
@@ -175,7 +175,7 @@
 
 void serialRxCallback()
 {
-    ser_bf.save(pc.getc());
+    ser_bf.push(pc.getc());
     rx_isr_busy = true;
     tsk.signal_set(0x01);
 }
@@ -187,7 +187,7 @@
 
     while(true) {
         Thread::signal_wait(0x01);
-        if (ser_bf.check() == 0) {
+        if (ser_bf.empty()) {
             if (linebf_irq_len != 0) {
                 linebf_irq[linebf_irq_len] = 0;
                 adjust_line(linebf_irq);
@@ -195,8 +195,9 @@
                 uartTXCharacteristic.write(NUM_ONCE, linebf_irq);
             }
         }
-        while(ser_bf.check() != 0) {
-            char c = ser_bf.read();
+        while(!ser_bf.empty()) {
+            char c;
+            ser_bf.pop(c);
             if (c == '\b') {
                 linebf_irq_len--;
                 pc.putc(c);