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
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!
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.
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.
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?
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.