• 3

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

Currently, I am developing an app which is communicating with one BLE Hardware which is receiving commands and responding back the command response. To Simulate hardware, We have developed one iOS Simulator app, which is working in Peripheral and responding back on requested command. But Somehow, As and when I try to write to the write characteristics, I got the status = BluetoothGatt .GATT_REQUEST_NOT_SUPPORTED in the onCharacteristicWrite callback. But somehow, I came to know that we need to implement the Central and Peripheral roles into Android app.

But I am still not sure, Do we need to implement Peripheral role as well to send and receive data in multiple packets.

I am developing the app using following nice blog post:
- https://medium.com/@avigezerit/bluetooth-low-energy-on-android-22bc7310387a - https://android.jlelse.eu/android-bluetooth-low-energy-communication-simplified-d4fc67d3d26e - https://www.bignerdranch.com/blog/bluetooth-low-energy-on-android-part-2/

And using following repo as learning point of view:
- https://github.com/bignerdranch/android-bluetooth-testbed/tree/a/android-ble-part-3

Thanks in advance!

      • 2
    • If you get GATT_REQUEST_NOT_SUPPORTED, can you check the Gatt configuration on the iOS simulator. Can you add the code? In general you don't need to implement both roles as @Steve mentioned.
      • 2
    • Many Android devices can't even function in the peripheral role, so in any case it's better to stick with the central role.

Typically your phone app is the central and it communicates with a peripheral device over Bluetooth. If you want to send data to the peripheral, you can write a characteristic in the phone app, given writing is enabled for that characteristic. Your central can get data from the peripheral in 2 ways: it can either read a characteristic (if it's enabled) from the peripheral or receive notifications from the peripheral (if it's enabled). So if all you have is a central (phone app) and a peripheral (some kind of Bluetooth device) and you want to send data back and forth, you don't need to have both central and peripheral roles in the phone app. If you have some special stuff going on, it might be different for you, I don't know. I'm talking about a typical setup.

If you want to send commands to the peripheral, you could write those commands to a characteristic. The peripheral could in turn respond with notifications. This is basically the way I develop a Bluetooth solution, but it can be different depending what you want to achieve.

  • 1
Reply Report

It takes two devices to communicate with each other.

Device A: It will be Peripheral device which will be advertising the data. i.e.: Beacons, BLE Hardware

Device B: It will be Central device which will send request for read,write. i.e.: Mobile

Setup for Device A:

If you don't have Peripheral, there is a way to make your android mobile to act like a Peripheral if your device is supporting that advance feature.

So before beginning, you may simply check that by using following app: https://play.google.com/store/apps/details?id=com.kyriakosalexandrou.bluetoothsupportcheck

To make your device act like Peripheral, you may install following app which simply simulates the GATT and advertising: https://play.google.com/store/apps/details?id=com.ble.peripheral.sim

Important: Setup service and characteristics based on your requirements, make sure characteristic is write enabled if you want write data on it.

  • 0
Reply Report