Disable listening mode on "fresh" device


#1

I’m building a device which incorporates a P1. We’re gearing up for an early manufacturing run, and I’ve been setting up the programming station.

I’ve primarily been working with our system in the “standard” way – that is, working with a device claimed to my particle account, flashing via WiFi, etc. On the production line, however, we’re flashing an application binary (and attendant system firmware) via JTAG, and doing no claiming etc. at all. Because our system operates in SEMI_AUTOMATIC mode (with SYSTEM_THREAD enabled), our application begins to run behind the scenes. However, since the system has never completed setup (and hence received wifi credentials), it never exits listening mode.

One of the intended use-cases for our product is to be used in “offline” mode – that is, a customer would purchase the device, plug it in to power, and be able to perform a few basic functions (some of which involve receiving feedback through the system LED) without ever connecting it to WiFi or claiming it. Because of this, I’d like the system not to enter listening mode unless the user explicitly tells it to.

I’d read elsewhere that listening mode is permanent until the system has some form of credentials, so I tried manually setting the credentials

if (!WiFi.hasCredentials()) {
    Serial.println("Setting dummy credentials...");

    // The system will never leave listening mode unless it has some form
        // of credentials. Give it what it wants!
        WiFi.setCredentials("notanssid");
}

but this never seems to take (i.e. WiFi.hasCredentials() continues to return false, and WiFi.getCredentials() 0.

I’d be willing to accept solutions which simply make the system appear not to be in listening mode (for instance, by disabling that LED indication under certain circumstances), but my understanding of the LEDStatus API is that even if I “disable” the listening mode indication by configuring it to be black (RGB 0x00000000) I’d still have to boost the priority of other custom indications so they override the normal priority listening mode indication. I’m very unwilling to make indications which are currently of background priority critical all of a sudden.

I’ve read some of the other topics on this subject (most notably Can you turn off WiFi.listen() once it starts? and what is the purpose of WiFi.listening()? [SOLVED]), but all seem somewhat orthogonal to my current issue.


#2

For anyone interested, I came up with a simple solution. Since I don’t need (in fact, can’t use) WiFi when there are no credentials, the easiest thing to do is just to turn it off with WiFi.off().

I’ve still got some finessing to do to my logic (since I definitely need to still allow a manual entry into setup mode), but this seems to solve the fundamental issue I was having.


#3

In order to have getCredentials()/setCredentials() work in non-AUTOMATIC mode, you need to switch the WiFi module on first - have you done that?


#4

I am operating in SEMI_AUTOMATIC mode, and had assumed that the module was on by default (especially since the system is going into listening mode and functioning as an access point.


#5

Ah, I see you said non-AUTOMATIC rather than non-_AUTOMATIC (which was how I read it). I’ll give that a shot and see if it works better