Skip to content

Instantly share code, notes, and snippets.

@houwasystemdesign
Created December 12, 2019 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save houwasystemdesign/62a3e97d7124190fb81dac70160d783f to your computer and use it in GitHub Desktop.
Save houwasystemdesign/62a3e97d7124190fb81dac70160d783f to your computer and use it in GitHub Desktop.
public class AdvertisementListItem
{
public ulong BluetoothAddress;
public string AdvertisementData;
public AdvertisementListItem(BluetoothLEAdvertisementReceivedEventArgs eventArgs)
{
BluetoothAddress = eventArgs.BluetoothAddress;
var dataSections = eventArgs.Advertisement.DataSections;
foreach (BluetoothLEAdvertisementDataSection dataSection in dataSections)
{
//DataTypeが0xFF(メーカー固有のデータ)なら、Dataをシリアルナンバーとアドバタイズデータにして代入
if (dataSection.DataType == 0xFF)
{
byte[] datas = dataSection.Data.ToArray();
StringBuilder sb = new StringBuilder();
foreach (byte data in datas)
{
sb.Append(data.ToString("X2"));
}
AdvertisementData = sb.ToString();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment