![](/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:
- 63:e1efbe3402d9
- Parent:
- 62:9751a8504c82
- Child:
- 64:46c8819c07cc
--- a/xDotBridge/src/main.cpp Tue Mar 14 08:32:55 2017 -0600 +++ b/xDotBridge/src/main.cpp Tue Mar 14 09:54:04 2017 -0600 @@ -7,6 +7,7 @@ #include "UserInterface.h" //#include <xdot_low_power.h> #include "mDot.h" +#include "MyLog.h" #include "BaseboardIO.h" #include "CommProtocolPeerBrute.h" @@ -43,27 +44,29 @@ RadioEvent events; // Custom event handler for automatically displaying RX data mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL); + MyLog::setLogLevel(MyLog::INFO_LEVEL); dot = mDot::getInstance(); // make sure library logging is turned on - dot->setLogLevel(mts::MTSLog::INFO_LEVEL); + dot->setLogLevel(mts::MTSLog::WARNING_LEVEL); - logInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION); - logInfo("libxDot-mbed5 library ID: %s", dot->getId().c_str()); + myLogInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION); + myLogInfo("libxDot-mbed5 library ID: %s", dot->getId().c_str()); // attach the custom events handler dot->setEvents(&events); // Little bonus event debug information // Finish radio init - pc.printf("= Protocol Init Starting =\r\n"); + myLogInfo("= Protocol Init Starting =\r\n"); protocol->init(); if (result == cmdSuccess) { - pc.printf("= Protocol Init Finished Successfully =\r\n"); + myLogInfo("= Protocol Init Finished Successfully =\r\n"); } else { - pc.printf("= Protocol Init Finished with Error =\r\n"); + myLogInfo("= Protocol Init Finished with Error =\r\n"); } + protocol->printDotConfig(); // save changes to configuration // logInfo("saving configuration"); @@ -99,13 +102,13 @@ // display configuration // display_config(); - pc.printf("= Baseboard Init Starting =\r\n"); + myLogInfo("= Baseboard Init Starting =\r\n"); result = bbio->init(); if (result == cmdSuccess) { - pc.printf("= Baseboard Init Finished Successfully =\r\n"); + myLogInfo("= Baseboard Init Finished Successfully =\r\n"); } else { - pc.printf("= Baseboard Init Finished with Error =\r\n"); + myLogInfo("= Baseboard Init Finished with Error =\r\n"); } uint16_t txSeqNum=0; @@ -155,15 +158,16 @@ protocol->sampleDLC(); protocol->configForPairingNetwork(); protocol->sendPairReq(); - logInfo("Sent pair request. Waiting %f secs for accept.", TX_ACCEPT_WAIT_TIME); + myLogInfo("Sent pair request. Waiting %f secs for accept.", TX_ACCEPT_WAIT_TIME); result = protocol->waitForAccept(TX_ACCEPT_WAIT_TIME); if (result == cmdSuccess) { - logInfo("Got accept"); + myLogInfo("Got accept"); } else { - logInfo("Did not receive accept"); + myLogInfo("Did not receive accept"); } protocol->configForSavedNetwork(); + protocol->printDotConfig(); } } if (protocol->isRx()) { @@ -171,31 +175,32 @@ protocol->sampleDLC(); protocol->configForPairingNetwork(); bbio->ledOn(); - logInfo("Waiting for pair request for %f seconds", RX_PAIR_WAIT_TIME); + myLogInfo("Waiting for pair request for %f seconds", RX_PAIR_WAIT_TIME); result = protocol->waitForPairing(RX_PAIR_WAIT_TIME); bbio->ledOff(); if (result == cmdSuccess) { - logInfo("Got pair request and responded"); + myLogInfo("Got pair request and responded"); } else if (result == cmdTimeout) { - logInfo("Did not receive request"); + myLogInfo("Did not receive request"); } else { - logInfo("Unknown pair error"); + myLogInfo("Unknown pair error"); } protocol->configForSavedNetwork(); + protocol->printDotConfig(); } else if (pairBtnState == pairBtnLongPress) { - logInfo("Clearing pair values and generating new ones."); + myLogInfo("Clearing pair values and generating new ones."); protocol->clearPair(); - // Maybe add Nvm save commands here + protocol->printDotConfig(); } } } // Alert code if (protocol->isTx()) { - logInfo("Loop #%d. CCFlag %d, CCAlertState %d, TamperFlag %d, PairBtnFlag %d", + myLogInfo("Loop #%d. CCFlag %d, CCAlertState %d, TamperFlag %d, PairBtnFlag %d", loopCnt, ccIntFlag, bbio->isCCInAlert(), tamperIntFlag, pairBtnIntFlag); // TODO add tamper if (ccIntFlag || // If contact closure in @@ -210,7 +215,7 @@ data.push_back((txSeqNum >> 8) & 0xFF); data.push_back(txSeqNum & 0xFF); std::string dataStr(data.begin(), data.end()); - logInfo("Sent msg num: %d, payload: %s", txSeqNum, dataStr.c_str()); + myLogInfo("Sent msg num: %d, payload: %s", txSeqNum, dataStr.c_str()); protocol->send(data); txSeqNum++; wait(0.5); // Leave the LED on so a person can see it. @@ -232,12 +237,12 @@ if (protocol->isRx()) { bool msgPending; protocol->listen(msgPending); - logInfo("Loop Cnt %d. Listening.", loopCnt); + myLogInfo("Loop Cnt %d. Listening.", loopCnt); if (msgPending) { data.clear(); protocol->recv(data); std::string dataStr(data.begin(), data.end()); - logInfo("Got msg num: %d, payload: %s", rxSeqNum, dataStr.c_str()); + myLogInfo("Got msg num: %d, payload: %s", rxSeqNum, dataStr.c_str()); bbio->relayAlert(); rxSeqNum++; #if LED_FEEDBACK @@ -245,20 +250,19 @@ #endif // Hold time for alert // TODO maybe use sleep instead of wait - logInfo("Holding alert for %f secs", HoldTimeSetting::rotVal2Sec(bbio->rotarySwitch1())); + myLogInfo("Holding alert for %f secs", HoldTimeSetting::rotVal2Sec(bbio->rotarySwitch1())); wait(HoldTimeSetting::rotVal2Sec(bbio->rotarySwitch1())); bbio->ledOff(); bbio->relayNormal(); } - logInfo("Sleeping. Time %d", us_ticker_read()); + myLogInfo("Sleeping. Time %d", us_ticker_read()); protocol->sampleDLC(); bbio->prepareSleep(); dot->sleep(2, mDot::RTC_ALARM_OR_INTERRUPT, false); // Go to sleep until wake button bbio->exitSleep(); } - logInfo("\r\n================================"); -// wait(1.0); // May want to remove + myLogInfo("\r\n================================"); loopCnt++; }