libmDot-mbed5 Maximum payload size always 11 bytes
Tagged: libmDot-mbed5
- This topic has 7 replies, 2 voices, and was last updated 8 years ago by Mike Fiore.
-
AuthorPosts
-
October 24, 2016 at 4:52 pm #15124Huo ChenParticipant
Hi,
I tried to move my previous application to libmDot-mbed5. I first set the setTxDataRate to SF_9 (or other spreading factor which allow more payload size than 11 bytes). Then I use update_ota_config_name_phrase() in dot-util.h to connect my mdot to gateway. The problem is, no matter what data rate I choose, I always get the messge: Data exceeds datarate max payload. Is this a bug or am I doing something wrong?
PS: The data I want to send is “Hello World!” which has 12 bytes.
Best
November 1, 2016 at 11:18 am #15216Mike FioreBlockedHuo,
You can see from the source of update_ota_config_name_phrase() in dot_util.cpp that that function does not change the tx datarate. However, all the examples in Dot-Examples do default the configuration during initialization – if you are adding code to set the tx datarate before that default happens, that could explain the issue. Can you post your complete source code?
Cheers,
Mike
November 3, 2016 at 2:33 am #15280Huo ChenParticipantHere 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
November 3, 2016 at 1:08 pm #15306Mike FioreBlockedHuo,
Can you post the contents of your get_fake_data() function?
Also, all of your functionality is within the if (!dot->getStandbyFlag()) block. That may not be what you intended.
Cheers,
Mike
November 4, 2016 at 12:00 am #15339Huo ChenParticipantHere 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; }
November 4, 2016 at 12:09 am #15340Huo ChenParticipantI 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; }
November 4, 2016 at 9:43 am #15341Mike FioreBlockedHuo,
I have verified this issue. We will get this fixed in the next release. A simple workaround is to set the TX datarate after the join is successful.
The following block of code can be used to change the data rate after joining.
if (dot->getTxDataRate() != mDot::DR1) { logInfo("changing TX datarate to DR1"); if (dot->setTxDataRate(mDot::DR1) != mDot::MDOT_OK) { logError("failed to set TX datarate to DR1"); } }
I apologize for the trouble this has caused you. We will get it fixed in the next mDot release.
Cheers,
Mike
November 4, 2016 at 11:29 am #15342Mike FioreBlockedHuo,
The latest version of libmDot-dev-mbed5 will also have this fix if you’d prefer to use that until the next libmDot-mbed5 release instead of implementing the workaround.
https://developer.mbed.org/teams/MultiTech/code/libmDot-dev-mbed5/
Cheers,
Mike
-
AuthorPosts
- You must be logged in to reply to this topic.