SoftAP tweaking to use digital IO pins

Hi everyone. I’ve been looking into the SoftAP code the last days wondering if it could be tweaked to do more than just the AP connection setup.
My actual question is, can I access the digital IOs of the ARM core from the broadcom side by adding new JSONCommand classes handling that sort of requests and how would I do that?

Thanks for any help in advance.

@elTo, the intent is to open SoftAP to the user code so it can be used for more. At present, SoftAP is activated in listen mode. The goal is to have it available in non-listening mode as well. I’m not sure when this feature is schedule to be deployed.

@peekay123

Is the intention that the WiFi access point is available in non-listening mode, or that the web server page handler is available in non-listening mode, or even both? Either would be interesting :slight_smile:

@elTo

I’ve had the SoftAP serving me my customised web pages and I have also been able to switch D7 on and off, flash the on-board RGB LED, rebooted it, displayed free memory in a web page, etc, from code actioned by specific URLs so presume you can do quite a lot more while in that mode. My code is a heavily-modified version of the Particle example.

What I did was enable the SYSTEM thread and then set a flag (int loopaction) from within the SoftAP web server page handler based on the URL requested. The flag is checked within loop(). Don’t do anything in the page handler that takes any significant time because it blocks the HTTP response, hence why I used a flag. My loop() contains a long switch statement. Extract below:

    switch (loopaction)
    {
...

        case 5:
            digitalWrite(d7led, HIGH);
            break;

        case 6:
            digitalWrite(d7led, LOW);
            break;

        case 10:
            RGB.control(true);
            for (int i=0; i< 5; i++) {
                RGB.color(255, 255, 255);
                Serial.printlnf("FLASH !!");
                delay(150);
                RGB.color(0, 0, 0);
                delay(150);
            }
            RGB.control(false);
            break;
...
    }

    loopaction = -1;

I used firmware 0.5.0.

Both!

3 Likes

thanks timx, that’s kind what I’m looking for. at least a start.
could you expand your code snippet? where did you put that? inside softap.cpp? Did you made a new JSONCommand class?

@peekay123, what I like to see is the possibility to create a standalone connectable device with a web interface. One could imagine that it works like the sign in pages of hotspot solution that pop up just after connecting. on the web page then you could interact with whatever that device is capable.
My actual project is to modify a coffee machine so you could connect to it by WiFi and by a press on the appropriate button on the web page it starts making coffee or cappuccino.

@timx SYSTEM thread is enabled in my application with this?

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

Where do I define the loopaction variable?

Never mind, I figured it out. Will provide explanation and code snippets tomorrow…