0

I have looked on numerous topics on android BLE stack in various website. From what i gathered, the bluetooth stack in android is unreliable and not suitable for any fast and concurrent connection.

I am currently assigned to a project that uses BLE as their main business idea. The idea is to setup BLE devices on the top of each door to advertise to the phones using ibeacon frame (to support both iOS and Android). Whereas the android app will read the advertisement and connect to it via GATT and do a characteristic write. The biggest problem is that the project requires a fast write for each beacon it pass by (within 6s to connect and write characteristic) .

This means that scanning and writing must be done frequently for each door it pass by. I know for a fact that android 7 and above have a max of 5start/stop scan for each 30second. Therefore my logic uses a interval of 3second scan and then followed by a 3second write for each beacon it discovered. EG. During the 3s scan period, the app found 3 beacon, those 3 are added into a queue. Write period of 3second the queue is dequeued and proceed one by one to connect and write for each beacon found.

Scanning and writing are mutually excursive as i heard and encounted many problems when doing them together. Such as high failure rate when doing connecting ble -> write characteristic. However by making them mutually excursive, this means that i can only connect and write to a limited number of beacon if i walk pass through multiple doors with ble beacon.

My connect and write logic contains a default timeout of retry for 1.5s with max of 3 retry. Each gatt action such as .connect, .discovery contains a delay of 200ms.

I am wondering the following question

  1. What is the average time required for ble connect then ble write characteristic (not including scanning). I have tried and seems that certain phones takes as slow as 500ms, whereas some other phone takes as long as 4.5s or just fail to establish connect and write .

  2. Is the whole idea viable? The whole project requires at most 6s to connect and write characteristic to each door it pass by which has ble beaconattached on it.

  3. Any improvement to be make?

ericlee
  • 2,703
  • 11
  • 43
  • 68
  • Why you need to connect to each ble and write characteristics, Is your purpose to connect to ble to get advertisements sent by beacon ?? – Mohammad Fahmawi Sep 03 '18 at 10:08
  • i need to write characteristics to the ble device for certain IOT functionality on the device. Due to the poor reliability on current android's bluestack, i have no choice but to migrate the connectivity to the cloud. Phone -> Cloud-> IOT Via http protocol Instead of Phone -> IOT Via write characteristics using bluetooth – ericlee Nov 12 '18 at 05:23

0 Answers0