Demonstration program for Multitech System MTDOT-EVB an evaluation board for the mDot LoRa module
Dependencies: DOGS102 ISL29011 MMA845x MPL3115A2 NCP5623B libmDot mbed-rtos mbed
Diff: main.cpp
- Revision:
- 7:85445a8cc189
- Parent:
- 4:49d19abdfd04
- Child:
- 9:ed86d5ae29cc
--- a/main.cpp Wed Oct 28 17:56:40 2015 +0000 +++ b/main.cpp Wed Oct 28 17:58:55 2015 +0000 @@ -203,7 +203,7 @@ * mode to PullNone */ mDot09.mode(PullUp); - + mDot09.enable_irq(); /* @@ -230,7 +230,7 @@ evbLCD->endUpdate(); - printf("\r\n setup mdot\r\n"); + printf("\r\n setup mdot\r\n"); // get a mDot handle mdot_radio = mDot::getInstance(); @@ -255,29 +255,29 @@ // Setting up the mDot with network information. -/* - * This call sets up private or public mode on the MTDOT. Set the function to true if - * connecting to a public network - */ - printf("setting Private Network Mode\r\n"); - if ((mdot_ret = mdot_radio->setPublicNetwork(false)) != mDot::MDOT_OK) { - log_error(mdot_radio, "failed to set Public Network Mode", mdot_ret); - } + /* + * This call sets up private or public mode on the MTDOT. Set the function to true if + * connecting to a public network + */ + printf("setting Private Network Mode\r\n"); + if ((mdot_ret = mdot_radio->setPublicNetwork(false)) != mDot::MDOT_OK) { + log_error(mdot_radio, "failed to set Public Network Mode", mdot_ret); + } -/* - * Frequency sub-band is valid for NAM only and for Private networks should be set to a value - * between 1-8 that matches the the LoRa gateway setting. Public networks use sub-band 0 only. - * This function can be commented out for EU networks - */ + /* + * Frequency sub-band is valid for NAM only and for Private networks should be set to a value + * between 1-8 that matches the the LoRa gateway setting. Public networks use sub-band 0 only. + * This function can be commented out for EU networks + */ printf("setting frequency sub band\r\n"); if ((mdot_ret = mdot_radio->setFrequencySubBand(config_frequency_sub_band)) != mDot::MDOT_OK) { log_error(mdot_radio, "failed to set frequency sub band", mdot_ret); } -/* - * setNetworkName is used for private networks. - * Use setNetworkID(AppID) for public networks - */ + /* + * setNetworkName is used for private networks. + * Use setNetworkID(AppID) for public networks + */ // config_app_id.assign(app_id,app_id+7); @@ -287,10 +287,10 @@ log_error(mdot_radio, "failed to set network name", mdot_ret); } -/* - * setNetworkPassphrase is used for private networks - * Use setNetworkKey for public networks - */ + /* + * setNetworkPassphrase is used for private networks + * Use setNetworkKey for public networks + */ // config_app_key.assign(app_key,app_key+15); @@ -304,13 +304,12 @@ printf("joining network\r\n"); while (((mdot_ret = mdot_radio->joinNetwork()) != mDot::MDOT_OK) && (!exit_program)) { log_error(mdot_radio,"failed to join network:", mdot_ret); - if (mdot_radio->getFrequencyBand() == mDot::FB_868){ - mdot_ret = mdot_radio->getNextTxMs(); + if (mdot_radio->getFrequencyBand() == mDot::FB_868) { + mdot_ret = mdot_radio->getNextTxMs(); + } else { + mdot_ret = 0; } - else { - mdot_ret = 0; - } - + printf("delay = %lu\r\n",mdot_ret); osDelay(mdot_ret + 1); } @@ -555,8 +554,8 @@ */ void pb1ISR(void) { - if (!pb1_low) - pb1_low = true; + if (!pb1_low) + pb1_low = true; } /* @@ -570,15 +569,15 @@ while (true) { if (pb1_low && (mDot08 == 0)) - count++; + count++; else { - count = 0; - pb1_low = false; + count = 0; + pb1_low = false; } - - if (count == 5) - exit_program = true; - + + if (count == 5) + exit_program = true; + Thread::wait(5); } } @@ -588,8 +587,8 @@ */ void pb2ISR(void) { - if (!pb2_low) - pb2_low = true; + if (!pb2_low) + pb2_low = true; } /* @@ -605,24 +604,24 @@ while (true) { if (pb2_low && (mDot09 == 0)) - count++; + count++; else { - count = 0; - pb2_low = false; + count = 0; + pb2_low = false; } - - if (count == 5){ + + if (count == 5) { - if (pckt_time >= 5) - pckt_time /= 2; - else pckt_time = 20; + if (pckt_time >= 5) + pckt_time /= 2; + else pckt_time = 20; - thread_3->signal_set(0x10); // signal config_pkt_xmit to send packet - } - + thread_3->signal_set(0x10); // signal config_pkt_xmit to send packet + } + Thread::wait(5); - } - } + } +} /* * Function that print clear text verion of mDot errors