Cloud API in Listening mode?

Hi,

Newbie to Particle so apologies if I mix up my terminology.

Our product needs to support a range of connectivity scenarios. The standard model of WiFi (or 3G) -> Particle Cloud -> app is a no-brainer.

However, we also wish to support a direct mode, for when there is no 3G signal available, but would still like the phone app to connect directly to the particle, to monitor and update device state.

From my reading so far, this sounds like Listening (AP) mode, but as I understand it that only supports a simple web interface whose sole purpose is to tell the particle which WiFi network to connect to.

Is my understanding correct, and more generally does anybody have any advice on whether Particle could be suitable in this situation, and broadly the way we would go about achieving it?

Thanks,

John

You can always modify the softAP html code to do what you might require. The demo docs shows that you can use softAP to show a html page that allows wifi scanning.

Let’s try to clarify things a little, since you’re talking both about Wi-Fi and 3G and these behave very differently.

  • to maintain contact with a 3G device (Electron) when the 3G network is down, you will need to be physically connected to the device, via Serial, I2C or some other local peripheral interface. This is because the 3G network is needed for wireless communication.

  • maintaining contact with a Wi-Fi device (Photon) when your external Wi-Fi network is down is possible because the device can host it’s own Access Point. You would communicate with the device directly by adding pages to the SoftAP webserver as @kennethlimcp mentioned above. Your phone could connect to this webserver on the device and send/receive data by requesting special pages that your application creates. These pages would allow the phone to query and set device state once the Phone has connected to the Photon’s Wi-Fi access point.

2 Likes

Thanks Kenneth and MDMA for your replies. You’ve basically confirmed what I thought.

I’d been hoping to avoid writing what is essentially two versions of the device-to-app comms layer - one using the nice Particle API and another home-brew in SoftAP pages mode.

It’s slightly surprising to me that this use case is not readily supported in any of the IoT platforms I’ve looked at. Where I am there are large parts of the countryside not covered by 3G (or even 2G / GPRS), or at even just littered with coverage black spots. Yet, we’d still like to create a headless device that can be managed by a phone or tablet locally if need be.

Cheers,

John

You could look into using the Redbear Duo. It works on the Particle platform, but has BLE as well, offering local comms if needed. Might be interesting :smile:

In the next firmware release, we will open up the AP mode of the photon to allow you to create TCP client/server and UDP sockets on the AP interface.

You can avoid writing your code twice if you abstract your code from the transport layer and just plug in an appropriate transport (Cloud API or SoftAP http pages.)

2 Likes

Thanks MDMA that sounds great. I recognise there are many potential complications in such a mode, not least of which is whether/how to sync locally handled events back to the cloud when either the phone or device get back online.

This is related to the current behaviour of the publish() API call which seems for now to drop any messages sent when offline (https://docs.particle.io/reference/firmware/photon/#particle-publish-)