Einzelnen Beitrag anzeigen

rabatscher

Registriert seit: 13. Dez 2007
Ort: Bruck an der Mur
66 Beiträge
 
#7

AW: Bluetooth LE unter Windows 11 funktioniert nicht mehr

  Alt 17. Aug 2023, 08:07
Das Problem scheint hier Emba zu sein, die nicht auf Size = 0 testen - Size ist ein Cardinal und bei eingeschaltenem Range check gibts eine
Exception. Size ist 0 wenn keine solche Descriptors da sind oder was mit dem Pairing nicht passt (selbiges bei den Characteristics,
da hab ich auch schon öfters keine bekommen...)

Meine Implementierung ist hier:

Code:
function TWinRTBluetoothGattCharacteristic.DoGetDescriptors: TBluetoothGattDescriptorList;
var
  LGattDescriptors: IVectorView_1__GenericAttributeProfile_IGattDescriptor;
  I: Integer;
  characteristic3 : GenericAttributeProfile_IGattCharacteristic3;
  descriptorRes3 : IAsyncOperation_1__GenericAttributeProfile_IGattDescriptorsResult;
  descrRes : GenericAttributeProfile_IGattDescriptorsResult;
begin
  FDescriptors.Clear;

  if Supports(FGattCharacteristic, GenericAttributeProfile_IGattCharacteristic3, characteristic3) then
  begin
       // async
       if TAsyncOperation<IAsyncOperation_1__GenericAttributeProfile_IGattDescriptorsResult>.Wait(
                        characteristic3.GetDescriptorsAsync(BluetoothCacheMode.Uncached), descriptorRes3 ) = AsyncStatus.Completed then
       begin
            descrRes := descriptorRes3.GetResults;
            LGattDescriptors := descrRes.Descriptors;
            if LGattDescriptors.Size > 0 then
            begin
                 for I := 0 to LGattDescriptors.Size - 1 do
                     FDescriptors.Add(TWinRTBluetoothGattDescriptor.Create(Self, LGattDescriptors.GetAt(I)));
            end;
       end;
  end
  else
  begin
    // deprecated use only if not yet supported
    LGattDescriptors := (FGattCharacteristic as GenericAttributeProfile_IGattCharacteristic2).GetAllDescriptors;
    if LGattDescriptors.Size > 0 then
      for I := 0 to LGattDescriptors.Size - 1 do
        FDescriptors.Add(TWinRTBluetoothGattDescriptor.Create(Self, LGattDescriptors.GetAt(I)));
  end;
  Result := FDescriptors;
end;
  Mit Zitat antworten Zitat