things4u / LoRa-LMIC-1.51

Port of LMIC-1.5 library tp Atmega 328 and ESP6822, including alternative AES encription library
81 stars 42 forks source link

Is there a way to check if the module is connected to a gateway #13

Open pierrot10 opened 7 years ago

pierrot10 commented 7 years ago

Hello,

I am using that library since a short time. I configured a gateway at home. Now I ledt my place but I still in the range of my gateway,but I suggest I am to far. But I am closer to another gateway.

I run my node. Here is the print:

-- Send Job --

Time: 60 Send, txCnhl: 2 Opmode check: EV_TXCOMPLETE, time: 67 Sent: 1 Time: 7s

That menas that my data has been sent but I saw nothing in my console. It work when I am in my flat.

Also, at startup, there is those function:

// LMIC init
  sprintln(F("os_init"),2);
  os_init();
  // Reset the MAC state. Session and pending data transfers will be discarded.
  LMIC_reset();
  // Set static session parameters. Instead of dynamically establishing a session
  // by joining the network, precomputed session parameters are be provided.;
  LMIC_setSession (0x1, DevAddr, (uint8_t*)NwkSkey, (uint8_t*)AppSkey);
  // Disable data rate adaptation
  LMIC_setAdrMode(0);
  // Disable link check validation
  LMIC_setLinkCheckMode(0);
  // Disable beacon tracking
 // LMIC_disableTracking ();
  // Stop listening for downstream data (periodical reception)
 // LMIC_stopPingable();
  // Set data rate and transmit power (note: txpow seems to be ignored by the library)
  sprintln(F("Set data rate and transmit power"),2);
  LMIC_setDrTxpow(DR_SF7,14);

And I am particuéarely thinking about LMIC_setSession (0x1, DevAddr, (uint8_t*)NwkSkey, (uint8_t*)AppSkey);

IS there a wayto make sure that my module is connected to a gateway and can transmit data? Why This is printed

Opmode check: EV_TXCOMPLETE, time: 67

Where nothing is sent/recorded to my TTN console

Many thank for your help and suggestion

pierrot10 commented 7 years ago

Morever, I am actually into a building and I thnk my node can not get a gateway. So there is no reason to have dislpayed TXCOMPLETE :o)

platenspeler commented 7 years ago

Hi,

Let clarify a little. First of all: Nodes are not connected to a gateway. Nodes send their messages and ANY gateway can pick these up. So their communication is different from for example WiFI tcpi/ip connections.

Therefore it will tell that messages have been sent even if noone would listen.

There are at least two ways to know that a gateway has received your message. First of all you can look at the gateway to see if it receives messages. My single channel gateway would log the messages in an easy format. Then you can register the nide with for example TTN and see the messages come in. Or your application can subscribe to MQTT and you see all incoming messages of that node. Lastly you can send your messages in confirmed way. Ig your nide istens to these confimations it will detect that message has received by some gateway and it has sent an ACK.

So your node-gateway communication is more complex yet allows for plenty of ways to monitor the communication.

MAARTEN

pierrot10 commented 7 years ago

Dear Platenspeler,

Thank fror yourr reply. I have understannd exctely all of your writing. I would like my node to know if it message has been reveive or not. As the node can not "see" at the gateway, you first proposition is not what I am looking for. However, you wrote

Lastly you can send your messages in confirmed way. Ig your nide istens to these confimations it will detect that message has received by some gateway and it has sent an ACK.

What is "confirmed way"? How can I make it listing a confirmation?

In that code

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
      Serial.print("EV_TXCOMPLETE, time: ");
      dataSent = true;
      Serial.println(millis() / 1000);

Serial.print(F("DEBUG 2 "));
Serial.println(LMIC.dataLen);
      if(LMIC.dataLen) { // data received in rx slot after tx   
      //   debug_buf(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
        Serial.println("Data Received");
      }
      break;
     default:
      dataSent = false;
      break;
  }
}

this part

 if(LMIC.dataLen) { // data received in rx slot after tx   
      //   debug_buf(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
        Serial.println("Data Received");
      }

when a message is sent to the gateway, it never print "Data received" even if I see a record in my gateway. Data received, does it mean that the data has been received by the gateway? How can I debug LMIC.datalen.

It important for my to have an ACK confirmation in order to have an alarm when a message when not received by the gateway.

Many thank for you suggestion and help Have a nice day

pierrot10 commented 7 years ago

Dear Platenspeler, By the way, can I ask you about (config.h)

define LORAWAN_CLASSB=1

What does bacon/ping support

gpiscopo commented 5 years ago

Dear pierrot10, Did you find a solution to have an ACK confirmation?

Thanks a lot in advance