
BLE PLX profile with customized services (raw data).
Dependencies: MtSense06
https://blog.mtmtech.com.tw/2016/06/28/pulse-oximeter-with-mtconnect04/
Revision 2:7a08b9410b96, committed 2017-03-31
- Comitter:
- johnathanlyu
- Date:
- Fri Mar 31 08:05:22 2017 +0000
- Parent:
- 1:0ec0e5694c4a
- Commit message:
- add feature UART show raw data.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0ec0e5694c4a -r 7a08b9410b96 main.cpp --- a/main.cpp Thu Feb 23 09:31:56 2017 +0000 +++ b/main.cpp Fri Mar 31 08:05:22 2017 +0000 @@ -24,6 +24,12 @@ #include "PulseOximeterService.h" #include "M1.h" +/* + * set 0 disable M1 data send to uart + * 1 enable M1 data send to urat + */ +#define M1_UART_RAW_DATA_ENABLE 0 + DigitalOut ledRed(p16, 1); Serial pc(p5, p4); I2C i2c(p3, p2); @@ -89,6 +95,14 @@ } } +void rawCallbackToUART() { + M1::Raw raw; + if(m1.IsSkinIn()) { + m1.GetRaw(&raw); + pc.printf("%d,%d,%d\r\n",raw.red, raw.ir, raw.green); + } +} + void StatusCallback(void) { M1::Status sta; @@ -164,13 +178,18 @@ /* Disable the hardware flow control of Serial, then show the mbed version */ pc.set_flow_control(SerialBase::Disabled); pc.baud(115200); - pc.printf("\n"); - pc.printf("mbed version(%d.%d.%d)\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); - pc.printf("\n"); + pc.printf("\r\n"); + pc.printf("mbed version(%d.%d.%d)\r\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); + pc.printf("\r\n"); /* Config device */ m1.ConfigDevice(); +#if M1_UART_RAW_DATA_ENABLE + /* 35ms getter raw data to uart */ + eventQueue.call_every(35, rawCallbackToUART); + eventQueue.call_every(500, blinkCallback); +#else /* Update each data every N ms */ eventQueue.call_every(1000, plxCallback); eventQueue.call_every(35, rawCallback); @@ -181,6 +200,7 @@ BLE &ble = BLE::Instance(); ble.onEventsToProcess(scheduleBleEventsProcessing); ble.init(bleInitComplete); +#endif eventQueue.dispatch_forever();