Big ESP32 / SX127x topic part 1

I will go back and try ABP. I have applied the patch you linked, to my local library, but I still get no further than EV_JOINING. I added the following to radio.c

// called by hal to check if we got one IRQ
u1_t radio_has_irq (void) {
    u1_t flags ;
    if( (readReg(RegOpMode) & OPMODE_LORA) != 0) { // LORA modem
        flags = readReg(LORARegIrqFlags);
        if( flags & ( IRQ_LORA_TXDONE_MASK | IRQ_LORA_RXDONE_MASK | IRQ_LORA_RXTOUT_MASK ) ) 
            return 1;
    } else { // FSK modem
        flags = readReg(FSKRegIrqFlags2);
        if ( flags & ( IRQ_FSK2_PACKETSENT_MASK | IRQ_FSK2_PAYLOADREADY_MASK) ) 
            return 1;
        flags = readReg(FSKRegIrqFlags1);
        if ( flags & IRQ_FSK1_TIMEOUT_MASK ) 
            return 1;
    }
    return 0;
}

added declaration in oslmic.h

u1_t radio_has_irq (void);

changed this routine in hal.c

static void hal_io_check() {
    uint8_t i;
    for (i = 0; i < NUM_DIO; ++i) {
        if (lmic_pins.dio[i] == LMIC_UNUSED_PIN)
        {
            // Check IRQ flags in radio module
            if ( radio_has_irq() ) 
                radio_irq_handler(0);

            // We've soft checked IRQ reading Radio register no need to continue
            // Setting this will exit us from for loop
            i = NUM_DIO;
        } else {
            if (dio_states[i] != digitalRead(lmic_pins.dio[i])) {
                dio_states[i] = !dio_states[i];
                if (dio_states[i])
                    radio_irq_handler(i);
            }
        }
    }
}

and commented out these two lines in hal_io_init

//ASSERT(lmic_pins.dio[0] != LMIC_UNUSED_PIN);
//ASSERT(lmic_pins.dio[1] != LMIC_UNUSED_PIN || lmic_pins.dio[2] != LMIC_UNUSED_PIN);

This all made sense tom me :slight_smile:

1 Like