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:
- 16:7f6599312962
- Child:
- 20:653923c2f37a
diff -r a6ee32969e8e -r 7f6599312962 src/mDotLoRa/LoRaInit.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mDotLoRa/LoRaInit.cpp Wed Sep 07 18:38:35 2016 +0000
@@ -0,0 +1,72 @@
+#include "mbed.h"
+#include "mDot.h"
+#include "MTSLog.h"
+#include "LoRaInit.h"
+
+static std::string config_network_name = "davedesk";
+static std::string config_network_pass = "davedesk";
+static uint8_t config_frequency_sub_band = 7;
+
+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("Programm is: mDot_LoRa_pump_control");
+
+ my_dot->resetConfig();
+
+ my_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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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()) {
+ logError("failed to save configuration");
+ }
+
+ logInfo("joining network");
+ while ((ret = my_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()));
+ }
+ logInfo("Joined Network");
+}
\ No newline at end of file
