![](/media/cache/profiles/2dd26bee3d25f4e22c3db125e415203a.jpg.50x50_q85.jpg)
This program connects to the The Things Network backend in OTAA Mode. It logs sensor values from a BME 280 to the backend. Tried adding support for Grove GPS using SerialGPS library but it is not working - conflicting with mbed-rtos, so it commented. Deep Sleep for mDot implemented BUT avoiding reprogramming of the mDot config is NOT working.
Dependencies: BME280 SerialGPS libmDot mbed-rtos mbed
Diff: main.cpp
- Revision:
- 3:5c2bcba214b5
- Parent:
- 2:866a72c3c3bf
- Child:
- 4:97f9ad3f2566
--- a/main.cpp Mon Jul 04 22:29:31 2016 +0000 +++ b/main.cpp Mon Jul 04 22:42:27 2016 +0000 @@ -47,6 +47,7 @@ void readandprintBME280(); void mDotConfig(); void mDotGotoDeepSleep(int seconds); +void mDotConfigPrint(); @@ -58,6 +59,8 @@ // Simple Test Functions, "Hello World on UDK setUpLEDBlink(); mDotConfig(); + mDotConfigPrint(); + wait(15); endLessTestLoop(); return 0; @@ -87,6 +90,66 @@ } +void mDotConfigPrint() { + + // Display what is set + printf("\r\n"); + printf(" ********** mDot Configuration ************ \n"); + std::vector<uint8_t> tmp = dot->getNetworkSessionKey(); + printf("Network Session Key: "); + printf("%s\n", mts::Text::bin2hexString(tmp, " ").c_str()); + + tmp = dot->getDataSessionKey(); + printf("Data Session Key: "); + printf("%s\n", mts::Text::bin2hexString(tmp, " ").c_str()); + + // App EUI + tmp = dot->getNetworkId(); + printf("App EUI: "); + printf("%s\n", mts::Text::bin2hexString(tmp, " ").c_str()); + + // App Key + tmp = dot->getNetworkKey(); + printf("App Key: "); + printf("%s\n", mts::Text::bin2hexString(tmp, " ").c_str()); + + + printf("Device ID "); + std::vector<uint8_t> deviceId; + deviceId = dot->getDeviceId(); + for (std::vector<uint8_t>::iterator it = deviceId.begin() ; it != deviceId.end(); ++it) + printf("%2.2x",*it ); + printf("\n"); + + std::vector<uint8_t> netAddress; + + printf("Network Address "); + netAddress = dot->getNetworkAddress(); + for (std::vector<uint8_t>::iterator it = netAddress.begin() ; it != netAddress.end(); ++it) + printf("%2.2x",*it ); + + printf("\n"); + + // Display LoRa parameters + // Display label and values in different colours, show pretty values not numeric values where applicable + printf("Public Network: %s\n", (char*)(dot->getPublicNetwork() ? "Yes" : "No") ); + printf("Frequency: %s\n", (char*)mDot::FrequencyBandStr(dot->getFrequencyBand()).c_str() ); + printf("Sub Band: %s\n", (char*)mDot::FrequencySubBandStr(dot->getFrequencySubBand()).c_str() ); + printf("Join Mode: %s\n", (char*)mDot::JoinModeStr(dot->getJoinMode()).c_str() ); + printf("Join Retries: %d\n", dot->getJoinRetries() ); + printf("Join Byte Order: %s\n", (char*)(dot->getJoinByteOrder() == 0 ? "LSB" : "MSB") ); + printf("Link Check Count: %d\n", dot->getLinkCheckCount() ); + printf("Link Check Thold: %d\n", dot->getLinkCheckThreshold() ); + printf("Tx Data Rate: %s\n", (char*)mDot::DataRateStr(dot->getTxDataRate()).c_str() ); + printf("Tx Power: %d\n", dot->getTxPower() ); + printf("TxWait: %s, ", (dot->getTxWait() ? "Y" : "N" )); + printf("CRC: %s, ", (dot->getCrc() ? "Y" : "N") ); + printf("Ack: %s\n", (dot->getAck() ? "Y" : "N") ); + + + +} + /*****************************************************