dotintent / FlutterBleLib

Bluetooth Low Energy library for Flutter with support for simulating peripherals
Apache License 2.0
531 stars 195 forks source link

Is full-duplex communication possible #541

Closed emretufekci closed 3 years ago

emretufekci commented 3 years ago

I would like to make full-duplex communication via notification.

ANDROID/IOS <--> BLE DEVICE

I have a notification on ble device side, i can enable notifications and reading stream data.

But is there any possible way to be able to enable same thing on mobile device side?

So basically, can i create notification on ANDROID/IOS side as well?

Currently, i'm just doing this:

characteristic.first.monitor().listen((event) {
log("Data:" ${event.toString()}");
});

I would like to write a data directly to notification, instead writeWithoutResponse or writeWithResponse services from ble device.

mikolak commented 3 years ago

The only way to do that would be to create a peripheral module in the app and have your BLE device act not only as the peripheral, but also a central. This library only supports central role at the moment, so you'd need something like https://pub.dev/packages/flutter_ble_peripheral

If you're not familiar with those terms, you can think of peripheral role as a server and the central as a client.

JasonEdinburgh commented 3 years ago

I may be misunderstanding this conversation, but I have 2 way communication.

I use the Nordic uart service on my NRF52840 based device and FlutterBleLib on the smartphone.

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.0.0%2Fble_sdk_app_nus_eval.html

emretufekci commented 3 years ago

@JasonEdinburgh Hi Jason, thanks for answer. I have two way communication as well but not via gatt server on both side.

For ex: Android (Gatt Client) -> BLE (Gatt Server) [NOTIFICATION ENABLED] By doing this i can receive all datas from ble device

Android (Gatt Client) -> BLE(Gatt Server) [WRITE WITHOUT RESPONSE] By doing this i can send all datas to ble device

Instead of doing this, i would like to create a notification service on mobile phone side (so actually it is making phone as server), so ble device can enabled my notification then i can use full duplex communication.

So

RX Characteristic (UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E) The peer can send data to the device by writing to the RX Characteristic of the service. ATT Write Request or ATT Write Command can be used. The received data is sent on the UART interface.

TX Characteristic (UUID: 6E400003-B5A3-F393-E0A9-E50E24DCCA9E) If the peer has enabled notifications for the TX Characteristic, the application can send data to the peer as notifications. The application will transmit all data received over UART as notifications.

As far as i understood;

This is offering the same way what i have currently.

emretufekci commented 3 years ago

@mikolak Thanks for advise, the library seems missing features. I will test it one more time. Thanks again.

JasonEdinburgh commented 3 years ago

yes, sorry, I misunderstood.