matthijskooijman / arduino-lmic

:warning: This library is deprecated, see the README for alternatives.
705 stars 651 forks source link

LMIC_disableTracking() in setup() locks up Feather M0 RFM95 #86

Open jcwren opened 7 years ago

jcwren commented 7 years ago

Using the demo code in examples/ttn-ota, I modified the setup() as shown below, and enabled debugging in src/lmic/config.h. If I comment out the LMIC_disableTracking() line, the code happily runs. However, when enabled, the Feather is flat locking up somewhere. Once locked up, new code can't be loaded without double-clicking the reset button to get it back to the bootloader.

I had also put some debugging code around the os_runloop_once() call. The number of times it was called depended on how much debugging output there was, leading me to think that it's a time-based event or a change in the RFM95 DIO pins that is causing the problem, not how many times it's called. The LMIC.opmode flags were set to 0x88c across all the calls.

I haven't been able to try this with a live gateway yet, so I'm not sure if the LMIC_disableTracking() call in the EV_JOINED event will hang it the same way or not.

The configuration is using

#define CFG_us915 1
#define CFG_sx1276_radio 1
#define LMIC_DEBUG_LEVEL 2
#define LMIC_PRINTF_TO Serial1

Setup code:

const lmic_pinmap lmic_pins =
{
  .nss = 8,
  .rxtx = LMIC_UNUSED_PIN,
  .rst = 4,
  .dio =
  {  3, // Required
     6, // Required for LoRa (DIO1)
    11  // Required for FSK (DIO2)
  },
};

void setup ()
{
  LMIC_PRINTF_TO.begin (115200);

  os_init ();

  printf ("%lu: Starting (connecting via OTAA)\n", os_getTime ());

  LMIC_reset ();
  LMIC_selectSubBand (0);
  LMIC_setLinkCheckMode (0);
  LMIC_disableTracking (); // Comment me out to demonstrate problem
  LMIC_setAdrMode (0);
  LMIC_setDrTxpow (DR_SF10, 20);

  do_send (&sendjob);
}

Output with LMIC_disableTracking() enabled:

167: RXMODE_RSSI
150: Starting (connecting via OTAA)
373: engineUpdate, opmode=0x0
528: engineUpdate, opmode=0x80c
826: TXMODE, freq=902300000, len=23, SF=10, BW=125, CR=4/5, IH=0
858: Packet queued

Same code with LMIC_disableTracking() commented out:

166: RXMODE_RSSI
127: Starting (connecting via OTAA)
351: engineUpdate, opmode=0x8
506: Packet queued
608: EV_JOINING
695: engineUpdate, opmode=0xc
981: TXMODE, freq=902300000, len=23, SF=7, BW=125, CR=4/5, IH=0
316995: RXMODE_SINGLE, freq=923300000, SF=7, BW=500, CR=4/5, IH=0
380240: RXMODE_SINGLE, freq=923300000, SF=12, BW=500, CR=4/5, IH=0
382443: engineUpdate, opmode=0xc
417663: engineUpdate, opmode=0xc
417959: TXMODE, freq=903000000, len=23, SF=8, BW=500, CR=4/5, IH=0
el8550 commented 6 years ago

Hey,

You need to set up the configure.h file in the LMIC library folder. Uncomment this line as follows:

// Include Class B beacon/ping support?

define LORAWAN_CLASSB 1

Now you should be able to uncomment the disable_tracking function.

-Jack