![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
Diff: xDotBridge/src/main.cpp
- Revision:
- 25:fea776239709
- Parent:
- 24:fdf87e4b72e5
- Child:
- 26:9411b26a5084
--- a/xDotBridge/src/main.cpp Tue Jan 03 10:49:44 2017 -0700 +++ b/xDotBridge/src/main.cpp Tue Jan 03 16:07:16 2017 -0700 @@ -23,6 +23,7 @@ static uint8_t network_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 }; static uint8_t data_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 }; +DigitalOut led1(LED1); mDot* dot = NULL; Serial pc(USBTX, USBRX); @@ -109,7 +110,9 @@ #endif // Common Configuration - dot->setWakePin(WAKE); + dot->setWakePin(WAKE); // Use the wake pin as sleep interrupt + dot->setClass("C"); // Set class C + dot->setAck(0); // Disable Ack // save changes to configuration logInfo("saving configuration"); @@ -121,26 +124,46 @@ display_config(); uint16_t seqNum=0; + uint32_t cDwnLink; while (true) { + std::vector<uint8_t> data; + led1=0; /////////////////////////// // Transmitter main loop // /////////////////////////// #if BRIDGE_TX - std::vector<uint8_t> tx_data; // join network if not joined if (!dot->getNetworkJoinStatus()) { join_network(); } - tx_data.push_back((seqNum >> 8) & 0xFF); - tx_data.push_back(seqNum & 0xFF); + data.push_back((seqNum >> 8) & 0xFF); + data.push_back(seqNum & 0xFF); logInfo("seqNum: %lu", seqNum); - send_data(tx_data); + send_data(data); seqNum++; + led1=1; + wait(0.5); + led1=0; dot->sleep(0, wakeMode, false); // Go to sleep until wake button #endif + #if BRIDGE_RX + cDwnLink = dot->getDownLinkCounter(); + logInfo("Waiting for new message current DLC: %d", cDwnLink); + while (cDwnLink >= dot->getDownLinkCounter()) { + wait(0.1); + } + led1 = 1; + dot->recv(data); + std::string dataStr(data.begin(), data.end()); + logInfo("Got msg num: %d, payload: %s", seqNum, dataStr.c_str()); + seqNum++; + wait(0.5); + led1=0; + + #endif } return 0;