Skip to content

[Windows] Crash on writeValue #90

@ivs

Description

@ivs

Hi! This code gives me sigterm on Windows:

void handleConnection(String deviceId, BlueConnectionState state) {
    d.log('handleConnection ' + state.value);
    QuickBlue.discoverServices(deviceId);
    QuickBlue.setNotifiable(deviceId, SERVICE_MIBAND2, CHARACTERISTIC_AUTH,
        BleInputProperty.notification);
    QuickBlue.writeValue(deviceId, SERVICE_MIBAND2, CHARACTERISTIC_AUTH,
        Uint8List.fromList(key_cmd + key), BleOutputProperty.withResponse);
  }

  void handleService(String deviceId, String serviceId) {
    d.log('handleService ' + serviceId);
  }

  void handleValue(String deviceId, String characteristicId, Uint8List value) {
    d.log('handleValue ' + characteristicId);
  }

  @override
  void initState() {
    super.initState();
    QuickBlue.setConnectionHandler(handleConnection);
    QuickBlue.setServiceHandler(handleService);
    QuickBlue.setValueHandler(handleValue);

    QuickBlue.scanResultStream.listen((result) {
      d.log('onScanResult ' + result.name);

      if (result.name == "Mi Band 3" && !bandFound) {
        bandFound = true;

        d.log('onScanResult ' + result.name);
        QuickBlue.stopScan();
        QuickBlue.connect(result.deviceId);
      }
    });

    QuickBlue.startScan();
  }

The output:

Launching lib\main.dart on Windows in debug mode...
lib\main.dart:1
Connecting to VM Service at w[s://127.0.0.1:56503]()/sOU5DQmnXDg=/ws
flutter: startScan invokeMethod success
4[log] onScanResult [Monitor] Samsung M7 (32)
[log] onScanResult Amazfit GTS2 mini
[log] onScanResult [Monitor] Samsung M7 (32)
flutter: stopScan invokeMethod success
2[log] onScanResult Mi Band 3
[log] handleConnection connected
Lost connection to device.
Exited (sigterm)

How I can debug it?
I'm new to BLE maybe I do something wrong. I'm trying to port this project:
https://github.com/4lhc/MiBand_HRX/blob/master/base.py#L103

Is setNotifiable with BleInputProperty.notification the same as writing 0x01 to 0x2902 descriptor?

There's no crash if I set BleOutputProperty.withoutResponse for writeValue but no response from device too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions