![](/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:
- 65:d546060aa03d
- Parent:
- 64:46c8819c07cc
- Child:
- 66:bcaa6dbf538a
--- a/xDotBridge/src/main.cpp Tue Mar 14 11:53:53 2017 -0600 +++ b/xDotBridge/src/main.cpp Wed Mar 15 09:49:58 2017 -0600 @@ -49,8 +49,7 @@ dot = mDot::getInstance(); // make sure library logging is turned on -// dot->setLogLevel(mts::MTSLog::WARNING_LEVEL); - dot->setLogLevel(mts::MTSLog::WARNING_LEVEL); + dot->setLogLevel(mts::MTSLog::INFO_LEVEL); myLogInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION); myLogInfo("libxDot-mbed5 library ID: %s", dot->getId().c_str()); @@ -113,8 +112,6 @@ } LedPatterns ledPatterns(bbio); - uint16_t txSeqNum=0; - uint16_t rxSeqNum=0; Callback<void()> ccInIntObj (&ccInIntCallback); Callback<void()> tamperIntObj (&tamperIntCallback); Callback<void()> pairBtnIntObj (&pairBtnIntCallback); @@ -135,7 +132,7 @@ * Main Loop */ while (true) { - std::vector<uint8_t> data; +// std::vector<uint8_t> data; ledPatterns.turnOff(); // Sample IO and update any configuration @@ -219,13 +216,8 @@ ccIntFlag = false; ledPatterns.turnOn(); - data.clear(); - data.push_back((txSeqNum >> 8) & 0xFF); - data.push_back(txSeqNum & 0xFF); - std::string dataStr(data.begin(), data.end()); - myLogInfo("Sent msg num: %d, payload: %s", txSeqNum, dataStr.c_str()); - protocol->send(data); - txSeqNum++; + protocol->sendAlert(0xBEEF); // TODO use this field to encode the alert type e.g. CCIN vs tamper + myLogInfo("Sent msg num: %d.", protocol->getSeqNum()); ledPatterns.turnOff(); } @@ -247,12 +239,13 @@ protocol->listen(msgPending); myLogInfo("Loop Cnt %d. Listening.", loopCnt); if (msgPending) { - data.clear(); - protocol->recv(data); - std::string dataStr(data.begin(), data.end()); - myLogInfo("Got msg num: %d, payload: %s", rxSeqNum, dataStr.c_str()); + std::vector<uint8_t> txEui; + txEui.reserve(8); + uint16_t data; + uint32_t msgSeqNum; + protocol->recvAlert(txEui, data, msgSeqNum); + myLogInfo("Got msg num: TODO"); bbio->relayAlert(); - rxSeqNum++; ledPatterns.turnOn(); // Hold time for alert // TODO maybe use sleep instead of wait