# Setting custom AP name

**URL:** <https://discuss.blues.com/t/setting-custom-ap-name/1212>\
**Category:** Notecard API\
**Created:** [January 28, 2023, 2:29pm UTC](https://discuss.blues.com/t/setting-custom-ap-name/1212 "2023-01-28T14:29:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abari](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@abari](https://discuss.blues.com/u/abari)\
**Post date:** [January 28, 2023, 2:29pm UTC](https://discuss.blues.com/t/setting-custom-ap-name/1212/1 "2023-01-28T14:29:23Z")

</div>

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:

```auto
  {
    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:

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

```

which responds:

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

```

Then i turn on AP mode:

```auto
  {
    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:

```auto
{ "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:

```auto
{ "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.

```auto
{
 "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?

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [January 28, 2023, 2:51pm UTC](https://discuss.blues.com/t/setting-custom-ap-name/1212/2 "2023-01-28T14:51:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abari](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@abari](https://discuss.blues.com/u/abari)\
**Post date:** [January 28, 2023, 3:04pm UTC](https://discuss.blues.com/t/setting-custom-ap-name/1212/3 "2023-01-28T15:04:19Z")

</div>

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

```auto
  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

```auto
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”.

---

<div class="post-metadata">

**Author:** ![seant](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@seant](https://discuss.blues.com/u/seant)\
**Post date:** [January 28, 2023, 6:03pm UTC](https://discuss.blues.com/t/setting-custom-ap-name/1212/4 "2023-01-28T18:03:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abari](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@abari](https://discuss.blues.com/u/abari)\
**Post date:** [January 28, 2023, 8:44pm UTC](https://discuss.blues.com/t/setting-custom-ap-name/1212/5 "2023-01-28T20:44:16Z")

</div>

Thanks and glad to know its not just me 😂!

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.
