Here it is ...
Dependencies: libxDot-mbed5 TSL2561
Fork of Dot-Examples by
Diff: examples/src/ota_example.cpp
- Revision:
- 35:b51d482e9731
- Parent:
- 34:fbdd22159585
- Child:
- 36:5529d26e97e6
--- a/examples/src/ota_example.cpp Sun Jul 22 17:25:10 2018 +0000 +++ b/examples/src/ota_example.cpp Tue Jul 24 11:57:49 2018 -0400 @@ -1,5 +1,6 @@ #include "dot_util.h" #include "RadioEvent.h" + #if ACTIVE_EXAMPLE == OTA_EXAMPLE @@ -49,8 +50,7 @@ pc.printf("main started \r\n"); // Custom event handler for automatically displaying RX data RadioEvent events; - - + mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL); @@ -88,7 +88,7 @@ dot->resetNetworkSession(); // set the data_rate - (*dot).setTxDataRate(lora::DR_1); + dot->setTxDataRate(lora::DR_1); // make sure library logging is turned on dot->setLogLevel(mts::MTSLog::INFO_LEVEL); @@ -139,14 +139,9 @@ uint8_t counter = 0; std::vector<uint8_t> tx_data; - - while (true) { + char buffer[5]; - //******** perhaps I'm double decaling and the compiler isn't catching it ********* - // try moving this up with the counter, y a ver como se comporta - // not dealocating just erasing/resizing buffer bc it's stack based??? - //std::vector<uint8_t> tx_data; - + while (true) { // join network if not joined if (!dot->getNetworkJoinStatus()) { @@ -156,11 +151,27 @@ // hourly loop while( counter < 12) { + uint8_t light_data = get_light_data(); - tx_data.push_back(light_data); pc.printf("pseudo-light data: %d\r\n", light_data); pc.printf("hour: %d\r\n", ++counter); - + + + // clean out char buffer + strcpy(buffer, "XXXX"); + // pc.printf("char buffer X: %s\r\n", buffer); + + // convert to ascii char && push to vector + ascii_converter(buffer, light_data, &tx_data, &pc); + pc.printf("char buffer converted: %s\r\n", buffer); + + if( counter < 12) + tx_data.push_back(' '); + + send_data(tx_data, &pc); + pc.printf("size: %d\r\n", tx_data.size()); + pc.printf("capacity: %d\r\n", tx_data.capacity()); + // if going into deepsleep mode, save the session so we don't need to join again after waking up // not necessary if going into sleep mode since RAM is retained if (deep_sleep) { @@ -171,19 +182,27 @@ // ONLY ONE of the three functions below should be uncommented depending on the desired wakeup method //sleep_wake_rtc_only(deep_sleep); //sleep_wake_interrupt_only(deep_sleep); - sleep_wake_rtc_or_interrupt(deep_sleep); + //sleep_wake_rtc_or_interrupt(deep_sleep); } //print vector data pc.printf("vector data:"); + for(std::vector<uint8_t>::const_iterator iter = tx_data.begin(); iter != tx_data.end(); ++iter) { - pc.printf(" %d",*iter); + pc.printf(" %c",*iter); } pc.printf("\r\n"); - pc.printf("size of tx_data: %d\r\n", sizeof(tx_data)); + + pc.printf("capacity tx_data: %d\r\n", tx_data.capacity()); + //tx_data.resize(tx_data.size()); + //tx_data.resize(36); + pc.printf("sized tx_data: %d\r\n", tx_data.size()); //actually send the data pc.printf("sending data\r\n"); - send_data(tx_data, &pc); + + int retVal = send_data(tx_data, &pc); + //while(retVal == 1) + //retVal = send_data(tx_data, &pc); // erase vector data & reset counter tx_data.erase(tx_data.begin(), tx_data.end());