ABP and OTAA nodes doesn't work - OTAA with MIC MISMATCH

Hardware:

Lora Gateway: Raspberry PI + RAK833 SPI SX1301Chip
Lora Node: Arduino nano + HPD13A Sx1276 (RFM95W Compatible) - pin mapping has been taken care off. (DIO0 and DIO1 has been wired)
(memory is OK to work with and not affecting any normal operation of radio, but I am not sure if it affects any AES algorithms, possibly not otherwise the node should keep restarting)

Distance between Gateway and node is nothing but with in the room, which can be seen from the RSSI and SNR.

Software:

Gateway Current: v2.1.0 (GitHub - Lora-net/packet_forwarder: A LoRa packet forwarder is a program running on the host of a LoRa gateway that forwards RF packets receive by the concentrator to a server through a IP/UDP link, and emits RF packets that are sent by the server.)
Gateway (Also tried): v4.0.1 (GitHub - Lora-net/packet_forwarder: A LoRa packet forwarder is a program running on the host of a LoRa gateway that forwards RF packets receive by the concentrator to a server through a IP/UDP link, and emits RF packets that are sent by the server.)

Node Current: MCCI LoRaWAN LMIC Library v4.1.1
Node also tried: Arduino-LMIC library v1.5.1

Region & Frequency:

Current: India (standard 3 frequencies used, others used in accordance with EU like style)
Also tried: EU (recommended with standard frequency set)

LoRaWAN MAC and PHY:

Current: MAC V1.0.3 and PHY V1.0.3 REV A
Also tried: MAC V1.0.2 and PHY V1.0.2 REV B
Also tried: MAC V1.0.4 and PHY V1.0.3 REV A

Activation mode:

Currently OTAA
Tried ABP

Keys and EUI’s:

Gateway: New ID registered with v3
Node: New key, EUI, App EUI (generated from Random EUI or Key generator) (OTAA tried with both ‘allzero’ and generated APP EUI)
NB: Keys has beeen cross checked and LSB/MSB flip has been taken care off.

History:

Gateway: Was registered with v2 with different ID. (2015-16 possibly)
Node: Multiple nodes were registered and working in ABP mode for testing and ranging purpose with the gateway. (GPS mapper and a simple event node)
NB: Gateway and nodes were not used for last two years and when thought of reinstating, found that the network has moved on to v3.

Node Prints:

ABP

8443: EV_TXSTART
RO: 81
8563: TXMODE, freq=865985000, len=26, SF=7, BW=125, CR=4/5, IH=0, CRC=1,
data=b2cb59c5dd98632c5b4fd9ec904f23a74c01000080260bb6e040
Packet queued
139139: EV_TXCOMPLETE (includes waiting for RX windows)

OTAA

7447181: EV_TXSTART
RO: 81
7447312: TXMODE, freq=865402500, len=23, SF=9, BW=125, CR=4/5, IH=0, CRC=1,
data=c10837c291a670b3d57ed004b6fa8e27c9360959569300
7838680: EV_JOIN_TXCOMPLETE: no JoinAccept
9768418: EV_TXSTART
RO: 81
9768548: TXMODE, freq=865062500, len=23, SF=9, BW=125, CR=4/5, IH=0, CRC=1,
data=c214fd1491a770b3d57ed004b6fa8e27c9360959569300
10159917: EV_JOIN_TXCOMPLETE: no JoinAccept
10905409: EV_TXSTART

NB: I have put some extra prints in the library as debugging cannot be enabled with the low memory of arduino nano.

Problem:

ABP device: Successfully sends the data and gateway receives it and is populated in console, but the node in network is not able to get any communication in console.
OTAA device: Successfully sends JOIN data to gateway and shown in console, but at the node end “mic_mismatch” error is shown.

Solutions tried:

ABP: Changed the old library used for old v2 device as it was customized when it was created for GPS mapper, so thought I have broken something required for new v3.
Changed to MCCI LMIC version mentioned above. (Tried with reset frame counters enabled also)
OTAA: Latest version as mentioned was used. (other versions were also tried). Went through a lot of similar threads showing MIC MISMATCH (which occured mostly due to MSB/LSB flip of app key, app key mismatch, or somewhere wrong MAC and PHY selection. All these possibilities were considered.

More problems ahead:

Join receive timing issues, session key reception etc. and finally sending data and decoding the payload.

ABP in Gateway Console:

ABP_Gateway

OTAA in Gateway Console:

Gateway_OTAA

OTAA in node console:

Node_OTAA

**Click to get Gateway OTAA json**
[
  {
    "name": "gs.up.receive",
    "time": "2022-01-18T15:57:58.687804358Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.UplinkMessage",
      "raw_payload": "AJNWWQk2ySeO+rYE0H7Vs3DzxnoR60k=",
      "payload": {
        "m_hdr": {},
        "mic": "ehHrSQ==",
        "join_request_payload": {
          "join_eui": "8E27C93609595693",
          "dev_eui": "70B3D57ED004B6FA",
          "dev_nonce": "C6F3"
        }
      },
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7
          }
        },
        "coding_rate": "4/5",
        "frequency": "865985000",
        "timestamp": 3346786499,
        "time": "2022-01-18T15:57:58.637660Z"
      },
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "openwaytvm",
            "eui": "B827EBFFFEC085CA"
          },
          "time": "2022-01-18T15:57:58.637660Z",
          "timestamp": 3346786499,
          "rssi": -30,
          "channel_rssi": -30,
          "snr": 10.2,
          "location": {
            "latitude": 8.527403715667655,
            "longitude": 76.94841653108598,
            "altitude": 30,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "ChgKFgoKb3BlbndheXR2bRIIuCfr//7AhcoQw9HvuwwaDAiGx5uPBhD1mvDHAiC485Tgs2EqDAiGx5uPBhDg1oewAg==",
          "channel_index": 2
        }
      ],
      "received_at": "2022-01-18T15:57:58.687607157Z",
      "correlation_ids": [
        "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
        "gs:uplink:01FSPYHHGZKC2JGK889VD6E50A"
      ]
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:uplink:01FSPYHHGZKC2JGK889VD6E50A"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_TRAFFIC_READ",
        "RIGHT_GATEWAY_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSPYHHGZQZ6FBGKBFQG4P685"
  },
  {
    "name": "gs.up.receive",
    "time": "2022-01-18T15:57:47.887330638Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.UplinkMessage",
      "raw_payload": "AJNWWQk2ySeO+rYE0H7Vs3DyxliDyeM=",
      "payload": {
        "m_hdr": {},
        "mic": "WIPJ4w==",
        "join_request_payload": {
          "join_eui": "8E27C93609595693",
          "dev_eui": "70B3D57ED004B6FA",
          "dev_nonce": "C6F2"
        }
      },
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7
          }
        },
        "coding_rate": "4/5",
        "frequency": "865402500",
        "timestamp": 3335977067,
        "time": "2022-01-18T15:57:47.831106Z"
      },
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "openwaytvm",
            "eui": "B827EBFFFEC085CA"
          },
          "time": "2022-01-18T15:57:47.831106Z",
          "timestamp": 3335977067,
          "rssi": -28,
          "channel_rssi": -28,
          "snr": 8.5,
          "location": {
            "latitude": 8.527403715667655,
            "longitude": 76.94841653108598,
            "altitude": 30,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "ChgKFgoKb3BlbndheXR2bRIIuCfr//7AhcoQ6/DbtgwaDAj7xpuPBhDttYGnAyD4w+m9i2EqDAj7xpuPBhDQ16aMAw==",
          "channel_index": 1
        }
      ],
      "received_at": "2022-01-18T15:57:47.887118573Z",
      "correlation_ids": [
        "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
        "gs:uplink:01FSPYH6ZF3M4QWE9ZC3D65SY1"
      ]
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:uplink:01FSPYH6ZF3M4QWE9ZC3D65SY1"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_TRAFFIC_READ",
        "RIGHT_GATEWAY_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSPYH6ZF05E8CW3GY1KHGXNB"
  },
  {
    "name": "gs.status.receive",
    "time": "2022-01-18T15:57:44.533465904Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.GatewayStatus",
      "time": "2022-01-18T15:57:44Z",
      "versions": {
        "ttn-lw-gateway-server": "3.17.0-SNAPSHOT-d76af1e33"
      },
      "ip": [
        "49.37.242.78"
      ],
      "metrics": {
        "ackr": 0,
        "rxfw": 1,
        "rxin": 1,
        "rxok": 1,
        "txin": 0,
        "txok": 0
      }
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:status:01FSPYH3PNWWAZ293H37JP7GX8"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_STATUS_READ",
        "RIGHT_GATEWAY_STATUS_READ"
      ]
    },
    "unique_id": "01FSPYH3PN0HB2FEFN3XTVEYNW"
  },
  {
    "name": "gs.up.receive",
    "time": "2022-01-18T15:57:37.445170885Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.UplinkMessage",
      "raw_payload": "AJNWWQk2ySeO+rYE0H7Vs3DxxiqpXPE=",
      "payload": {
        "m_hdr": {},
        "mic": "Kqlc8Q==",
        "join_request_payload": {
          "join_eui": "8E27C93609595693",
          "dev_eui": "70B3D57ED004B6FA",
          "dev_nonce": "C6F1"
        }
      },
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7
          }
        },
        "coding_rate": "4/5",
        "frequency": "865062500",
        "timestamp": 3325534859,
        "time": "2022-01-18T15:57:37.392724Z"
      },
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "openwaytvm",
            "eui": "B827EBFFFEC085CA"
          },
          "time": "2022-01-18T15:57:37.392724Z",
          "timestamp": 3325534859,
          "rssi": -29,
          "channel_rssi": -29,
          "snr": 10.5,
          "location": {
            "latitude": 8.527403715667655,
            "longitude": 76.94841653108598,
            "altitude": 30,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "ChgKFgoKb3BlbndheXR2bRIIuCfr//7AhcoQi8XesQwaDAjxxpuPBhDy+JfUASD43cvK5GAqDAjxxpuPBhCg/KG7AQ=="
        }
      ],
      "received_at": "2022-01-18T15:57:37.444988530Z",
      "correlation_ids": [
        "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
        "gs:uplink:01FSPYGWS5H9MFY37P1TSNEC7R"
      ]
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:uplink:01FSPYGWS5H9MFY37P1TSNEC7R"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_TRAFFIC_READ",
        "RIGHT_GATEWAY_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSPYGWS539FRN5WK6Z55NPD7"
  }
]
**Click to get Gateway ABP json**
[
  {
    "name": "gs.up.receive",
    "time": "2022-01-18T17:44:45.922285154Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.UplinkMessage",
      "raw_payload": "QOC2CyaAAQABsefP6i9P4L6N8fOPpxyHYvY=",
      "payload": {
        "m_hdr": {
          "m_type": "UNCONFIRMED_UP"
        },
        "mic": "HIdi9g==",
        "mac_payload": {
          "f_hdr": {
            "dev_addr": "260BB6E0",
            "f_ctrl": {
              "adr": true
            },
            "f_cnt": 1
          },
          "f_port": 1,
          "frm_payload": "sefP6i9P4L6N8fOPpw=="
        }
      },
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7
          }
        },
        "coding_rate": "4/5",
        "frequency": "865402500",
        "timestamp": 1164066491,
        "time": "2022-01-18T17:44:45.804731Z"
      },
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "openwaytvm",
            "eui": "B827EBFFFEC085CA"
          },
          "time": "2022-01-18T17:44:45.804731Z",
          "timestamp": 1164066491,
          "rssi": -25,
          "channel_rssi": -25,
          "snr": 9.5,
          "location": {
            "latitude": 8.527403715667655,
            "longitude": 76.94841653108598,
            "altitude": 30,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "ChgKFgoKb3BlbndheXR2bRIIuCfr//7AhcoQu/2IqwQaDAiN+ZuPBhCThde3AyD4lJS+8JsCKgwIjfmbjwYQ+PDc/wI=",
          "channel_index": 1
        }
      ],
      "received_at": "2022-01-18T17:44:45.922075795Z",
      "correlation_ids": [
        "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
        "gs:uplink:01FSQ4N2K2Q15DY2RVB1C0K1BK"
      ]
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:uplink:01FSQ4N2K2Q15DY2RVB1C0K1BK"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_TRAFFIC_READ",
        "RIGHT_GATEWAY_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSQ4N2K2Q4DM79S4257SX6JF"
  },
  {
    "name": "gs.status.receive",
    "time": "2022-01-18T17:44:44.852753196Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.GatewayStatus",
      "time": "2022-01-18T17:44:44Z",
      "versions": {
        "ttn-lw-gateway-server": "3.17.0-SNAPSHOT-d76af1e33"
      },
      "ip": [
        "49.37.242.78"
      ],
      "metrics": {
        "ackr": 0,
        "rxfw": 0,
        "rxin": 0,
        "rxok": 0,
        "txin": 0,
        "txok": 0
      }
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:status:01FSQ4N1HMWXJJAEQ62FE5ZDX1"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_STATUS_READ",
        "RIGHT_GATEWAY_STATUS_READ"
      ]
    },
    "unique_id": "01FSQ4N1HMZK6N50AFBYVYY28V"
  },
  {
    "name": "gs.status.receive",
    "time": "2022-01-18T17:44:14.856276877Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.GatewayStatus",
      "time": "2022-01-18T17:44:14Z",
      "versions": {
        "ttn-lw-gateway-server": "3.17.0-SNAPSHOT-d76af1e33"
      },
      "ip": [
        "49.37.242.78"
      ],
      "metrics": {
        "ackr": 0,
        "rxfw": 0,
        "rxin": 3,
        "rxok": 0,
        "txin": 0,
        "txok": 0
      }
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:status:01FSQ4M488W8ZZ3X3WX9802YZF"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_STATUS_READ",
        "RIGHT_GATEWAY_STATUS_READ"
      ]
    },
    "unique_id": "01FSQ4M488BSEZQB3T6W66DBHF"
  },
  {
    "name": "gs.status.receive",
    "time": "2022-01-18T17:43:44.856637164Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.GatewayStatus",
      "time": "2022-01-18T17:43:44Z",
      "versions": {
        "ttn-lw-gateway-server": "3.17.0-SNAPSHOT-d76af1e33"
      },
      "ip": [
        "49.37.242.78"
      ],
      "metrics": {
        "ackr": 0,
        "rxfw": 2,
        "rxin": 2,
        "rxok": 2,
        "txin": 0,
        "txok": 0
      }
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:status:01FSQ4K6YRWW3N8C281V997E8V"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_STATUS_READ",
        "RIGHT_GATEWAY_STATUS_READ"
      ]
    },
    "unique_id": "01FSQ4K6YRCSYZ4SJPY0NY3T8M"
  },
  {
    "name": "gs.up.receive",
    "time": "2022-01-18T17:43:43.815134723Z",
    "identifiers": [
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm"
        }
      },
      {
        "gateway_ids": {
          "gateway_id": "openwaytvm",
          "eui": "B827EBFFFEC085CA"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.UplinkMessage",
      "raw_payload": "QOC2CyaAAAABTKcjT5Ds2U9bLGOY3cVZy7I=",
      "payload": {
        "m_hdr": {
          "m_type": "UNCONFIRMED_UP"
        },
        "mic": "xVnLsg==",
        "mac_payload": {
          "f_hdr": {
            "dev_addr": "260BB6E0",
            "f_ctrl": {
              "adr": true
            }
          },
          "f_port": 1,
          "frm_payload": "TKcjT5Ds2U9bLGOY3Q=="
        }
      },
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7
          }
        },
        "coding_rate": "4/5",
        "frequency": "865985000",
        "timestamp": 1101958651,
        "time": "2022-01-18T17:43:43.699366Z"
      },
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "openwaytvm",
            "eui": "B827EBFFFEC085CA"
          },
          "time": "2022-01-18T17:43:43.699366Z",
          "timestamp": 1101958651,
          "rssi": -27,
          "channel_rssi": -27,
          "snr": 9.5,
          "location": {
            "latitude": 8.527403715667655,
            "longitude": 76.94841653108598,
            "altitude": 30,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "ChgKFgoKb3BlbndheXR2bRIIuCfr//7AhcoQ+5u6jQQaDAjP+JuPBhDv/82EAyD4uOqOiZoCKgwIz/ibjwYQ8PS9zQI=",
          "channel_index": 2
        }
      ],
      "received_at": "2022-01-18T17:43:43.814972911Z",
      "correlation_ids": [
        "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
        "gs:uplink:01FSQ4K5Y781BSDT5VN8WMWVV4"
      ]
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:uplink:01FSQ4K5Y781BSDT5VN8WMWVV4"
    ],
    "origin": "ip-10-100-5-46.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_GATEWAY_TRAFFIC_READ",
        "RIGHT_GATEWAY_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSQ4K5Y7KSDB2K340XNXHPYW"
  }
 ]
**Click to get OTAA node json**
[
  {
    "name": "ns.up.join.cluster.fail",
    "time": "2022-01-18T15:57:58.699377903Z",
    "identifiers": [
      {
        "device_ids": {
          "device_id": "eui-70b3d57ed004b6fa",
          "application_ids": {
            "application_id": "tvmopengatewayapplication"
          }
        }
      },
      {
        "device_ids": {
          "device_id": "eui-70b3d57ed004b6fa",
          "application_ids": {
            "application_id": "tvmopengatewayapplication"
          },
          "dev_eui": "70B3D57ED004B6FA",
          "join_eui": "8E27C93609595693"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/joinserver",
      "name": "mic_mismatch",
      "message_format": "MIC mismatch",
      "correlation_id": "7607fc30ea1148ed841d38deff0fdc75",
      "code": 3
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:up:host:01FSPVBFK5JTM5Q1JWGVFYD30A",
      "gs:uplink:01FSPYHHGZKC2JGK889VD6E50A",
      "ns:uplink:01FSPYHHH131DVDY9J8NRS0X5A",
      "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FSPYHHH1NDX9RE5ADJN0F43X"
    ],
    "origin": "ip-10-100-13-30.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_APPLICATION_TRAFFIC_READ",
        "RIGHT_APPLICATION_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSPYHHHBPY7E8PS1GQWMBFVZ"
  },
  {
    "name": "ns.up.join.cluster.fail",
    "time": "2022-01-18T15:57:47.897261453Z",
    "identifiers": [
      {
        "device_ids": {
          "device_id": "eui-70b3d57ed004b6fa",
          "application_ids": {
            "application_id": "tvmopengatewayapplication"
          }
        }
      },
      {
        "device_ids": {
          "device_id": "eui-70b3d57ed004b6fa",
          "application_ids": {
            "application_id": "tvmopengatewayapplication"
          },
          "dev_eui": "70B3D57ED004B6FA",
          "join_eui": "8E27C93609595693"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/joinserver",
      "name": "mic_mismatch",
      "message_format": "MIC mismatch",
      "correlation_id": "0c2131932d734c2585cabbfbe7a443d8",
      "code": 3
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:up:host:01FSPVBFK5JTM5Q1JWGVFYD30A",
      "gs:uplink:01FSPYH6ZF3M4QWE9ZC3D65SY1",
      "ns:uplink:01FSPYH6ZGM4QQV8S5HP6PW2BP",
      "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FSPYH6ZGRFB3V1S1P5E45DXZ"
    ],
    "origin": "ip-10-100-13-30.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_APPLICATION_TRAFFIC_READ",
        "RIGHT_APPLICATION_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSPYH6ZS42PERBZAJCF4ZC7C"
  },
  {
    "name": "ns.up.join.cluster.fail",
    "time": "2022-01-18T15:57:37.457324812Z",
    "identifiers": [
      {
        "device_ids": {
          "device_id": "eui-70b3d57ed004b6fa",
          "application_ids": {
            "application_id": "tvmopengatewayapplication"
          }
        }
      },
      {
        "device_ids": {
          "device_id": "eui-70b3d57ed004b6fa",
          "application_ids": {
            "application_id": "tvmopengatewayapplication"
          },
          "dev_eui": "70B3D57ED004B6FA",
          "join_eui": "8E27C93609595693"
        }
      }
    ],
    "data": {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/joinserver",
      "name": "mic_mismatch",
      "message_format": "MIC mismatch",
      "correlation_id": "36845dc26e3b4da0ba2948292fc056d2",
      "code": 3
    },
    "correlation_ids": [
      "gs:conn:01FSPVBFJYEPN84Z5JA6JZ5H1M",
      "gs:up:host:01FSPVBFK5JTM5Q1JWGVFYD30A",
      "gs:uplink:01FSPYGWS5H9MFY37P1TSNEC7R",
      "ns:uplink:01FSPYGWS6JG0XTWSXC5HJQBE8",
      "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FSPYGWS65HFT4VFMX4G33K57"
    ],
    "origin": "ip-10-100-15-48.eu-west-1.compute.internal",
    "context": {
      "tenant-id": "CgN0dG4="
    },
    "visibility": {
      "rights": [
        "RIGHT_APPLICATION_TRAFFIC_READ",
        "RIGHT_APPLICATION_TRAFFIC_READ"
      ]
    },
    "unique_id": "01FSPYGWSHPNQS6GX1EDXVYTWZ"
  }
]

ABP Node NW Details:

ABP_Node_networkdetails

OTAA Node NW Details

OTAA_NodeNetworkDetails

I have tried everything possible from my side. I am sure it would be a very small problem as I have used all standard libraries. Unfortunately, I am not able to sort it out. Any help is very much appreciated. I am ok with programming and not an expert, so hopefully would be able to understand the instructions.

I would be able to attend to the instructions between 10:00 AM IST to 12:00 AM midnight IST.

Any details regarding the gateway and node can be provided even the login credentials as the whole system is meant for open source and some future public service related work in my region.

MIC mismatch means that either registration details do not match between the device and the network, or else that being too close to the gateway is causing overload and distortion.

If you’re willing to burn a set of keys (and then replace them) you can check the MIC of raw packets against applicable keys at the online LoRaWAN packet decoder.

Yes I also thought it might be compressing the input of the gateway. So as a hack I removed the SMA antenna at the node side, thereby reducing the RSSI considerably.

The results are same.

Figures for RSSI.

OTAA Gateway Console:

OTAA_LOWRSSI

ABP Gateway Console:

ABP_LOWRSSI

I would like to try the packet decoder. I don’t mind using the keys. The use in OTAA is given below:

67B705AE2F9855FAAA593AB6433C03B1

Array format (LSB First as given in the LMIC array)
0xB1, 0x03, 0x3C, 0x43, 0xB6, 0x3A, 0x59, 0xAA, 0xFA, 0x55, 0x98, 0x2F, 0xAE, 0x05, 0xB7, 0x67

Data is “Hello, world!

Or is it that you wanted me to decode it using the key. I will definitely try, if you could please provide the any available link.

@cslorabox As suggested I used the decoder from the site [https://lorawan-packet-decoder-0ta6puiniaut.runkit.sh/](https://LoRaWAN 1.0.x packet decoder)

Below is the OTAA node arduino print:

1889: EV_JOINING
114258: EV_TXSTART
RO: 81
114382: TXMODE, freq=865985000, len=23, SF=7, BW=125, CR=4/5, IH=0, CRC=1,
data=a4530a55a76470b3d57ed004b6fa8e27c9360959569300
496745: EV_JOIN_TXCOMPLETE: no JoinAccept

Data printed in MSB first format: 009356590936c9278efab604d07ed5b37064a7550a53a4 (from arduino print before sending)

The decoder output:

Assuming base64-encoded packet
AJNWWQk2ySeO+rYE0H7Vs3Bkp1UKU6Q=

Message Type = Join Request
  PHYPayload = 009356590936C9278EFAB604D07ED5B37064A7550A53A4

( PHYPayload = MHDR[1] | MACPayload[..] | MIC[4] )
        MHDR = 00
  MACPayload = 9356590936C9278EFAB604D07ED5B37064A7
         MIC = 550A53A4 (from packet) INVALID (tried MSB 0000-FFFF)
             = 6E32BA2B (expected, assuming 32 bits frame counter with MSB 0000)

( MACPayload = AppEUI[8] | DevEUI[8] | DevNonce[2] )
      AppEUI = 8E27C93609595693
      DevEUI = 70B3D57ED004B6FA
    DevNonce = A764

PHYPayload = 009356590936C9278EFAB604D07ED5B37064A7550A53A4

It matched with the one printed in the Arduino. (but had to be reversed may be i printed it like that in arduino)

Anyway decoder also says MIC mismatch. So any inference from this.

NB: Is it anything to do with any settings in LMIC library regarding the encryption. Did I fail to enable something?

That can damage the node I think.

It means your keys or other registration details do not match.

Since we’re burning up these keys anyway such that they’ll need to be replaced, please show how you put them (literally, the actual keys) in the Arduino sketch, and how you entered them in TTN and the packet decoder

1 Like

Yes you are right as its seeing VSWR above tolerance. But its node so I am ready to take the damage. Till spares run out :sweat_smile:

You are absolutely right. I have been wasting all you guys precious time. So many LSB/MSB problems I read, but i didn’t sort it out. It was a LSB/MSB flip.

I found it by inverting the key in the decoder link and now successfully received the dev address and keys.

But, I have a reason why I did this terrible mistake, may be my wrong understanding forced to it.

Please see the below image of ABP and OTAA node console.

ABP

ABP_Node_networkdetails

OTAA

OTAA_NodeNetworkDetails

The reson why took 67 as MSB is because of the way DEV address is presented in ABP.

In that 0x260BB6E0 format, 26 is supposed to be MSB. So i went with similar usage for all keys.

The reason might be as the keys are in arrays and device address is in a 32 bit value.

Below image shows the reason why I got it wrong.

DEvice_appkey_comparison

Like i thought first one in an array is LSB as shown in image below:

Initialise array

Anyway before closing if anyone would be able to clear this doubt it would have been great. :innocent:

Current entry in Arduino:

static const u1_t PROGMEM APPEUI[8]={ 0x93, 0x56, 0x59, 0x09, 0x36, 0xC9, 0x27, 0x8E };
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}

// This should also be in little endian format, see above.
static const u1_t PROGMEM DEVEUI[8]={ 0xFA, 0xB6, 0x04, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}

// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
static const u1_t PROGMEM APPKEY[16] = { 0xB1, 0x03, 0x3C, 0x43, 0xB6, 0x3A, 0x59, 0xAA, 0xFA, 0x55, 0x98, 0x2F, 0xAE, 0x05, 0xB7, 0x67 };
void os_getDevKey (u1_t* buf) {  memcpy_P(buf, APPKEY, 16);}

Current Keys in console:

APP_Dev_EUI_Key

See, the keys are all displayed in console in MSB format. But, in Arduino I had to enter AppEUI and DevEUI in LSB to match but Appkey in MSB to match. So really consfused. Might be a simple ignorance, but it would have been great if clarified.

1 Like

The thread can be closed.
Sorry to waste your precious time.
The solution was to the small mistake I made.
APPEUI and DEVEUI should be in LITTLE ENDIAN format
APP KEY should be in BIG ENDIAN format
I messed up such simple mistake. Everything clarified.

The solution was from @cslorabox, but I am marking this so that anyone who is looking for the same get it right away.

Thanks to the support @cslorabox @jimg

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.