Receiving data
Tagged: mDot
- This topic has 11 replies, 4 voices, and was last updated 8 years, 9 months ago by Howard Bray.
-
AuthorPosts
-
January 4, 2016 at 4:11 pm #10756Anthony HuyParticipant
How do I received data from the Conduit to the mDot. I’m using the mDotLib from mbed. I send data and then call “recv”. On the conduit side, I’m add data to the MQTT server, which i think works as I’m able to subscribe to that “up” channel and see it added. However, on the mDot side, when i call “recv” i get back an error of -5, MDOT TIMEOUT.
Do you have any sample code for this? Again, I’m NOT using the AT command but the mbed library. Thanks
January 4, 2016 at 4:49 pm #10758Mike FioreBlockedAnthony,
Take a look at this page on the developer site:It has examples of sending and receiving packets to and from the mDot and an example node.js application.
Cheers,
MikeJanuary 7, 2016 at 5:10 pm #10945Howard BrayParticipantI’m also having trouble at the mDot end using the mBed library. The linked page (above) is great from the conduit PoV but it’s the mDot end I can’t receive. Tx is OK. I cannot find any examples of code that use the library, only examples using the AT terminal.
PS I’ve just come across: https://developer.mbed.org/teams/MultiTech/code/mDot_LoRa_Connect_Example/
Very helpful, just hard to find.
January 8, 2016 at 8:25 am #10961Mike FioreBlockedHoward,
All of our mDot library examples are linked to from our mDot platform page on mbed:https://developer.mbed.org/platforms/MTS-mDot-F411/
Cheers,
MikeJanuary 10, 2016 at 5:40 pm #11001Howard BrayParticipantHi Mike
Yep, the Connect example explains a lot and I’m now finding my Conduit, setting parameters, connecting to network and sending stuff. The Node-RED is an excellent testing tool.
Is there an example of receiving strings on the mDot? I’m having lots of trouble as it seems that there are timing factors that I’m not aware of.The in on https://developer.mbed.org/questions/61950/Receive-data/ is helpful, but a 5 line example might clear up everyone’s misunderstanding.
I’m getting back an MDOT_OK but length is 0.
There’s some important factor that I’m missing here …
many thanks again.
- This reply was modified 8 years, 9 months ago by Howard Bray.
- This reply was modified 8 years, 9 months ago by Howard Bray.
- This reply was modified 8 years, 9 months ago by Howard Bray.
- This reply was modified 8 years, 9 months ago by Howard Bray.
- This reply was modified 8 years, 9 months ago by Howard Bray.
January 11, 2016 at 7:26 am #11009Jason ReissKeymasterHoward,
Did you send a packet to the Conduit?
The mDot will only be able to receive a packet after a successful send.
January 11, 2016 at 3:45 pm #11030Howard BrayParticipantHi Jason
Sure did. I have a small test program that sends a ‘*’ to the conduit every 10 seconds and checks the receiver after a 500mS delay (not a blocking wait). If I do nothing, I see the ‘*’ at the conduit (love the Node-RED!) and my loop reports No Packet Received. If I send something from the Conduit, my loop reports that the receiver got something after the next send, but the length is zero.
thanks
-H
January 11, 2016 at 5:23 pm #11031Jason ReissKeymasterThe packets sent down to mDot are during two receive windows at 1 and 2 seconds after end of transmission.
January 11, 2016 at 5:45 pm #11032Howard BrayParticipantHi Jason
Just prior to your response, I saw the mention of the receive windows. Probably as you were writing your post, I was changing my test to wait 5 secs before asking the receiver. Same result – the receiver says something has come in, but length is zero.
—————
else
{
pc.printf(“successfully sent data to gateway\n”);
}data_str.clear();
osDelay(5000);if ((ret = dot->recv(data)) != mDot::MDOT_OK)
{
pc.printf(“failed to get – %ld: %s, %s\n”, ret, mDot::getReturnCodeString(ret).c_str(), dot->getLastError().c_str());
}
else
{
pc.printf(“revc says something from gateway\n”);
if (data_str.length() > 0)
{
for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
{
data.push_back((char) *it); // return it from binary to character
}pc.printf(“successfully got data from gateway : %s (%d)\n”, data_str.c_str(),data_str.length());
}
}January 11, 2016 at 7:11 pm #11033Jason ReissKeymasterWhen is data_str being filled?
I don’t believe data_str.length() will ever be > 0.Shouldn’t you check ‘data.length()’ and iterate over ‘data’ calling push_back on ‘data_str’?
January 11, 2016 at 7:26 pm #11034Howard BrayParticipantI think we’re zeroing in on the problem. My understanding is that the data_str is filled by the receiver as it’s referenced by the vector ‘data’ passed to recv(). Basically the same as the send but in reverse.
If I could find an example of the mechanics of this, it would be a great help.
January 11, 2016 at 7:44 pm #11035Howard BrayParticipantI have just found https://developer.mbed.org/users/mfiore/code/mDot_test_rx/
I found it as a link on Mike Fiore’s page. So much useful information, if only it compiled. There’s a problem with no overloaded function bin2hexString matching the call.I’m puzzled as to why it’s so hard to find a working example of receiving data on an mDot. I know I’m not the only one asking, but no one has an answer.
- This reply was modified 8 years, 9 months ago by Howard Bray.
- This reply was modified 8 years, 9 months ago by Howard Bray.
-
AuthorPosts
- You must be logged in to reply to this topic.