🛠 Canal sécurisé : OTAA, MIC et élément ATECC508

Arduino MKR WAN 1300 · avance · Schéma : IMG-mkr-wan-1300-avance-1-mkrwan-lien-securise.svg — lien sécurisé OTAA/AES avec élément ATECC508 en évidence

Objectives

There is no TLS on this board (no Wi-Fi, hence no WiFiSSLClient). The equivalent "secure channel" is LoRaWAN security: OTAA join with key derivation, MIC integrity (AES-128) on each frame, and key protection within the MKR ecosystem (embedded ATECC508 element). This tutorial covers key best practices and link verification.

Hardware

Complete code

#include <MKRWAN.h>

LoRaModem modem;

// En production : NE JAMAIS laisser les cles en clair dans le depot.
// Les stocker hors du code (zone config, element securise) et les regenerer.
String appEui = "0080000000000001";
String appKey = "GENEREE_PAR_TON_SERVEUR_32_HEX";

void setup {
  Serial.begin(115200);
  if (!modem.begin(EU868)) while (1) {}
  // OTAA (mode 1) : derive NwkSKey/AppKey par session, prefere a ABP (mode 0)
  if (!modem.joinOTAA(appEui, appKey)) {
    Serial.println("Join refuse : verifier AppEUI/AppKey et couverture");
    while (1) {}
  }
  modem.minPollInterval(60);
  modem.linkAdaptiveDataRate(true);  // ADR : monte la DR quand le lien est bon
}

void loop {
  modem.beginPacket;
  modem.print("secure");
  // uplink confirmee = ACK signe MIC : preuve de reception integre
  bool ok = modem.endPacket(true) > 0;
  Serial.print(ok ? "MIC OK " : "MIC ECHEC ");
  Serial.print("rssi="); Serial.print(modem.readRSSI);
  Serial.print(" snr="); Serial.println(modem.readSNR);
  delay(120000);
}

Expected verification

The OTAA join creates a fresh session (session keys never travel in clear text); confirmed uplinks receive an ACK whose MIC validates integrity. On the server side, the session changes after each rejoin.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials