Problem in receiving messages

Hi everyone,
I am using a single channel gateway using Heltec wireless shell and I used a DIY gateway code from github. The node is also using Heltec module and LMIC library.
The problem is my TTN console is displaying only 3rd consecutive data(Frame count: 2,5,8,11…). Can someone tell what is the reason?

Your node is sensing randomly on different frequencies while your single channel gateway only receives on one frequency. A single channel gateway is not LoRaWAN compliant. If you want to receive all messages you have to use a compliant gateway. Normally these gateways use 8 channels.

3 Likes

But I have enabled only one channel in my node

#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

// LoRaWAN NwkSKey, network session key
// This should be in big-endian (aka msb).
static const PROGMEM u1_t NWKSKEY[16] ={ Entered in actual code};

// LoRaWAN AppSKey, application session key
// This should also be in big-endian (aka msb).
static const u1_t PROGMEM APPSKEY[16] = { };

// LoRaWAN end-device address (DevAddr)
// See http://thethingsnetwork.org/wiki/AddressSpace
// The library converts the address to network byte order as needed, so this should be in big-endian (aka msb) too.
static const u4_t DEVADDR = ; // <-- Change this address for every node!

// These callbacks are only used in over-the-air activation, so they are
// left empty here (we cannot leave them out completely unless
// DISABLE_JOIN is set in arduino-lmic/project_config/lmic_project_config.h,
// otherwise the linker will complain).
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }

static uint8_t mydata[]="Transmitting";
int count=0;
static osjob_t sendjob;

// Schedule TX every this many seconds (might become longer due to duty
// cycle limitations).
const unsigned TX_INTERVAL = 10;

// Pin mapping
// Adapted for Feather M0 per p.10 of [feather]
const lmic_pinmap lmic_pins = {
    .nss = 18,                       // chip select on feather (rf95module) CS
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 14,                       // reset pin
    .dio = {26, 35 , 34}, // assumes external jumpers [feather_lora_jumper]
                                    // DIO1 is on JP1-1: is io1 - we connect to GPO6
                                    // DIO1 is on JP5-3: is D2 - we connect to GPO5
};

void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println(F("EV_SCAN_TIMEOUT"));
            break;
        case EV_BEACON_FOUND:
            Serial.println(F("EV_BEACON_FOUND"));
            break;
        case EV_BEACON_MISSED:
            Serial.println(F("EV_BEACON_MISSED"));
            break;
        case EV_BEACON_TRACKED:
            Serial.println(F("EV_BEACON_TRACKED"));
            break;
        case EV_JOINING:
            Serial.println(F("EV_JOINING"));
            break;
        case EV_JOINED:
            Serial.println(F("EV_JOINED"));
            break;
        
        case EV_RFU1:
            Serial.println(F("EV_RFU1"));
            break;
       
        case EV_JOIN_FAILED:
            Serial.println(F("EV_JOIN_FAILED"));
            break;
        case EV_REJOIN_FAILED:
            Serial.println(F("EV_REJOIN_FAILED"));
            break;
        case EV_TXCOMPLETE:
            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
            if (LMIC.txrxFlags & TXRX_ACK)
              Serial.println(F("Received ack"));
            if (LMIC.dataLen) {
              Serial.println(F("Received "));
              Serial.println(LMIC.dataLen);
              Serial.println(F(" bytes of payload"));
            }
            // Schedule next transmission
            os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
            break;
        case EV_LOST_TSYNC:
            Serial.println(F("EV_LOST_TSYNC"));
            break;
        case EV_RESET:
            Serial.println(F("EV_RESET"));
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println(F("EV_RXCOMPLETE"));
            break;
        case EV_LINK_DEAD:
            Serial.println(F("EV_LINK_DEAD"));
            break;
        case EV_LINK_ALIVE:
            Serial.println(F("EV_LINK_ALIVE"));
            break;
        
         case EV_SCAN_FOUND:
            Serial.println(F("EV_SCAN_FOUND"));
           break;
        
        case EV_TXSTART:
            Serial.println(F("EV_TXSTART"));
            break;
        default:
            Serial.print(F("Unknown event: "));
            Serial.println((unsigned) ev);
            break;
    }
}

void do_send(osjob_t* j){
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println(F("OP_TXRXPEND, not sending"));
    } else {
        // Prepare upstream data transmission at the next possible time.
        LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
        Serial.println("count:"+ String(count));
        Serial.println(F("Packet queued"));
    }
    // Next TX is scheduled after TX_COMPLETE event.
    ++count;
}

void setup() {
    while (!Serial); // wait for Serial to be initialized
    Serial.begin(115200);
    delay(100);     // per sample code on RF_95 test
    Serial.println(F("Starting"));
    SPI.begin(5,19,27);

 
    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.
    #ifdef PROGMEM

        uint8_t appskey[sizeof(APPSKEY)];
        uint8_t nwkskey[sizeof(NWKSKEY)];
        memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
        memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
        LMIC_setSession (0x13, DEVADDR, nwkskey, appskey);
        
    #else
        // If not running an AVR with PROGMEM, just use the arrays directly
        LMIC_setSession (0x13, DEVADDR, NWKSKEY, APPSKEY);
    #endif

    #if defined(CFG_in866)
    
         LMIC_enableChannel(2);
     
    #elif defined(CFG_us915)
    
    #endif

        // Disable link check validation
        LMIC_setLinkCheckMode(0);
    
        // TTN uses SF9 for its RX2 window.
        LMIC.dn2Dr = DR_SF9;
    
        // Set data rate and transmit power for uplink
        LMIC_setDrTxpow(DR_SF9,20);
    
        // Start job
        do_send(&sendjob);
}

void loop() {
    
    os_runloop_once();

}

Depending on single gateway code you must force you gateway to only receive on one channel. Some single channel has this . E.G enable channel 0 or you can disable all other channels. Note functions like ADR will not work

1 Like

Also be careful where you operate your single channel packet forwarder, it can interfere with the operation of geniune compliant Gateways and nodes.

1 Like

Almost, but not quite. Your code doesn’t add any additional TTN-specific channels, but then you’ll still have the 3 default channels. These are needed in each network for OTAA joins of LoRaWAN-compliant devices that need to know some basic settings that are generic for all networks.

I don’t see you disable the other two defaults anywhere. The following just enables a channel that is already enabled by default, but you’ll need a few LMIC_disableChannel instead:

That’s also a problem of using a single-channel forwarder rather than a true gateway: nodes that are adjusted for such forwarder will often use one of the default channels, making those default channels being used far more often than the other channels a network might support.

Also, are you sure 20 is allowed in your region?

(For your next post please also see How do I format my forum post? [HowTo] And please add all details in your first post next time. Thanks.)

3 Likes

Thanks sir for your replay. After disabling the other channels ,it is working perfectly. I think 20 is accepted in India, but anyway I am just using this for testing. And next time I will take care of formatting

1 Like