6 years, 8 months ago.

how to receive data using mdot.

I just have a problem when I try to use 2 mdots to work in peer-to-peer mode. one of them is transmitter and another one is receiver. However, I found that if I enable ACK, I cannot receive any data in the dot->recv(). If i disable ACK by set-ACK(0), I can receive data using dot->recv(), and I can print them out. Anyone know how to solve this problem? My code is as follows:, just change a little bit from the mdot-examples-peer-to-peer-example. The only difference is with setACK(0), I can receive data using dot-recv(), with setACK(1), the recv_data is empty, and I receive nothing.

The transmitter keeps transmitting data every 1s, and the receiver is always receiving data and then try to print. Main code for transmitter: while (true) { uint16_t light; std::vector<uint8_t> tx_data;

join network if not joined if (!dot->getNetworkJoinStatus()) { join_network(); }

light = lux.read_u16(); tx_data.push_back((light >> 8) & 0xFF); tx_data.push_back(light & 0xFF); logInfo("light: %lu [0x%04X]", light, light); send_data(tx_data);

wait(1); }

Main code for receiver: while (true) { uint16_t light; std::vector<uint8_t> tx_data;

join network if not joined if (!dot->getNetworkJoinStatus()) { join_network(); }

std::vector<uint8_t> recv_data; if ((ret = dot->recv(recv_data)) != mDot::MDOT_OK) { logError("failed to recv %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); sending succeeded, just recv failed } logInfo("received size:%d",recv_data.size()); if (recv_data.size() > 0) { printf("[debug] received %d bytes:", recv_data.size()); for (size_t ix = 0; ix < recv_data.size(); ix++) { printf(" I received %u", recv_data[ix]); }

printf("\r\n"); }

}

Other parts are similar to the peer_to-peer example code. I'm using AU915Mhz channel plan.

Be the first to answer this question.