I am having a problem with the BluetoothLEAdvertisementDataSection.BluetoothLEAdvertisementDataSection class from the Windows 10 Bluetooth Low Energy (BLE) API.
If I check the length of an element IBuffer Datausing this code:
IBuffer
Data
var myDataSection = new BluetoothLEAdvertisementDataSection(); Debug.WriteLine($"Data Capacity: {myDataSection.Data.Capacity}"); //Looks like SO needs to update for C# 6.0
I get the expected result:
Data capacity: 29
For more information on BLE packages, I recommend visiting this great blog post .
Now suppose I declared byte[], called a myPayloadlength of 29 bytes. The following code throws an exception:
byte[]
myPayload
DataWriter writer = new DataWriter(); writer.WriteBytes(myPayload); myDataSection.Data = writer.DetachBuffer(); //throws ArgumentException
ArgumentException very helpful suggest that
ArgumentException
"The value is not in the expected range."
, myPayload 20+ . 19 , , .
, , .
... . 29 . 30 . API.
static readonly byte[] myPayload = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, //8 bytes 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, //8 bytes 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, //8 bytes 0x00,0x00,0x00,0x00,0x00}; //5 bytes Total:29 bytes
... .
Source: https://habr.com/ru/post/1658741/More articles:Second derivative in Python - scipy / numpy / pandas - pythonНе удается подключиться к ноутбуку Tensorflow Jupyter в окнах 10 - dockerDoes MSBuild need to translate .ts files in Angular2 dependencies (in node_modules) for Angular2? - node.jsКомбинации двух массивов с заказом в Julia - combinatoricsTable cell separators partitions in iOS 10 - iosXcode color mismatch - iosAngular 2 и модульное тестирование жасмина: невозможно получить innerHtml - unit-testingSolve DBContext using another interface in Asp.Net Core - c #Form validation does not display results on laravel - phpPropTypes in reaction + redux - reactjsAll Articles