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

Dependencies:   StrLib myTimer RingBuffer

Dependents:   Theremin

Revision:
2:3a28bc9332b6
Parent:
1:5ed110051e39
Child:
3:2a87c102ddd3
--- a/RN41.h	Thu Oct 22 05:02:36 2015 +0000
+++ b/RN41.h	Wed Oct 28 04:49:41 2015 +0000
@@ -82,6 +82,8 @@
      */
     RN41(PinName TX, PinName RX, int baudrate, int bit=8, int parity=SerialBase::None, int stop=1, bool CRLN=true);
 
+    string read();
+
     /**
      *      RxStrのCRまでを返す。
      */
@@ -106,24 +108,31 @@
 private:
     Serial rn41;
     string cr;
-    string rxStr, str4GetLine;      // 内部バッファ。read()での保管用と、GetLineまでの保管用。
-
+    string rxStr, rxStrStored;      // 内部バッファ。read()での保管用と、GetLineまでの保管用。
+    // 9,600bpsなら、1文字受信に833us必要。安全率1.3として13ループさせるため、待ち時間us/0.1文字とする。
+//    int usWait4readBuf;       // -> attach
 //    Timer timerLocal;
     myTimer timer;
 
     static const int findCmp1, findCmp2, findCmp12;
+
+    struct bool2 {
+        bool b1, b2;
+    };
+
     /** check reply from RN41.
      *  @Param  cmp; string to compare
      *  @Param  timeout; timeout [ms]
      *  @return bool; true: ok, false: NG.
      */
-    int chkReply(string cmp1, int timeout, string cmp2="");
-
-    bool chkReply_woCR(string cmp, int timeout);
+//    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);
 
-    /** Just copy to rxStr from Buffer.
-    *
-    */
-    void read();
+    /** Just copy to rxStr from Buffer. */
+    void _read();
+    void _readIrq();
+};
 
-};
\ No newline at end of file
+// EOF
\ No newline at end of file