libmDot-mbed5 Maximum payload size always 11 bytes

Home Forums mDot/xDot libmDot-mbed5 Maximum payload size always 11 bytes

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #15124
    Huo Chen
    Participant

    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

    #15216
    Mike Fiore
    Blocked

    Huo,

    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

    #15280
    Huo Chen
    Participant

    Here 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
    
    • This reply was modified 7 years, 5 months ago by Huo Chen.
    • This reply was modified 7 years, 5 months ago by Huo Chen.
    #15306
    Mike Fiore
    Blocked

    Huo,

    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

    #15339
    Huo Chen
    Participant

    Here 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;
    }
    
    #15340
    Huo Chen
    Participant

    I 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;
    }
    
    #15341
    Mike Fiore
    Blocked

    Huo,

    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

    #15342
    Mike Fiore
    Blocked

    Huo,

    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.