private async void BLE_SendData()
{
var writer = new DataWriter();
string sendTxt = sendText.Text;
byte[] bytes = Encoding.ASCII.GetBytes(sendTxt);
writer.WriteBytes(bytes);
var services = result.Services;
foreach (var service in services)
{
if (service.Uuid.ToString("N").Substring(4, 4) == BT_Device_Id)
{
GattCharacteristicsResult characteristicsResult = await service.GetCharacteristicsAsync();
if (characteristicsResult.Status == GattCommunicationStatus.Success)
{
var characteristics = characteristicsResult.Characteristics;
foreach (var characteristic in characteristics)
{
GattCommunicationStatus writeResult;
writeResult = await characteristic.WriteValueAsync(writer.DetachBuffer());
if (writeResult== GattCommunicationStatus.Success)
{
button2.ForeColor = Color.Green;
Thread.Sleep(1000);
button2.ForeColor = Color.Red;
}
}
}
}
}
}`
Bu komut ile Bluetooth verisi göndermeye çalışırken
System.Reflection.TargetInvocationException
HResult=0x80131604
İleti=Özel durum bir çağırma hedefi tarafından oluşturuldu.
Kaynak=mscorlib
StackTrace:
konum System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
konum System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
konum System.Delegate.DynamicInvokeImpl(Object[] args)
konum System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
konum System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
konum System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
konum System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
konum System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
konum System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
konum System.Windows.Forms.Control.InvokeMarshaledCallbacks()
konum System.Windows.Forms.Control.WndProc(Message& m)
konum System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
konum System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
konum System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
konum System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
konum System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
konum System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
konum System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
konum System.Windows.Forms.Application.Run(Form mainForm)
konum WindowsFormsApp4.Program.Main() C:\Users\asd\source\repos\WindowsFormsApp4\WindowsFormsApp4\Program.cs içinde: 19. satır
İçteki Özel Durum 1:
Exception: Öznitelik yazılamıyor. (HRESULT özel durum döndürdü: 0x80650003)
gönderirken böyle bir hata alıyorum.