虽然移植完毕,但是不work。需要细调……

Dependencies:   mbed

Revision:
0:a4d8f5b3c546
diff -r 000000000000 -r a4d8f5b3c546 Protocol.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocol.h	Sat Jun 04 03:16:52 2016 +0000
@@ -0,0 +1,52 @@
+#include "Microduino_Protocol_HardSer.h"
+
+//BLE//////////////////////
+Serial pc(P0_4,P0_0);
+//Serial pc(P0_0, P0_4);
+Protocol bleProtocol(&pc, TYPE_NUM);  //软串口,校验数据类
+
+#define this_node  1  //设置本机ID
+#define other_node 0
+struct send_a { //发送
+    uint32_t node_ms;   //节点运行时间
+};
+struct receive_a { //接收
+    uint32_t ms;
+    uint16_t rf_CH[CHANNEL_NUM];
+};
+
+//Mode//////////////////////
+enum _Mode {
+    NRF,
+    BLE
+};
+
+bool protocolSetup(void)
+{
+    bleProtocol.begin(BLE_SPEED);
+    return BLE;
+}
+
+bool protocolRead(uint16_t *_channel, bool _mode)
+{
+    switch (bleProtocol.parse(_channel, MODE_WHILE)) {
+        case P_NONE:  //DATA NONE
+            break;
+        case P_FINE:  //DATA OK
+            return true;
+            break;
+        case P_ERROR: //DATA ERROR
+#ifdef BLE_SoftSerial
+            mySerial.stopListening();
+            mySerial.listen();
+#endif
+            break;
+        case P_TIMEOUT: //DATA TIMEOUT
+#ifdef BLE_SoftSerial
+            mySerial.stopListening();
+            mySerial.listen();
+#endif
+            break;
+    }
+    return false;
+}