1

I'm have a concept for an app but I can't find the right information to know if it is possible. So if anyone has experience with this your help would be appreciated.

The idea is to create an app that connects trough BLE with a device that functions like a gateway(OS is linux). The mobile app needs to control the gateway device to make connections(also BLE) with other devices(peripherals). The peripherals have data that is send to the gateway device. The mobile app should be able to read that data and be able to tell the gateway device to send data back. What i could find is that the gateway should connect and disconnect to every device when it wants to send data.

My questions are:
- What is the best practice to create something like this?
- How stable would this be?
- If is make simulated RFCOMM in linux can i have more that 1 connection open?

Thank you for your help.

1 Answers1

0

Your idea is definitely doable but requires a lot of knowledge on BLE, iOS/Android app development, and BlueZ (Bluetooth stack on Linux). My first recommendation is not to use classic Bluetooth at all (RFCOMM) and instead use Bluetooth Low Energy (BLE). The reason is that with classic Bluetooth there are limitations on iOS and a lot fewer resources than what currently exists for BLE.

As for your specific questions:-

What is the best practice to create something like this?

You will need an iOS/Android app that acts as a BLE central (i.e. responsible for scanning and initiating BLE connections). This app should also act as a GATT client (i.e. read data data from remote GATT servers.

You then need to use the BlueZ commands in a shell script or use the BlueZ C API to write and compile a program for your Linux machine/gateway. The Linux gateway should act as both a Central/Peripheral device (i.e. advertise and accept incoming connections as well as scan and make remote connections), and should also act as a GATT Client/Server (i.e. read data from a remote GATT server and also host the read data in a GATT server locally).

The sequence of operation would for the Linux program/script to start scanning for the specific devices on boot up, then connect to them and read their data using GATT operations. Once the data is read it will host the data in a local GATT server. Also on boot up the Linux machine needs to advertise itself for remote connections. The iOS/Android app can then be used to scan for the remote Linux device, connect to it, and read the data from it using GATT commands.

How stable would this be?

This will have good stability without an issue, but it all depends on the number of connections and the amount of data you want to send per transaction. A lot of BLE devices allow at least 8 connections and if your number is within this range then there shouldn't be any issue.

If is make simulated RFCOMM in linux can i have more that 1 connection open?

You can have more than one RFCOMM connection on Linux, but you will find very limited resources on this as BlueZ has not been used extensively for RFCOMM. Moreover I believe iOS apps don't support RFCOMM or there is maybe very limited support so you'll run into issues there.

Some references that may be useful to you:-

I hope this helps.

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
  • 1
    Thank you for the answer. This really helped me to get a better understanding of the possibilities. –  Jan 16 '20 at 10:05
  • One more question. I'll be using BLE but how can I use it because of my understanding BLE can only have 1 connection at the time? –  Jan 23 '20 at 08:02
  • 1
    No, you can have multiple connections at the same time without an issue, unless this is something restricted by the chip/module manufacturer. – Youssif Saeed Jan 23 '20 at 09:26