BigHead
BigHead

Reputation: 11

how to send hexadecimal data packets using Bluetooth in flutter

It's my first time using Dart and Flutter. I want to send and receive data packets to some device. I tried a lot of things through google but failed. Please let me know how I can send it. Please help me.

void sendData() async {
Uint8List list = new Uint8List(13);
list[0]=0x80;
list[1]=0x80;
list[2]=0xF0;
list[3]=0x7D;
list[4]=0x05;
list[5]=0x00;
list[6]=0x0E;
list[7]=0x01;
list[8]=0x70;
list[9]=0x70;
list[10]=127;
list[11]=0x80;
list[12]=0xF7;
print(list);
  
await _curPeripheral.discoverAllServicesAndCharacteristics();

_curPeripheral.writeCharacteristic(
    "Service Uuid",
    "Charactoristic Uuid",
    Uint8List.fromList(list), false);

---- debug Console ----

D/com.polidea.flutter_ble_lib.FlutterBleLibPlugin(22538): on native side observed method: discoverAllServicesAndCharacteristics
D/com.polidea.flutter_ble_lib.FlutterBleLibPlugin(22538): on native side observed method: writeCharacteristicForDevice

Upvotes: 1

Views: 1442

Answers (1)

Michael Kotzjan
Michael Kotzjan

Reputation: 2662

There are multiple different libraries to choose if you want to send and receive data using Bluetooth Low Energy. For flutter you could use flutter_reactive_ble for example. The description includes usage examples.

Another library for flutter is flutter_blue.

Upvotes: 1

Related Questions