MQTT client on AP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
EyLa_3227556
Level 3
Level 3
10 replies posted 5 replies posted 10 questions asked

Hi,

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:

  1. Where there's WIFI coverage - the device connects as STA and runs MQTT client. This is a straightforward case; and
  2. 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.

0 Likes
1 Solution
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

Hello:

If it can't find any it switches to AP mode itself and waits for a smartphone to make a connection to itself .

I think this process is very normal and easy to have a role switch in the code .

For Mqtt client running on STA mode or AP mode, I think the device normally runs as STA mode to connect with a AP which can ping internet successfully.     I think your smart phone should run as  a Hotspot to make the connection stable.

about relaying the messages (as an MQTT client) to the clout MQTT broker  it sounds reasonable to me.

View solution in original post

1 Reply
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

Hello:

If it can't find any it switches to AP mode itself and waits for a smartphone to make a connection to itself .

I think this process is very normal and easy to have a role switch in the code .

For Mqtt client running on STA mode or AP mode, I think the device normally runs as STA mode to connect with a AP which can ping internet successfully.     I think your smart phone should run as  a Hotspot to make the connection stable.

about relaying the messages (as an MQTT client) to the clout MQTT broker  it sounds reasonable to me.