Setting custom AP name

I’m having trouble with customizing the AP name via the host MCU. All my other setup/config is working (ie hub set, sensors, syncing data, etc).

This is my request:

  {
    J *req = notecard.newRequest("card.wifi");
    JAddStringToObject(req, "name", "hellonotecard");
    JAddStringToObject(req, "org", "helloorg");
    JAddBoolToObject(req, "start", true);
    notecard.sendRequest(req);
  }

Which starts the AP with the name “Notecard”

I also tried separately:

  {
    J *req = notecard.newRequest("card.wifi");
    JAddStringToObject(req, "name", "hellonotecard");
    JAddStringToObject(req, "org", "helloorg");
    notecard.sendRequest(req);
  }

which responds:

{"version":"WFM200.0.0.0","name":"hellonotecard","org":"helloorg","security":"open"}

Then i turn on AP mode:

  {
    J *req = notecard.newRequest("card.wifi");
    JAddBoolToObject(req, "start", true);
    notecard.sendRequest(req);
  }

And the name is still “Notecard”

I even tried without the notecard library just in case that was causing the problem but same result.

But the Funny thing is if i set the AP name via USB / notehub browser terminal in one request ie:

{ "req": "card.wifi", "name": "test", "start": true}

It starts the AP with the name “Notecard” still, ignoring my request.

BUT if i send it as two requests:

{ "req": "card.wifi", "name": "test"}
//get response and then i send:
{ "req": "card.wifi", "start": true}

Then it finally saves the name and loads the AP with the name “test”. It keeps the new name regardless of what i do via MCU requests and also keeps it even after device restore {“req”:“card.restore”, “delete”: true}

Card version was 3.5.2.15620 but i thought it might be a fixed bug so i updated to latest and tried again, same issue.

{
 "version": "notecard-4.1.1.4015681",
 "device": "dev:xxxxxxxxxxx",
 "name": "Blues Wireless Notecard",
 "sku": "NOTE-WIFI",
 "board": "2.11",
 "api": 4,
 "body": {
  "org": "Blues Wireless",
  "product": "Notecard",
  "version": "notecard-4.1.1",
  "ver_major": 4,
  "ver_minor": 1,
  "ver_patch": 1,
  "ver_build": 4015681,
  "built": "Dec  5 2022 12:54:58"
 }

I’ve tried everything i can think of, what am i doing wrong or missing here?

Hi @abari,

Is the Wi-Fi Notecard in continuous mode (via your hub.set call)? I may be wrong, but if it is, I don’t think you can update the AP name until you’ve put it into minimum or periodic mode first. That’s the first thing I can think of checking.

Rob

First thing i checked, my hub set (runs before what i posted above)

  notecard.begin(txRxPinsSerial, 9600);
  delay(250);

  #ifdef usbSerial
    notecard.setDebugOutputStream(usbSerial);
  #endif

  J *req = notecard.newRequest("hub.set");
  if (req != NULL) {
    JAddStringToObject(req, "product", myProductID);
    JAddStringToObject(req, "mode", "periodic");
    JAddNumberToObject(req, "outbound", outboundFreq);
    JAddNumberToObject(req, "inbound", inboundFreq);
    JAddBoolToObject(req, "align", true);
    notecard.sendRequest(req);
  }
  delay(250);

then after that i run my reset ap function

void resetWifiAP() {
   //clear saved credentials
  {
    J *req = notecard.newRequest("card.wifi");
    JAddStringToObject(req, "ssid", "-");
    JAddStringToObject(req, "password", "-");
    notecard.sendRequest(req);
  }
  #ifdef usbSerial
    Serial.println("credentials cleared, turning on AP next");
  #endif

  delay(250);
  //  set new wifi name
  {
    J *req = notecard.newRequest("card.wifi");
    JAddStringToObject(req, "name", "hellonotecard");
    JAddStringToObject(req, "org", "helloorg");
    notecard.sendRequest(req);
  }

  delay(250);
  //  enable AP mode - command
  {
    // use command instead of a request because the notecard disconnects us to turn on AP
    J *req = NoteNewCommand("card.wifi");
    JAddBoolToObject(req, "start", true);
    notecard.sendRequest(req);
  }
// enable AP mode - request
//  {
//    J *req = notecard.newRequest("card.wifi");
//    JAddBoolToObject(req, "start", true);
//    notecard.sendRequest(req);
//  }

  #ifdef usbSerial
    Serial.println("Access point was turned on..");
  #endif
}

Ive tried both requests and commands (logic for commands is that it gives errors in my console using request as the notecard disconnects the MCU to start the AP), but both result in the notecard starting with the AP name of “Notecard”.

Hi @abari I was able to repro your problem and the issue is one of timing. {"req":"card.wifi","name":"hellonotecard","org":"helloorg"} doesn’t backup the AP configuration to flash immediately. Depending on what the Notecard is up to it could take a few seconds before the settings are stored to flash. I’ll see if I can get a more accurate timing, but I think the advice would be to set the name and org then wait 5 seconds before issuing start:true - which triggers an immediate reboot.

I’ll make sure this timing issue is fixed in future firmware releases, but for the time being a few seconds delay between the two requests should fix your issue.

{"req":"card.restore","delete":true} does not erase WiFi configuration because it is assumed that resetting other aspects of the Notecard configuration should not erase the SSID, password and AP details. You can use card.wifi to overwrite these values, instead of card.restore.
Thanks
Sean

1 Like

Thanks and glad to know its not just me :joy:!

I had tried a 2s delay for different reasons but that didn’t work. I set it to 6s and now its working perfectly.

Makes sense re the card restore. I was just trying to rule out “I screwed it up” by resetting the card and was surprised credentials/data remained is all.

Appreciate the quick response.