Reading SenseAir LP8 CO2 sensor over bluetooth low energy
Dependencies: BLE_API mbed nRF51822
Revision 4:320febe026ed, committed 2017-08-21
- Comitter:
- jony1401
- Date:
- Mon Aug 21 08:44:33 2017 +0000
- Parent:
- 3:933dd59ad44d
- Commit message:
- bugfix
Changed in this revision
LP8.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 933dd59ad44d -r 320febe026ed LP8.h --- a/LP8.h Fri Aug 18 18:20:41 2017 +0000 +++ b/LP8.h Mon Aug 21 08:44:33 2017 +0000 @@ -233,6 +233,9 @@ //read response from lp8 void Response( int bytesToRead ){ int Count = 0; + + lp8Wait.start(); /* timeout timer if something goes wrong */ + do { if(Device.readable()) { response[Count] = Device.getc(); @@ -240,7 +243,10 @@ --bytesToRead; } } - while( bytesToRead > 0); + while( (bytesToRead > 0) || (lp8Wait.read() < 0.2 )); + + lp8Wait.stop(); + lp8Wait.reset(); }; //transmit data over serial lines