Quantcast
Channel: MultiTech Developer Resources » All Posts
Viewing all articles
Browse latest Browse all 7111

Reply To: libmDot-mbed5 Maximum payload size always 11 bytes

$
0
0

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;
}

Viewing all articles
Browse latest Browse all 7111

Trending Articles