I get the Payload 48656C6C6F2C20776F726C6421 in the TTN Console.
If i send Payload to the Arduino in the console i get the Message in the Arduino seriell console:
33303433: 10EV_TXCOMPLETE (includes waiting for RX windows)
Received
5
bytes of payload
But i have no idea how i see the payload of the message, can anyone help me?
void onEvent (ev_t ev) {
Serial.print(os_getTime()); # the Number u see "33303433"
Serial.print(": ");
Serial.print(ev);
switch(ev) {
....
case EV_TXCOMPLETE:
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
if (LMIC.txrxFlags & TXRX_ACK)
Serial.println(F("Received ack"));
if (LMIC.dataLen) {
Serial.println(F("Received "));
Serial.println(LMIC.dataLen); # <-- i think the payload is in LMIC.anything but i dont find it?!
Serial.println(F(" bytes of payload"));
}...
I see only the dataLen but not what payload i send.
If i not send any payload i only see this in de Arduino Seriel Monitor:
…
Packet queued
437839436: 10EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
442028291: 10EV_TXCOMPLETE (includes waiting for RX windows)
…
For future reference, a quick way to print binary content as hexadecimal bytes for debugging:
if (LMIC.dataLen) {
// data received in rx slot after tx
Serial.print(F("Received "));
Serial.print(LMIC.dataLen);
Serial.print(F(" bytes of payload: 0x"));
for (int i = 0; i < LMIC.dataLen; i++) {
if (LMIC.frame[LMIC.dataBeg + i] < 0x10) {
Serial.print(F("0"));
}
Serial.print(LMIC.frame[LMIC.dataBeg + i], HEX);
}
Serial.println();
}
Does anyone of you know how the cpp code has to be written to print out the LMIC.dataLen ? We have a RPi as MCU instead of an Arduino - so no ino file.
Here is the cpp example file provided with the Dragino shield that I actually use but not sure if there is any downlink payload sent up to my node. We are investigating this downlink matter, the same salvatore_forte does in another thread.
void onEvent (ev_t ev) {
//debug_event(ev);
switch(ev) {
// scheduled data sent (optionally data received)
// note: this includes the receive window!
case EV_TXCOMPLETE:
// use this event to keep track of actual transmissions
fprintf(stdout, "Event EV_TXCOMPLETE, time: %d\n", millis() / 1000);
if(LMIC.dataLen) { // data received in rx slot after tx
//debug_buf(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
fprintf(stdout, "Data Received!\n");
}
break;
default:
break;
}
}
Already thanks to anyone for coding this in cpp - we are not familiar with.
if(LMIC.dataLen) { // data received in rx slot after tx
fprintf(stdout, "Received %d bytes of payload: 0x", LMIC.dataLen);
for (int i = 0; i < LMIC.dataLen; i++) {
fprintf(stdout, "%02X", LMIC.frame[LMIC.dataBeg + i]);
}
fprintf(stdout, "\n");
}
That is it Arjan !
I have tested your cpp code and no problem, the lora node now shows in its console that it receives payload_raw in hex.
The proof of my research is then given : the TTN backend sends data back in downlink via our IMST lora concentrator to the lora device. I guess in its first receive window as the delay is not more than 1s.
Now we can start to do some nice things once we know that the device is able to receive downlink data and store it in its register …
Many tnx for your contribution and also the other comments I have been reading from you on other posts. Always nice and valuable to read.
Thanks for this this info, but still I can’t access to what I need.
arjanvanb gave a nice reference to print out downlink message,
but it seems that I can not make use of it (or I’m just not so educated as I should be)
I’m using initial setup Arduino with dragino Shield and OTAA activation sample.
I want to make an if statement for tx payload mydata[] depending on downlink statement. let’s say node received 0x01 in downlink then mydata is “rx works” and if nothing is received than “hello world”
How I can analyze a downlink message and regarding of what bytes node receive it declares some variables?