Example #1
0
// initial job
static void initfunc (osjob_t* j) {

    LMIC_reset();	// reset MAC state

   LMIC_setSession(0x12345678, 0xB710566C, nwkKey, artKey);

   //LMIC_startJoining();	// start joining
   // init done - onEvent() callback will be invoked...

/*void LMIC_setSession (u4_t netid, devaddr_t(u4_t) devaddr, xref2u1_t nwkKey, xref2u1_t artKey) {
LMIC.netid = netid;
LMIC.devaddr = devaddr;
if( nwkKey != (xref2u1_t)0 )
os_copyMem(LMIC.nwkKey, nwkKey, 16);
if( artKey != (xref2u1_t)0 )
os_copyMem(LMIC.artKey, artKey, 16);*/

debug_str("\r\nSending");
// immediately prepare next transmission
LMIC.frame[0] = LMIC.snr;
// schedule transmission (port 1, datalen 1, no ack requested)
LMIC_setTxData2(1, LMIC.frame, 1, 0);
// (will be sent as soon as duty cycle permits)

LMIC_sendAlive();
}
Example #2
0
// initial job
static void initfunc (osjob_t* j) {
    // reset MAC state
    LMIC_reset();
    // start joining
    LMIC_setSession(0x12345678, 0xB710566C, nwkKey, artKey);
    // enable tracking mode, start scanning...
    LMIC_enableTracking(0);
    debug_str("SCANNING...\r\n");

    //LMIC_startJoining();
    // init done - onEvent() callback will be invoked...
}
void setup() {
//  Serial.begin(9600);
  //Serial.println("Starting");
  printf("Starting, will wait 1 second\n");
  //SPI.begin();
  //delay(3000); //Give teensy USB some time
  while (millis() < 1000);
  //Serial.println("setting up");
  printf("setting up\n");
  fprintf(stderr, "stderr test\n");
  // LMIC init
  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*)DEVKEY, (uint8_t*)ARTKEY);
  // 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)
  LMIC_setDrTxpow(DR_SF7,14);
  //
//  Serial.flush();
    fflush(stdout);
  #ifdef SINGLE_CHANNEL_GATEWAY
  //Serial.println("Disabling all channels but 0 (902.3 MHz) for single-channel gateway compatibility");
  printf("Disabling all channels but 0 (902.3 MHz) for single-channel gateway compatibility\n");
  for (int i=1; i<75; i++)
   LMIC_disableChannel(i);
  #endif
}