Here it is ...

Dependencies:   libxDot-mbed5 TSL2561

Fork of Dot-Examples by MultiTech

Committer:
David Gutsch dgutsch@umail.iu.edu
Date:
Mon Jul 30 08:51:08 2018 -0400
Revision:
40:314e6b1c289f
Parent:
39:0d4362063352
refactored for boy scout demo. Gain is being set to high (16x) too.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfiore 0:a151a6350d7f 1 #include "dot_util.h"
Mike Fiore 14:19fae4509473 2 #include "RadioEvent.h"
dgutsch 38:401bd606d2dd 3 #include "TSL2561.h"
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 4
mfiore 0:a151a6350d7f 5
mfiore 0:a151a6350d7f 6 #if ACTIVE_EXAMPLE == OTA_EXAMPLE
mfiore 0:a151a6350d7f 7
mfiore 17:d4f82e16de5f 8 /////////////////////////////////////////////////////////////////////////////
mfiore 17:d4f82e16de5f 9 // -------------------- DOT LIBRARY REQUIRED ------------------------------//
mfiore 17:d4f82e16de5f 10 // * Because these example programs can be used for both mDot and xDot //
mfiore 17:d4f82e16de5f 11 // devices, the LoRa stack is not included. The libmDot library should //
mfiore 17:d4f82e16de5f 12 // be imported if building for mDot devices. The libxDot library //
mfiore 17:d4f82e16de5f 13 // should be imported if building for xDot devices. //
mfiore 17:d4f82e16de5f 14 // * https://developer.mbed.org/teams/MultiTech/code/libmDot-dev-mbed5/ //
mfiore 17:d4f82e16de5f 15 // * https://developer.mbed.org/teams/MultiTech/code/libmDot-mbed5/ //
mfiore 17:d4f82e16de5f 16 // * https://developer.mbed.org/teams/MultiTech/code/libxDot-dev-mbed5/ //
mfiore 17:d4f82e16de5f 17 // * https://developer.mbed.org/teams/MultiTech/code/libxDot-mbed5/ //
mfiore 17:d4f82e16de5f 18 /////////////////////////////////////////////////////////////////////////////
mfiore 17:d4f82e16de5f 19
Mike Fiore 5:97ed5f2f099e 20 /////////////////////////////////////////////////////////////
Mike Fiore 5:97ed5f2f099e 21 // * these options must match the settings on your gateway //
Mike Fiore 5:97ed5f2f099e 22 // * edit their values to match your configuration //
Mike Fiore 5:97ed5f2f099e 23 // * frequency sub band is only relevant for the 915 bands //
Mike Fiore 5:97ed5f2f099e 24 // * either the network name and passphrase can be used or //
Mike Fiore 5:97ed5f2f099e 25 // the network ID (8 bytes) and KEY (16 bytes) //
Mike Fiore 5:97ed5f2f099e 26 /////////////////////////////////////////////////////////////
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 27
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 28 // wifi gateway
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 29 static std::string network_name = "MTCDT-19400691";
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 30 static std::string network_passphrase = "MTCDT-19400691";
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 31
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 32 // cellular gateway
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 33 //static std::string network_name = "iuiot-gw1";
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 34 //static std::string network_passphrase = "pivotiot";
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 35
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 36
Mike Fiore 5:97ed5f2f099e 37 static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
Mike Fiore 5:97ed5f2f099e 38 static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B };
dgutsch 30:0059ae42ff02 39 static uint8_t frequency_sub_band = 1;
dgutsch 30:0059ae42ff02 40 static lora::NetworkType public_network;// = lora::PUBLIC_LORAWAN;
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 41 static uint8_t join_delay = 1;
Mike Fiore 15:364df461110f 42 static uint8_t ack = 0;
Mike Fiore 21:09d05faf0e13 43 static bool adr = true;
mfiore 0:a151a6350d7f 44
mfiore 0:a151a6350d7f 45 // deepsleep consumes slightly less current than sleep
mfiore 0:a151a6350d7f 46 // in sleep mode, IO state is maintained, RAM is retained, and application will resume after waking up
mfiore 0:a151a6350d7f 47 // in deepsleep mode, IOs float, RAM is lost, and application will start from beginning after waking up
mfiore 0:a151a6350d7f 48 // if deep_sleep == true, device will enter deepsleep mode
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 49 static bool deep_sleep = false;
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 50 static const uint16_t HOURLY_SLEEP_INTERVAL = 5; // 1 hour *** changed for demo 1 min
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 51 static const uint16_t DAILY_SLEEP_INTERVAL = 43200; // 12 hours
mfiore 0:a151a6350d7f 52
mfiore 0:a151a6350d7f 53 mDot* dot = NULL;
Mike Fiore 21:09d05faf0e13 54 lora::ChannelPlan* plan = NULL;
mfiore 0:a151a6350d7f 55
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 56 DigitalOut led1(LED1);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 57 Serial pc(PA_9, PA_10);
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 58 TSL2561 lightSensor(PB_9, PB_8);
mfiore 0:a151a6350d7f 59
mfiore 0:a151a6350d7f 60 int main() {
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 61 pc.baud(115200);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 62 pc.printf("main started \r\n");
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 63 // Custom event handler for automatically displaying RX data
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 64 RadioEvent events;
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 65
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 66
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 67 /////////////////////////////
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 68 // visual display
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 69 led1 = 0;
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 70 for(int i = 0; i < 5; i++) {
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 71 led1 = 1;
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 72 wait(1);
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 73 led1 = 0;
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 74 wait(1);
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 75 }
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 76
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 77 // set gain on light sensor
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 78 lightSensor.set_timing_reg(TIMING_GAIN_16);
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 79
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 80
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 81 mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 82
Mike Fiore 21:09d05faf0e13 83 #if CHANNEL_PLAN == CP_US915
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 84 plan = new lora::ChannelPlan_US915();
Mike Fiore 21:09d05faf0e13 85 #elif CHANNEL_PLAN == CP_AU915
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 86 plan = new lora::ChannelPlan_AU915();
Mike Fiore 21:09d05faf0e13 87 #elif CHANNEL_PLAN == CP_EU868
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 88 plan = new lora::ChannelPlan_EU868();
Mike Fiore 21:09d05faf0e13 89 #elif CHANNEL_PLAN == CP_KR920
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 90 plan = new lora::ChannelPlan_KR920();
Mike Fiore 21:09d05faf0e13 91 #elif CHANNEL_PLAN == CP_AS923
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 92 plan = new lora::ChannelPlan_AS923();
Mike Fiore 21:09d05faf0e13 93 #elif CHANNEL_PLAN == CP_AS923_JAPAN
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 94 plan = new lora::ChannelPlan_AS923_Japan();
mfiore 22:d9bc10bbc433 95 #elif CHANNEL_PLAN == CP_IN865
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 96 plan = new lora::ChannelPlan_IN865();
Mike Fiore 21:09d05faf0e13 97 #endif
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 98 assert(plan);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 99
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 100 dot = mDot::getInstance(plan);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 101 assert(dot);
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 102
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 103
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 104 // attach the custom events handler
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 105 dot->setEvents(&events);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 106
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 107 if (!dot->getStandbyFlag()) {
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 108 logInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 109
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 110 // start from a well-known state
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 111 logInfo("defaulting Dot configuration");
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 112 dot->resetConfig();
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 113 dot->resetNetworkSession();
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 114
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 115 // set the data_rate
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 116 dot->setTxDataRate(lora::DR_1);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 117
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 118 // make sure library logging is turned on
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 119 dot->setLogLevel(mts::MTSLog::INFO_LEVEL);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 120
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 121 // update configuration if necessary
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 122 if (dot->getJoinMode() != mDot::OTA) {
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 123 logInfo("changing network join mode to OTA");
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 124 if (dot->setJoinMode(mDot::OTA) != mDot::MDOT_OK) {
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 125 logError("failed to set network join mode to OTA");
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 126 }
mfiore 0:a151a6350d7f 127 }
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 128 // in OTA and AUTO_OTA join modes, the credentials can be passed to the library as a name and passphrase or an ID and KEY
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 129 // only one method or the other should be used!
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 130 // network ID = crc64(network name)
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 131 // network KEY = cmac(network passphrase)
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 132 update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, public_network, ack);
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 133 //update_ota_config_id_key(network_id, network_key, frequency_sub_band, public_network, ack);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 134
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 135 // configure network link checks
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 136 // network link checks are a good alternative to requiring the gateway to ACK every packet and should allow a single gateway to handle more Dots
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 137 // check the link every count packets
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 138 // declare the Dot disconnected after threshold failed link checks
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 139 // for count = 3 and threshold = 5, the Dot will ask for a link check response every 5 packets and will consider the connection lost if it fails to receive 3 responses in a row
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 140 update_network_link_check_config(3, 5);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 141
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 142 // enable or disable Adaptive Data Rate
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 143 dot->setAdr(adr);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 144
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 145 // Configure the join delay
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 146 dot->setJoinDelay(join_delay);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 147
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 148 pc.printf("network information set\r\n");
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 149
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 150 // save changes to configuration
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 151 logInfo("saving configuration");
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 152 if (!dot->saveConfig()) {
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 153 logError("failed to save configuration");
mfiore 0:a151a6350d7f 154 }
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 155
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 156 // display configuration
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 157 display_config();
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 158 } else {
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 159 // restore the saved session if the dot woke from deepsleep mode
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 160 // useful to use with deepsleep because session info is otherwise lost when the dot enters deepsleep
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 161 logInfo("restoring network session from NVM");
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 162 dot->restoreNetworkSession();
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 163 }
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 164
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 165 uint8_t counter = 0;
dgutsch 34:fbdd22159585 166 std::vector<uint8_t> tx_data;
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 167 char buffer[5];
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 168
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 169 while (true) {
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 170
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 171 // join network if not joined
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 172 if (!dot->getNetworkJoinStatus()) {
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 173 pc.printf("joining lora network.\r\n");
David Gutsch dgutsch@umail.iu.edu 32:cc05a2e80969 174 join_network(&pc);
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 175 }
David Gutsch dgutsch@umail.iu.edu 36:5529d26e97e6 176
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 177
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 178 // hourly loop
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 179 while( counter < 12) {
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 180
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 181 uint8_t light_data = get_light_data(&lightSensor, &pc);
David Gutsch dgutsch@umail.iu.edu 36:5529d26e97e6 182 //pc.printf("pseudo-light data: %d\r\n", light_data);
David Gutsch dgutsch@umail.iu.edu 37:4818522075f8 183 pc.printf("\r\nhour: %d\r\n", ++counter);
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 184
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 185
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 186 // clean out char buffer
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 187 strcpy(buffer, "XXXX");
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 188
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 189 // convert to ascii char && push to vector
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 190 ascii_converter(buffer, light_data, &tx_data, &pc);
David Gutsch dgutsch@umail.iu.edu 36:5529d26e97e6 191 pc.printf("char buffer: %s\r\n", buffer);
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 192
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 193 if( counter < 12)
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 194 tx_data.push_back(' ');
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 195
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 196
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 197 // if going into deepsleep mode, save the session so we don't need to join again after waking up
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 198 // not necessary if going into sleep mode since RAM is retained
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 199 if (deep_sleep) {
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 200 logInfo("saving network session to NVM");
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 201 dot->saveNetworkSession();
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 202 }
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 203
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 204 // ONLY ONE of the three functions below should be uncommented depending on the desired wakeup method
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 205 sleep_wake_rtc_only(deep_sleep, HOURLY_SLEEP_INTERVAL, &pc);
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 206 //sleep_wake_interrupt_only(deep_sleep);
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 207 //sleep_wake_rtc_or_interrupt(deep_sleep);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 208 }
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 209
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 210 //print vector data
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 211 pc.printf("vector data:");
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 212
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 213 for(std::vector<uint8_t>::const_iterator iter = tx_data.begin(); iter != tx_data.end(); ++iter) {
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 214 pc.printf(" %c",*iter);
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 215 }
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 216 pc.printf("\r\n");
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 217
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 218 pc.printf("capacity tx_data: %d\r\n", tx_data.capacity());
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 219 pc.printf("sized tx_data: %d\r\n", tx_data.size());
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 220 //actually send the data
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 221 pc.printf("sending data\r\n");
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 222
David Gutsch dgutsch@umail.iu.edu 36:5529d26e97e6 223
David Gutsch dgutsch@umail.iu.edu 36:5529d26e97e6 224 // set the data_rate (from forum)
David Gutsch dgutsch@umail.iu.edu 37:4818522075f8 225 dot->setTxDataRate(lora::DR_1);
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 226 int retVal = send_data(tx_data, &pc);
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 227 //while(retVal == 1)
David Gutsch dgutsch@umail.iu.edu 35:b51d482e9731 228 //retVal = send_data(tx_data, &pc);
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 229
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 230 // erase vector data & reset counter
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 231 tx_data.erase(tx_data.begin(), tx_data.end());
David Gutsch dgutsch@umail.iu.edu 33:79e4c812d91d 232 counter = 0;
David Gutsch dgutsch@umail.iu.edu 36:5529d26e97e6 233 pc.printf("deleted tx_data and reset counter\r\ncap: %d size: %d\r\n", tx_data.capacity(), tx_data.size());
David Gutsch dgutsch@umail.iu.edu 39:0d4362063352 234
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 235 // sleep for the day *** don't want to sleep for 12 hours for the demo
David Gutsch dgutsch@umail.iu.edu 40:314e6b1c289f 236 //sleep_wake_rtc_only(deep_sleep, DAILY_SLEEP_INTERVAL, &pc);
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 237
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 238 }
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 239
David Gutsch dgutsch@umail.iu.edu 31:b990f61b9ee0 240 return 0;
mfiore 0:a151a6350d7f 241 }
mfiore 0:a151a6350d7f 242
mfiore 0:a151a6350d7f 243 #endif