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
src/mDotLoRa/LoRaInit.cpp
- Committer:
- davidjhoward
- Date:
- 2016-09-08
- Revision:
- 21:85c69494c0ff
- Parent:
- 20:653923c2f37a
- Child:
- 27:38205cebc3da
File content as of revision 21:85c69494c0ff:
#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;
// print library version information
logInfo("version: %s", dot->getId().c_str());
logInfo("Program is: mDot_LoRa_pump_control");
dot->resetConfig();
dot->setLogLevel(mts::MTSLog::INFO_LEVEL);
// dot->setLogLevel(mts::MTSLog::TRACE_LEVEL);
logInfo("setting frequency sub band");
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 = 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 = 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 = 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 = 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 = 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 (! dot->saveConfig()) {
logError("failed to save configuration");
}
logInfo("joining network");
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)dot->getNextTxMs()));
}
logInfo("Joined Network");
}
