Adafruit feather m0 with TTN

Not only did I tell you how to format the code using the </> on the toolbar but I also provided a link earlier on how to format posts. I strongly suggest you read that before you post anything else.

The initialisation of the keys is a mess - I’ll pick through it later

Okay sir thank you so much.

I’m a bit concerned about this:

Does this mean that the example code is setup to work with a single channel gateway in TTN?

Wow, that’s a co-incidence, I was literally looking at that line myself!

I think we need to ask that at the start of a new post, forum members give full information about their device hardware, software, gateway and region. It will save a lot of guesswork.

Yeah, I have some templates for data collection as the teeth-pulling has gone way past ‘getting old’ - plus some etiquette rules, like, if you don’t answer my questions to help solve your problem, please don’t expect me to respond!

I’m a relative newbie, so I’ve had to learn. Newbie to TTN that is, realtime assembler programmer (off and on) since 1980 :slight_smile:

Sir, I tried example code ttn-abp and the node sends ‘‘Hello World!’’ successfully. However, it can’t send with this code. I am pretty sure the only problem is with the devaddr.

If you use ABP, setup the device in the TTN V2 console. Take the device settings for ABP from there and use those in the device code. It should work first time.

Sir, could you please let me know how to change the version of ttn console? Is the below screenshot v2 or v3 console?

image

That looks like the V2 console. You are OK to stay in V2 for the next few weeks. At some point V2 will become read only. It will still work but you will not be able to add new gateways or nodes.

@Junaid_Qadir, some questions & observations:

Where is this library from: #include <SRSPacket.h> - this is important as there is no way to know what the size of the payload is without knowing what this code does.

This breaches the TTN Fair Use Policy and may be illegal as well: const unsigned TX_INTERVAL = 60;

Line 299 starting for (size_t i = 0; i < UniqueIDsize; i++) { NWKSKEY[i] = UniqueID[I]; is overwriting the NwksKey with some number - which means the entry at the top on line 34 is wrong / irrelevant. I strongly suggest you use a proper key copied from the console.

Line 307: memcpy((void *)&DEVADDR, (void *)0x0080A048, sizeof(DEVADDR)); // word #3 Serial Number see 9.3.3 Serial Number Samd21 datasheet - again, overwriting the perfectly good DevAddr key at the top of the file, thereby breaking it all.

Lines 362-366 seem to be some what random.

Line 373:

  // We'll only enable Channel 16 (905.5Mhz) since we're transmitting on a single-channel
  LMIC_enableChannel(16);

If this is trying to only use one channel, that’s not compliant at all, you have an 8 channel gateway, let it use all the channels.

This if (((long)(millis() - millis2Acquire)) >= 0) { will not take account for the millis rolling over. As both values are unsigned longs, why cast the answer to long?

Sure thank you so much. Would it be changed automatically to v3 or may I change it now?

I’m pretty sure most of the code needs starting again.

Nah, there’s code in there that trashes the DevAddr and the NwksKey …

No, and it won’t help as your code is the problem so you’ll just have it not working in two places.

It will not change automatically to V3. Please read the forum for more information.

I think @Descartes has some valid concerns about the code you are using. Was it written to be used with TTN? Or is it intended for a private LoRaWan implementation? A lot of the setup is very different from the usual code for TTN.

It’s a borked version of LMiC - hard to tell if it’s Classic or MCCI or which release.

Dear Sir, the SRSPacket.h library is included in the separate folder of this code.

image

Last time, it was tested on resiot lorawan (ResIOT Login - ResIOT LoRaWAN Network Server and IoT Platform) platform and it was working fine with this code. But the only problem is with the ttn.

image

There was some very similar code back in 2019 OTAA Join with Adafruit feather M0 LoraWan.

Where on the internet do I find this code please.