p kj
/
LPC824-CubeFine
Microduino
Fork of CubeFine by
Embed:
(wiki syntax)
Show/hide line numbers
Protocol.h
00001 #include "Microduino_Protocol_HardSer.h" 00002 00003 //BLE////////////////////// 00004 Serial pc(P0_4,P0_0); 00005 //Serial pc(P0_0, P0_4); 00006 Protocol bleProtocol(&pc, TYPE_NUM); //软串口,校验数据类 00007 00008 #define this_node 1 //设置本机ID 00009 #define other_node 0 00010 struct send_a { //发送 00011 uint32_t node_ms; //节点运行时间 00012 }; 00013 struct receive_a { //接收 00014 uint32_t ms; 00015 uint16_t rf_CH[CHANNEL_NUM]; 00016 }; 00017 00018 //Mode////////////////////// 00019 enum _Mode { 00020 NRF, 00021 BLE 00022 }; 00023 00024 bool protocolSetup(void) 00025 { 00026 bleProtocol.begin(BLE_SPEED); 00027 return BLE; 00028 } 00029 00030 bool protocolRead(uint16_t *_channel, bool _mode) 00031 { 00032 switch (bleProtocol.parse(_channel, MODE_WHILE)) { 00033 case P_NONE: //DATA NONE 00034 break; 00035 case P_FINE: //DATA OK 00036 return true; 00037 break; 00038 case P_ERROR: //DATA ERROR 00039 #ifdef BLE_SoftSerial 00040 mySerial.stopListening(); 00041 mySerial.listen(); 00042 #endif 00043 break; 00044 case P_TIMEOUT: //DATA TIMEOUT 00045 #ifdef BLE_SoftSerial 00046 mySerial.stopListening(); 00047 mySerial.listen(); 00048 #endif 00049 break; 00050 } 00051 return false; 00052 }
Generated on Fri Jul 22 2022 01:51:59 by 1.7.2