RN41/42 control lib. RN41/42 is bluetooth module with class 1 or 2.

Dependencies:   StrLib myTimer RingBuffer

Dependents:   Theremin

Revision:
3:2a87c102ddd3
Parent:
2:3a28bc9332b6
Child:
5:63925964cbd5
--- a/RN41.h	Wed Oct 28 04:49:41 2015 +0000
+++ b/RN41.h	Mon Nov 02 07:39:14 2015 +0000
@@ -49,14 +49,12 @@
  @endcode
 */
 
-
 #pragma once
 
 #include "mbed.h"
 #include "StrLib.h"
 #include "myTimer.h"
-
-
+#include "RingBuffer.h"
 
 /**     Bluetooth module RN41/42 control class.
  *
@@ -106,9 +104,11 @@
     bool disconnect();
 
 private:
-    Serial rn41;
+    RawSerial rn41;
     string cr;
     string rxStr, rxStrStored;      // 内部バッファ。read()での保管用と、GetLineまでの保管用。
+    RingBuffer ringBuf;             // rxIRQ用の循環バッファ256kB。
+//    string rxStrStored;      // 内部バッファ。read()での保管用と、GetLineまでの保管用。
     // 9,600bpsなら、1文字受信に833us必要。安全率1.3として13ループさせるため、待ち時間us/0.1文字とする。
 //    int usWait4readBuf;       // -> attach
 //    Timer timerLocal;
@@ -119,6 +119,10 @@
     struct bool2 {
         bool b1, b2;
     };
+    struct b2i2 {
+        bool b1, b2;
+        int i1, i2;
+    };
 
     /** check reply from RN41.
      *  @Param  cmp; string to compare
@@ -128,7 +132,10 @@
 //    int chkReply(string cmp1, int timeout, string cmp2="");
 //    bool chkReply_woCR(string cmp, int timeout);
     bool2 chkReply(string cmp1, int timeout, string cmp2= "", bool wCR= true);
-    bool2 chkReply_line(string trg, string cmp1, string cmp2);
+    bool2 chkReply_process_wCR( string cmp1, string cmp2);
+    bool2 chkReply_process_woCR(string cmp1, string cmp2, bool wCR);
+    b2i2 chkReply_find(string trg, string cmp1, string cmp2);
+
 
     /** Just copy to rxStr from Buffer. */
     void _read();