-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(IBluetoothService): add BluetoothFilterOption parameter (#4496)
* feat: 增加 BluetoothRequestOptions 参数 * refactor: 更新脚本 * doc: 更新示例 * doc: 更新示例 * test: 更新单元测试 * chore: bump version 8.10.4 * test: 更新单元测试
- Loading branch information
Showing
11 changed files
with
222 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace BootstrapBlazor.Components; | ||
|
||
/// <summary> | ||
/// BluetoothFilter 类 | ||
/// </summary> | ||
public class BluetoothFilter | ||
{ | ||
/// <summary> | ||
/// An array of values indicating the Bluetooth GATT (Generic Attribute Profile) services that a Bluetooth device must support. Each value can be a valid name from the GATT assigned services list, such as 'battery_service' or 'blood_pressure'. You can also pass a full service UUID such as '0000180F-0000-1000-8000-00805f9b34fb' or the short 16-bit (0x180F) or 32-bit alias. Note that these are the same values that can be passed to BluetoothUUID.getService(). | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public List<string>? Services { get; set; } | ||
|
||
/// <summary> | ||
/// A string containing the precise name of the device to match against. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? Name { get; set; } | ||
|
||
/// <summary> | ||
/// A string containing the name prefix to match against. All devices that have a name starting with this string will be matched. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? NamePrefix { get; set; } | ||
|
||
/// <summary> | ||
/// An array of objects matching against manufacturer data in the Bluetooth Low Energy (BLE) advertising packets. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public List<BluetoothManufacturerDataFilter>? ManufacturerData { get; set; } | ||
|
||
/// <summary> | ||
/// An array of objects matching against service data in the Bluetooth Low Energy (BLE) advertising packets. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public List<BluetoothServiceDataFilter>? ServiceData { get; set; } | ||
} |
31 changes: 31 additions & 0 deletions
31
src/BootstrapBlazor/Services/Bluetooth/BluetoothManufacturerDataFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace BootstrapBlazor.Components; | ||
|
||
/// <summary> | ||
/// BluetoothManufacturerDataFilter 配置类 | ||
/// </summary> | ||
public class BluetoothManufacturerDataFilter | ||
{ | ||
/// <summary> | ||
/// A mandatory number identifying the manufacturer of the device. Company identifiers are listed in the Bluetooth specification Assigned numbers, Section 7. For example, to match against devices manufactured by "Digianswer A/S", with assigned hex number 0x000C, you would specify 12. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public int? CompanyIdentifier { get; set; } | ||
|
||
/// <summary> | ||
/// The data prefix. A buffer containing values to match against the values at the start of the advertising manufacturer data. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? DataPrefix { get; set; } | ||
|
||
/// <summary> | ||
/// This allows you to match against bytes within the manufacturer data, by masking some bytes of the service data dataPrefix. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? Mask { get; set; } | ||
} |
43 changes: 43 additions & 0 deletions
43
src/BootstrapBlazor/Services/Bluetooth/BluetoothRequestOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace BootstrapBlazor.Components; | ||
|
||
/// <summary> | ||
/// BluetoothRequestOptions 参数类 | ||
/// </summary> | ||
public class BluetoothRequestOptions | ||
{ | ||
/// <summary> | ||
/// An array of filter objects indicating the properties of devices that will be matched. To match a filter object, a device must match all the values of the filter: all its specified services, name, namePrefix, and so on | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public List<BluetoothFilter>? Filters { get; set; } | ||
|
||
/// <summary> | ||
/// An array of filter objects indicating the characteristics of devices that will be excluded from matching. The properties of the array elements are the same as for <see cref="Filters"/>. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public List<BluetoothFilter>? ExclusionFilters { get; set; } | ||
|
||
/// <summary> | ||
/// An array of optional service identifiers. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public List<string>? OptionalServices { get; set; } | ||
|
||
/// <summary> | ||
/// An optional array of integer manufacturer codes. This takes the same values as companyIdentifier. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public List<string>? OptionalManufacturerData { get; set; } | ||
|
||
/// <summary> | ||
/// A boolean value indicating that the requesting script can accept all Bluetooth devices. The default is false. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] | ||
public bool AcceptAllDevices { get; set; } | ||
} |
31 changes: 31 additions & 0 deletions
31
src/BootstrapBlazor/Services/Bluetooth/BluetoothServiceDataFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace BootstrapBlazor.Components; | ||
|
||
/// <summary> | ||
/// BluetoothServiceDataFilter 配置类 | ||
/// </summary> | ||
public class BluetoothServiceDataFilter | ||
{ | ||
/// <summary> | ||
/// The GATT service name, the service UUID, or the UUID 16-bit or 32-bit form. This takes the same values as the elements of the services array. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? Service { get; set; } | ||
|
||
/// <summary> | ||
/// The data prefix. A buffer containing values to match against the values at the start of the advertising service data. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? DataPrefix { get; set; } | ||
|
||
/// <summary> | ||
/// This allows you to match against bytes within the manufacturer data, by masking some bytes of the service data dataPrefix. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? Mask { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters