activation-abp.ino

Arduino MKR WAN 1310 · File : activation-abp.ino · Language : Arduino · Use case : Activer la carte en ABP (adresse fixe, sans join)

ABP skips the join step: the address and session keys are hand-written into the MKR WAN 1310 and the server. Useful on private networks or for quick debugging, but with no key rotation or replay resistance: avoid on public networks.

Hardware

An Arduino MKR WAN 1310 (SAMD21 microcontroller, LoRa modem driven by an onboard ESP32 that also exposes Wi-Fi, LoRa antenna and Wi-Fi antenna). MKR WAN 1310, LoRaWAN server where the device is created in ABP mode with the same keys.

Wiring

No wiring; generate keys randomly on the server, do not leave the example zeros.

How it works

join(ABP,...) simply configures the MAC stack with the static address and keys; the first sendBuffer goes immediately, with no join window.

Running it

Install Arduino SAMD Boards and the MKRWAN 2.x library (MKRWAN1310), select the board, upload. The 1310 is driven through AT commands over its internal ESP32; for LoRa, plan a second LoRa board on the other end.

Variants

Compare first-frame latency OTAA vs ABP on your coverage — that is ABP's argument in emergency scenarios.

activation-abp.ino

// Activation ABP pour la MKR WAN 1310 : pas de jointure OTAA.
// A reserver aux reseaux prives ou a la banque de test.
#include <MKRWiSOLAR.h>

const uint32_t DEV_ADDR = 0x26020102;
const uint8_t NWK_SKEY[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t APP_SKEY[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

LoRaWAN lora;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  lora.setDeviceAddress(DEV_ADDR);
  lora.setNetworkSKey(NWK_SKEY);
  lora.setAppSKey(APP_SKEY);
  lora.setRegion(EU_863_870_R1);
  // ABP : pas d'echange join, on emet directement
  if (lora.join(ABP, MODEL_TYPE_A, 5000, 1) == 0) {
    Serial.println(F("ABP refuse (config?)"));
    while (true);
  }
  Serial.println(F("ABP actif, emission possible"));
  uint8_t t[1] = { 42 };
  lora.sendBuffer(t, 1, 1, 0);
  Serial.println(F("trame de test emise"));
}

void loop() {
  lora.run();
}

← Back to the board