【发布时间】:2016-05-05 21:22:59
【问题描述】:
在我的程序中,我向设备发送一个命令,然后它会发回一些数据。只要数据可用,就会调用以下事件处理程序。
private void notify_change(GattCharacteristic sender, GattValueChangedEventArgs args)
{
lock (this._dataRec)
{
notCounter++;
byte[] bArray = new byte[args.CharacteristicValue.Length];
DataReader.FromBuffer(args.CharacteristicValue).ReadBytes(bArray);
dataQ.Enqueue(Encoding.ASCII.GetString(bArray));
Monitor.Pulse(this._dataRec);
}
}
有时,我注意到在读取之前的数据之前调用了它(或类似的东西;从命令列表中,数据似乎丢失了)。看起来每当调用函数时缓冲区都会被覆盖。有没有办法将数据添加到缓冲区而不是覆盖它?
【问题讨论】:
标签: c# bluetooth win-universal-app gatt