Huo Chen
Forum Replies Created
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
Huo Chen
ParticipantI also tried to use the code from previous version, but it still didn’t work
int main() { int32_t ret; std::vector<uint8_t> data; std::string data_str = "hello world!"; pc.baud(115200); mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL); dot = mDot::getInstance(); 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_10)) != mDot::MDOT_OK) { logError("failed to set TX datarate %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); } logInfo("enabling ACKs"); if ((ret = dot->setAck(1)) != mDot::MDOT_OK) { logError("failed to enable ACKs %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); } logInfo("setting join mode to AUTO_OTA"); if ((ret = dot->setJoinMode(mDot::AUTO_OTA)) != mDot::MDOT_OK) { logError("failed to set join mode %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); } logInfo("saving config"); if (! dot->saveConfig()) { logError("failed to save configuration"); } for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++) data.push_back((uint8_t) *it); if (!dot->getNetworkJoinStatus()) { logInfo("network not joined, joining network"); if ((ret = dot->joinNetwork()) != mDot::MDOT_OK) { logError("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); } } if (dot->getNetworkJoinStatus()) { if ((ret = dot->send(data)) != mDot::MDOT_OK) { logError("failed to send %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); } else { logInfo("successfully sent data to gateway"); } } wait_ms(2000); return 0; }
Huo Chen
ParticipantHere is what get_fake_data() is:
std::vector<uint8_t> get_fake_data(void) { std::string fake_data="Hello World!"; std::vector<uint8_t> data_send; for (std::string::iterator it=fake_data.begin(); it!=fake_data.end(); it++) { data_send.push_back(*it); } return data_send; }
Huo Chen
ParticipantHere is my code:
mDot* dot = NULL; Serial pc(USBTX, USBRX); int main() { RadioEvent events; pc.baud(115200); mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL); dot = mDot::getInstance(); dot->setEvents(&events); if (!dot->getStandbyFlag()) { logInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION); dot->resetConfig(); dot->resetNetworkSession(); dot->setLogLevel(mts::MTSLog::INFO_LEVEL); if (dot->getJoinMode() != mDot::AUTO_OTA) { logInfo("changing network join mode to AUTO_OTA"); if (dot->setJoinMode(mDot::AUTO_OTA) != mDot::MDOT_OK) { logError("failed to set network join mode to AUTO_OTA"); } } update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, public_network, ack); update_network_link_check_config(3, 5); dot->setTxDataRate(mDot::DR1); logInfo("saving configuration"); if (!dot->saveConfig()) { logError("failed to save configuration"); } display_config(); if (!dot->getNetworkJoinStatus()) { join_network(); } send_data(get_fake_data()); } }
And when display_config() printing out the information. Tx data rate is set correctly.
[INFO] TX datarate -------------- DR1
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)