We are about to begin developing a portable WIFi based IoT sensor. Occasionally the sensor wakes up and transfers some data to the cloud.
Two use cases should be covered:
- Where there's WIFI coverage - the device connects as STA and runs MQTT client. This is a straightforward case; and
- If there's no WiFI, the device uses the user's smartphone (Android/iOS) as a gateway to the cloud.
What are my options in case #2?
Is the following feasible/reasonable approach:
- The IoT device wakes up and tries to connect to its 'known' AP
- If it can't find any it switches to AP mode itself and waits for a smartphone to make a connection to itself.
- The IoT device (acting as AP) runs MQTT client while the smartphone runs MQTT broker that in turn relays the messages (as an MQTT client) to the clout MQTT broker.
Can the above work? Can the AP device be also an MQTT client and initiate transfers to smartphone/gateway MQTT?
We thought about another approach of using WiFi Direct to communicate with the smartphone. However, if I understand correctly, WiFI Direct is not supported on the iPhone...
Other ideas are welcomed.
Many thanks in advance for any advice.