capacitor-community / bluetooth-le

Capacitor plugin for Bluetooth Low Energy
MIT License
285 stars 85 forks source link

Gatt Error on startNotifications #690

Closed Theo-55 closed 1 month ago

Theo-55 commented 1 month ago

Describe the bug This may be a personal error but could really use some help. Im attempting to connect to an MCU supporting BLE. On web, i am able to connect to the device and get the id, capture services and characteristics. The problem arrises when attempting to start notifications. When attempting to start the notifications i am receiving a GATT error as well as an unsupported device error. The goal here is that have the notifications update on my frontend every time a sensor is hit. We are putting sensors on a putting mat to track putts made. Simple, yet proving to be difficult.

Expected behavior I would expect to see just have basic console logs of the notifications when a sensor is hit.

Screenshots ` async startNotifications(deviceId: string, service: string, characteristic: string): Promise { try { const readValue = await BleClient.read(deviceId, service, characteristic); console.log('Read value:', readValue);

    const decoder = new TextDecoder('utf-8');
    const message = decoder.decode(readValue);
    console.log('Parsed read message:', message);

    await BleClient.startNotifications(deviceId, service, characteristic, (value) => {
      console.log('Notification received:', value);
      const notificationMessage = decoder.decode(value);
      console.log('Parsed notification message:', notificationMessage);
    });

  } catch (error) {
    console.error(`didnt work :(`, error);
  }

}`

Plugin version:

Desktop (please complete the following information): Latest Chrome version

Additional context Add any other context about the problem here.