Challenger RP2040 LTE Arduino startup example

Here’s a short example on how to use the support class in your application. This example will start the modem, check the MNO profile and correct it if it doesn’t match your default setting and finally set the Power Save mode according to your choice.

/*
Simple test program to test access to the LTE modem on the Challenger RP2040 LTE board
*/
#include "ChallengerLTE.h"

#define TERM Serial
#define SYSTEM_MNO_PROF 100
#define DEFAULT_PS_ENABLED 0

char buf[4096];

// the setup function runs once when you press reset or power the board
void setup() {
  TERM.begin(115200); // Terminal
  while (!TERM)
  delay(10);
  TERM.println("Challenger RP2040 LTE test program !");
  TERM.println("Waiting for modem to start..");

  // Power on modem
  if (!Challenger2040LTE.doPowerOn()) {
    TERM.println("Failed to start the modem properly !");
    while(1);
  } else {
    TERM.println("Modem started !");
    delay(1000);

    // Read current modem MNO profile
    int mnoprof = Challenger2040LTE.getMNOProfile();
    if (mnoprof < 0) {
      TERM.println("Failed setting reading the MNO profile !");
      while(1);
    }
    // if current modem MNO profile differs from system default change it
    if (mnoprof != SYSTEM_MNO_PROF) {
      TERM.println("Current modem MNO profile differs from system default !");
      if(Challenger2040LTE.setMNOProfile(100)) {
        TERM.println("Suceeded setting new MNO profile !");
      } else {
        TERM.println("Failed setting new MNO profile !");
      }
    }
  }
}