I have a device that connects using Bluetooth Low Energy (BLE). I want it to communicate with a server over the internet using a smartphone as a gateway.
I have thought of different approaches and I would appreciate any objective input.
Approach 1
Write a smartphone app that processes data between the internet and Bluetooth. Data coming from the server would get sent over Bluetooth Low Energy to the device. Data coming from the device would be sent over to the server.
Since the smartphone is a gateway, it does not know where to send that data to over IP because the device may want to communicate with one of many servers. So the device would need to specify the address and other information along with the payload when sending it.
On the other hand, the server would have to somehow specify the device outside of the message payload. So the IP communication terminates at the smartphone. There can be more than one device connected to the smartphone. So this adds some overhead. We also have to take into account the speed of the transport medium, so some sort of buffer would have to be used.
Approach 2
Implement a simplified form of TCP/IP protocol over Bluetooth on the device. I am considering the MQTT protocol. In this case, I assume the device would have its own IP address so the server can directly address it. With this approach, the protocol is all TCP/IP end to end, but the transport medium is the same as before. Of course, this will significantly increase the code in the device.
I would appreciate input on which is the better design approach based on best practice and design trade-offs.