ABP- unable to receive Downlink

Forum de support et échanges autour du Chistera-Pi

ABP- unable to receive Downlink

Message non lude akandasa » Mar 18 Avr 2017 20:08

I've been trying to receive a Downlink packet from lorawan with no success. (It works with ota and transmit hough)
I tweaked the code from github.com/Snootlab/lmic_chisterapi/blob/master/src/OTAA_JoinAndTransmit.c to adapt the ABP method.
I notice that after the transmission, the event is not swtiched to TX_COMPLETE though the Gateway sends a downlink.

Following is the code that I used; kindly let me know if there are any obvious errors;

Code: Tout sélectionner
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <wiringPi.h>
#include <lmic.h>
#include <hal.h>
#include <local_hal.h>


static const u1_t DEVEUI[8]  = { 0xfe, 0xca, 0xef, 0xbe, 0xce, 0xfa, 0xad, 0xde };
static const u1_t APPEUI[8]  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
u1_t nwkskey[16] = {0x3f, 0x73, 0x68, 0xf3, 0x3f, 0xc5, 0x6d, 0x28,  0xaf,  0xa6,  0xbd,  0x32,  0x9a,  0x7d,  0x8d,  0xed};
u1_t appskey[16] = {0xa1, 0x44, 0xeb, 0x6b, 0xd4, 0x29, 0xdb, 0x94,  0x31,  0x74,  0x21,  0x77,  0x61,  0x99,  0x55,  0x30};
static const u1_t DEVKEY[16] = { 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78 };
static u4_t fcntUp = 1;

 * These three functions are accessor for
 * the LMIC library, do not modify.
void os_getArtEui(u1_t * buf) {
  memcpy(buf, APPEUI, 8);

void os_getDevEui(u1_t * buf) {
  memcpy(buf, DEVEUI, 8);

void os_getDevKey(u1_t * buf) {
  memcpy(buf, DEVKEY, 16);

 * Pinout for the LMIC library.
 * This is the pinout of the RFM95 on
 * the ChisteraPi.
lmic_pinmap pins = {
  .nss = 10,
  .rxtx = UNUSED_PIN,
  .rst = 0,
  .dio = {

void onEvent(ev_t ev) {
  switch (ev) {
      // scheduled data sent (optionally data received)
      case EV_TXCOMPLETE:
        if (TXRX_ACK) {
                fprintf(stdout, "TXRX_ACK confirmed UP frame was acked\n");
        fprintf(stdout, "TX complete .....................................%d %d \n", LMIC.dataLen,LMIC.frame[LMIC.dataBeg-1]);
        for (int i = 0;  i <LMIC.dataLen;  i++) {
             fprintf(stdout, "%c", LMIC.frame[LMIC.dataBeg + i]);
        fprintf(stdout, "\n");

// initial job
static void initfunc(osjob_t * j) {
  fprintf(stdout, "init ....\n");
  LMIC_reset(); // reset MAC state
  LMIC_setSession(0x010203, 0x06094620, nwkskey, appskey);
  fprintf(stdout, "NetID = %02x DevAddr = %02x \n", LMIC.netid, LMIC.devaddr);
  LMIC.frame[0] = 0x4a;
  LMIC.seqnoUp = fcntUp +1;
  LMIC_setTxData2(1, LMIC.frame, 1, LORAWAN_CONFIRMED_MSG_ON);

// application entry point
int main() {
  osjob_t initjob;
  // initialize runtime env
  // setup initial job
  os_setCallback(&initjob, initfunc);
  // execute scheduled jobs and events
  return 0;

Messages: 1
Inscription: Mar 18 Avr 2017 19:50

Retourner vers Chistera-Pi

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité