Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
Diff: src/mDotLoRa/LoRaInit.cpp
- Revision:
- 21:85c69494c0ff
- Parent:
- 20:653923c2f37a
- Child:
- 27:38205cebc3da
--- a/src/mDotLoRa/LoRaInit.cpp Thu Sep 08 15:01:52 2016 +0000
+++ b/src/mDotLoRa/LoRaInit.cpp Thu Sep 08 15:16:31 2016 +0000
@@ -7,66 +7,61 @@
static std::string config_network_pass = "davedesk";
static uint8_t config_frequency_sub_band = 7;
-void mDotRadioInit(mDot **dot)
+void mDotRadioInit(mDot *dot)
{
int32_t ret;
- mDot *my_dot;
-
- // get a mDot handle
- *dot = mDot::getInstance();
- my_dot = *dot;
// print library version information
- logInfo("version: %s", my_dot->getId().c_str());
+ logInfo("version: %s", dot->getId().c_str());
logInfo("Program is: mDot_LoRa_pump_control");
- my_dot->resetConfig();
+ dot->resetConfig();
- my_dot->setLogLevel(mts::MTSLog::INFO_LEVEL);
+ dot->setLogLevel(mts::MTSLog::INFO_LEVEL);
// dot->setLogLevel(mts::MTSLog::TRACE_LEVEL);
logInfo("setting frequency sub band");
- if ((ret = my_dot->setFrequencySubBand(config_frequency_sub_band)) != mDot::MDOT_OK) {
+ if ((ret = dot->setFrequencySubBand(config_frequency_sub_band)) != mDot::MDOT_OK) {
logError("failed to set frequency sub band %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
}
logInfo("setting network name");
- if ((ret = my_dot->setNetworkName(config_network_name)) != mDot::MDOT_OK) {
+ if ((ret = dot->setNetworkName(config_network_name)) != mDot::MDOT_OK) {
logError("failed to set network name %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
}
logInfo("setting network password");
- if ((ret = my_dot->setNetworkPassphrase(config_network_pass)) != mDot::MDOT_OK) {
+ if ((ret = dot->setNetworkPassphrase(config_network_pass)) != mDot::MDOT_OK) {
logError("failed to set network password %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
}
logInfo("setting TX spreading factor");
- if ((ret = my_dot->setTxDataRate(mDot::SF_7)) != mDot::MDOT_OK) {
+ if ((ret = dot->setTxDataRate(mDot::SF_7)) != mDot::MDOT_OK) {
logError("failed to set TX datarate %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
}
logInfo("setting TX Output power");
- if ((ret = my_dot->setTxPower(18)) != mDot::MDOT_OK) {
+ if ((ret = dot->setTxPower(18)) != mDot::MDOT_OK) {
logError("failed to set TX outputpower %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
}
// request receive confirmation of packets from the gateway
logInfo("enabling ACKs");
- if ((ret = my_dot->setAck(1)) != mDot::MDOT_OK) {
+ if ((ret = dot->setAck(1)) != mDot::MDOT_OK) {
logError("failed to enable ACKs %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
}
// save this configuration to the mDot's NVM
logInfo("saving config");
- if (! my_dot->saveConfig()) {
+ if (! dot->saveConfig()) {
logError("failed to save configuration");
}
logInfo("joining network");
- while ((ret = my_dot->joinNetwork()) != mDot::MDOT_OK) {
+ while ((ret = dot->joinNetwork()) != mDot::MDOT_OK) {
logError("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
// in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
- osDelay(std::max((uint32_t)1000, (uint32_t)my_dot->getNextTxMs()));
+ osDelay(std::max((uint32_t)1000, (uint32_t)dot->getNextTxMs()));
}
logInfo("Joined Network");
}
\ No newline at end of file
