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